bug-14715: DrawIndirect fix
This patch contains fixes to structure layout for draws.
These structures are accessed by HW and must be in a specific order.
This change also includes reordering of the parameters for
vkCmdDraw and vkCmdDrawIndexed.
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index ef178ae..b3aceb4 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -155,10 +155,10 @@
/* Convenience functions that use built-in command buffer */
VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_cmdBuffer); }
VkResult EndCommandBuffer() { return EndCommandBuffer(*m_cmdBuffer); }
- void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
- { m_cmdBuffer->Draw(firstVertex, vertexCount, firstInstance, instanceCount); }
- void DrawIndexed(uint32_t firstVertex, uint32_t vertexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
- { m_cmdBuffer->DrawIndexed(firstVertex, vertexCount, vertexOffset,firstInstance, instanceCount); }
+ void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
+ { m_cmdBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); }
+ void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
+ { m_cmdBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); }
void QueueCommandBuffer() { m_cmdBuffer->QueueCommandBuffer(); }
void QueueCommandBuffer(const VkFence& fence) { m_cmdBuffer->QueueCommandBuffer(fence); }
void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding)
@@ -301,7 +301,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet, failMask);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2584,7 +2584,7 @@
static const float vbo_data[3] = {1.f, 0.f, 1.f};
VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data);
BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO
- Draw(0, 1, 0, 0);
+ Draw(1, 0, 0, 0);
msgFlags = m_errorMonitor->GetState(&msgString);
ASSERT_TRUE(0 != (msgFlags & VK_DBG_REPORT_ERROR_BIT)) << "Did not receive error after binding Vtx Buffer w/o VBO attached to PSO.";
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index 95f0358..9db980f 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -280,10 +280,10 @@
VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_cmdBuffer); }
VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *beginInfo) { return BeginCommandBuffer(*m_cmdBuffer, beginInfo); }
VkResult EndCommandBuffer() { return EndCommandBuffer(*m_cmdBuffer); }
- void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
- { m_cmdBuffer->Draw(firstVertex, vertexCount, firstInstance, instanceCount); }
- void DrawIndexed(uint32_t firstVertex, uint32_t vertexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
- { m_cmdBuffer->DrawIndexed(firstVertex, vertexCount, vertexOffset,firstInstance, instanceCount); }
+ void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
+ { m_cmdBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); }
+ void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
+ { m_cmdBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); }
void QueueCommandBuffer() { m_cmdBuffer->QueueCommandBuffer(); }
void RotateTriangleVSUniform(glm::mat4 Projection, glm::mat4 View, glm::mat4 Model,
VkConstantBufferObj *constantBuffer)
@@ -526,7 +526,7 @@
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
ASSERT_VK_SUCCESS(EndCommandBuffer());
@@ -797,7 +797,7 @@
BindVertexBuffer(&meshBuffer, 0, 0);
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
ASSERT_VK_SUCCESS(EndCommandBuffer());
@@ -884,7 +884,7 @@
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
ASSERT_VK_SUCCESS(EndCommandBuffer());
@@ -991,7 +991,7 @@
BindIndexBuffer(&indexBuffer, 0);
// render two triangles
- DrawIndexed(0, 6, 0, 0, 1);
+ DrawIndexed(6, 1, 0, 0, 0);
// finalize recording of the command buffer
ASSERT_VK_SUCCESS(EndCommandBuffer());
@@ -1079,7 +1079,7 @@
#endif
// render triangle
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1165,7 +1165,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1265,7 +1265,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1354,7 +1354,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1430,7 +1430,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1506,7 +1506,7 @@
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1595,7 +1595,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1698,7 +1698,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1791,7 +1791,7 @@
#endif
// render two triangles
- Draw(0, 6, 0, 1);
+ Draw(6, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -1907,7 +1907,7 @@
#endif
// render triangles
- Draw(0, 36, 0, 1);
+ Draw(36, 1, 0, 0);
// finalize recording of the command buffer
@@ -1978,7 +1978,7 @@
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2048,7 +2048,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2126,7 +2126,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2194,7 +2194,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2281,7 +2281,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2361,7 +2361,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2460,7 +2460,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2554,7 +2554,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2672,7 +2672,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2799,7 +2799,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, num_verts, 0, 1);
+ Draw(num_verts, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -2912,7 +2912,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3018,7 +3018,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3267,7 +3267,7 @@
pDSDumpDot((char*)"triTest2.dot");
#endif
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3374,7 +3374,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3478,7 +3478,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3829,7 +3829,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -3954,7 +3954,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
@@ -4089,7 +4089,7 @@
GenericDrawPreparation(pipelineobj, descriptorSet);
// render triangle
- Draw(0, 3, 0, 1);
+ Draw(3, 1, 0, 0);
// finalize recording of the command buffer
EndCommandBuffer();
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index 6e7df3d..d6cf64b 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -1505,14 +1505,14 @@
m_renderTargets.push_back(renderTarget);
}
-void VkCommandBufferObj::DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
+void VkCommandBufferObj::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
{
- vkCmdDrawIndexed(handle(), firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
+ vkCmdDrawIndexed(handle(), indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
-void VkCommandBufferObj::Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
+void VkCommandBufferObj::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
{
- vkCmdDraw(handle(), firstVertex, vertexCount, firstInstance, instanceCount);
+ vkCmdDraw(handle(), vertexCount, instanceCount, firstVertex, firstInstance);
}
void VkCommandBufferObj::QueueCommandBuffer()
diff --git a/tests/vkrenderframework.h b/tests/vkrenderframework.h
index d3136f2..4bc6d42 100644
--- a/tests/vkrenderframework.h
+++ b/tests/vkrenderframework.h
@@ -185,8 +185,8 @@
void BeginRenderPass(const VkRenderPassBeginInfo &info);
void EndRenderPass();
void FillBuffer(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize fill_size, uint32_t data);
- void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
- void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
+ void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
+ void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance);
void QueueCommandBuffer();
void QueueCommandBuffer(VkFence fence);
void SetViewport(uint32_t viewportCount, const VkViewport* pViewports);