remove D3D9-syntax from default d3d11 vertex/pixel shader, split the shader into two (more efficient for constant buffer usage)

This commit is contained in:
CasualPokePlayer 2024-05-15 18:40:01 -07:00
parent f78fcc82e3
commit bfec776bd7
1 changed files with 19 additions and 67 deletions

View File

@ -33,8 +33,8 @@ namespace BizHawk.Bizware.Graphics
switch (owner.DispMethodEnum)
{
case EDispMethod.D3D11:
vsProgram = DefaultShader_d3d9;
psProgram = DefaultShader_d3d9;
vsProgram = DefaultVertexShader_d3d11;
psProgram = DefaultPixelShader_d3d11;
break;
case EDispMethod.OpenGL:
vsProgram = DefaultVertexShader_gl;
@ -275,17 +275,11 @@ namespace BizHawk.Bizware.Graphics
// shaders are hand-coded for each platform to make sure they stay as fast as possible
#if false // this doesn't work for reasons unknown (TODO make this work)
public const string DefaultShader_d3d11 = @"
public const string DefaultVertexShader_d3d11 = @"
//vertex shader uniforms
float4x4 um44Modelview, um44Projection;
float4 uModulateColor;
//pixel shader uniforms
bool uSamplerEnable;
Texture2D texture0, texture1;
SamplerState uSampler0 = sampler_state { Texture = (texture0); };
struct VS_INPUT
{
float2 aPosition : POSITION;
@ -300,62 +294,6 @@ struct VS_OUTPUT
float4 vCornerColor : COLOR0;
};
struct PS_INPUT
{
float4 vPosition : SV_POSITION;
float2 vTexcoord0 : TEXCOORD0;
float4 vCornerColor : COLOR0;
};
VS_OUTPUT vsmain(VS_INPUT src)
{
VS_OUTPUT dst;
dst.vPosition = float4(src.aPosition,0,1);
dst.vTexcoord0 = src.aTexcoord;
dst.vCornerColor = src.aColor;
return dst;
}
float4 psmain(PS_INPUT src) : SV_TARGET
{
float4 temp = src.vCornerColor;
temp *= texture0.Sample(uSampler0,src.vTexcoord0);
return temp;
}
";
#endif
public const string DefaultShader_d3d9 = @"
//vertex shader uniforms
float4x4 um44Modelview, um44Projection;
float4 uModulateColor;
//pixel shader uniforms
bool uSamplerEnable;
texture2D texture0, texture1;
sampler uSampler0 = sampler_state { Texture = (texture0); };
struct VS_INPUT
{
float2 aPosition : POSITION;
float2 aTexcoord : TEXCOORD0;
float4 aColor : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 vPosition : POSITION;
float2 vTexcoord0 : TEXCOORD0;
float4 vCornerColor : COLOR0;
};
struct PS_INPUT
{
float4 vPosition : POSITION;
float2 vTexcoord0 : TEXCOORD0;
float4 vCornerColor : COLOR0;
};
VS_OUTPUT vsmain(VS_INPUT src)
{
VS_OUTPUT dst;
@ -365,11 +303,25 @@ VS_OUTPUT vsmain(VS_INPUT src)
dst.vCornerColor = src.aColor * uModulateColor;
return dst;
}
";
float4 psmain(PS_INPUT src) : COLOR
public const string DefaultPixelShader_d3d11 = @"
//pixel shader uniforms
bool uSamplerEnable;
Texture2D texture0;
sampler uSampler0;
struct PS_INPUT
{
float4 vPosition : SV_POSITION;
float2 vTexcoord0 : TEXCOORD0;
float4 vCornerColor : COLOR0;
};
float4 psmain(PS_INPUT src) : SV_Target
{
float4 temp = src.vCornerColor;
if(uSamplerEnable) temp *= tex2D(uSampler0,src.vTexcoord0);
if(uSamplerEnable) temp *= texture0.Sample(uSampler0,src.vTexcoord0);
return temp;
}
";