Skip to content

Commit

Permalink
Improve logging in shader compilation (resolves #1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Dec 2, 2019
1 parent a5c3a4a commit 1d7b1b4
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions BizHawk.Client.EmuHawk/DisplayManager/Filters/Retro.cs
Expand Up @@ -45,36 +45,39 @@ public RetroShaderChain(IGL owner, RetroShaderPreset preset, string baseDirector
Owner = owner;
this.Preset = preset;
Passes = preset.Passes.ToArray();

bool ok = true;
Errors = "";

//load up the shaders
Shaders = new RetroShader[preset.Passes.Count];
for (int i = 0; i < preset.Passes.Count; i++)
for (var i = 0; i < preset.Passes.Count; i++)
{
RetroShaderPreset.ShaderPass pass = preset.Passes[i];

//acquire content
string path = Path.Combine(baseDirectory, pass.ShaderPath);
if (!File.Exists(path))
var path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
string content;
try
{
ok = false;
break;
content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
}
catch (DirectoryNotFoundException e)
{
Errors += $"caught {nameof(DirectoryNotFoundException)}: {e.Message}\n";
return;
}
catch (FileNotFoundException e)
{
Errors += $"could not read file {e.FileName}\n";
return;
}
string content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));


var shader = new RetroShader(Owner, content, debug);
Shaders[i] = shader;
var shader = Shaders[i] = new RetroShader(Owner, content, debug);
if (!shader.Available)
{
Errors += $"===================\r\nPass {i}:\r\n{shader.Errors}";
ok = false;
Errors += $"===================\r\nPass {i}:\r\n{shader.Errors}\n";
return;
}
}

Available = ok;
Available = true;
}

public void Dispose()
Expand All @@ -85,12 +88,9 @@ public void Dispose()
_isDisposed = true;
}

/// <summary>
/// Whether this shader chain is available (it wont be available if some resources failed to load or compile)
/// </summary>
public bool Available { get; private set; }
public string Errors { get; private set; }

/// <summary>Whether this shader chain is available (it wont be available if some resources failed to load or compile)</summary>
public readonly bool Available;
public readonly string Errors;
public readonly IGL Owner;
public readonly RetroShaderPreset Preset;
public readonly RetroShader[] Shaders;
Expand Down

0 comments on commit 1d7b1b4

Please sign in to comment.