Commit fe83848a authored by Laszlo Agocs's avatar Laszlo Agocs

Convert cb api to QRhiCommandBuffer members

...in order to make the api nicer. Does not affect the internals.
parent eb7a7ce1
......@@ -283,12 +283,12 @@ void Window::customRender()
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, d.ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(d.ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
m_r->endPass(cb);
cb->endPass();
}
......@@ -480,14 +480,14 @@ void Window::render()
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
// Apply buffer updates, clear, start the renderpass (where applicable).
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } });
m_r->draw(cb, 3);
cb->setGraphicsPipeline(m_ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { m_vbuf, 0 } });
cb->draw(3);
m_r->endPass(cb);
cb->endPass();
// Submit.
m_r->endFrame(m_sc);
......
......@@ -162,17 +162,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -175,17 +175,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -185,17 +185,17 @@ int main(int argc, char **argv)
opacity = qBound(0.0f, opacity, 1.0f);
}
r->beginPass(rt, cb, { 0, 1, 0, 1 }, { 1, 0 }, u);
r->setGraphicsPipeline(cb, ps);
r->setViewport(cb, { 0, 0, 1280, 720 });
r->setVertexInput(cb, 0, { { vbuf, 0 } });
r->draw(cb, 3);
r->endPass(cb);
cb->beginPass(rt, { 0, 1, 0, 1 }, { 1, 0 }, u);
cb->setGraphicsPipeline(ps);
cb->setViewport({ 0, 0, 1280, 720 });
cb->setVertexInput(0, { { vbuf, 0 } });
cb->draw(3);
cb->endPass();
QRhiReadbackDescription rb(tex);
QRhiReadbackResult rbResult;
rbResult.completed = [frame] { qDebug(" - readback %d completed", frame); };
r->readback(cb, rb, &rbResult);
cb->readback(rb, &rbResult);
qDebug("Submit and wait");
r->endOffscreenFrame();
......
......@@ -246,7 +246,7 @@ void ExampleWindow::render()
if (!m_onScreenOnly)
m_liveTexCubeRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, outputSize);
if (!m_triangleOnly) {
m_quadRenderer.queueDraw(cb, outputSize);
......@@ -254,7 +254,7 @@ void ExampleWindow::render()
}
if (!m_onScreenOnly)
m_liveTexCubeRenderer.queueDraw(cb, outputSize);
m_r->endPass(cb);
cb->endPass();
#ifdef READBACK_SWAPCHAIN
QRhiReadbackDescription rb; // no texture given -> backbuffer
......
......@@ -147,8 +147,8 @@ void QuadRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpdates
void QuadRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &/*outputSizeInPixels*/)
{
m_r->setGraphicsPipeline(cb, m_ps, m_srb);
//m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } }, m_ibuf, 0, QRhi::IndexUInt16);
m_r->drawIndexed(cb, 6);
cb->setGraphicsPipeline(m_ps, m_srb);
//cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 } }, m_ibuf, 0, QRhiCommandBuffer::IndexUInt16);
cb->drawIndexed(6);
}
......@@ -211,8 +211,8 @@ void TexturedCubeRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourc
void TexturedCubeRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
}
......@@ -272,15 +272,15 @@ void TriangleOnCubeRenderer::queueOffscreenPass(QRhiCommandBuffer *cb)
m_image = QImage();
}
m_r->beginPass(m_rt, cb, { 0.0f, 0.4f, 0.7f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_rt, { 0.0f, 0.4f, 0.7f, 1.0f }, { 1.0f, 0 }, u);
m_offscreenTriangle.queueDraw(cb, OFFSCREEN_SIZE);
m_r->endPass(cb);
cb->endPass();
}
void TriangleOnCubeRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 }, { m_vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
}
......@@ -199,8 +199,8 @@ void TriangleRenderer::queueResourceUpdates(QRhiResourceUpdateBatch *resourceUpd
void TriangleRenderer::queueDraw(QRhiCommandBuffer *cb, const QSize &outputSizeInPixels)
{
m_r->setGraphicsPipeline(cb, m_ps);
m_r->setViewport(cb, QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
m_r->setVertexInput(cb, 0, { { m_vbuf, 0 } });
m_r->draw(cb, 3);
cb->setGraphicsPipeline(m_ps);
cb->setViewport(QRhiViewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height()));
cb->setVertexInput(0, { { m_vbuf, 0 } });
cb->draw(3);
}
......@@ -256,14 +256,14 @@ void Window::customRender()
QRhiCommandBuffer *cb = m_sc->currentFrameCommandBuffer();
const QSize outputSizeInPixels = m_sc->effectivePixelSize();
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_r->setGraphicsPipeline(cb, d.ps);
m_r->setViewport(cb, { 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
m_r->setVertexInput(cb, 0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
m_r->draw(cb, 36);
cb->setGraphicsPipeline(d.ps);
cb->setViewport({ 0, 0, float(outputSizeInPixels.width()), float(outputSizeInPixels.height()) });
cb->setVertexInput(0, { { d.vbuf, 0 }, { d.vbuf, 36 * 3 * sizeof(float) } });
cb->draw(36);
m_r->endPass(cb);
cb->endPass();
d.frameCount += 1;
}
......@@ -117,9 +117,9 @@ void Renderer::startNextFrame()
QRhiResourceUpdateBatch *u = m_r->nextResourceUpdateBatch();
m_triRenderer.queueResourceUpdates(u);
m_r->beginPass(m_sc->currentFrameRenderTarget(), cb, { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
cb->beginPass(m_sc->currentFrameRenderTarget(), { 0.4f, 0.7f, 0.0f, 1.0f }, { 1.0f, 0 }, u);
m_triRenderer.queueDraw(cb, m_sc->effectivePixelSize());
m_r->endPass(cb);
cb->endPass();
m_r->endFrame(m_sc);
......
......@@ -512,6 +512,70 @@ void QRhiResourceUpdateBatchPrivate::merge(QRhiResourceUpdateBatchPrivate *other
texturePrepares += other->texturePrepares;
}
void QRhiCommandBuffer::beginPass(QRhiRenderTarget *rt,
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates)
{
rhi->beginPass(rt, this, colorClearValue, depthStencilClearValue, resourceUpdates);
}
void QRhiCommandBuffer::endPass()
{
rhi->endPass(this);
}
void QRhiCommandBuffer::setGraphicsPipeline(QRhiGraphicsPipeline *ps,
QRhiShaderResourceBindings *srb)
{
rhi->setGraphicsPipeline(this, ps, srb);
}
void QRhiCommandBuffer::setVertexInput(int startBinding, const QVector<VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
IndexFormat indexFormat)
{
rhi->setVertexInput(this, startBinding, bindings, indexBuf, indexOffset, indexFormat);
}
void QRhiCommandBuffer::setViewport(const QRhiViewport &viewport)
{
rhi->setViewport(this, viewport);
}
void QRhiCommandBuffer::setScissor(const QRhiScissor &scissor)
{
rhi->setScissor(this, scissor);
}
void QRhiCommandBuffer::setBlendConstants(const QVector4D &c)
{
rhi->setBlendConstants(this, c);
}
void QRhiCommandBuffer::setStencilRef(quint32 refValue)
{
rhi->setStencilRef(this, refValue);
}
void QRhiCommandBuffer::draw(quint32 vertexCount,
quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)
{
rhi->draw(this, vertexCount, instanceCount, firstVertex, firstInstance);
}
void QRhiCommandBuffer::drawIndexed(quint32 indexCount,
quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance)
{
rhi->drawIndexed(this, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
bool QRhiCommandBuffer::readback(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
return rhi->readback(this, rb, result);
}
int QRhi::ubufAligned(int v) const
{
const int byteAlign = ubufAlignment();
......@@ -615,78 +679,11 @@ QRhi::FrameOpResult QRhi::endOffscreenFrame()
return d->endOffscreenFrame();
}
bool QRhi::readback(QRhiCommandBuffer *cb, const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
return d->readback(cb, rb, result);
}
QRhi::FrameOpResult QRhi::finish()
{
return d->finish();
}
void QRhi::beginPass(QRhiRenderTarget *rt,
QRhiCommandBuffer *cb,
const QRhiColorClearValue &colorClearValue,
const QRhiDepthStencilClearValue &depthStencilClearValue,
QRhiResourceUpdateBatch *resourceUpdates)
{
d->beginPass(rt, cb, colorClearValue, depthStencilClearValue, resourceUpdates);
}
void QRhi::endPass(QRhiCommandBuffer *cb)
{
d->endPass(cb);
}
void QRhi::setGraphicsPipeline(QRhiCommandBuffer *cb,
QRhiGraphicsPipeline *ps,
QRhiShaderResourceBindings *srb)
{
d->setGraphicsPipeline(cb, ps, srb);
}
void QRhi::setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
IndexFormat indexFormat)
{
d->setVertexInput(cb, startBinding, bindings, indexBuf, indexOffset, indexFormat);
}
void QRhi::setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport)
{
d->setViewport(cb, viewport);
}
void QRhi::setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor)
{
d->setScissor(cb, scissor);
}
void QRhi::setBlendConstants(QRhiCommandBuffer *cb, const QVector4D &c)
{
d->setBlendConstants(cb, c);
}
void QRhi::setStencilRef(QRhiCommandBuffer *cb, quint32 refValue)
{
d->setStencilRef(cb, refValue);
}
void QRhi::draw(QRhiCommandBuffer *cb, quint32 vertexCount,
quint32 instanceCount, quint32 firstVertex, quint32 firstInstance)
{
d->draw(cb, vertexCount, instanceCount, firstVertex, firstInstance);
}
void QRhi::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
quint32 instanceCount, quint32 firstIndex,
qint32 vertexOffset, quint32 firstInstance)
{
d->drawIndexed(cb, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
QVector<int> QRhi::supportedSampleCounts() const
{
return d->supportedSampleCounts();
......
This diff is collapsed.
......@@ -100,9 +100,9 @@ public:
QRhiShaderResourceBindings *srb = nullptr) = 0;
virtual void setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<QRhi::VertexInput> &bindings,
int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
QRhi::IndexFormat indexFormat) = 0;
QRhiCommandBuffer::IndexFormat indexFormat) = 0;
virtual void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) = 0;
virtual void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) = 0;
......
......@@ -332,8 +332,8 @@ void QRhiD3D11::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
}
}
void QRhiD3D11::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhi::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhi::IndexFormat indexFormat)
void QRhiD3D11::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
{
Q_ASSERT(inPass);
QD3D11CommandBuffer *cbD = QRHI_RES(QD3D11CommandBuffer, cb);
......@@ -363,7 +363,8 @@ void QRhiD3D11::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QV
cmd.cmd = QD3D11CommandBuffer::Command::BindIndexBuffer;
cmd.args.bindIndexBuffer.buffer = ibufD->buffer;
cmd.args.bindIndexBuffer.offset = indexOffset;
cmd.args.bindIndexBuffer.format = indexFormat == QRhi::IndexUInt16 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
cmd.args.bindIndexBuffer.format = indexFormat == QRhiCommandBuffer::IndexUInt16 ? DXGI_FORMAT_R16_UINT
: DXGI_FORMAT_R32_UINT;
cbD->commands.append(cmd);
if (ibufD->m_type == QRhiBuffer::Dynamic)
executeBufferHostWritesForCurrentFrame(ibufD);
......
......@@ -413,9 +413,9 @@ public:
QRhiShaderResourceBindings *srb) override;
void setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<QRhi::VertexInput> &bindings,
int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
QRhi::IndexFormat indexFormat) override;
QRhiCommandBuffer::IndexFormat indexFormat) override;
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
......
......@@ -256,8 +256,8 @@ void QRhiGles2::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
}
}
void QRhiGles2::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhi::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhi::IndexFormat indexFormat)
void QRhiGles2::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
{
Q_ASSERT(inPass);
QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb);
......@@ -283,7 +283,7 @@ void QRhiGles2::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QV
cmd.cmd = QGles2CommandBuffer::Command::BindIndexBuffer;
cmd.args.bindIndexBuffer.buffer = ibufD->buffer;
cmd.args.bindIndexBuffer.offset = indexOffset;
cmd.args.bindIndexBuffer.type = indexFormat == QRhi::IndexUInt16 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
cmd.args.bindIndexBuffer.type = indexFormat == QRhiCommandBuffer::IndexUInt16 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
cbD->commands.append(cmd);
}
}
......
......@@ -377,9 +377,9 @@ public:
QRhiShaderResourceBindings *srb) override;
void setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<QRhi::VertexInput> &bindings,
int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
QRhi::IndexFormat indexFormat) override;
QRhiCommandBuffer::IndexFormat indexFormat) override;
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
......
......@@ -361,8 +361,8 @@ void QRhiMetal::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
psD->lastActiveFrameSlot = currentFrameSlot;
}
void QRhiMetal::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhi::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhi::IndexFormat indexFormat)
void QRhiMetal::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
{
Q_ASSERT(inPass);
QMetalCommandBuffer *cbD = QRHI_RES(QMetalCommandBuffer, cb);
......@@ -480,7 +480,7 @@ void QRhiMetal::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
if (!cbD->currentIndexBuffer)
return;
const quint32 indexOffset = cbD->currentIndexOffset + firstIndex * (cbD->currentIndexFormat == QRhi::IndexUInt16 ? 2 : 4);
const quint32 indexOffset = cbD->currentIndexOffset + firstIndex * (cbD->currentIndexFormat == QRhiCommandBuffer::IndexUInt16 ? 2 : 4);
Q_ASSERT(indexOffset == aligned(indexOffset, 4));
QMetalBuffer *ibufD = QRHI_RES(QMetalBuffer, cbD->currentIndexBuffer);
......@@ -488,7 +488,7 @@ void QRhiMetal::drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount,
[cbD->d->currentPassEncoder drawIndexedPrimitives: QRHI_RES(QMetalGraphicsPipeline, cbD->currentPipeline)->d->primitiveType
indexCount: indexCount
indexType: cbD->currentIndexFormat == QRhi::IndexUInt16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32
indexType: cbD->currentIndexFormat == QRhiCommandBuffer::IndexUInt16 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32
indexBuffer: mtlbuf
indexBufferOffset: indexOffset
instanceCount: instanceCount
......
......@@ -280,9 +280,9 @@ public:
QRhiShaderResourceBindings *srb) override;
void setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<QRhi::VertexInput> &bindings,
int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
QRhi::IndexFormat indexFormat) override;
QRhiCommandBuffer::IndexFormat indexFormat) override;
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
......
......@@ -2432,8 +2432,8 @@ void QRhiVulkan::setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline
srbD->lastActiveFrameSlot = currentFrameSlot;
}
void QRhiVulkan::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhi::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhi::IndexFormat indexFormat)
void QRhiVulkan::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat)
{
Q_ASSERT(inPass);
......@@ -2463,7 +2463,8 @@ void QRhiVulkan::setVertexInput(QRhiCommandBuffer *cb, int startBinding, const Q
executeBufferHostWritesForCurrentFrame(ibufD);
const int idx = ibufD->m_type == QRhiBuffer::Dynamic ? currentFrameSlot : 0;
const VkIndexType type = indexFormat == QRhi::IndexUInt16 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32;
const VkIndexType type = indexFormat == QRhiCommandBuffer::IndexUInt16 ? VK_INDEX_TYPE_UINT16
: VK_INDEX_TYPE_UINT32;
df->vkCmdBindIndexBuffer(cbD->cb, ibufD->buffers[idx], indexOffset, type);
}
}
......
......@@ -343,9 +343,9 @@ public:
QRhiShaderResourceBindings *srb) override;
void setVertexInput(QRhiCommandBuffer *cb,
int startBinding, const QVector<QRhi::VertexInput> &bindings,
int startBinding, const QVector<QRhiCommandBuffer::VertexInput> &bindings,
QRhiBuffer *indexBuf, quint32 indexOffset,
QRhi::IndexFormat indexFormat) override;
QRhiCommandBuffer::IndexFormat indexFormat) override;
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override;
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override;
......
......@@ -55,6 +55,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
move cb api into QRhiCommandBuffer
d3d: texcopy
copyimage (color, with rect?, no resolve or transforms here)
vk, d3d, gl: tex upload with pos
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment