Add typedef for shader data struct and utility accessors in pipeline

This commit is contained in:
baldurk
2016-11-18 12:32:31 +01:00
parent c08a357598
commit 4c24dcecde
4 changed files with 79 additions and 87 deletions
+1 -2
View File
@@ -2337,8 +2337,7 @@ void D3D12DebugManager::BuildShader(string source, string entry, const uint32_t
byteCode.BytecodeLength = blob->GetBufferSize();
byteCode.pShaderBytecode = blob->GetBufferPointer();
WrappedID3D12PipelineState::ShaderEntry *sh =
WrappedID3D12PipelineState::AddShader(byteCode, m_WrappedDevice, NULL);
WrappedID3D12Shader *sh = WrappedID3D12PipelineState::AddShader(byteCode, m_WrappedDevice, NULL);
SAFE_RELEASE(blob);
+12 -18
View File
@@ -240,8 +240,8 @@ FetchTexture D3D12Replay::GetTexture(ResourceId id)
ShaderReflection *D3D12Replay::GetShader(ResourceId shader, string entryPoint)
{
WrappedID3D12PipelineState::ShaderEntry *sh =
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12PipelineState::ShaderEntry>(shader);
WrappedID3D12Shader *sh =
m_pDevice->GetResourceManager()->GetCurrentAs<WrappedID3D12Shader>(shader);
if(sh)
return &sh->GetDetails();
@@ -944,8 +944,7 @@ void D3D12Replay::MakePipelineState()
if(pipe && pipe->IsCompute())
{
WrappedID3D12PipelineState::ShaderEntry *sh =
(WrappedID3D12PipelineState::ShaderEntry *)pipe->compute->CS.pShaderBytecode;
WrappedID3D12Shader *sh = (WrappedID3D12Shader *)pipe->compute->CS.pShaderBytecode;
state.m_CS.Shader = sh->GetResourceID();
state.m_CS.stage = eShaderStage_Compute;
@@ -975,8 +974,7 @@ void D3D12Replay::MakePipelineState()
dst.stage = (ShaderStageType)stage;
WrappedID3D12PipelineState::ShaderEntry *sh =
(WrappedID3D12PipelineState::ShaderEntry *)src.pShaderBytecode;
WrappedID3D12Shader *sh = (WrappedID3D12Shader *)src.pShaderBytecode;
if(sh)
{
@@ -1331,13 +1329,13 @@ void D3D12Replay::FillCBufferVariables(ResourceId shader, string entryPoint, uin
ID3D12DeviceChild *res = m_pDevice->GetResourceManager()->GetCurrentResource(shader);
if(!WrappedID3D12PipelineState::ShaderEntry::IsAlloc(res))
if(!WrappedID3D12Shader::IsAlloc(res))
{
RDCERR("Shader ID %llu does not correspond to a known fake shader", shader);
return;
}
WrappedID3D12PipelineState::ShaderEntry *sh = (WrappedID3D12PipelineState::ShaderEntry *)res;
WrappedID3D12Shader *sh = (WrappedID3D12Shader *)res;
DXBC::DXBCFile *dxbc = sh->GetDXBC();
const ShaderBindpointMapping &bindMap = sh->GetMapping();
@@ -1498,10 +1496,9 @@ void D3D12Replay::ReplaceResource(ResourceId from, ResourceId to)
{
ID3D12DeviceChild *resource = rm->GetLiveResource(from);
if(WrappedID3D12PipelineState::ShaderEntry::IsAlloc(resource))
if(WrappedID3D12Shader::IsAlloc(resource))
{
WrappedID3D12PipelineState::ShaderEntry *sh =
(WrappedID3D12PipelineState::ShaderEntry *)resource;
WrappedID3D12Shader *sh = (WrappedID3D12Shader *)resource;
for(size_t i = 0; i < sh->m_Pipes.size(); i++)
{
@@ -1511,8 +1508,7 @@ void D3D12Replay::ReplaceResource(ResourceId from, ResourceId to)
ID3D12PipelineState *replpipe = NULL;
D3D12_SHADER_BYTECODE shDesc =
rm->GetLiveAs<WrappedID3D12PipelineState::ShaderEntry>(to)->GetDesc();
D3D12_SHADER_BYTECODE shDesc = rm->GetLiveAs<WrappedID3D12Shader>(to)->GetDesc();
if(pipe->graphics)
{
@@ -1526,8 +1522,7 @@ void D3D12Replay::ReplaceResource(ResourceId from, ResourceId to)
{
if(shaders[s]->BytecodeLength > 0)
{
WrappedID3D12PipelineState::ShaderEntry *stage =
(WrappedID3D12PipelineState::ShaderEntry *)shaders[s]->pShaderBytecode;
WrappedID3D12Shader *stage = (WrappedID3D12Shader *)shaders[s]->pShaderBytecode;
if(stage->GetResourceID() == from)
*shaders[s] = shDesc;
@@ -1568,10 +1563,9 @@ void D3D12Replay::RemoveReplacement(ResourceId id)
{
ID3D12DeviceChild *resource = rm->GetLiveResource(id);
if(WrappedID3D12PipelineState::ShaderEntry::IsAlloc(resource))
if(WrappedID3D12Shader::IsAlloc(resource))
{
WrappedID3D12PipelineState::ShaderEntry *sh =
(WrappedID3D12PipelineState::ShaderEntry *)resource;
WrappedID3D12Shader *sh = (WrappedID3D12Shader *)resource;
for(size_t i = 0; i < sh->m_Pipes.size(); i++)
{
+5 -6
View File
@@ -29,12 +29,11 @@
GPUAddressRangeTracker WrappedID3D12Resource::m_Addresses;
std::map<ResourceId, WrappedID3D12Resource *> *WrappedID3D12Resource::m_List = NULL;
std::map<WrappedID3D12PipelineState::DXBCKey, WrappedID3D12PipelineState::ShaderEntry *>
WrappedID3D12PipelineState::m_Shaders;
std::map<WrappedID3D12PipelineState::DXBCKey, WrappedID3D12Shader *> WrappedID3D12PipelineState::m_Shaders;
const GUID RENDERDOC_ID3D12ShaderGUID_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_struct;
void WrappedID3D12PipelineState::ShaderEntry::TryReplaceOriginalByteCode()
void WrappedID3D12Shader::TryReplaceOriginalByteCode()
{
if(!DXBC::DXBCFile::CheckForDebugInfo((const void *)&m_Bytecode[0], m_Bytecode.size()))
{
@@ -145,7 +144,7 @@ void WrappedID3D12PipelineState::ShaderEntry::TryReplaceOriginalByteCode()
ALL_D3D12_TYPES;
WRAPPED_POOL_INST(WrappedID3D12PipelineState::ShaderEntry);
WRAPPED_POOL_INST(WrappedID3D12Shader);
D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr)
{
@@ -181,8 +180,8 @@ TrackedResource12 *GetTracked(ID3D12DeviceChild *ptr)
ALL_D3D12_TYPES;
if(WrappedID3D12PipelineState::ShaderEntry::IsAlloc(ptr))
return (TrackedResource12 *)(WrappedID3D12PipelineState::ShaderEntry *)ptr;
if(WrappedID3D12Shader::IsAlloc(ptr))
return (TrackedResource12 *)(WrappedID3D12Shader *)ptr;
return NULL;
}
+61 -61
View File
@@ -453,53 +453,6 @@ public:
bool IsGraphics() { return graphics != NULL; }
bool IsCompute() { return compute != NULL; }
D3D12_COMPUTE_PIPELINE_STATE_DESC GetComputeDesc()
{
D3D12_COMPUTE_PIPELINE_STATE_DESC ret = *compute;
ret.CS = ((ShaderEntry *)compute->CS.pShaderBytecode)->GetDesc();
return ret;
}
D3D12_GRAPHICS_PIPELINE_STATE_DESC GetGraphicsDesc()
{
D3D12_GRAPHICS_PIPELINE_STATE_DESC ret = *graphics;
ShaderEntry *vs = (ShaderEntry *)graphics->VS.pShaderBytecode;
ShaderEntry *hs = (ShaderEntry *)graphics->HS.pShaderBytecode;
ShaderEntry *ds = (ShaderEntry *)graphics->DS.pShaderBytecode;
ShaderEntry *gs = (ShaderEntry *)graphics->GS.pShaderBytecode;
ShaderEntry *ps = (ShaderEntry *)graphics->PS.pShaderBytecode;
if(vs)
ret.VS = vs->GetDesc();
else
RDCEraseEl(ret.VS);
if(hs)
ret.HS = hs->GetDesc();
else
RDCEraseEl(ret.HS);
if(ds)
ret.DS = ds->GetDesc();
else
RDCEraseEl(ret.DS);
if(gs)
ret.GS = gs->GetDesc();
else
RDCEraseEl(ret.GS);
if(ps)
ret.PS = ps->GetDesc();
else
RDCEraseEl(ret.PS);
return ret;
}
struct DXBCKey
{
DXBCKey(const D3D12_SHADER_BYTECODE &byteCode)
@@ -622,6 +575,59 @@ public:
TypeEnum = Resource_PipelineState,
};
ShaderEntry *VS() { return (ShaderEntry *)graphics->VS.pShaderBytecode; }
ShaderEntry *HS() { return (ShaderEntry *)graphics->HS.pShaderBytecode; }
ShaderEntry *DS() { return (ShaderEntry *)graphics->DS.pShaderBytecode; }
ShaderEntry *GS() { return (ShaderEntry *)graphics->GS.pShaderBytecode; }
ShaderEntry *PS() { return (ShaderEntry *)graphics->PS.pShaderBytecode; }
ShaderEntry *CS() { return (ShaderEntry *)compute->CS.pShaderBytecode; }
D3D12_COMPUTE_PIPELINE_STATE_DESC GetComputeDesc()
{
D3D12_COMPUTE_PIPELINE_STATE_DESC ret = *compute;
ret.CS = CS()->GetDesc();
return ret;
}
D3D12_GRAPHICS_PIPELINE_STATE_DESC GetGraphicsDesc()
{
D3D12_GRAPHICS_PIPELINE_STATE_DESC ret = *graphics;
ShaderEntry *vs = VS();
ShaderEntry *hs = HS();
ShaderEntry *ds = DS();
ShaderEntry *gs = GS();
ShaderEntry *ps = PS();
if(vs)
ret.VS = vs->GetDesc();
else
RDCEraseEl(ret.VS);
if(hs)
ret.HS = hs->GetDesc();
else
RDCEraseEl(ret.HS);
if(ds)
ret.DS = ds->GetDesc();
else
RDCEraseEl(ret.DS);
if(gs)
ret.GS = gs->GetDesc();
else
RDCEraseEl(ret.GS);
if(ps)
ret.PS = ps->GetDesc();
else
RDCEraseEl(ret.PS);
return ret;
}
static ShaderEntry *AddShader(const D3D12_SHADER_BYTECODE &byteCode, WrappedID3D12Device *device,
WrappedID3D12PipelineState *pipeline)
{
@@ -663,26 +669,18 @@ public:
if(graphics)
{
ShaderEntry *vs = (ShaderEntry *)graphics->VS.pShaderBytecode;
ShaderEntry *hs = (ShaderEntry *)graphics->HS.pShaderBytecode;
ShaderEntry *ds = (ShaderEntry *)graphics->DS.pShaderBytecode;
ShaderEntry *gs = (ShaderEntry *)graphics->GS.pShaderBytecode;
ShaderEntry *ps = (ShaderEntry *)graphics->PS.pShaderBytecode;
ReleaseShader(vs);
ReleaseShader(hs);
ReleaseShader(ds);
ReleaseShader(gs);
ReleaseShader(ps);
ReleaseShader(VS());
ReleaseShader(HS());
ReleaseShader(DS());
ReleaseShader(GS());
ReleaseShader(PS());
SAFE_DELETE(graphics);
}
if(compute)
{
ShaderEntry *cs = (ShaderEntry *)compute->CS.pShaderBytecode;
ReleaseShader(cs);
ReleaseShader(CS());
SAFE_DELETE(compute);
}
@@ -700,6 +698,8 @@ private:
static map<DXBCKey, ShaderEntry *> m_Shaders;
};
typedef WrappedID3D12PipelineState::ShaderEntry WrappedID3D12Shader;
class WrappedID3D12QueryHeap : public WrappedDeviceChild12<ID3D12QueryHeap>
{
public: