mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-10 00:31:00 +00:00
Process fake OpModuleProcessed comments in non-semantic debug source
This commit is contained in:
@@ -580,47 +580,7 @@ void Reflector::RegisterOp(Iter it)
|
||||
{
|
||||
OpSource source(it);
|
||||
|
||||
// glslang based tools output fake OpModuleProcessed comments at the start of pre-1.3
|
||||
// shaders source before OpModuleProcessed existed (in SPIR-V 1.1)
|
||||
if(m_MajorVersion == 1 && m_MinorVersion < 1 && HasCommandLineInModuleProcessed(m_Generator))
|
||||
{
|
||||
rdcstr &src = source.source;
|
||||
|
||||
const char compileFlagPrefix[] = "// OpModuleProcessed ";
|
||||
const char endMarker[] = "#line 1\n";
|
||||
if(src.find(compileFlagPrefix) == 0)
|
||||
{
|
||||
// process compile flags
|
||||
int32_t nextLine = src.indexOf('\n');
|
||||
while(nextLine > 0)
|
||||
{
|
||||
bool finished = false;
|
||||
if(src.find(compileFlagPrefix) == 0)
|
||||
{
|
||||
size_t offs = sizeof(compileFlagPrefix) - 1;
|
||||
cmdline += " --" + src.substr(offs, nextLine - offs);
|
||||
}
|
||||
else if(src.find(endMarker) == 0)
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Unexpected preamble line with OpModuleProcessed: %s",
|
||||
src.substr(0, nextLine).c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// erase this line
|
||||
src.erase(0, nextLine + 1);
|
||||
|
||||
nextLine = src.indexOf('\n');
|
||||
|
||||
if(finished)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ProcessFakeModuleProcessed(source.source);
|
||||
|
||||
sourceLanguage = source.sourceLanguage;
|
||||
|
||||
@@ -664,6 +624,8 @@ void Reflector::RegisterOp(Iter it)
|
||||
rdcstr name = strings[dbg.arg<Id>(0)];
|
||||
rdcstr source = dbg.params.size() > 1 ? strings[dbg.arg<Id>(1)] : rdcstr();
|
||||
|
||||
ProcessFakeModuleProcessed(source);
|
||||
|
||||
// don't add empty source statements as actual files
|
||||
if(!name.empty() || !source.empty())
|
||||
{
|
||||
@@ -729,6 +691,49 @@ void Reflector::UnregisterOp(Iter it)
|
||||
RDCFATAL("Reflector should not be used for editing! UnregisterOp() call invalid");
|
||||
}
|
||||
|
||||
void Reflector::ProcessFakeModuleProcessed(rdcstr &src)
|
||||
{
|
||||
// glslang based tools output fake OpModuleProcessed comments at the start of pre-1.3
|
||||
// shaders source before OpModuleProcessed existed (in SPIR-V 1.1)
|
||||
if(m_MajorVersion == 1 && m_MinorVersion < 1 && HasCommandLineInModuleProcessed(m_Generator))
|
||||
{
|
||||
const char compileFlagPrefix[] = "// OpModuleProcessed ";
|
||||
const char endMarker[] = "#line 1\n";
|
||||
if(src.find(compileFlagPrefix) == 0)
|
||||
{
|
||||
// process compile flags
|
||||
int32_t nextLine = src.indexOf('\n');
|
||||
while(nextLine > 0)
|
||||
{
|
||||
bool finished = false;
|
||||
if(src.find(compileFlagPrefix) == 0)
|
||||
{
|
||||
size_t offs = sizeof(compileFlagPrefix) - 1;
|
||||
cmdline += " --" + src.substr(offs, nextLine - offs);
|
||||
}
|
||||
else if(src.find(endMarker) == 0)
|
||||
{
|
||||
finished = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Unexpected preamble line with OpModuleProcessed: %s",
|
||||
src.substr(0, nextLine).c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// erase this line
|
||||
src.erase(0, nextLine + 1);
|
||||
|
||||
nextLine = src.indexOf('\n');
|
||||
|
||||
if(finished)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Reflector::CalculateArrayTypeName(DataType &type)
|
||||
{
|
||||
// prefer the name
|
||||
@@ -2429,6 +2434,8 @@ TEST_CASE("Validate SPIR-V reflection", "[spirv][reflection]")
|
||||
|
||||
REQUIRE(!spirv.empty());
|
||||
|
||||
FileIO::WriteAll("T:/tmp/a.spv", spirv);
|
||||
|
||||
rdcspv::Reflector spv;
|
||||
spv.Parse(spirv);
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ private:
|
||||
virtual void RegisterOp(Iter iter);
|
||||
virtual void UnregisterOp(Iter iter);
|
||||
|
||||
void ProcessFakeModuleProcessed(rdcstr &src);
|
||||
|
||||
void CalculateArrayTypeName(DataType &type);
|
||||
|
||||
rdcstr StringiseConstant(rdcspv::Id id) const;
|
||||
|
||||
Reference in New Issue
Block a user