Consistently treat file containing entry point as the 'main' file

* This fixes shader editing when the entry point file wasn't the first
  in the list.
* Might need better detection of the main file than just searching for
  the entry point substring - could produce false positives in other
  files in a comment or #define or something similar?
This commit is contained in:
baldurk
2015-06-26 01:13:48 +02:00
parent b7fd43f237
commit 5a03794a5a
8 changed files with 43 additions and 8 deletions
+3 -1
View File
@@ -192,13 +192,15 @@ struct ShaderResource
struct ShaderDebugChunk
{
ShaderDebugChunk() : compileFlags(0) {}
ShaderDebugChunk() : compileFlags(0), entryFile(0) {}
rdctype::str entryFunc;
uint32_t compileFlags;
rdctype::array< rdctype::pair<rdctype::str, rdctype::str> > files; // <filename, source>
int32_t entryFile; // index in above array of 'main' file with entry point
};
struct ShaderReflection
+1 -1
View File
@@ -212,7 +212,7 @@ void Serialiser::Serialise(const char *name, ShaderReflection &el)
Serialise("", el.Interfaces);
SIZE_CHECK(ShaderReflection, 68);
SIZE_CHECK(ShaderReflection, 72);
}
template<>
+8
View File
@@ -888,11 +888,19 @@ ShaderReflection *MakeShaderReflection(DXBC::DXBCFile *dxbc)
ret->DebugInfo.entryFunc = dxbc->m_DebugInfo->GetEntryFunction();
ret->DebugInfo.compileFlags = dxbc->m_DebugInfo->GetShaderCompileFlags();
ret->DebugInfo.entryFile = -1;
create_array_uninit(ret->DebugInfo.files, dxbc->m_DebugInfo->Files.size());
for(size_t i=0; i < dxbc->m_DebugInfo->Files.size(); i++)
{
ret->DebugInfo.files[i].first = dxbc->m_DebugInfo->Files[i].first;
ret->DebugInfo.files[i].second = dxbc->m_DebugInfo->Files[i].second;
if(ret->DebugInfo.entryFile == -1 &&
strstr(ret->DebugInfo.files[i].second.elems, ret->DebugInfo.entryFunc.elems))
{
ret->DebugInfo.entryFile = (int32_t)i;
}
}
}
+2
View File
@@ -749,6 +749,8 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
refl.DebugInfo.entryFunc = "main";
refl.DebugInfo.compileFlags = 0;
refl.DebugInfo.entryFile = 0;
refl.Disassembly = "";
vector<ShaderResource> resources;
+2
View File
@@ -373,6 +373,8 @@ namespace renderdoc
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
public DebugFile[] files;
public Int32 entryFile;
};
[StructLayout(LayoutKind.Sequential)]
@@ -225,15 +225,19 @@ namespace renderdocui.Windows.PipelineState
{
string shaderfn = "";
int entryFile = shaderDetails.DebugInfo.entryFile;
if (entryFile < 0 || entryFile >= shaderDetails.DebugInfo.files.Length)
entryFile = 0;
try
{
shaderfn = Path.GetFileName(shaderDetails.DebugInfo.files[0].filename);
shaderfn = Path.GetFileName(shaderDetails.DebugInfo.files[entryFile].filename);
}
catch (ArgumentException)
{
// invalid path or similar, just try to go from last \ or / onwards
shaderfn = shaderDetails.DebugInfo.files[0].filename;
shaderfn = shaderDetails.DebugInfo.files[entryFile].filename;
int idx = shaderfn.LastIndexOfAny(new char[] { '/', '\\' });
if (idx > 0)
shaderfn = shaderfn.Substring(idx + 1);
@@ -1863,7 +1867,11 @@ namespace renderdocui.Windows.PipelineState
foreach (var s in shaderDetails.DebugInfo.files)
files.Add(Path.GetFileName(s.filename), s.filetext);
mainfile = Path.GetFileName(shaderDetails.DebugInfo.files[0].filename);
int entryFile = shaderDetails.DebugInfo.entryFile;
if (entryFile < 0 || entryFile >= shaderDetails.DebugInfo.files.Length)
entryFile = 0;
mainfile = Path.GetFileName(shaderDetails.DebugInfo.files[entryFile].filename);
}
else
{
@@ -1948,7 +1956,7 @@ namespace renderdocui.Windows.PipelineState
// Save Callback
(ShaderViewer viewer, Dictionary<string, string> updatedfiles) =>
{
string compileSource = updatedfiles.First().Value;
string compileSource = updatedfiles[mainfile];
// try and match up #includes against the files that we have. This isn't always
// possible as fxc only seems to include the source for files if something in
@@ -1867,7 +1867,9 @@ namespace renderdocui.Windows.PipelineState
// Save Callback
(ShaderViewer viewer, Dictionary<string, string> updatedfiles) =>
{
string compileSource = updatedfiles.First().Value;
string compileSource = "";
foreach (var kv in updatedfiles)
compileSource += kv.Value;
// invoke off to the ReplayRenderer to replace the log's shader
// with our edited one
+12 -1
View File
@@ -521,6 +521,8 @@ namespace renderdocui.Windows
else
Text = String.Format("{0}()", shader.DebugInfo.entryFunc);
int fileIdx = 0;
DockContent sel = null;
foreach (var f in shader.DebugInfo.files)
{
@@ -540,8 +542,17 @@ namespace renderdocui.Windows
m_Scintillas.Add(scintilla1);
if (f.filetext.Contains(shader.DebugInfo.entryFunc))
if (shader.DebugInfo.entryFile >= 0 && shader.DebugInfo.entryFile < shader.DebugInfo.files.Length)
{
if (fileIdx == shader.DebugInfo.entryFile)
sel = w;
}
else if (f.filetext.Contains(shader.DebugInfo.entryFunc))
{
sel = w;
}
fileIdx++;
}
if (trace != null || sel == null)