retro shaders no longer need sampler to be named s_p
This commit is contained in:
parent
7f5546fac4
commit
19b3f8b205
|
@ -51,6 +51,8 @@ namespace BizHawk.Client.EmuHawk.Filters
|
||||||
Shaders[i] = shader;
|
Shaders[i] = shader;
|
||||||
if (!shader.Pipeline.Available)
|
if (!shader.Pipeline.Available)
|
||||||
ok = false;
|
ok = false;
|
||||||
|
if (!shader.Available)
|
||||||
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Available = ok;
|
Available = ok;
|
||||||
|
|
|
@ -311,6 +311,8 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
||||||
|
|
||||||
if (type == ActiveUniformType.Sampler2D)
|
if (type == ActiveUniformType.Sampler2D)
|
||||||
{
|
{
|
||||||
|
ui.IsSampler = true;
|
||||||
|
ui.Index = loc;
|
||||||
ui.Opaque = loc | (samplers.Count << 24);
|
ui.Opaque = loc | (samplers.Count << 24);
|
||||||
samplers.Add(loc);
|
samplers.Add(loc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,7 +476,11 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
||||||
uw.FS = (ct == fsct);
|
uw.FS = (ct == fsct);
|
||||||
uw.CT = ct;
|
uw.CT = ct;
|
||||||
if (descr.Type == ParameterType.Sampler2D)
|
if (descr.Type == ParameterType.Sampler2D)
|
||||||
|
{
|
||||||
|
ui.IsSampler = true;
|
||||||
|
ui.Index = descr.RegisterIndex;
|
||||||
uw.SamplerIndex = descr.RegisterIndex;
|
uw.SamplerIndex = descr.RegisterIndex;
|
||||||
|
}
|
||||||
uniforms.Add(ui);
|
uniforms.Add(ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,15 @@ namespace BizHawk.Bizware.BizwareGL
|
||||||
SpecialWorkingDictionary UniformsDictionary;
|
SpecialWorkingDictionary UniformsDictionary;
|
||||||
IDictionary<string, PipelineUniform> Uniforms { get { return UniformsDictionary; } }
|
IDictionary<string, PipelineUniform> Uniforms { get { return UniformsDictionary; } }
|
||||||
|
|
||||||
|
public IEnumerable<PipelineUniform> GetUniforms() { return Uniforms.Values; }
|
||||||
|
|
||||||
|
public PipelineUniform TryGetUniform(string name)
|
||||||
|
{
|
||||||
|
PipelineUniform ret = null;
|
||||||
|
Uniforms.TryGetValue(name,out ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public PipelineUniform this[string key]
|
public PipelineUniform this[string key]
|
||||||
{
|
{
|
||||||
get { return UniformsDictionary[key]; }
|
get { return UniformsDictionary[key]; }
|
||||||
|
|
|
@ -30,7 +30,33 @@ namespace BizHawk.Bizware.BizwareGL
|
||||||
var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
|
var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
|
||||||
var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
|
var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
|
||||||
Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");
|
Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");
|
||||||
|
|
||||||
|
//retroarch shaders will sometimes not have the right sampler name
|
||||||
|
//it's unclear whether we should bind to s_p or sampler0
|
||||||
|
//lets bind to sampler0 in case we dont have s_p
|
||||||
|
sampler0 = Pipeline.TryGetUniform("s_p");
|
||||||
|
if (sampler0 == null)
|
||||||
|
{
|
||||||
|
//sampler wasn't named correctly. this can happen on some retroarch shaders
|
||||||
|
foreach (var u in Pipeline.GetUniforms())
|
||||||
|
{
|
||||||
|
if (u.Sole.IsSampler && u.Sole.Index == 0)
|
||||||
|
{
|
||||||
|
sampler0 = u;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sampler0 == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Available = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Available { get; private set; }
|
||||||
|
|
||||||
|
PipelineUniform sampler0;
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
@ -66,7 +92,7 @@ namespace BizHawk.Bizware.BizwareGL
|
||||||
|
|
||||||
Owner.SetTextureWrapMode(tex, true);
|
Owner.SetTextureWrapMode(tex, true);
|
||||||
|
|
||||||
Pipeline["s_p"].Set(tex);
|
sampler0.Set(tex);
|
||||||
Owner.SetViewport(OutputSize);
|
Owner.SetViewport(OutputSize);
|
||||||
|
|
||||||
int w = OutputSize.Width;
|
int w = OutputSize.Width;
|
||||||
|
|
|
@ -7,5 +7,7 @@ namespace BizHawk.Bizware.BizwareGL
|
||||||
{
|
{
|
||||||
public object Opaque;
|
public object Opaque;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
public int Index;
|
||||||
|
public bool IsSampler;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue