Handle arrays of objects in shaders

This commit is contained in:
baldurk
2016-02-07 18:46:32 +01:00
parent 13907a6c05
commit a012652049
5 changed files with 25 additions and 0 deletions
+1
View File
@@ -226,6 +226,7 @@ struct BindpointMap
int32_t bindset;
int32_t bind;
bool32 used;
uint32_t arraySize;
};
struct ShaderBindpointMapping
+2
View File
@@ -531,6 +531,7 @@ D3D11PipelineState D3D11Replay::MakePipelineState()
dst.BindpointMapping.ConstantBlocks[s].bindset = 0;
dst.BindpointMapping.ConstantBlocks[s].bind = s;
dst.BindpointMapping.ConstantBlocks[s].used = true;
dst.BindpointMapping.ConstantBlocks[i].arraySize = 1;
}
create_array_uninit(dst.BindpointMapping.Resources, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
@@ -539,6 +540,7 @@ D3D11PipelineState D3D11Replay::MakePipelineState()
dst.BindpointMapping.Resources[s].bindset = 0;
dst.BindpointMapping.Resources[s].bind = s;
dst.BindpointMapping.Resources[s].used = true;
dst.BindpointMapping.Resources[i].arraySize = 1;
}
create_array_uninit(dst.ConstantBuffers, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT);
+10
View File
@@ -1810,6 +1810,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
gl.glGetUniformiv(curProg, loc, dummyReadback);
mapping.Resources[i].bindset = 0;
mapping.Resources[i].bind = dummyReadback[0];
mapping.Resources[i].arraySize = 1;
}
// handle sampler arrays, use the base name
@@ -1851,6 +1852,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
mapping.Resources[i].bindset = -1;
mapping.Resources[i].bind = -1;
mapping.Resources[i].used = false;
mapping.Resources[i].arraySize = 1;
}
else
{
@@ -1863,6 +1865,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
mapping.Resources[i].bindset = -1;
mapping.Resources[i].bind = -1;
mapping.Resources[i].used = false;
mapping.Resources[i].arraySize = 1;
}
else
{
@@ -1879,6 +1882,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
GLint used = 0;
gl.glGetActiveAtomicCounterBufferiv(curProg, atomicIndex, atomicRefEnum[shadIdx], &used);
mapping.Resources[i].used = (used != 0);
mapping.Resources[i].arraySize = 1;
}
}
}
@@ -1892,6 +1896,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
mapping.Resources[i].bindset = -1;
mapping.Resources[i].bind = -1;
mapping.Resources[i].used = false;
mapping.Resources[i].arraySize = 1;
}
else
{
@@ -1901,13 +1906,16 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
GLint used = 0;
gl.glGetProgramResourceiv(curProg, eGL_SHADER_STORAGE_BLOCK, idx, 1, &refEnum[shadIdx], 1, NULL, &used);
mapping.Resources[i].used = (used != 0);
mapping.Resources[i].arraySize = 1;
}
}
}
else
{
mapping.Resources[i].bindset = -1;
mapping.Resources[i].bind = -1;
mapping.Resources[i].used = false;
mapping.Resources[i].arraySize = 1;
}
}
@@ -1924,12 +1932,14 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade
gl.glGetActiveUniformBlockiv(curProg, loc, eGL_UNIFORM_BLOCK_BINDING, dummyReadback);
mapping.ConstantBlocks[i].bindset = 0;
mapping.ConstantBlocks[i].bind = dummyReadback[0];
mapping.ConstantBlocks[i].arraySize = 1;
}
}
else
{
mapping.ConstantBlocks[i].bindset = -1;
mapping.ConstantBlocks[i].bind = -1;
mapping.ConstantBlocks[i].arraySize = 1;
}
if(!refl->ConstantBlocks.elems[i].bufferBacked)
@@ -2221,6 +2221,13 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp
if(type->type == SPVTypeData::ePointer)
type = type->baseType;
uint32_t arraySize = 1;
if(type->type == SPVTypeData::eArray)
{
arraySize = type->arraySize;
type = type->baseType;
}
if(type->type == SPVTypeData::eStruct)
{
ConstantBlock cblock;
@@ -2250,6 +2257,8 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp
bindmap.used = false;
bindmap.arraySize = arraySize;
for(size_t o=0; o < operations.size(); o++)
{
if(operations[o]->op)
@@ -2327,6 +2336,8 @@ void SPVModule::MakeReflection(ShaderReflection *reflection, ShaderBindpointMapp
bindmap.used = false;
bindmap.arraySize = arraySize;
for(size_t o=0; o < operations.size(); o++)
{
if(operations[o]->op)
+1
View File
@@ -452,6 +452,7 @@ namespace renderdoc
public Int32 bindset;
public Int32 bind;
public bool used;
public UInt32 arraySize;
};
[StructLayout(LayoutKind.Sequential)]