[Coverity] Remove some dodgy code to iterate shader stages

This commit is contained in:
baldurk
2016-07-20 18:42:10 +02:00
parent 0f6bc31b2c
commit e8e1b34d26
3 changed files with 43 additions and 19 deletions
+15 -5
View File
@@ -104,9 +104,11 @@ void D3D11RenderState::ReleaseRefs()
for(UINT i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++)
ReleaseRef(IA.VBs[i]);
shader *sh = &VS;
shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS};
for(int s = 0; s < 6; s++)
{
shader *sh = stages[s];
ReleaseRef(sh->Shader);
for(UINT i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
@@ -217,9 +219,11 @@ void D3D11RenderState::MarkReferenced(WrappedID3D11DeviceContext *ctx, bool init
ctx->MarkResourceReferenced(GetIDForResource(IA.VBs[i]),
initial ? eFrameRef_Unknown : eFrameRef_Read);
const shader *sh = &VS;
const shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS};
for(int s = 0; s < 6; s++)
{
const shader *sh = stages[s];
ctx->MarkResourceReferenced(GetIDForResource(sh->Shader),
initial ? eFrameRef_Unknown : eFrameRef_Read);
@@ -419,9 +423,11 @@ void D3D11RenderState::AddRefs()
for(UINT i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++)
TakeRef(IA.VBs[i]);
shader *sh = &VS;
shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS};
for(int s = 0; s < 6; s++)
{
shader *sh = stages[s];
TakeRef(sh->Shader);
for(UINT i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
@@ -517,9 +523,11 @@ void D3D11RenderState::Serialise(LogState m_State, WrappedID3D11Device *device)
#undef MAKE_NAMES
shader *sh = &VS;
shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS};
for(int s = 0; s < 6; s++)
{
shader *sh = stages[s];
SERIALISE_ELEMENT(ResourceId, Shader, GetIDForResource(sh->Shader));
if(m_State < WRITING)
{
@@ -1108,9 +1116,11 @@ void D3D11RenderState::UnbindIUnknownForRead(const ResourceRange &range, bool al
}
// const char *names[] = { "VS", "DS", "HS", "GS", "PS", "CS" };
shader *sh = &VS;
shader *stages[] = {&VS, &HS, &DS, &GS, &PS, &CS};
for(int s = 0; s < 6; s++)
{
shader *sh = stages[s];
for(UINT i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++)
{
if(range.Intersects(ResourceRange(sh->ConstantBuffers[i])))
+6 -4
View File
@@ -498,15 +498,17 @@ D3D11PipelineState D3D11Replay::MakePipelineState()
/////////////////////////////////////////////////
{
D3D11PipelineState::ShaderStage *dstArr = &ret.m_VS;
const D3D11RenderState::shader *srcArr = &rs->VS;
D3D11PipelineState::ShaderStage *dstArr[] = {&ret.m_VS, &ret.m_HS, &ret.m_DS,
&ret.m_GS, &ret.m_PS, &ret.m_CS};
const D3D11RenderState::shader *srcArr[] = {&rs->VS, &rs->HS, &rs->DS,
&rs->GS, &rs->PS, &rs->CS};
const char *stageNames[] = {"Vertex", "Hull", "Domain", "Geometry", "Pixel", "Compute"};
for(size_t stage = 0; stage < 6; stage++)
{
D3D11PipelineState::ShaderStage &dst = dstArr[stage];
const D3D11RenderState::shader &src = srcArr[stage];
D3D11PipelineState::ShaderStage &dst = *dstArr[stage];
const D3D11RenderState::shader &src = *srcArr[stage];
dst.stage = (ShaderStageType)stage;
+22 -10
View File
@@ -1627,25 +1627,37 @@ void ReplayRenderer::FetchPipelineState()
m_VulkanPipelineState = m_pDevice->GetVulkanPipelineState();
{
D3D11PipelineState::ShaderStage *stage = &m_D3D11PipelineState.m_VS;
D3D11PipelineState::ShaderStage *stages[] = {
&m_D3D11PipelineState.m_VS, &m_D3D11PipelineState.m_HS, &m_D3D11PipelineState.m_DS,
&m_D3D11PipelineState.m_GS, &m_D3D11PipelineState.m_PS, &m_D3D11PipelineState.m_CS,
};
for(int i = 0; i < 6; i++)
if(stage[i].Shader != ResourceId())
stage[i].ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stage[i].Shader), "");
if(stages[i]->Shader != ResourceId())
stages[i]->ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stages[i]->Shader), "");
}
{
GLPipelineState::ShaderStage *stage = &m_GLPipelineState.m_VS;
GLPipelineState::ShaderStage *stages[] = {
&m_GLPipelineState.m_VS, &m_GLPipelineState.m_TCS, &m_GLPipelineState.m_TES,
&m_GLPipelineState.m_GS, &m_GLPipelineState.m_FS, &m_GLPipelineState.m_CS,
};
for(int i = 0; i < 6; i++)
if(stage[i].Shader != ResourceId())
stage[i].ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stage[i].Shader), "");
if(stages[i]->Shader != ResourceId())
stages[i]->ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stages[i]->Shader), "");
}
{
VulkanPipelineState::ShaderStage *stage = &m_VulkanPipelineState.VS;
VulkanPipelineState::ShaderStage *stages[] = {
&m_VulkanPipelineState.VS, &m_VulkanPipelineState.TCS, &m_VulkanPipelineState.TES,
&m_VulkanPipelineState.GS, &m_VulkanPipelineState.FS, &m_VulkanPipelineState.CS,
};
for(int i = 0; i < 6; i++)
if(stage[i].Shader != ResourceId())
stage[i].ShaderDetails =
m_pDevice->GetShader(m_pDevice->GetLiveID(stage[i].Shader), stage[i].entryPoint.elems);
if(stages[i]->Shader != ResourceId())
stages[i]->ShaderDetails = m_pDevice->GetShader(m_pDevice->GetLiveID(stages[i]->Shader),
stages[i]->entryPoint.elems);
}
}