keep working on CGC-removal

This commit is contained in:
zeromus 2020-06-19 22:33:26 -04:00
parent b842f3ed16
commit 00e546a537
7 changed files with 38 additions and 56 deletions

View File

@ -1,30 +1,21 @@
struct input
{
float2 video_size;
float2 texture_size;
float2 output_size;
};
void main_vertex
(
float4 position : POSITION,
out float4 oPosition : POSITION,
float2 tex : TEXCOORD0,
uniform float4x4 modelViewProj,
float2 tex : TEXCOORD,
uniform input IN,
out float2 oTexcoord : TEXCOORD
out float4 oPosition : POSITION,
out float2 oTexcoord : TEXCOORD0
)
{
oPosition = mul(modelViewProj, position);
oPosition = mul(modelViewProj, position);
oTexcoord = tex;
}
uniform float uIntensity;
float4 main_fragment (in float2 texcoord : TEXCOORD, in float2 wpos : WPOS, uniform sampler2D s_p : TEXUNIT0) : COLOR
float4 main_fragment (in float2 texcoord : TEXCOORD0, in float2 wpos : VPOS, uniform sampler2D s_p : TEXUNIT0) : COLOR
{
float4 temp = tex2D(s_p,texcoord);
if(floor(wpos.y/2) != floor(wpos.y)/2) temp.rgb *= uIntensity;

View File

@ -37,17 +37,15 @@ void main_vertex
float dx = delta.x;
float dy = delta.y;
coords = tex_coords (
tex + float2(-dx, -dy),
tex + float2(-dx, 0),
tex + float2(-dx, dy),
tex + float2(0, -dy),
tex + float2(0, 0),
tex + float2(0, dy),
tex + float2(dx, -dy),
tex + float2(dx, 0),
tex + float2(dx, dy)
);
coords.c00 = tex + float2(-dx, -dy);
coords.c01 = tex + float2(-dx, 0.0);
coords.c02 = tex + float2(-dx, dy);
coords.c10 = tex + float2(0.0, -dy);
coords.c11 = tex + float2(0.0, 0.0);
coords.c12 = tex + float2(0.0, dy);
coords.c20 = tex + float2(dx, -dy);
coords.c21 = tex + float2(dx, 0);
coords.c22 = tex + float2(dx, dy);
}
const float mx = 0.325; // start smoothing wt.
@ -67,7 +65,7 @@ float4 main_fragment (in tex_coords co, uniform sampler2D s_p : TEXUNIT0) : COLO
float3 c20 = tex2D(s_p, co.c20).xyz;
float3 c21 = tex2D(s_p, co.c21).xyz;
float3 c22 = tex2D(s_p, co.c22).xyz;
float3 dt = float3(1.0);
float3 dt = float3(1.0,1.0,1.0);
float md1 = dot(abs(c00 - c22), dt);
float md2 = dot(abs(c02 - c20), dt);

View File

@ -9,8 +9,7 @@ namespace BizHawk.Bizware.BizwareGL
{
/// <summary>
/// This is a wrapper over hopefully any OpenGL bindings..
/// And possibly, quite possibly, Direct3d.. even though none of your shaders would work. (could use nvidia CG, native dlls in necessary since this would only be for windows)
/// This is a wrapper over OpenGL and direct3d to give a uniform interface
/// TODO - This really needs to be split up into an internal and a user interface. so many of the functions are made to support the smart wrappers
/// Maybe make a method that returns an interface used for advanced methods (and IGL_TK could implement that as well and just "return this:")
///

View File

@ -20,10 +20,10 @@ namespace BizHawk.Bizware.BizwareGL
VertexLayout = owner.CreateVertexLayout();
VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 40, 0);
VertexLayout.DefineVertexAttribute("color", 1, 4, VertexAttribPointerType.Float, AttributeUsage.Color0, false, 40, 16); //just dead weight, i have no idea why this is here. but some old HLSL compilers (used in bizhawk for various reasons) will want it to exist here since it exists in the vertex shader
VertexLayout.DefineVertexAttribute("texCoord1", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 40, 32);
VertexLayout.DefineVertexAttribute("tex", 2, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 40, 32);
VertexLayout.Close();
string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
string defines = "";
string vsSource = $"#define VERTEX\r\n{defines}{source}";
string psSource = $"#define FRAGMENT\r\n{defines}{source}";
var vs = owner.CreateVertexShader(vsSource, "main_vertex", debug);
@ -53,6 +53,7 @@ namespace BizHawk.Bizware.BizwareGL
}
}
//if a sampler isn't available, we can't do much, although this does interfere with debugging (shaders just returning colors will malfunction)
if (sampler0 == null)
return;

View File

@ -42,9 +42,21 @@ namespace BizHawk.Client.EmuHawk.Filters
Shaders = new RetroShader[preset.Passes.Count];
for (var i = 0; i < preset.Passes.Count; i++)
{
//acquire content
var path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
//acquire content. we look for it in any reasonable filename so that one preset can bind to multiple shaders
string content;
var path = Path.Combine(baseDirectory, preset.Passes[i].ShaderPath);
if (!File.Exists(path))
{
if (!Path.HasExtension(path))
path += ".cg";
if (!File.Exists(path))
{
if (owner.API == "OPENGL")
path = Path.ChangeExtension(path, ".glsl");
else
path = Path.ChangeExtension(path, ".hlsl");
}
}
try
{
content = ResolveIncludes(File.ReadAllText(path), Path.GetDirectoryName(path));
@ -166,24 +178,6 @@ namespace BizHawk.Client.EmuHawk.Filters
public List<ShaderPass> Passes { get; set; } = new List<ShaderPass>();
/// <summary>
/// Indicates whether any of the passes contain GLSL filenames (these are invalid now)
/// </summary>
public bool ContainsGlsl
{
get
{
foreach (var pass in Passes)
{
if (Path.GetExtension(pass.ShaderPath)?.ToLowerInvariant() == ".glsl")
{
return true;
}
}
return false;
}
}
public enum ScaleType
{

View File

@ -436,6 +436,10 @@ namespace BizHawk.Client.EmuHawk
ui.Opaque = uw;
string name = prefix + descr.Name;
//uniforms done through the entry point signature have $ in their names which isn't helpful, so get rid of that
if (name.StartsWith("$"))
name = name.Substring(1);
ui.Name = name;
uw.Description = descr;
uw.EffectHandle = handle;

View File

@ -255,11 +255,6 @@ namespace BizHawk.Client.EmuHawk
using (var stream = File.OpenRead(choice))
{
var cgp = new RetroShaderPreset(stream);
if (cgp.ContainsGlsl)
{
MessageBox.Show("Specified CGP contains references to .glsl files. This is illegal. Use .cg");
return;
}
// try compiling it
bool ok = false;