diff --git a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp index 6ec0e1f90..d397673f7 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp @@ -1792,6 +1792,20 @@ DXBCContainer::DXBCContainer(const bytebuf &ByteCode, const rdcstr &debugInfoPat m_Reflection = new Reflection; } + if(dxilReflectProgram) + { + m_EntryPoints = dxilReflectProgram->GetEntryPoints(); + } + else if(m_EntryPoints.empty()) + { + rdcstr entry; + if(GetDebugInfo()) + entry = GetDebugInfo()->GetEntryFunction(); + if(entry.empty()) + entry = "main"; + m_EntryPoints = {ShaderEntryPoint(entry, GetShaderStage(m_Type))}; + } + SAFE_DELETE(dxilSTATProgram); for(uint32_t chunkIdx = 0; chunkIdx < header->numChunks; chunkIdx++) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_container.h b/renderdoc/driver/shaders/dxbc/dxbc_container.h index acc73ecc0..690caa02c 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_container.h +++ b/renderdoc/driver/shaders/dxbc/dxbc_container.h @@ -184,6 +184,8 @@ public: const Reflection *GetReflection() const { return m_Reflection; } D3D_PRIMITIVE_TOPOLOGY GetOutputTopology(); + rdcarray GetEntryPoints() const { return m_EntryPoints; } + const rdcstr &GetDisassembly(bool dxcStyle); void FillTraceLineInfo(ShaderDebugTrace &trace) const; @@ -249,6 +251,7 @@ private: DXIL::Program *m_DXILByteCode = NULL; IDebugInfo *m_DebugInfo = NULL; Reflection *m_Reflection = NULL; + rdcarray m_EntryPoints; }; }; // namespace DXBC diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.h b/renderdoc/driver/shaders/dxil/dxil_bytecode.h index 537c3c7f2..3cd892a24 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.h +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.h @@ -1229,6 +1229,7 @@ public: const bytebuf &GetBytes() const { return m_Bytes; } void FetchComputeProperties(DXBC::Reflection *reflection); DXBC::Reflection *GetReflection(); + rdcarray GetEntryPoints(); DXBC::ShaderType GetShaderType() const { return m_Type; } uint32_t GetMajorVersion() const { return m_Major; } diff --git a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp index 9bcca2831..b5c836f9a 100644 --- a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp @@ -1242,6 +1242,42 @@ static void AddResourceBind(DXBC::Reflection *refl, const TypeInfo &typeInfo, co refl->UAVs.push_back(bind); } +rdcarray Program::GetEntryPoints() +{ + rdcarray ret; + + DXMeta dx(m_NamedMeta); + + if(dx.entryPoints) + { + for(Metadata *entry : dx.entryPoints->children) + { + if(entry->children.size() > 2 && entry->children[0] != NULL) + { + ShaderEntryPoint entryPoint; + entryPoint.name = entry->children[1]->str; + + Metadata *tags = entry->children[4]; + + for(size_t i = 0; i < tags->children.size(); i += 2) + { + // 8 is the type tag + if(getival(tags->children[i]) == 8U) + { + entryPoint.stage = + GetShaderStage((DXBC::ShaderType)getival(tags->children[i + 1])); + break; + } + } + + ret.push_back(entryPoint); + } + } + } + + return ret; +} + DXBC::Reflection *Program::GetReflection() { using namespace DXBC;