Clean up interfaces between objects
diff --git a/tests/tony_objs.cpp b/tests/tony_objs.cpp
index 7f3454d..076bf03 100644
--- a/tests/tony_objs.cpp
+++ b/tests/tony_objs.cpp
@@ -7,23 +7,23 @@
}
-void XglDescriptorSetObj::AttachMemoryView(XGL_MEMORY_VIEW_ATTACH_INFO* memoryView)
+void XglDescriptorSetObj::AttachMemoryView(XglConstantBufferObj *constantBuffer)
{
- m_memoryViews.push_back(memoryView);
+ m_memoryViews.push_back(&constantBuffer->m_constantBufferView);
m_memorySlots.push_back(m_nextSlot);
m_nextSlot++;
}
-void XglDescriptorSetObj::AttachSampler(XGL_SAMPLER* sampler)
+void XglDescriptorSetObj::AttachSampler(XglSamplerObj *sampler)
{
- m_samplers.push_back(sampler);
+ m_samplers.push_back(&sampler->m_sampler);
m_samplerSlots.push_back(m_nextSlot);
m_nextSlot++;
}
-void XglDescriptorSetObj::AttachImageView(XGL_IMAGE_VIEW_ATTACH_INFO* imageView)
+void XglDescriptorSetObj::AttachImageView(XglTextureObj *texture)
{
- m_imageViews.push_back(imageView);
+ m_imageViews.push_back(&texture->m_textureViewInfo);
m_imageSlots.push_back(m_nextSlot);
m_nextSlot++;
@@ -33,12 +33,12 @@
vector<XGL_OBJECT>objs )
{
int nSlots = m_memorySlots.size() + m_imageSlots.size() + m_samplerSlots.size();
- XGL_DESCRIPTOR_SLOT_INFO *slotInfo = (XGL_DESCRIPTOR_SLOT_INFO*) malloc( nSlots * sizeof(XGL_DESCRIPTOR_SLOT_INFO) );
- memset(slotInfo,0,nSlots*sizeof(XGL_DESCRIPTOR_SLOT_INFO));
+ m_slotInfo = (XGL_DESCRIPTOR_SLOT_INFO*) malloc( nSlots * sizeof(XGL_DESCRIPTOR_SLOT_INFO) );
+ memset(m_slotInfo,0,nSlots*sizeof(XGL_DESCRIPTOR_SLOT_INFO));
for (int i=0; i<nSlots; i++)
{
- slotInfo[i].slotObjectType = XGL_SLOT_UNUSED;
+ m_slotInfo[i].slotObjectType = XGL_SLOT_UNUSED;
}
for (int i=0; i<slots.size(); i++)
@@ -47,35 +47,35 @@
{
if ( (XGL_OBJECT) m_memoryViews[j] == objs[i])
{
- slotInfo[m_memorySlots[j]].shaderEntityIndex = slots[i];
- slotInfo[m_memorySlots[j]].slotObjectType = types[i];
+ m_slotInfo[m_memorySlots[j]].shaderEntityIndex = slots[i];
+ m_slotInfo[m_memorySlots[j]].slotObjectType = types[i];
}
}
for (int j=0; j<m_imageSlots.size(); j++)
{
if ( (XGL_OBJECT) m_imageViews[j] == objs[i])
{
- slotInfo[m_imageSlots[j]].shaderEntityIndex = slots[i];
- slotInfo[m_imageSlots[j]].slotObjectType = types[i];
+ m_slotInfo[m_imageSlots[j]].shaderEntityIndex = slots[i];
+ m_slotInfo[m_imageSlots[j]].slotObjectType = types[i];
}
}
for (int j=0; j<m_samplerSlots.size(); j++)
{
if ( (XGL_OBJECT) m_samplers[j] == objs[i])
{
- slotInfo[m_samplerSlots[j]].shaderEntityIndex = slots[i];
- slotInfo[m_samplerSlots[j]].slotObjectType = types[i];
+ m_slotInfo[m_samplerSlots[j]].shaderEntityIndex = slots[i];
+ m_slotInfo[m_samplerSlots[j]].slotObjectType = types[i];
}
}
}
for (int i=0;i<nSlots;i++)
{
- printf("SlotInfo[%d]: Index = %d, Type = %d\n",i,slotInfo[i].shaderEntityIndex, slotInfo[i].slotObjectType);
+ printf("SlotInfo[%d]: Index = %d, Type = %d\n",i,m_slotInfo[i].shaderEntityIndex, m_slotInfo[i].slotObjectType);
fflush(stdout);
}
- return(slotInfo);
+ return(m_slotInfo);
}
@@ -384,25 +384,25 @@
return stageInfo;
}
-void XglShaderObj::BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XGL_OBJECT object)
+void XglShaderObj::BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer)
{
m_memSlots.push_back(slot);
m_memTypes.push_back(type);
- m_memObjs.push_back(object);
+ m_memObjs.push_back((XGL_OBJECT) &constantBuffer->m_constantBufferView);
}
-void XglShaderObj::BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XGL_OBJECT object)
+void XglShaderObj::BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture)
{
m_imageSlots.push_back(slot);
m_imageTypes.push_back(type);
- m_imageObjs.push_back(object);
+ m_imageObjs.push_back((XGL_OBJECT) &texture->m_textureViewInfo);
}
-void XglShaderObj::BindShaderEntitySlotToSampler(int slot, XGL_OBJECT object)
+void XglShaderObj::BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler)
{
m_samplerSlots.push_back(slot);
m_samplerTypes.push_back(XGL_SLOT_SHADER_SAMPLER);
- m_samplerObjs.push_back(object);
+ m_samplerObjs.push_back(sampler->m_sampler);
}
XglShaderObj::XglShaderObj(XglDevice *device, const char * shader_code, XGL_PIPELINE_SHADER_STAGE stage)
@@ -466,7 +466,8 @@
XGL_RESULT err;
m_device = device;
- m_vi_attrib_count = m_vi_binding_count = m_vertexBufferCount = 0;
+ m_vi_state.attributeCount = m_vi_state.bindingCount = 0;
+ m_vertexBufferCount = 0;
m_ia_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO;
m_ia_state.pNext = XGL_NULL_HANDLE;
@@ -512,14 +513,14 @@
void XglPipelineObj::AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count)
{
- m_vi_attribs = vi_attrib;
- m_vi_attrib_count = count;
+ m_vi_state.pVertexAttributeDescriptions = vi_attrib;
+ m_vi_state.attributeCount = count;
}
void XglPipelineObj::AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count)
{
- m_vi_binding = vi_binding;
- m_vi_binding_count = count;
+ m_vi_state.pVertexBindingDescriptions = vi_binding;
+ m_vi_state.bindingCount = count;
}
void XglPipelineObj::AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding)
@@ -545,14 +546,10 @@
head_ptr = shaderCreateInfo;
}
- if (m_vi_attrib_count && m_vi_binding_count)
+ if (m_vi_state.attributeCount && m_vi_state.bindingCount)
{
m_vi_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO;
m_vi_state.pNext = head_ptr;
- m_vi_state.bindingCount = m_vi_binding_count;
- m_vi_state.pVertexBindingDescriptions = m_vi_binding;
- m_vi_state.attributeCount = m_vi_attrib_count;
- m_vi_state.pVertexAttributeDescriptions = m_vi_attribs;
head_ptr = &m_vi_state;
}
@@ -578,8 +575,11 @@
XglMemoryRefManager::XglMemoryRefManager() {
}
-void XglMemoryRefManager::AddMemoryRef(XGL_GPU_MEMORY *memoryRef) {
- m_bufferObjs.push_back(memoryRef);
+void XglMemoryRefManager::AddMemoryRef(XglConstantBufferObj *constantBuffer) {
+ m_bufferObjs.push_back(&constantBuffer->m_constantBufferMem);
+}
+void XglMemoryRefManager::AddMemoryRef(XglTextureObj *texture) {
+ m_bufferObjs.push_back(&texture->m_textureMem);
}
XGL_MEMORY_REF* XglMemoryRefManager::GetMemoryRefList() {
diff --git a/tests/tony_render_tests.cpp b/tests/tony_render_tests.cpp
index fca4167..4d2e615 100644
--- a/tests/tony_render_tests.cpp
+++ b/tests/tony_render_tests.cpp
@@ -626,15 +626,15 @@
XglShaderObj vs(m_device,vertShaderText,XGL_SHADER_STAGE_VERTEX );
XglShaderObj ps(m_device,fragShaderText, XGL_SHADER_STAGE_FRAGMENT);
- vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &constantBuffer.m_constantBufferView);
+ vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &constantBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&constantBuffer.m_constantBufferView);
- m_memoryRefManager.AddMemoryRef(&constantBuffer.m_constantBufferMem);
+ descriptorSet.AttachMemoryView(&constantBuffer);
+ m_memoryRefManager.AddMemoryRef(&constantBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
@@ -927,14 +927,14 @@
const float constants[constantCount] = { 1.0, 0.0, 0.0, 1.0,
0.0, 0.0, 1.0, 1.0 };
XglConstantBufferObj constantBuffer(m_device,constantCount, sizeof(constants[0]), (const void*) constants);
- ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &constantBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &constantBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&constantBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&constantBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -978,7 +978,7 @@
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&meshBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&meshBuffer);
XGL_VERTEX_INPUT_BINDING_DESCRIPTION vi_binding = {
sizeof(g_vbData[0]), // strideInBytes; Distance between vertices in bytes (0 = no advancement)
@@ -1041,17 +1041,17 @@
XglShaderObj vs(m_device,vertShaderText,XGL_SHADER_STAGE_VERTEX );
XglShaderObj ps(m_device,fragShaderText, XGL_SHADER_STAGE_FRAGMENT);
- vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &MVPBuffer.m_constantBufferView);
+ vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &MVPBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
// Create descriptor set and attach the constant buffer to it
- XglDescriptorSetObj descriptorSet(m_device); XGL_RESULT err = XGL_SUCCESS;
- descriptorSet.AttachMemoryView(&MVPBuffer.m_constantBufferView);
+ XglDescriptorSetObj descriptorSet(m_device);
+ descriptorSet.AttachMemoryView(&MVPBuffer);
- m_memoryRefManager.AddMemoryRef(&MVPBuffer.m_constantBufferMem);
+ m_memoryRefManager.AddMemoryRef(&MVPBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(m_memoryRefManager.GetMemoryRefList(), m_memoryRefManager.GetNumRefs());
@@ -1157,7 +1157,7 @@
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&meshBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&meshBuffer);
XGL_VERTEX_INPUT_BINDING_DESCRIPTION vi_binding = {
sizeof(g_vbData[0]), // strideInBytes; Distance between vertices in bytes (0 = no advancement)
@@ -1230,7 +1230,7 @@
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&meshBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&meshBuffer);
XGL_VERTEX_INPUT_BINDING_DESCRIPTION vi_binding = {
sizeof(g_vbData[0]), // strideInBytes; Distance between vertices in bytes (0 = no advancement)
@@ -1302,17 +1302,17 @@
XglShaderObj vs(m_device,vertShaderText,XGL_SHADER_STAGE_VERTEX );
XglShaderObj ps(m_device,fragShaderText, XGL_SHADER_STAGE_FRAGMENT);
- vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &MVPBuffer.m_constantBufferView);
+ vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &MVPBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&MVPBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&MVPBuffer);
- m_memoryRefManager.AddMemoryRef(&meshBuffer.m_constantBufferMem);
- m_memoryRefManager.AddMemoryRef(&MVPBuffer.m_constantBufferMem);
+ m_memoryRefManager.AddMemoryRef(&meshBuffer);
+ m_memoryRefManager.AddMemoryRef(&MVPBuffer);
XGL_VERTEX_INPUT_BINDING_DESCRIPTION vi_binding = {
sizeof(g_vbData[0]), // strideInBytes; Distance between vertices in bytes (0 = no advancement)
@@ -1378,18 +1378,18 @@
XglSamplerObj sampler(m_device);
XglTextureObj texture(m_device);
- vs.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &texture.m_textureViewInfo);
- vs.BindShaderEntitySlotToSampler(0, (XGL_OBJECT) &sampler.m_sampler);
+ vs.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, &texture);
+ vs.BindShaderEntitySlotToSampler(0, &sampler);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachImageView(&texture.m_textureViewInfo);
- descriptorSet.AttachSampler(&sampler.m_sampler);
+ descriptorSet.AttachImageView(&texture);
+ descriptorSet.AttachSampler(&sampler);
- m_memoryRefManager.AddMemoryRef(&texture.m_textureMem);
+ m_memoryRefManager.AddMemoryRef(&texture);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1436,18 +1436,18 @@
XglSamplerObj sampler(m_device);
XglTextureObj texture(m_device);
- ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &texture.m_textureViewInfo);
- ps.BindShaderEntitySlotToSampler(0, (XGL_OBJECT) &sampler.m_sampler);
+ ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, &texture);
+ ps.BindShaderEntitySlotToSampler(0, &sampler);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachImageView(&texture.m_textureViewInfo);
- descriptorSet.AttachSampler(&sampler.m_sampler);
+ descriptorSet.AttachImageView(&texture);
+ descriptorSet.AttachSampler(&sampler);
- m_memoryRefManager.AddMemoryRef(&texture.m_textureMem);
+ m_memoryRefManager.AddMemoryRef(&texture);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1504,18 +1504,18 @@
XglSamplerObj sampler(m_device);
XglTextureObj texture(m_device);
- ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &texture.m_textureViewInfo);
- ps.BindShaderEntitySlotToSampler(0, (XGL_OBJECT) &sampler.m_sampler);
+ ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, &texture);
+ ps.BindShaderEntitySlotToSampler(0, &sampler);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachImageView(&texture.m_textureViewInfo);
- descriptorSet.AttachSampler(&sampler.m_sampler);
+ descriptorSet.AttachImageView(&texture);
+ descriptorSet.AttachSampler(&sampler);
- m_memoryRefManager.AddMemoryRef(&texture.m_textureMem);
+ m_memoryRefManager.AddMemoryRef(&texture);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1561,18 +1561,18 @@
XglSamplerObj sampler(m_device);
XglTextureObj texture(m_device);
- ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &texture.m_textureViewInfo);
- ps.BindShaderEntitySlotToSampler(0, (XGL_OBJECT) &sampler.m_sampler);
+ ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, &texture);
+ ps.BindShaderEntitySlotToSampler(0, &sampler);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachImageView(&texture.m_textureViewInfo);
- descriptorSet.AttachSampler(&sampler.m_sampler);
+ descriptorSet.AttachImageView(&texture);
+ descriptorSet.AttachSampler(&sampler);
- m_memoryRefManager.AddMemoryRef(&texture.m_textureMem);
+ m_memoryRefManager.AddMemoryRef(&texture);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1629,14 +1629,14 @@
1.0, 1.0, 1.0, 1.0 };
XglConstantBufferObj colorBuffer(m_device, valCount, sizeof(bufferVals[0]), (const void*) bufferVals);
- vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &colorBuffer.m_constantBufferView);
+ vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &colorBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&colorBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&colorBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1704,26 +1704,26 @@
const int whiteCount = sizeof(whiteVals) / sizeof(float);
XglConstantBufferObj redBuffer(m_device, redCount, sizeof(redVals[0]), (const void*) redVals);
- ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &redBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &redBuffer);
XglConstantBufferObj greenBuffer(m_device, greenCount, sizeof(greenVals[0]), (const void*) greenVals);
- ps.BindShaderEntitySlotToMemory(1, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &greenBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(1, XGL_SLOT_SHADER_RESOURCE, &greenBuffer);
XglConstantBufferObj blueBuffer(m_device, blueCount, sizeof(blueVals[0]), (const void*) blueVals);
- ps.BindShaderEntitySlotToMemory(2, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &blueBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(2, XGL_SLOT_SHADER_RESOURCE, &blueBuffer);
XglConstantBufferObj whiteBuffer(m_device, whiteCount, sizeof(whiteVals[0]), (const void*) whiteVals);
- ps.BindShaderEntitySlotToMemory(3, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &whiteBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(3, XGL_SLOT_SHADER_RESOURCE, &whiteBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&redBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&greenBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&blueBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&whiteBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&redBuffer);
+ descriptorSet.AttachMemoryView(&greenBuffer);
+ descriptorSet.AttachMemoryView(&blueBuffer);
+ descriptorSet.AttachMemoryView(&whiteBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1788,26 +1788,26 @@
const int whiteCount = sizeof(whiteVals) / sizeof(float);
XglConstantBufferObj redBuffer(m_device, redCount, sizeof(redVals[0]), (const void*) redVals);
- ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &redBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &redBuffer);
XglConstantBufferObj greenBuffer(m_device, greenCount, sizeof(greenVals[0]), (const void*) greenVals);
- ps.BindShaderEntitySlotToMemory(1, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &greenBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(1, XGL_SLOT_SHADER_RESOURCE, &greenBuffer);
XglConstantBufferObj blueBuffer(m_device, blueCount, sizeof(blueVals[0]), (const void*) blueVals);
- ps.BindShaderEntitySlotToMemory(2, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &blueBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(2, XGL_SLOT_SHADER_RESOURCE, &blueBuffer);
XglConstantBufferObj whiteBuffer(m_device, whiteCount, sizeof(whiteVals[0]), (const void*) whiteVals);
- ps.BindShaderEntitySlotToMemory(3, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &whiteBuffer.m_constantBufferView);
+ ps.BindShaderEntitySlotToMemory(3, XGL_SLOT_SHADER_RESOURCE, &whiteBuffer);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
pipelineobj.AddShader(&ps);
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&redBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&greenBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&blueBuffer.m_constantBufferView);
- descriptorSet.AttachMemoryView(&whiteBuffer.m_constantBufferView);
+ descriptorSet.AttachMemoryView(&redBuffer);
+ descriptorSet.AttachMemoryView(&greenBuffer);
+ descriptorSet.AttachMemoryView(&blueBuffer);
+ descriptorSet.AttachMemoryView(&whiteBuffer);
GenericDrawTriangleTest(pipelineobj, descriptorSet, 1);
QueueCommandBuffer(NULL, 0);
@@ -1875,9 +1875,9 @@
XglTextureObj texture(m_device);
// vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_VERTEX_INPUT, (XGL_OBJECT) &meshBuffer.m_constantBufferView);
- vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &mvpBuffer.m_constantBufferView);
- ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, (XGL_OBJECT) &texture.m_textureViewInfo);
- ps.BindShaderEntitySlotToSampler(0, (XGL_OBJECT) &sampler.m_sampler);
+ vs.BindShaderEntitySlotToMemory(0, XGL_SLOT_SHADER_RESOURCE, &mvpBuffer);
+ ps.BindShaderEntitySlotToImage(0, XGL_SLOT_SHADER_RESOURCE, &texture);
+ ps.BindShaderEntitySlotToSampler(0, &sampler);
XglPipelineObj pipelineobj(m_device);
pipelineobj.AddShader(&vs);
@@ -1885,14 +1885,13 @@
XglDescriptorSetObj descriptorSet(m_device);
- descriptorSet.AttachMemoryView(&mvpBuffer.m_constantBufferView);
- // descriptorSet.AttachMemoryView(&meshBuffer.m_constantBufferView);
- descriptorSet.AttachImageView(&texture.m_textureViewInfo);
- descriptorSet.AttachSampler(&sampler.m_sampler);
+ descriptorSet.AttachMemoryView(&mvpBuffer);
+ descriptorSet.AttachImageView(&texture);
+ descriptorSet.AttachSampler(&sampler);
- m_memoryRefManager.AddMemoryRef(&meshBuffer.m_constantBufferMem);
- m_memoryRefManager.AddMemoryRef(&mvpBuffer.m_constantBufferMem);
- m_memoryRefManager.AddMemoryRef(&texture.m_textureMem);
+ m_memoryRefManager.AddMemoryRef(&meshBuffer);
+ m_memoryRefManager.AddMemoryRef(&mvpBuffer);
+ m_memoryRefManager.AddMemoryRef(&texture);
XGL_VERTEX_INPUT_BINDING_DESCRIPTION vi_binding = {
sizeof(g_vbData[0]), // strideInBytes; Distance between vertices in bytes (0 = no advancement)
diff --git a/tests/xglrenderframework.h b/tests/xglrenderframework.h
index da1e204..8757ea3 100644
--- a/tests/xglrenderframework.h
+++ b/tests/xglrenderframework.h
@@ -120,30 +120,19 @@
}
};
-class XglDescriptorSetObj
+class XglConstantBufferObj
{
public:
- XglDescriptorSetObj(XglDevice *device);
- void AttachMemoryView( XGL_MEMORY_VIEW_ATTACH_INFO* memoryView);
- void AttachSampler( XGL_SAMPLER* sampler);
- void AttachImageView( XGL_IMAGE_VIEW_ATTACH_INFO* imageView);
- void BindCommandBuffer(XGL_CMD_BUFFER commandBuffer);
- XGL_DESCRIPTOR_SLOT_INFO * GetSlotInfo(vector<int>slots, vector<XGL_DESCRIPTOR_SET_SLOT_TYPE>types, vector<XGL_OBJECT>objs );
+ XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data);
+ void SetMemoryState(XGL_CMD_BUFFER cmdBuffer, XGL_MEMORY_STATE newState);
+ XGL_MEMORY_VIEW_ATTACH_INFO m_constantBufferView;
+ XGL_GPU_MEMORY m_constantBufferMem;
protected:
- XGL_DESCRIPTOR_SET_CREATE_INFO m_descriptorInfo;
- XGL_DESCRIPTOR_SET m_rsrcDescSet;
- XGL_GPU_MEMORY m_descriptor_set_mem;
- XglDevice *m_device;
- int m_nextSlot;
- vector<int> m_memorySlots;
- vector<XGL_MEMORY_VIEW_ATTACH_INFO*> m_memoryViews;
- vector<int> m_samplerSlots;
- vector<XGL_SAMPLER*> m_samplers;
- vector<int> m_imageSlots;
- vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageViews;
+ XglDevice *m_device;
+ int m_numVertices;
+ int m_stride;
};
-
class XglTextureObj
{
public:
@@ -170,27 +159,40 @@
};
-class XglConstantBufferObj
+class XglDescriptorSetObj
{
public:
- XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data);
- void SetMemoryState(XGL_CMD_BUFFER cmdBuffer, XGL_MEMORY_STATE newState);
- XGL_MEMORY_VIEW_ATTACH_INFO m_constantBufferView;
- XGL_GPU_MEMORY m_constantBufferMem;
+ XglDescriptorSetObj(XglDevice *device);
+ void AttachMemoryView(XglConstantBufferObj* constantBuffer);
+ void AttachSampler( XglSamplerObj* sampler);
+ void AttachImageView( XglTextureObj* texture);
+ void BindCommandBuffer(XGL_CMD_BUFFER commandBuffer);
+ XGL_DESCRIPTOR_SLOT_INFO * GetSlotInfo(vector<int>slots, vector<XGL_DESCRIPTOR_SET_SLOT_TYPE>types, vector<XGL_OBJECT>objs );
protected:
- XglDevice *m_device;
- int m_numVertices;
- int m_stride;
+ XGL_DESCRIPTOR_SET_CREATE_INFO m_descriptorInfo;
+ XGL_DESCRIPTOR_SET m_rsrcDescSet;
+ XGL_GPU_MEMORY m_descriptor_set_mem;
+ XglDevice *m_device;
+ XGL_DESCRIPTOR_SLOT_INFO *m_slotInfo;
+ int m_nextSlot;
+ vector<int> m_memorySlots;
+ vector<XGL_MEMORY_VIEW_ATTACH_INFO*> m_memoryViews;
+ vector<int> m_samplerSlots;
+ vector<XGL_SAMPLER*> m_samplers;
+ vector<int> m_imageSlots;
+ vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageViews;
};
+
+
class XglShaderObj
{
public:
XglShaderObj(XglDevice *device, const char * shaderText, XGL_PIPELINE_SHADER_STAGE stage );
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* GetStageCreateInfo(XglDescriptorSetObj descriptorSet);
- void BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XGL_OBJECT object);
- void BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XGL_OBJECT object);
- void BindShaderEntitySlotToSampler(int slot, XGL_OBJECT object);
+ void BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer);
+ void BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture);
+ void BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler);
protected:
XGL_PIPELINE_SHADER_STAGE_CREATE_INFO stage_info;
@@ -230,10 +232,6 @@
XGL_PIPELINE_CB_ATTACHMENT_STATE m_cb_attachment_state;
XGL_GPU_MEMORY m_pipe_mem;
XglDevice *m_device;
- XGL_VERTEX_INPUT_BINDING_DESCRIPTION *m_vi_binding;
- int m_vi_binding_count;
- XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION *m_vi_attribs;
- int m_vi_attrib_count;
vector<XglShaderObj*> m_shaderObjs;
vector<XglConstantBufferObj*> m_vertexBufferObjs;
vector<int> m_vertexBufferBindings;
@@ -243,7 +241,8 @@
class XglMemoryRefManager{
public:
XglMemoryRefManager();
- void AddMemoryRef(XGL_GPU_MEMORY* memoryRef);
+ void AddMemoryRef(XglConstantBufferObj* constantBuffer);
+ void AddMemoryRef(XglTextureObj *texture);
XGL_MEMORY_REF* GetMemoryRefList();
int GetNumRefs();