mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Report and handle source-level entry point name from exported name
* The compiler could compile an entry point "foo" into an export "bar". We use the exported name in most places as that's guaranteed to be unique by the API and used for cross-referencing, but when recompiling we pass the original source name as in the debug info.
This commit is contained in:
@@ -1026,7 +1026,7 @@ IShaderViewer *PipelineStateViewer::EditOriginalShaderSource(ResourceId id,
|
||||
files.push_back(make_rdcpair(s.filename, s.contents));
|
||||
}
|
||||
|
||||
return EditShader(id, shaderDetails->stage, shaderDetails->entryPoint,
|
||||
return EditShader(id, shaderDetails->stage, shaderDetails->debugInfo.entrySourceName,
|
||||
shaderDetails->debugInfo.compileFlags, shaderDetails->debugInfo.compiler,
|
||||
shaderDetails->debugInfo.encoding, files);
|
||||
}
|
||||
|
||||
@@ -1440,6 +1440,13 @@ The first entry in the list is always the file where the entry point is.
|
||||
)");
|
||||
rdcarray<ShaderSourceFile> files;
|
||||
|
||||
DOCUMENT(R"(The name of the entry point in the source code, not necessarily the same as the
|
||||
entry point name exported to the API.
|
||||
|
||||
:type: str
|
||||
)");
|
||||
rdcstr entrySourceName;
|
||||
|
||||
DOCUMENT(R"(The source location of the first executable line or the entry point.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -1228,7 +1228,7 @@ void MakeShaderReflection(GLenum shadType, GLuint sepProg, ShaderReflection &ref
|
||||
const FixedFunctionVertexOutputs &outputUsage)
|
||||
{
|
||||
refl.stage = MakeShaderStage(shadType);
|
||||
refl.entryPoint = "main";
|
||||
refl.debugInfo.entrySourceName = refl.entryPoint = "main";
|
||||
refl.encoding = ShaderEncoding::GLSL;
|
||||
refl.debugInfo.compiler = KnownShaderTool::Unknown;
|
||||
refl.debugInfo.encoding = ShaderEncoding::GLSL;
|
||||
|
||||
@@ -285,11 +285,11 @@ void MakeShaderReflection(DXBC::DXBCContainer *dxbc, ShaderReflection *refl,
|
||||
break;
|
||||
}
|
||||
|
||||
refl->entryPoint = "main";
|
||||
refl->debugInfo.entrySourceName = refl->entryPoint = "main";
|
||||
|
||||
if(dxbc->GetDebugInfo())
|
||||
{
|
||||
refl->entryPoint = dxbc->GetDebugInfo()->GetEntryFunction();
|
||||
refl->debugInfo.entrySourceName = refl->entryPoint = dxbc->GetDebugInfo()->GetEntryFunction();
|
||||
|
||||
refl->debugInfo.encoding = ShaderEncoding::HLSL;
|
||||
|
||||
|
||||
@@ -684,6 +684,8 @@ void Reflector::RegisterOp(Iter it)
|
||||
{
|
||||
LineColumnInfo &info = debugFuncToLocation[dbg.result];
|
||||
|
||||
debugFuncName[dbg.result] = strings[dbg.arg<Id>(0)];
|
||||
|
||||
// check this source file exists - we won't have registered it if there was no source code
|
||||
auto srcit = debugSources.find(dbg.arg<Id>(2));
|
||||
if(srcit != debugSources.end())
|
||||
@@ -1029,10 +1031,15 @@ void Reflector::MakeReflection(const GraphicsAPI sourceAPI, const ShaderStage st
|
||||
reflection.debugInfo.compileFlags.flags.push_back(
|
||||
{"@spirver", StringFormat::Fmt("spirv%d.%d", m_MajorVersion, m_MinorVersion)});
|
||||
|
||||
reflection.debugInfo.entrySourceName = entryPoint;
|
||||
|
||||
{
|
||||
auto it = funcToDebugFunc.find(entry->id);
|
||||
if(it != funcToDebugFunc.end())
|
||||
{
|
||||
rdcstr debugEntryName = debugFuncName[it->second];
|
||||
if(!debugEntryName.empty())
|
||||
reflection.debugInfo.entrySourceName = debugEntryName;
|
||||
reflection.debugInfo.entryLocation = debugFuncToLocation[it->second];
|
||||
if(debugFuncToCmdLine.find(it->second) != debugFuncToCmdLine.end())
|
||||
reflection.debugInfo.compileFlags.flags = {{"@cmdline", debugFuncToCmdLine[it->second]}};
|
||||
|
||||
@@ -140,6 +140,7 @@ private:
|
||||
SparseIdMap<size_t> debugFuncToBaseFile;
|
||||
SparseIdMap<rdcstr> debugFuncToCmdLine;
|
||||
SparseIdMap<LineColumnInfo> debugFuncToLocation;
|
||||
SparseIdMap<rdcstr> debugFuncName;
|
||||
SparseIdMap<Id> funcToDebugFunc;
|
||||
|
||||
Id curBlock;
|
||||
|
||||
@@ -275,7 +275,7 @@ void DoSerialise(SerialiserType &ser, ShaderDebugInfo &el)
|
||||
SERIALISE_MEMBER(sourceDebugInformation);
|
||||
SERIALISE_MEMBER(debugStatus);
|
||||
|
||||
SIZE_CHECK(112);
|
||||
SIZE_CHECK(136);
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
@@ -310,7 +310,7 @@ void DoSerialise(SerialiserType &ser, ShaderReflection &el)
|
||||
|
||||
SERIALISE_MEMBER(taskPayload);
|
||||
|
||||
SIZE_CHECK(456);
|
||||
SIZE_CHECK(480);
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
|
||||
Reference in New Issue
Block a user