From a3d3fe79a338cb43e0978bb9a0c1e942819584b0 Mon Sep 17 00:00:00 2001 From: Alexey Panteleev Date: Fri, 4 Aug 2023 15:16:34 -0700 Subject: [PATCH] Updated Donut and the Vertex Buffer example to test a recent fix in NVRHI. --- donut | 2 +- examples/vertex_buffer/vertex_buffer.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/donut b/donut index fbb8154..035c82f 160000 --- a/donut +++ b/donut @@ -1 +1 @@ -Subproject commit fbb815465d1538d935b0ba1aa8a27f0af5ba00e7 +Subproject commit 035c82f6bcca30cc090596dc4f7b0470c0a7a774 diff --git a/examples/vertex_buffer/vertex_buffer.cpp b/examples/vertex_buffer/vertex_buffer.cpp index 8aeb630..86c78a6 100644 --- a/examples/vertex_buffer/vertex_buffer.cpp +++ b/examples/vertex_buffer/vertex_buffer.cpp @@ -146,12 +146,14 @@ class VertexBuffer : public app::IRenderPass nvrhi::VertexAttributeDesc() .setName("POSITION") .setFormat(nvrhi::Format::RGB32_FLOAT) - .setOffset(offsetof(Vertex, position)) + .setOffset(0) + .setBufferIndex(0) .setElementStride(sizeof(Vertex)), nvrhi::VertexAttributeDesc() .setName("UV") .setFormat(nvrhi::Format::RG32_FLOAT) - .setOffset(offsetof(Vertex, uv)) + .setOffset(0) + .setBufferIndex(1) .setElementStride(sizeof(Vertex)), }; m_InputLayout = GetDevice()->createInputLayout(attributes, uint32_t(std::size(attributes)), m_VertexShader); @@ -275,7 +277,11 @@ class VertexBuffer : public app::IRenderPass // Pick the right binding set for this view. state.bindings = { m_BindingSets[viewIndex] }; state.indexBuffer = { m_IndexBuffer, nvrhi::Format::R32_UINT, 0 }; - state.vertexBuffers = { { m_VertexBuffer, 0, 0 } }; + // Bind the vertex buffers in reverse order to test the NVRHI implementation of binding slots + state.vertexBuffers = { + { m_VertexBuffer, 1, offsetof(Vertex, uv) }, + { m_VertexBuffer, 0, offsetof(Vertex, position) } + }; state.pipeline = m_Pipeline; state.framebuffer = framebuffer;