binding: update for xglCmdBindDescriptorSets()
This update makes it possible to bind multiple descriptor sets to the command
buffer. We introduced intel_cmd_dset_data to hold the descriptor set offsets
in the global descriptor region as well as their dynamic offsets. We also
changed the descriptor reading routines from
intel_desc_set_read_surface()
intel_desc_set_read_sampler()
to
intel_desc_region_read_surface()
intel_desc_region_read_sampler()
v2: fix a potential crash when allocation of dynamic_desc_indices fails
diff --git a/include/xgl.h b/include/xgl.h
index f90b8a7..bae9c3f 100644
--- a/include/xgl.h
+++ b/include/xgl.h
@@ -2336,7 +2336,7 @@
typedef XGL_RESULT (XGLAPI *xglResetCommandBufferType)(XGL_CMD_BUFFER cmdBuffer);
typedef void (XGLAPI *xglCmdBindPipelineType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline);
typedef void (XGLAPI *xglCmdBindDynamicStateObjectType)(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state);
-typedef void (XGLAPI *xglCmdBindDescriptorSetType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET descriptorSet, const uint32_t* pUserData);
+typedef void (XGLAPI *xglCmdBindDescriptorSetsType)(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET_LAYOUT_CHAIN layoutChain, uint32_t layoutChainSlot, uint32_t count, const XGL_DESCRIPTOR_SET* pDescriptorSets, const uint32_t* pUserData);
typedef void (XGLAPI *xglCmdBindIndexBufferType)(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType);
typedef void (XGLAPI *xglCmdBindVertexBufferType)(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t binding);
typedef void (XGLAPI *xglCmdDrawType)(XGL_CMD_BUFFER cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
@@ -2807,10 +2807,13 @@
XGL_STATE_BIND_POINT stateBindPoint,
XGL_DYNAMIC_STATE_OBJECT dynamicState);
-void XGLAPI xglCmdBindDescriptorSet(
+void XGLAPI xglCmdBindDescriptorSets(
XGL_CMD_BUFFER cmdBuffer,
XGL_PIPELINE_BIND_POINT pipelineBindPoint,
- XGL_DESCRIPTOR_SET descriptorSet,
+ XGL_DESCRIPTOR_SET_LAYOUT_CHAIN layoutChain,
+ uint32_t layoutChainSlot,
+ uint32_t count,
+ const XGL_DESCRIPTOR_SET* pDescriptorSets,
const uint32_t* pUserData);
void XGLAPI xglCmdBindIndexBuffer(
diff --git a/include/xglLayer.h b/include/xglLayer.h
index 98e5253..6111bcb 100644
--- a/include/xglLayer.h
+++ b/include/xglLayer.h
@@ -104,7 +104,7 @@
xglResetCommandBufferType ResetCommandBuffer;
xglCmdBindPipelineType CmdBindPipeline;
xglCmdBindDynamicStateObjectType CmdBindDynamicStateObject;
- xglCmdBindDescriptorSetType CmdBindDescriptorSet;
+ xglCmdBindDescriptorSetsType CmdBindDescriptorSets;
xglCmdBindVertexBufferType CmdBindVertexBuffer;
xglCmdBindIndexBufferType CmdBindIndexBuffer;
xglCmdDrawType CmdDraw;
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index cf8b398..57019aa 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -301,7 +301,7 @@
descriptorSet->CreateXGLDescriptorSet(cmdBuffer);
pipelineobj->CreateXGLPipeline(descriptorSet);
cmdBuffer->BindPipeline(pipelineobj->GetPipelineHandle());
- cmdBuffer->BindDescriptorSet(descriptorSet->GetDescriptorSetHandle());
+ cmdBuffer->BindDescriptorSet(descriptorSet);
}
void XglRenderTest::RotateTriangleVSUniform(glm::mat4 Projection, glm::mat4 View, glm::mat4 Model,
diff --git a/tests/xglrenderframework.cpp b/tests/xglrenderframework.cpp
index f5788b5..cd7414c 100644
--- a/tests/xglrenderframework.cpp
+++ b/tests/xglrenderframework.cpp
@@ -314,12 +314,12 @@
return m_nextSlot++;
}
-XGL_DESCRIPTOR_SET_LAYOUT_CHAIN XglDescriptorSetObj::GetLayoutChain()
+XGL_DESCRIPTOR_SET_LAYOUT_CHAIN XglDescriptorSetObj::GetLayoutChain() const
{
return m_layout_chain.obj();
}
-XGL_DESCRIPTOR_SET XglDescriptorSetObj::GetDescriptorSetHandle()
+XGL_DESCRIPTOR_SET XglDescriptorSetObj::GetDescriptorSetHandle() const
{
return m_set->obj();
}
@@ -1421,10 +1421,13 @@
xglCmdBindPipeline( obj(), XGL_PIPELINE_BIND_POINT_GRAPHICS, pipeline );
}
-void XglCommandBufferObj::BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet)
+void XglCommandBufferObj::BindDescriptorSet(const XglDescriptorSetObj *set)
{
+ XGL_DESCRIPTOR_SET set_obj = set->GetDescriptorSetHandle();
+
// bind pipeline, vertex buffer (descriptor set) and WVP (dynamic buffer view)
- xglCmdBindDescriptorSet(obj(), XGL_PIPELINE_BIND_POINT_GRAPHICS, descriptorSet, NULL );
+ xglCmdBindDescriptorSets(obj(), XGL_PIPELINE_BIND_POINT_GRAPHICS,
+ set->GetLayoutChain(), 0, 1, &set_obj, NULL );
}
void XglCommandBufferObj::BindIndexBuffer(XglIndexBufferObj *indexBuffer, uint32_t offset)
{
diff --git a/tests/xglrenderframework.h b/tests/xglrenderframework.h
index 5b92c5d..4a08f83 100644
--- a/tests/xglrenderframework.h
+++ b/tests/xglrenderframework.h
@@ -128,6 +128,7 @@
}
};
+class XglDescriptorSetObj;
class XglIndexBufferObj;
class XglConstantBufferObj;
@@ -146,7 +147,7 @@
void ClearAllBuffers(XGL_CLEAR_COLOR clear_color, float depth_clear_color, uint32_t stencil_clear_color, XGL_DEPTH_STENCIL_BIND_INFO *depthStencilBinding, XGL_IMAGE depthStencilImage);
void PrepareAttachments();
void BindPipeline(XGL_PIPELINE pipeline);
- void BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet);
+ void BindDescriptorSet(const XglDescriptorSetObj *set);
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);
@@ -318,8 +319,8 @@
int AppendSamplerTexture(XglSamplerObj* sampler, XglTextureObj* texture);
void CreateXGLDescriptorSet(XglCommandBufferObj *cmdBuffer);
- XGL_DESCRIPTOR_SET GetDescriptorSetHandle();
- XGL_DESCRIPTOR_SET_LAYOUT_CHAIN GetLayoutChain();
+ XGL_DESCRIPTOR_SET GetDescriptorSetHandle() const;
+ XGL_DESCRIPTOR_SET_LAYOUT_CHAIN GetLayoutChain() const;
protected:
XglDevice *m_device;
diff --git a/xgl.py b/xgl.py
index f9c6d44..0f89e5c 100644
--- a/xgl.py
+++ b/xgl.py
@@ -602,10 +602,13 @@
Param("XGL_STATE_BIND_POINT", "stateBindPoint"),
Param("XGL_DYNAMIC_STATE_OBJECT", "state")]),
- Proto("void", "CmdBindDescriptorSet",
+ Proto("void", "CmdBindDescriptorSets",
[Param("XGL_CMD_BUFFER", "cmdBuffer"),
Param("XGL_PIPELINE_BIND_POINT", "pipelineBindPoint"),
- Param("XGL_DESCRIPTOR_SET", "descriptorSet"),
+ Param("XGL_DESCRIPTOR_SET_LAYOUT_CHAIN", "layoutChain"),
+ Param("uint32_t", "layoutChainSlot"),
+ Param("uint32_t", "count"),
+ Param("const XGL_DESCRIPTOR_SET*", "pDescriptorSets"),
Param("const uint32_t*", "pUserData")]),
Proto("void", "CmdBindVertexBuffer",