Merge pull request #1521 from TASVideos/interp_bizware

Use string interpolation in BizHawk.Bizware
This commit is contained in:
adelikat 2019-03-27 19:27:21 -05:00 committed by GitHub
commit 5bae4961a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 23 deletions

View File

@ -183,9 +183,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
//if the shaders arent available, the pipeline isn't either
if (!vertexShader.Available || !fragmentShader.Available)
{
string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors);
string errors = $"Vertex Shader:\r\n {vertexShader.Errors} \r\n-------\r\nFragment Shader:\r\n{fragmentShader.Errors}";
if (required)
throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors);
throw new InvalidOperationException($"Couldn't build required GL pipeline:\r\n{errors}");
var pipeline = new Pipeline(this, null, false, null, null, null);
pipeline.Errors = errors;
return pipeline;
@ -246,14 +246,14 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
if (errcode != ErrorCode.NoError)
if (required)
throw new InvalidOperationException("Error creating pipeline (error returned from glLinkProgram): " + errcode + "\r\n\r\n" + resultLog);
throw new InvalidOperationException($"Error creating pipeline (error returned from glLinkProgram): {errcode}\r\n\r\n{resultLog}");
else success = false;
int linkStatus;
GL.GetProgram(pid, GetProgramParameterName.LinkStatus, out linkStatus);
if (linkStatus == 0)
if (required)
throw new InvalidOperationException("Error creating pipeline (link status false returned from glLinkProgram): " + "\r\n\r\n" + resultLog);
throw new InvalidOperationException($"Error creating pipeline (link status false returned from glLinkProgram): \r\n\r\n{resultLog}");
else success = false;
//need to work on validation. apparently there are some weird caveats to glValidate which make it complicated and possibly excuses (barely) the intel drivers' dysfunctional operation
@ -271,11 +271,11 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
//errcode = GL.GetError();
//resultLog = GL.GetProgramInfoLog(pid);
//if (errcode != ErrorCode.NoError)
// throw new InvalidOperationException("Error creating pipeline (error returned from glValidateProgram): " + errcode + "\r\n\r\n" + resultLog);
// throw new InvalidOperationException($"Error creating pipeline (error returned from glValidateProgram): {errcode}\r\n\r\n{resultLog}");
//int validateStatus;
//GL.GetProgram(pid, GetProgramParameterName.ValidateStatus, out validateStatus);
//if (validateStatus == 0)
// throw new InvalidOperationException("Error creating pipeline (validateStatus status false returned from glValidateProgram): " + "\r\n\r\n" + resultLog);
// throw new InvalidOperationException($"Error creating pipeline (validateStatus status false returned from glValidateProgram): \r\n\r\n{resultLog}");
//set the program to active, in case we need to set sampler uniforms on it
GL.UseProgram(pid);
@ -724,7 +724,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
errcode = GL.GetError();
if (errcode != ErrorCode.NoError)
if (required)
throw new InvalidOperationException("Error compiling shader (from previous operation) " + errcode);
throw new InvalidOperationException($"Error compiling shader (from previous operation) {errcode}");
else success = false;
GL.ShaderSource(sid, source);
@ -732,7 +732,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
errcode = GL.GetError();
if (errcode != ErrorCode.NoError)
if (required)
throw new InvalidOperationException("Error compiling shader (ShaderSource) " + errcode);
throw new InvalidOperationException($"Error compiling shader (ShaderSource) {errcode}");
else success = false;
GL.CompileShader(sid);
@ -742,7 +742,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
if (errcode != ErrorCode.NoError)
{
string message = "Error compiling shader (CompileShader) " + errcode + "\r\n\r\n" + resultLog;
string message = $"Error compiling shader (CompileShader) {errcode}\r\n\r\n{resultLog}";
if (required)
throw new InvalidOperationException(message);
else
@ -757,7 +757,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
if (n == 0)
if (required)
throw new InvalidOperationException("Error compiling shader (CompileShader )" + "\r\n\r\n" + resultLog);
throw new InvalidOperationException($"Error compiling shader (CompileShader )\r\n\r\n{resultLog}");
else success = false;
return success;

View File

@ -210,7 +210,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
}
catch (Exception ex)
{
throw new InvalidOperationException("Error compiling shader: " + errors, ex);
throw new InvalidOperationException($"Error compiling shader: {errors}", ex);
}
sw.ps = new PixelShader(dev, bytecode);
@ -266,7 +266,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
}
catch (Exception ex)
{
throw new InvalidOperationException("Error compiling shader: " + errors, ex);
throw new InvalidOperationException($"Error compiling shader: {errors}", ex);
}
sw.vs = new VertexShader(dev, bytecode);
@ -381,9 +381,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
{
if (!vertexShader.Available || !fragmentShader.Available)
{
string errors = string.Format("Vertex Shader:\r\n {0} \r\n-------\r\nFragment Shader:\r\n{1}", vertexShader.Errors, fragmentShader.Errors);
string errors = $"Vertex Shader:\r\n {vertexShader.Errors} \r\n-------\r\nFragment Shader:\r\n{fragmentShader.Errors}";
if (required)
throw new InvalidOperationException("Couldn't build required GL pipeline:\r\n" + errors);
throw new InvalidOperationException($"Couldn't build required GL pipeline:\r\n{errors}");
var pipeline = new Pipeline(this, null, false, null, null, null);
pipeline.Errors = errors;
return pipeline;
@ -466,11 +466,11 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
var handle = tuple.Item2;
var descr = ct.GetConstantDescription(handle);
//Console.WriteLine("D3D UNIFORM: " + descr.Name);
//Console.WriteLine($"D3D UNIFORM: {descr.Name}");
if (descr.StructMembers != 0)
{
string newprefix = prefix + descr.Name + ".";
string newprefix = $"{prefix}{descr.Name}.";
for (int j = 0; j < descr.StructMembers; j++)
{
var subhandle = ct.GetConstant(handle, j);
@ -490,7 +490,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
{
string key = name.TrimStart('$');
if (descr.Rows != 1)
key = key + "[0]";
key += "[0]";
if (fs.MapCodeToNative != null && ct == fsct) if (fs.MapCodeToNative.ContainsKey(key)) name = fs.MapCodeToNative[key];
if (vs.MapCodeToNative != null && ct == vsct) if (vs.MapCodeToNative.ContainsKey(key)) name = vs.MapCodeToNative[key];
}

View File

@ -21,7 +21,7 @@ namespace BizHawk.Bizware.BizwareGL
private static string[] Escape(IEnumerable<string> args)
{
return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray();
return args.Select(s => s.Contains(" ") ? $"\"{s}\"" : s).ToArray();
}
public class Results
@ -105,7 +105,7 @@ namespace BizHawk.Bizware.BizwareGL
if (hlslHacks)
{
ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => string.Format("({0}uniform sampler2D{1})", m.Groups[1].Value, m.Groups[3].Value));
ret.Code = rxHlslSamplerCrashWorkaround.Replace(ret.Code, m => $"({m.Groups[1].Value}uniform sampler2D{m.Groups[3].Value})");
}
//make variable name map

View File

@ -15,7 +15,7 @@ namespace BizHawk.Bizware.BizwareGL
public override string ToString()
{
return string.Format("GL RT: {0}x{1}", Texture2d.Width, Texture2d.Height);
return $"GL RT: {Texture2d.Width}x{Texture2d.Height}";
}
public object Opaque { get; private set; }

View File

@ -26,8 +26,8 @@ namespace BizHawk.Bizware.BizwareGL
VertexLayout.Close();
string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
string vsSource = "#define VERTEX\r\n" + defines + source;
string psSource = "#define FRAGMENT\r\n" + defines + source;
string vsSource = $"#define VERTEX\r\n{defines}{source}";
string psSource = $"#define FRAGMENT\r\n{defines}{source}";
var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");

View File

@ -37,7 +37,7 @@ namespace BizHawk.Bizware.BizwareGL
public override string ToString()
{
return string.Format("GL Tex: {0}x{1}", Width, Height);
return $"GL Tex: {Width}x{Height}";
}
public void LoadFrom(BitmapBuffer buffer)