xgl: Proposal to remove XGL_FRAMEBUFFER
bug # 13323
alpha header: r29635
Don't actually remove XGL_FRAMEBUFFER but do change how
RenderPass and Framebuffer are connected. Some comments
from the bug:
- Created a new structure XGL_RENDER_PASS_BEGIN that contains
both the XGL_RENDER_PASS and XGL_FRAMEBUFFER.
- XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO and xglCmdBeginRenderPass
both use XGL_RENDER_PASS_BEGIN to ensure they stay consistent.
- Renamed the member in XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO to
renderPassContinue with a comment to clarify that this is
only needed when a render pass is split across two command buffer.
The last has the biggest impact on this patch. The tests now
directly call CmdBeginRenderPass and CmdEndRenderPass in the
command buffer rather than set the BEGIN_INFO to a render pass and
have the driver implicitly do BeginRenderPass and EndRenderPass.
It would probably still work, but didn't seem to match the intent
with this change in the header file.
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index d6c940f..5683ea2 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -219,6 +219,8 @@
void InitDepthStencil();
void XGLTriangleTest(const char *vertShaderText, const char *fragShaderText, const bool rotate);
+ XGL_RESULT BeginCommandBuffer(XglCommandBufferObj &cmdBuffer);
+ XGL_RESULT EndCommandBuffer(XglCommandBufferObj &cmdBuffer);
protected:
XGL_IMAGE m_texture;
@@ -258,6 +260,35 @@
}
};
+XGL_RESULT XglRenderTest::BeginCommandBuffer(XglCommandBufferObj &cmdBuffer)
+{
+ XGL_RESULT result;
+
+ result = cmdBuffer.BeginCommandBuffer();
+
+ /*
+ * For render test all drawing happens in a single render pass
+ * on a single command buffer.
+ */
+ if (XGL_SUCCESS == result) {
+ cmdBuffer.BeginRenderPass(renderPass(), framebuffer());
+ }
+
+ return result;
+}
+
+XGL_RESULT XglRenderTest::EndCommandBuffer(XglCommandBufferObj &cmdBuffer)
+{
+ XGL_RESULT result;
+
+ cmdBuffer.EndRenderPass(renderPass());
+
+ result = cmdBuffer.EndCommandBuffer();
+
+ return result;
+}
+
+
void XglRenderTest::GenericDrawPreparation(XglCommandBufferObj *cmdBuffer, XglPipelineObj *pipelineobj, XglDescriptorSetObj *descriptorSet)
{
cmdBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color,
@@ -497,18 +528,20 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
#ifdef DUMP_STATE_DOT
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
+
// render triangle
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
+
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -796,7 +829,8 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
+
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
cmdBuffer.BindVertexBuffer(&meshBuffer, 0, 0);
@@ -805,7 +839,8 @@
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
+
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -878,7 +913,7 @@
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
cmdBuffer.AddRenderTarget(m_renderTargets[1]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -887,11 +922,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
+
// render triangle
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -986,7 +1022,7 @@
m_memoryRefManager.AddRTMemoryRefs(m_renderTargets, m_renderTargets.size());
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1002,7 +1038,7 @@
cmdBuffer.DrawIndexed(0, 6, 0, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1084,7 +1120,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1093,11 +1129,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
+
// render triangle
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1179,7 +1216,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1188,11 +1225,11 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1284,7 +1321,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1293,11 +1330,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1379,7 +1417,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1388,11 +1426,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1454,7 +1493,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1463,11 +1502,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1532,7 +1572,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1540,11 +1580,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
+
// render triangle
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1621,7 +1662,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1630,11 +1671,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1715,7 +1757,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1724,11 +1766,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render two triangles
cmdBuffer.Draw(0, 6, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1829,7 +1872,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
cmdBuffer.BindVertexBuffer(&meshBuffer, 0, 0);
@@ -1837,11 +1880,13 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
- // render triangle
+
+ // render triangles
cmdBuffer.Draw(0, 36, 0, 1);
+
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1899,7 +1944,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1907,11 +1952,12 @@
DRAW_STATE_DUMP_DOT_FILE pDSDumpDot = (DRAW_STATE_DUMP_DOT_FILE)xglGetProcAddr(gpu(), (char*)"drawStateDumpDotFile");
pDSDumpDot((char*)"triTest2.dot");
#endif
+
// render triangle
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -1972,7 +2018,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -1984,7 +2030,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2056,7 +2102,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2068,7 +2114,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2129,7 +2175,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2141,7 +2187,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2223,7 +2269,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2235,7 +2281,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2307,7 +2353,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2319,7 +2365,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2410,7 +2456,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2422,7 +2468,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2508,7 +2554,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2520,7 +2566,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2638,7 +2684,8 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
+
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
cmdBuffer.BindVertexBuffer(&meshBuffer, 0, 0);
@@ -2650,7 +2697,7 @@
cmdBuffer.Draw(0, 36, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2760,7 +2807,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2772,7 +2819,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -2876,7 +2923,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -2888,7 +2935,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
@@ -3129,7 +3176,7 @@
XglCommandBufferObj cmdBuffer(m_device);
cmdBuffer.AddRenderTarget(m_renderTargets[0]);
- ASSERT_XGL_SUCCESS(cmdBuffer.BeginCommandBuffer(renderPass()));
+ ASSERT_XGL_SUCCESS(BeginCommandBuffer(cmdBuffer));
GenericDrawPreparation(&cmdBuffer, &pipelineobj, &descriptorSet);
@@ -3141,7 +3188,7 @@
cmdBuffer.Draw(0, 3, 0, 1);
// finalize recording of the command buffer
- cmdBuffer.EndCommandBuffer();
+ EndCommandBuffer(cmdBuffer);
cmdBuffer.QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
for (int i = 0; i < m_renderTargets.size(); i++)
diff --git a/tests/xglrenderframework.cpp b/tests/xglrenderframework.cpp
index 9a46f78..3721816 100644
--- a/tests/xglrenderframework.cpp
+++ b/tests/xglrenderframework.cpp
@@ -76,7 +76,7 @@
if (m_stateDepthStencil) xglDestroyObject(m_stateDepthStencil);
if (m_stateRaster) xglDestroyObject(m_stateRaster);
if (m_cmdBuffer) xglDestroyObject(m_cmdBuffer);
- if (m_frameBuffer) xglDestroyObject(m_frameBuffer);
+ if (m_framebuffer) xglDestroyObject(m_framebuffer);
if (m_renderPass) xglDestroyObject(m_renderPass);
if (m_stateViewport) {
@@ -174,6 +174,9 @@
void XglRenderFramework::InitRenderTarget(uint32_t targets)
{
+ std::vector<XGL_ATTACHMENT_LOAD_OP> load_ops;
+ std::vector<XGL_ATTACHMENT_STORE_OP> store_ops;
+ std::vector<XGL_CLEAR_COLOR> clear_colors;
uint32_t i;
for (i = 0; i < targets; i++) {
@@ -184,16 +187,11 @@
m_colorBindings[i].view = img->targetView();
m_colorBindings[i].layout = XGL_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
m_renderTargets.push_back(img);
+ load_ops.push_back(XGL_ATTACHMENT_LOAD_OP_LOAD);
+ store_ops.push_back(XGL_ATTACHMENT_STORE_OP_STORE);
+ clear_colors.push_back(m_clear_color);
}
// Create Framebuffer and RenderPass with color attachments and any depth/stencil attachment
- XGL_ATTACHMENT_LOAD_OP load_op = XGL_ATTACHMENT_LOAD_OP_LOAD;
- XGL_ATTACHMENT_STORE_OP store_op = XGL_ATTACHMENT_STORE_OP_STORE;
- XGL_CLEAR_COLOR clear_color;
- clear_color.color.rawColor[0] = 64;
- clear_color.color.rawColor[1] = 64;
- clear_color.color.rawColor[2] = 64;
- clear_color.color.rawColor[3] = 0;
- clear_color.useRawValue = XGL_TRUE;
XGL_DEPTH_STENCIL_BIND_INFO *dsBinding;
if (m_depthStencilBinding.view)
dsBinding = &m_depthStencilBinding;
@@ -211,19 +209,26 @@
fb_info.layers = 1;
XGL_RENDER_PASS_CREATE_INFO rp_info;
+
memset(&rp_info, 0 , sizeof(rp_info));
- xglCreateFramebuffer(device(), &fb_info, &(m_frameBuffer));
- rp_info.framebuffer = m_frameBuffer;
+ xglCreateFramebuffer(device(), &fb_info, &m_framebuffer);
+
rp_info.sType = XGL_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
rp_info.renderArea.extent.width = m_width;
rp_info.renderArea.extent.height = m_height;
rp_info.colorAttachmentCount = m_renderTargets.size();
- rp_info.pColorLoadOps = &load_op;
- rp_info.pColorStoreOps = &store_op;
- rp_info.pColorLoadClearValues = &clear_color;
+ rp_info.pColorFormats = &m_render_target_fmt;
+ rp_info.pColorLayouts = &m_colorBindings[0].layout;
+ rp_info.pColorLoadOps = &load_ops[0];
+ rp_info.pColorStoreOps = &store_ops[0];
+ rp_info.pColorLoadClearValues = &clear_colors[0];
+ rp_info.depthStencilFormat = m_depth_stencil_fmt;
+ rp_info.depthStencilLayout = m_depthStencilBinding.layout;
rp_info.depthLoadOp = XGL_ATTACHMENT_LOAD_OP_LOAD;
+ rp_info.depthLoadClearValue = m_depth_clear_color;
rp_info.depthStoreOp = XGL_ATTACHMENT_STORE_OP_STORE;
rp_info.stencilLoadOp = XGL_ATTACHMENT_LOAD_OP_LOAD;
+ rp_info.stencilLoadClearValue = m_stencil_clear_color;
rp_info.stencilStoreOp = XGL_ATTACHMENT_STORE_OP_STORE;
xglCreateRenderPass(device(), &rp_info, &m_renderPass);
}
@@ -1128,9 +1133,9 @@
return XGL_SUCCESS;
}
-XGL_RESULT XglCommandBufferObj::BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj)
+XGL_RESULT XglCommandBufferObj::BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj, XGL_FRAMEBUFFER framebuffer_obj)
{
- begin(renderpass_obj);
+ begin(renderpass_obj, framebuffer_obj);
return XGL_SUCCESS;
}
@@ -1283,6 +1288,21 @@
}
}
+void XglCommandBufferObj::BeginRenderPass(XGL_RENDER_PASS renderpass, XGL_FRAMEBUFFER framebuffer)
+{
+ XGL_RENDER_PASS_BEGIN rp_begin = {
+ renderpass,
+ framebuffer,
+ };
+
+ xglCmdBeginRenderPass( obj(), &rp_begin);
+}
+
+void XglCommandBufferObj::EndRenderPass(XGL_RENDER_PASS renderpass)
+{
+ xglCmdEndRenderPass( obj(), renderpass);
+}
+
void XglCommandBufferObj::BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject)
{
xglCmdBindDynamicStateObject( obj(), stateBindPoint, stateObject);
diff --git a/tests/xglrenderframework.h b/tests/xglrenderframework.h
index 4bf55f1..531063d 100644
--- a/tests/xglrenderframework.h
+++ b/tests/xglrenderframework.h
@@ -55,6 +55,7 @@
XGL_DEVICE device() {return m_device->device();}
XGL_PHYSICAL_GPU gpu() {return objs[0];}
XGL_RENDER_PASS renderPass() {return m_renderPass;}
+ XGL_FRAMEBUFFER framebuffer() {return m_framebuffer;}
void InitViewport(float width, float height);
void InitViewport();
void InitRenderTarget();
@@ -72,7 +73,7 @@
XglDevice *m_device;
XGL_CMD_BUFFER m_cmdBuffer;
XGL_RENDER_PASS m_renderPass;
- XGL_FRAMEBUFFER m_frameBuffer;
+ XGL_FRAMEBUFFER m_framebuffer;
XGL_MEMORY_REF m_memRefs[5];
XGL_DYNAMIC_RS_STATE_OBJECT m_stateRaster;
XGL_DYNAMIC_CB_STATE_OBJECT m_colorBlend;
@@ -118,7 +119,7 @@
XglCommandBufferObj(XglDevice *device);
XGL_CMD_BUFFER GetBufferHandle();
XGL_RESULT BeginCommandBuffer(XGL_CMD_BUFFER_BEGIN_INFO *pInfo);
- XGL_RESULT BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj);
+ XGL_RESULT BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj, XGL_FRAMEBUFFER framebuffer_obj);
XGL_RESULT BeginCommandBuffer();
XGL_RESULT EndCommandBuffer();
void PipelineBarrier(XGL_PIPELINE_BARRIER *barrierPtr);
@@ -131,6 +132,8 @@
void BindVertexBuffer(XglConstantBufferObj *vertexBuffer, uint32_t offset, uint32_t binding);
void BindIndexBuffer(XglIndexBufferObj *indexBuffer, uint32_t offset);
void BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject);
+ void BeginRenderPass(XGL_RENDER_PASS renderpass, XGL_FRAMEBUFFER framebuffer);
+ void EndRenderPass(XGL_RENDER_PASS renderpass);
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 QueueCommandBuffer(XGL_MEMORY_REF *memRefs, uint32_t numMemRefs);
diff --git a/tests/xgltestbinding.cpp b/tests/xgltestbinding.cpp
index fcd91b7..8394566 100644
--- a/tests/xgltestbinding.cpp
+++ b/tests/xgltestbinding.cpp
@@ -914,13 +914,14 @@
EXPECT(xglBeginCommandBuffer(obj(), info) == XGL_SUCCESS);
}
-void CmdBuffer::begin(XGL_RENDER_PASS renderpass_obj)
+void CmdBuffer::begin(XGL_RENDER_PASS renderpass_obj, XGL_FRAMEBUFFER framebuffer_obj)
{
XGL_CMD_BUFFER_BEGIN_INFO info = {};
XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO graphics_cmd_buf_info = {};
graphics_cmd_buf_info.sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO;
graphics_cmd_buf_info.pNext = NULL;
- graphics_cmd_buf_info.renderPass = renderpass_obj;
+ graphics_cmd_buf_info.renderPassContinue.renderPass = renderpass_obj;
+ graphics_cmd_buf_info.renderPassContinue.framebuffer = framebuffer_obj;
info.flags = XGL_CMD_BUFFER_OPTIMIZE_GPU_SMALL_BATCH_BIT |
XGL_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT;
diff --git a/tests/xgltestbinding.h b/tests/xgltestbinding.h
index 4d1f213..86f27f0 100644
--- a/tests/xgltestbinding.h
+++ b/tests/xgltestbinding.h
@@ -591,7 +591,7 @@
// xglBeginCommandBuffer()
void begin(const XGL_CMD_BUFFER_BEGIN_INFO *info);
- void begin(XGL_RENDER_PASS renderpass_obj);
+ void begin(XGL_RENDER_PASS renderpass_obj, XGL_FRAMEBUFFER framebuffer_obj);
void begin();
// xglEndCommandBuffer()