MCPcopy Create free account
hub / github.com/YACReader/yacreader / executeDrawWithOffset

Method executeDrawWithOffset

common/rhi/yacreader_flow_rhi.cpp:740–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740void YACReaderFlow3D::executeDrawWithOffset(QRhiCommandBuffer *cb, QRhiTexture *texture,
741 const float *instanceData, int uniformSlot)
742{
743 if (!texture || !scene.instanceBuffer || !scene.vertexBuffer)
744 return;
745
746 Q_UNUSED(instanceData)
747
748 // Get or create shader resource bindings for this texture with dynamic offset support
749 QRhiShaderResourceBindings *srb = scene.shaderBindingsCache.value(texture, nullptr);
750 if (!srb) {
751 srb = m_rhi->newShaderResourceBindings();
752 srb->setBindings({ QRhiShaderResourceBinding::uniformBufferWithDynamicOffset(0, QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage, scene.uniformBuffer.get(), sizeof(UniformData)),
753 QRhiShaderResourceBinding::sampledTexture(1, QRhiShaderResourceBinding::FragmentStage, texture, scene.sampler.get()) });
754 srb->create();
755 scene.shaderBindingsCache.insert(texture, srb);
756 }
757
758 // Set shader resources with dynamic offset for uniform buffer
759 QRhiCommandBuffer::DynamicOffset dynOfs[] = {
760 { 0, quint32(uniformSlot * scene.alignedUniformSize) }
761 };
762 cb->setShaderResources(srb, 1, dynOfs);
763
764 // Bind vertex buffers with offset into instance buffer
765 const QRhiCommandBuffer::VertexInput vbufBindings[] = {
766 { scene.vertexBuffer.get(), 0 },
767 { scene.instanceBuffer.get(), quint32(uniformSlot * 22 * sizeof(float)) }
768 };
769 cb->setVertexInput(0, 2, vbufBindings);
770
771 // Draw two triangles (6 vertices) forming a quad
772 cb->draw(6);
773}
774
775void YACReaderFlow3D::removeCachedShaderBindings(QRhiTexture *texture)
776{

Callers

nothing calls this directly

Calls 4

drawMethod · 0.80
getMethod · 0.45
createMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected