Skip to content

Commit

Permalink
D3D12 Shader Debug loop downwards from highest shader model to 6.0
Browse files Browse the repository at this point in the history
CheckFeatureSupport will return E_INVALIDARG if HighestShaderModel isn't known by the current runtime.
  • Loading branch information
Zorro666 committed Oct 29, 2024
1 parent 21db7b5 commit 4a73100
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions renderdoc/driver/d3d12/d3d12_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,29 @@ bool D3D12DebugManager::CreateShaderDebugResources()
RDCERR("Failed to compile DXIL vertex shader for shader debugging");
return false;
}
// CheckFeatureSupport returns E_INVALIDARG if HighestShaderModel isn't known by the current runtime.
int smMajor = 6;
int smMinor = -1;
for(smMinor = D3D_HIGHEST_SHADER_MODEL & 0xF; smMinor >= 0; smMinor--)
{
D3D_SHADER_MODEL smModel = (D3D_SHADER_MODEL)(smMajor << 4 | smMinor);
D3D12_FEATURE_DATA_SHADER_MODEL smMaxSupport = {smModel};
if(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &smMaxSupport,
sizeof(smMaxSupport)) == S_OK)
{
smMajor = smMaxSupport.HighestShaderModel >> 4;
smMinor = smMaxSupport.HighestShaderModel & 0xF;
break;
}
}
if(smMinor < 0)
{
RDCERR("Failed to find highest shader model 6.x supported by the current runtime");
return false;
}

ID3DBlob *dxilPsBlob = NULL;
D3D12_FEATURE_DATA_SHADER_MODEL smMaxSupport = {D3D_SHADER_MODEL_6_8};
m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &smMaxSupport, sizeof(smMaxSupport));
D3D_SHADER_MODEL smModel = smMaxSupport.HighestShaderModel;
rdcstr psSM = StringFormat::Fmt("ps_%d_%d", (smModel >> 4), (smModel & 0xf));
rdcstr psSM = StringFormat::Fmt("ps_%d_%d", smMajor, smMinor);
if(m_pDevice->GetShaderCache()->GetShaderBlob(hlsl.c_str(), "RENDERDOC_DebugSamplePS",
D3DCOMPILE_WARNINGS_ARE_ERRORS, {}, psSM.c_str(),
&dxilPsBlob) != "")
Expand Down

0 comments on commit 4a73100

Please sign in to comment.