mirror of
https://github.com/holub/mame
synced 2025-04-16 05:24:54 +03:00
d3dhlsl.c: Add preliminary vector post-processing. [MooglyGuy]
This commit is contained in:
parent
7f3372abf3
commit
d157249cb7
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -271,8 +271,10 @@ hash/x68k_flop.xml svneol=native#text/xml
|
||||
hash/xegs.xml svneol=native#text/xml
|
||||
hash/xerox820.xml svneol=native#text/xml
|
||||
hash/xerox820ii.xml svneol=native#text/xml
|
||||
hlsl/bloom.fx svneol=native#text/plain
|
||||
hlsl/color.fx svneol=native#text/plain
|
||||
hlsl/deconverge.fx svneol=native#text/plain
|
||||
hlsl/downsample.fx svneol=native#text/plain
|
||||
hlsl/focus.fx svneol=native#text/plain
|
||||
hlsl/phosphor.fx svneol=native#text/plain
|
||||
hlsl/pincushion.fx svneol=native#text/plain
|
||||
|
242
hlsl/bloom.fx
Normal file
242
hlsl/bloom.fx
Normal file
@ -0,0 +1,242 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Effect File Variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
texture DiffuseA;
|
||||
texture DiffuseB;
|
||||
texture DiffuseC;
|
||||
texture DiffuseD;
|
||||
texture DiffuseE;
|
||||
texture DiffuseF;
|
||||
texture DiffuseG;
|
||||
texture DiffuseH;
|
||||
texture DiffuseI;
|
||||
texture DiffuseJ;
|
||||
texture DiffuseK;
|
||||
|
||||
sampler DiffuseSampler0 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseA>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler1 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseB>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler2 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseC>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler3 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseD>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler4 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseE>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler5 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseF>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler6 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseG>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler7 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseH>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler8 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseI>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler9 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseJ>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
sampler DiffuseSampler10 = sampler_state
|
||||
{
|
||||
Texture = <DiffuseK>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertex Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bloom Vertex Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform float2 TargetSize;
|
||||
|
||||
uniform float DiffuseScaleA;
|
||||
uniform float DiffuseScaleB;
|
||||
uniform float DiffuseScaleC;
|
||||
uniform float DiffuseScaleD;
|
||||
uniform float DiffuseScaleE;
|
||||
uniform float DiffuseScaleF;
|
||||
uniform float DiffuseScaleG;
|
||||
uniform float DiffuseScaleH;
|
||||
uniform float DiffuseScaleI;
|
||||
uniform float DiffuseScaleJ;
|
||||
uniform float DiffuseScaleK;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||
|
||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||
Output.Position.xy /= TargetSize;
|
||||
Output.Position.y = 1.0f - Output.Position.y;
|
||||
Output.Position.xy -= float2(0.5f, 0.5f);
|
||||
Output.Position.xy *= float2(2.0f, 2.0f);
|
||||
Output.Color = Input.Color;
|
||||
float2 inversePixel = 1.0f / TargetSize;
|
||||
Output.TexCoord = Input.Position.xy * inversePixel;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Bloom Pixel Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
float4 ps_main(PS_INPUT Input) : COLOR
|
||||
{
|
||||
float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb * DiffuseScaleA * 1.00f;
|
||||
float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb * DiffuseScaleB * 0.95f;
|
||||
float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb * DiffuseScaleC * 0.85f;
|
||||
float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb * DiffuseScaleD * 0.75f;
|
||||
float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb * DiffuseScaleE * 0.65f;
|
||||
float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb * DiffuseScaleF * 0.55f;
|
||||
float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb * DiffuseScaleG * 0.45f;
|
||||
float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb * DiffuseScaleH * 0.35f;
|
||||
float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb * DiffuseScaleI * 0.25f;
|
||||
float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb * DiffuseScaleJ * 0.15f;
|
||||
float3 texel10 = tex2D(DiffuseSampler10, Input.TexCoord).rgb * DiffuseScaleK * 0.10f;
|
||||
return float4(texel0 + texel1 + texel2 + texel3 + texel4 +
|
||||
texel5 + texel6 + texel7 + texel8 + texel9 + texel10, 1.0f);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Downsample Effect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
technique TestTechnique
|
||||
{
|
||||
pass Pass0
|
||||
{
|
||||
Lighting = FALSE;
|
||||
|
||||
Sampler[0] = <DiffuseSampler0>; // 2048x2048
|
||||
Sampler[1] = <DiffuseSampler1>; // 1024x1024
|
||||
Sampler[2] = <DiffuseSampler2>; // 512x512
|
||||
Sampler[3] = <DiffuseSampler3>; // 256x256
|
||||
Sampler[4] = <DiffuseSampler4>; // 128x128
|
||||
Sampler[5] = <DiffuseSampler5>; // 64x64
|
||||
Sampler[6] = <DiffuseSampler6>; // 32x32
|
||||
Sampler[7] = <DiffuseSampler7>; // 16x16
|
||||
Sampler[8] = <DiffuseSampler8>; // 8x8
|
||||
Sampler[9] = <DiffuseSampler9>; // 4x4
|
||||
Sampler[10] = <DiffuseSampler10>; // 2x2
|
||||
|
||||
VertexShader = compile vs_3_0 vs_main();
|
||||
PixelShader = compile ps_3_0 ps_main();
|
||||
}
|
||||
}
|
121
hlsl/downsample.fx
Normal file
121
hlsl/downsample.fx
Normal file
@ -0,0 +1,121 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Effect File Variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
texture Diffuse;
|
||||
|
||||
sampler DiffuseSampler = sampler_state
|
||||
{
|
||||
Texture = <Diffuse>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertex Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float4 TexCoord01 : TEXCOORD0;
|
||||
float4 TexCoord23 : TEXCOORD1;
|
||||
float4 TexCoord45 : TEXCOORD2;
|
||||
float4 TexCoord67 : TEXCOORD3;
|
||||
float4 TexCoord89 : TEXCOORD4;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
float4 Color : COLOR0;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 Color : COLOR0;
|
||||
float4 TexCoord01 : TEXCOORD0;
|
||||
float4 TexCoord23 : TEXCOORD1;
|
||||
float4 TexCoord45 : TEXCOORD2;
|
||||
float4 TexCoord67 : TEXCOORD3;
|
||||
float4 TexCoord89 : TEXCOORD4;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Downsample Vertex Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
uniform float2 TargetSize;
|
||||
uniform float2 SourceSize;
|
||||
|
||||
uniform float2 Defocus = float2(0.0f, 0.0f);
|
||||
|
||||
uniform float Brighten;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||
|
||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||
Output.Position.xy /= TargetSize;
|
||||
Output.Position.y = 1.0f - Output.Position.y;
|
||||
Output.Position.xy -= float2(0.5f, 0.5f);
|
||||
Output.Position.xy *= float2(2.0f, 2.0f);
|
||||
Output.Color = Input.Color;
|
||||
float2 inversePixel = 1.0f / TargetSize;
|
||||
Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.75f - 0.5f, 0.32f - 0.5f) * inversePixel;
|
||||
Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(0.35f - 0.5f, 0.65f - 0.5f) * inversePixel;
|
||||
Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.31f - 0.5f, 1.25f - 0.5f) * inversePixel;
|
||||
Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(0.58f - 0.5f, 1.61f - 0.5f) * inversePixel;
|
||||
Output.TexCoord45.xy = Input.Position.xy * inversePixel + float2(1.00f - 0.5f, 1.75f - 0.5f) * inversePixel;
|
||||
Output.TexCoord45.zw = Input.Position.xy * inversePixel + float2(1.35f - 0.5f, 1.64f - 0.5f) * inversePixel;
|
||||
Output.TexCoord67.xy = Input.Position.xy * inversePixel + float2(1.65f - 0.5f, 1.32f - 0.5f) * inversePixel;
|
||||
Output.TexCoord67.zw = Input.Position.xy * inversePixel + float2(1.72f - 0.5f, 0.93f - 0.5f) * inversePixel;
|
||||
Output.TexCoord89.xy = Input.Position.xy * inversePixel + float2(1.57f - 0.5f, 0.57f - 0.5f) * inversePixel;
|
||||
Output.TexCoord89.zw = Input.Position.xy * inversePixel + float2(1.25f - 0.5f, 0.33f - 0.5f) * inversePixel;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Downsample Pixel Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
float4 ps_main(PS_INPUT Input) : COLOR
|
||||
{
|
||||
float4 texel0 = tex2D(DiffuseSampler, Input.TexCoord01.xy);
|
||||
float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw);
|
||||
float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
|
||||
float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
|
||||
float4 texel4 = tex2D(DiffuseSampler, Input.TexCoord45.xy);
|
||||
float4 texel5 = tex2D(DiffuseSampler, Input.TexCoord45.zw);
|
||||
float4 texel6 = tex2D(DiffuseSampler, Input.TexCoord67.xy);
|
||||
float4 texel7 = tex2D(DiffuseSampler, Input.TexCoord67.zw);
|
||||
float4 texel8 = tex2D(DiffuseSampler, Input.TexCoord89.xy);
|
||||
float4 texel9 = tex2D(DiffuseSampler, Input.TexCoord89.zw);
|
||||
float4 outTexel = (texel0 + texel1 + texel2 + texel3 + texel4 + texel5 + texel6 + texel7 + texel8 + texel9) * 0.1f;
|
||||
return float4(outTexel.rgb, 1.0f);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Downsample Effect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
technique TestTechnique
|
||||
{
|
||||
pass Pass0
|
||||
{
|
||||
Lighting = FALSE;
|
||||
|
||||
Sampler[0] = <DiffuseSampler>;
|
||||
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_main();
|
||||
}
|
||||
}
|
@ -60,11 +60,7 @@ struct PS_INPUT
|
||||
uniform float TargetWidth;
|
||||
uniform float TargetHeight;
|
||||
|
||||
uniform float WidthRatio;
|
||||
uniform float HeightRatio;
|
||||
|
||||
uniform float2 Defocus = float2(0.0f, 0.0f);
|
||||
uniform float FocusEnable;
|
||||
|
||||
float2 Coord0Offset = float2( 0.0f, 0.0f);
|
||||
float2 Coord1Offset = float2(-0.2f, -0.6f);
|
||||
|
@ -61,12 +61,6 @@ struct PS_INPUT
|
||||
uniform float TargetWidth;
|
||||
uniform float TargetHeight;
|
||||
|
||||
uniform float RawWidth;
|
||||
uniform float RawHeight;
|
||||
|
||||
uniform float WidthRatio;
|
||||
uniform float HeightRatio;
|
||||
|
||||
uniform float TextureWidth;
|
||||
uniform float TextureHeight;
|
||||
|
||||
@ -86,7 +80,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
Output.Color = Input.Color;
|
||||
|
||||
float2 InvTexSize = float2(1.0f / TextureWidth, 1.0f / TextureHeight);
|
||||
Output.TexCoord = Input.TexCoord + float2(0.5f, 0.5f) * InvTexSize;
|
||||
Output.TexCoord = Input.TexCoord + float2(1.0f, 1.0f) * InvTexSize;
|
||||
Output.PrevCoord = Output.TexCoord;
|
||||
|
||||
return Output;
|
||||
|
@ -180,6 +180,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
||||
Output.r = pow(Output.r, Power.r);
|
||||
Output.g = pow(Output.g, Power.g);
|
||||
Output.b = pow(Output.b, Power.b);
|
||||
Output.a = 1.0f;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ uniform float TargetWidth;
|
||||
uniform float TargetHeight;
|
||||
uniform float PostPass;
|
||||
uniform float FixedAlpha;
|
||||
uniform float Brighten;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
@ -72,7 +73,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
float4 ps_main(PS_INPUT Input) : COLOR
|
||||
{
|
||||
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
|
||||
return BaseTexel * Input.Color;
|
||||
return BaseTexel * (Input.Color + float4(Brighten, Brighten, Brighten, 0.0f));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -2,19 +2,6 @@
|
||||
// Effect File Variables
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
texture Diffuse;
|
||||
|
||||
sampler DiffuseSampler = sampler_state
|
||||
{
|
||||
Texture = <Diffuse>;
|
||||
MipFilter = LINEAR;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
AddressU = CLAMP;
|
||||
AddressV = CLAMP;
|
||||
AddressW = CLAMP;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertex Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -45,6 +32,8 @@ struct PS_INPUT
|
||||
|
||||
uniform float TargetWidth;
|
||||
uniform float TargetHeight;
|
||||
uniform float2 TimeParams;
|
||||
uniform float3 LengthParams;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
@ -57,7 +46,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
Output.Position.x -= 0.5f;
|
||||
Output.Position.y -= 0.5f;
|
||||
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
|
||||
Output.Color = float4(0.0f, 0.0f, Input.Color.z, 1.0f);
|
||||
Output.Color = Input.Color;
|
||||
Output.TexCoord = Input.Position.xy / float2(TargetWidth, TargetHeight);
|
||||
|
||||
return Output;
|
||||
@ -67,10 +56,20 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
// Simple Pixel Shader
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// TimeParams.x: Frame time of the vector
|
||||
// TimeParams.y: How much frame time affects the vector's fade
|
||||
// LengthParams.x: Length of the vector
|
||||
// LengthParams.y: How much length affects the vector's fade
|
||||
// LengthParams.z: Size at which fade is maximum
|
||||
float4 ps_main(PS_INPUT Input) : COLOR
|
||||
{
|
||||
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
|
||||
return BaseTexel * Input.Color;
|
||||
float timeModulate = lerp(1.0f, TimeParams.x, TimeParams.y) * 2.0;
|
||||
|
||||
float lengthModulate = clamp(1.0f - LengthParams.x / LengthParams.z, 0.0f, 1.0f);
|
||||
lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y) * 2.0;
|
||||
|
||||
float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 2.5;
|
||||
return outColor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -83,8 +82,6 @@ technique TestTechnique
|
||||
{
|
||||
Lighting = FALSE;
|
||||
|
||||
//Sampler[0] = <DiffuseSampler>;
|
||||
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_main();
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ void construct_core_types(simple_list<input_type_entry> &typelist)
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_THROTTLE, "Throttle", input_seq(KEYCODE_F10) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FAST_FORWARD, "Fast Forward", input_seq(KEYCODE_INSERT) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_FPS, "Show FPS", input_seq(KEYCODE_F11, input_seq::not_code, KEYCODE_LCONTROL, input_seq::not_code, KEYCODE_LSHIFT) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SNAPSHOT, "Save Snapshot", input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SNAPSHOT, "Save Snapshot", input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_LCONTROL, input_seq::not_code, KEYCODE_LALT, input_seq::not_code, KEYCODE_RALT) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_MOVIE, "Record Movie", input_seq(KEYCODE_F12, KEYCODE_LSHIFT) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CHEAT, "Toggle Cheat", input_seq(KEYCODE_F6) )
|
||||
INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP, "UI Up", input_seq(KEYCODE_UP, input_seq::or_code, JOYCODE_Y_UP_SWITCH_INDEXED(0)) )
|
||||
|
@ -1766,7 +1766,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const
|
||||
|
||||
// scale the width by the minimum of X/Y scale factors
|
||||
prim->width = curitem->width() * MIN(container_xform.xscale, container_xform.yscale);
|
||||
prim->flags = curitem->flags();
|
||||
prim->flags |= curitem->flags();
|
||||
|
||||
// clip the primitive
|
||||
clipped = render_clip_line(&prim->bounds, &cliprect);
|
||||
@ -1819,7 +1819,7 @@ void render_target::add_container_primitives(render_primitive_list &list, const
|
||||
|
||||
// no texture -- set the basic flags
|
||||
prim->texture.base = NULL;
|
||||
prim->flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
|
||||
prim->flags = (curitem->flags() &~ PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
|
||||
|
||||
// apply clipping
|
||||
clipped = render_clip_quad(&prim->bounds, &cliprect, NULL);
|
||||
|
@ -86,6 +86,8 @@ struct d3d_poly_info
|
||||
UINT32 flags; // rendering flags
|
||||
DWORD modmode; // texture modulation mode
|
||||
d3d_texture_info * texture; // pointer to texture info
|
||||
float line_time; // used by vectors
|
||||
float line_length; // used by vectors
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -48,7 +48,7 @@
|
||||
// CONSTANTS
|
||||
//============================================================
|
||||
|
||||
#define HLSL_VECTOR (0)
|
||||
#define HLSL_VECTOR (0)
|
||||
|
||||
//============================================================
|
||||
// TYPE DEFINITIONS
|
||||
@ -91,6 +91,8 @@ struct hlsl_options
|
||||
float floor[3];
|
||||
float phosphor[3];
|
||||
float saturation;
|
||||
|
||||
// NTSC
|
||||
bool yiq_enable;
|
||||
float yiq_cc;
|
||||
float yiq_a;
|
||||
@ -103,6 +105,12 @@ struct hlsl_options
|
||||
float yiq_q;
|
||||
float yiq_scan_time;
|
||||
int yiq_phase_count;
|
||||
|
||||
// Vectors
|
||||
float vector_time_scale;
|
||||
float vector_time_period;
|
||||
float vector_length_scale;
|
||||
float vector_length_ratio;
|
||||
};
|
||||
|
||||
class hlsl_info
|
||||
@ -113,23 +121,26 @@ public:
|
||||
~hlsl_info();
|
||||
|
||||
void init(d3d_base *d3dintf, win_window_info *window);
|
||||
void init_fsfx_quad(void *vertbuf);
|
||||
|
||||
bool enabled() { return master_enable; }
|
||||
void toggle();
|
||||
|
||||
bool vector_enabled() { return vector_enable && (bool)HLSL_VECTOR; }
|
||||
d3d_render_target* get_vector_target(d3d_info *d3d);
|
||||
void create_vector_target(d3d_info *d3d, render_primitive *prim);
|
||||
bool vector_enabled() { return master_enable && vector_enable && (bool)HLSL_VECTOR; }
|
||||
d3d_render_target* get_vector_target();
|
||||
void create_vector_target(render_primitive *prim);
|
||||
|
||||
void begin_frame();
|
||||
void end_frame();
|
||||
|
||||
void begin_draw();
|
||||
void end_draw();
|
||||
|
||||
void begin();
|
||||
void init_effect_info(d3d_poly_info *poly);
|
||||
void render_quad(d3d_poly_info *poly, int vertnum);
|
||||
void end();
|
||||
|
||||
bool register_texture(d3d_texture_info *texture);
|
||||
bool register_prescaled_texture(d3d_texture_info *texture);
|
||||
bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale);
|
||||
bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom = false);
|
||||
bool add_cache_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index);
|
||||
|
||||
void window_save();
|
||||
@ -139,8 +150,7 @@ public:
|
||||
void avi_update_snap(d3d_surface *surface);
|
||||
void render_snapshot(d3d_surface *surface);
|
||||
void record_texture();
|
||||
|
||||
void frame_complete();
|
||||
void init_fsfx_quad(void *vertbuf);
|
||||
|
||||
void set_texture(d3d_texture_info *texture);
|
||||
d3d_render_target * find_render_target(d3d_texture_info *info);
|
||||
@ -155,6 +165,11 @@ public:
|
||||
slider_state *init_slider_list();
|
||||
|
||||
private:
|
||||
void blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
|
||||
D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count,
|
||||
int dstw, int dsth);
|
||||
void blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
|
||||
D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
|
||||
void enumerate_screens();
|
||||
|
||||
void end_avi_recording();
|
||||
@ -186,6 +201,9 @@ private:
|
||||
bitmap_argb32 shadow_bitmap; // shadow mask bitmap for post-processing shader
|
||||
d3d_texture_info * shadow_texture; // shadow mask texture for post-processing shader
|
||||
hlsl_options * options; // current uniform state
|
||||
D3DPRIMITIVETYPE vecbuf_type;
|
||||
UINT32 vecbuf_index;
|
||||
UINT32 vecbuf_count;
|
||||
|
||||
avi_file * avi_output_file; // AVI file
|
||||
bitmap_rgb32 avi_snap; // AVI snapshot
|
||||
@ -197,6 +215,9 @@ private:
|
||||
d3d_surface * avi_final_target; // AVI upscaled surface
|
||||
d3d_texture * avi_final_texture; // AVI upscaled texture
|
||||
|
||||
d3d_surface * black_surface; // black dummy surface
|
||||
d3d_texture * black_texture; // black dummy texture
|
||||
|
||||
bool render_snap; // whether or not to take HLSL post-render snapshot
|
||||
bool snap_rendered; // whether we just rendered our HLSL post-render shot or not
|
||||
d3d_surface * snap_copy_target; // snapshot destination surface in system memory
|
||||
@ -223,6 +244,8 @@ private:
|
||||
d3d_effect * yiq_encode_effect; // pointer to the YIQ encoder effect object
|
||||
d3d_effect * yiq_decode_effect; // pointer to the YIQ decoder effect object
|
||||
#if HLSL_VECTOR
|
||||
d3d_effect * bloom_effect; // pointer to the bloom composite effect
|
||||
d3d_effect * downsample_effect; // pointer to the bloom downsample effect
|
||||
d3d_effect * vector_effect; // pointer to the vector-effect object
|
||||
#endif
|
||||
d3d_vertex * fsfx_vertices; // pointer to our full-screen-quad object
|
||||
|
@ -365,7 +365,7 @@ static void pick_best_mode(win_window_info *window);
|
||||
static int update_window_size(win_window_info *window);
|
||||
|
||||
// drawing
|
||||
static void draw_line(d3d_info *d3d, const render_primitive *prim);
|
||||
static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time);
|
||||
static void draw_quad(d3d_info *d3d, const render_primitive *prim);
|
||||
|
||||
// primitives
|
||||
@ -499,6 +499,7 @@ static void drawd3d_window_save(win_window_info *window)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================
|
||||
// drawd3d_window_destroy
|
||||
//============================================================
|
||||
@ -598,7 +599,7 @@ mtlog_add("drawd3d_window_draw: begin");
|
||||
result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
|
||||
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
|
||||
|
||||
d3d->hlsl->record_texture();
|
||||
d3d->hlsl->begin_frame();
|
||||
|
||||
// first update any textures
|
||||
window->primlist->acquire_lock();
|
||||
@ -610,9 +611,9 @@ mtlog_add("drawd3d_window_draw: begin");
|
||||
}
|
||||
else if(d3d->hlsl->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags))
|
||||
{
|
||||
if (!d3d->hlsl->get_vector_target(d3d))
|
||||
if (!d3d->hlsl->get_vector_target())
|
||||
{
|
||||
d3d->hlsl->create_vector_target(d3d, prim);
|
||||
d3d->hlsl->create_vector_target(prim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,19 +625,46 @@ mtlog_add("drawd3d_window_draw: begin_scene");
|
||||
|
||||
d3d->lockedbuf = NULL;
|
||||
|
||||
// loop over primitives
|
||||
if(d3d->hlsl->enabled())
|
||||
{
|
||||
d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
|
||||
d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
|
||||
}
|
||||
// loop over primitives
|
||||
if(d3d->hlsl->enabled())
|
||||
{
|
||||
d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
|
||||
d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
|
||||
}
|
||||
|
||||
mtlog_add("drawd3d_window_draw: count lines");
|
||||
int line_count = 0;
|
||||
for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
|
||||
if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags))
|
||||
line_count++;
|
||||
|
||||
mtlog_add("drawd3d_window_draw: primitive loop begin");
|
||||
// Rotating index for vector time offsets
|
||||
static int start_index = 0;
|
||||
int line_index = 0;
|
||||
windows_options &options = downcast<windows_options &>(window->machine().options());
|
||||
float period = options.screen_vector_time_period();
|
||||
for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
|
||||
{
|
||||
switch (prim->type)
|
||||
{
|
||||
case render_primitive::LINE:
|
||||
draw_line(d3d, prim);
|
||||
if (PRIMFLAG_GET_VECTOR(prim->flags))
|
||||
{
|
||||
if (period == 0.0f || line_count == 0)
|
||||
{
|
||||
draw_line(d3d, prim, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_line(d3d, prim, (float)(start_index + line_index) / ((float)line_count * period));
|
||||
line_index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_line(d3d, prim, 0.0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case render_primitive::QUAD:
|
||||
@ -646,6 +674,12 @@ mtlog_add("drawd3d_window_draw: primitive loop begin");
|
||||
default:
|
||||
throw emu_fatalerror("Unexpected render_primitive type");
|
||||
}
|
||||
}
|
||||
start_index += (int)((float)line_index * period);
|
||||
if (line_count > 0)
|
||||
{
|
||||
start_index %= line_count;
|
||||
}
|
||||
mtlog_add("drawd3d_window_draw: primitive loop end");
|
||||
window->primlist->release_lock();
|
||||
|
||||
@ -654,6 +688,8 @@ mtlog_add("drawd3d_window_draw: flush_pending begin");
|
||||
primitive_flush_pending(d3d);
|
||||
mtlog_add("drawd3d_window_draw: flush_pending end");
|
||||
|
||||
d3d->hlsl->end_frame();
|
||||
|
||||
// finish the scene
|
||||
mtlog_add("drawd3d_window_draw: end_scene begin");
|
||||
result = (*d3dintf->device.end_scene)(d3d->device);
|
||||
@ -666,8 +702,6 @@ mtlog_add("drawd3d_window_draw: present begin");
|
||||
mtlog_add("drawd3d_window_draw: present end");
|
||||
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device present call\n", (int)result);
|
||||
|
||||
d3d->hlsl->frame_complete();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1446,7 +1480,7 @@ static int update_window_size(win_window_info *window)
|
||||
// draw_line
|
||||
//============================================================
|
||||
|
||||
static void draw_line(d3d_info *d3d, const render_primitive *prim)
|
||||
static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time)
|
||||
{
|
||||
const line_aa_step *step = line_aa_4step;
|
||||
render_bounds b0, b1;
|
||||
@ -1546,6 +1580,22 @@ static void draw_line(d3d_info *d3d, const render_primitive *prim)
|
||||
poly->flags = prim->flags;
|
||||
poly->modmode = D3DTOP_MODULATE;
|
||||
poly->texture = d3d->vector_texture;
|
||||
poly->line_time = line_time;
|
||||
poly->line_length = 1.0f;
|
||||
if (PRIMFLAG_GET_VECTOR(poly->flags))
|
||||
{
|
||||
float dx = fabs(prim->bounds.x1 - prim->bounds.x0);
|
||||
float dy = fabs(prim->bounds.y1 - prim->bounds.y0);
|
||||
float length2 = dx * dx + dy * dy;
|
||||
if (length2 > 0.0f)
|
||||
{
|
||||
poly->line_length = sqrt(length2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use default length of 1.0f from above
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1640,6 +1690,7 @@ static void draw_quad(d3d_info *d3d, const render_primitive *prim)
|
||||
poly->flags = prim->flags;
|
||||
poly->modmode = modmode;
|
||||
poly->texture = texture;
|
||||
//poly->
|
||||
}
|
||||
|
||||
|
||||
@ -1653,8 +1704,16 @@ static d3d_vertex *primitive_alloc(d3d_info *d3d, int numverts)
|
||||
|
||||
// if we're going to overflow, flush
|
||||
if (d3d->lockedbuf != NULL && d3d->numverts + numverts >= VERTEX_BUFFER_SIZE)
|
||||
{
|
||||
primitive_flush_pending(d3d);
|
||||
|
||||
if(d3d->hlsl->enabled())
|
||||
{
|
||||
d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
|
||||
d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
|
||||
}
|
||||
}
|
||||
|
||||
// if we don't have a lock, grab it now
|
||||
if (d3d->lockedbuf == NULL)
|
||||
{
|
||||
@ -1698,17 +1757,16 @@ static void primitive_flush_pending(d3d_info *d3d)
|
||||
result = (*d3dintf->device.set_stream_source)(d3d->device, 0, d3d->vertexbuf, sizeof(d3d_vertex));
|
||||
if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result);
|
||||
|
||||
d3d->hlsl->begin();
|
||||
d3d->hlsl->begin_draw();
|
||||
|
||||
// first remember the original render target in case we need to set a new one
|
||||
if(d3d->hlsl->enabled() && d3dintf->post_fx_available)
|
||||
{
|
||||
vertnum = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertnum = 0;
|
||||
}
|
||||
if (d3d->hlsl->enabled())
|
||||
{
|
||||
vertnum = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertnum = 0;
|
||||
}
|
||||
|
||||
// now do the polys
|
||||
for (polynum = 0; polynum < d3d->numpolys; polynum++)
|
||||
@ -1753,7 +1811,7 @@ static void primitive_flush_pending(d3d_info *d3d)
|
||||
vertnum += poly->numverts;
|
||||
}
|
||||
|
||||
d3d->hlsl->end();
|
||||
d3d->hlsl->end_draw();
|
||||
|
||||
// reset the vertex count
|
||||
d3d->numverts = 0;
|
||||
@ -2660,6 +2718,20 @@ static void texture_update(d3d_info *d3d, const render_primitive *prim)
|
||||
|
||||
d3d_cache_target::~d3d_cache_target()
|
||||
{
|
||||
for (int index = 0; index < 11; index++)
|
||||
{
|
||||
if (bloom_texture[index] != NULL)
|
||||
{
|
||||
(*d3dintf->texture.release)(bloom_texture[index]);
|
||||
bloom_texture[index] = NULL;
|
||||
}
|
||||
if (bloom_target[index] != NULL)
|
||||
{
|
||||
(*d3dintf->surface.release)(bloom_target[index]);
|
||||
bloom_target[index] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (last_texture != NULL)
|
||||
{
|
||||
(*d3dintf->texture.release)(last_texture);
|
||||
@ -2677,13 +2749,37 @@ d3d_cache_target::~d3d_cache_target()
|
||||
// d3d_cache_target::init - initializes a target cache
|
||||
//============================================================
|
||||
|
||||
bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
|
||||
bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
|
||||
{
|
||||
if (bloom)
|
||||
{
|
||||
int bloom_size = (width * prescale_x < height * prescale_y) ? width * prescale_x : height * prescale_y;
|
||||
int bloom_index = 0;
|
||||
int bloom_width = width * prescale_x;
|
||||
int bloom_height = height * prescale_y;
|
||||
for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
{
|
||||
printf("%d: %d, %d\n", bloom_index, bloom_width, bloom_height);
|
||||
bloom_width >>= 1;
|
||||
bloom_height >>= 1;
|
||||
HRESULT result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
|
||||
if (result != D3D_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
|
||||
bloom_index++;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(last_texture, 0, &last_target);
|
||||
|
||||
target_width = width * prescale_x;
|
||||
target_height = height * prescale_y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2693,6 +2789,20 @@ bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int hei
|
||||
|
||||
d3d_render_target::~d3d_render_target()
|
||||
{
|
||||
for (int index = 0; index < 11; index++)
|
||||
{
|
||||
if (bloom_texture[index] != NULL)
|
||||
{
|
||||
(*d3dintf->texture.release)(bloom_texture[index]);
|
||||
bloom_texture[index] = NULL;
|
||||
}
|
||||
if (bloom_target[index] != NULL)
|
||||
{
|
||||
(*d3dintf->surface.release)(bloom_target[index]);
|
||||
bloom_target[index] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < 5; index++)
|
||||
{
|
||||
if (texture[index] != NULL)
|
||||
@ -2735,42 +2845,70 @@ d3d_render_target::~d3d_render_target()
|
||||
// d3d_render_target::init - initializes a render target
|
||||
//============================================================
|
||||
|
||||
bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
|
||||
bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
|
||||
{
|
||||
HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[0]);
|
||||
D3DFORMAT format = bloom ? D3DFMT_A16B16G16R16F : D3DFMT_A8R8G8B8;
|
||||
|
||||
HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[0]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[0], 0, &target[0]);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[1]);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[1]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[1], 0, &target[1]);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[2]);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[2]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[2], 0, &target[2]);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
|
||||
if (!bloom)
|
||||
{
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
|
||||
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
|
||||
|
||||
for (int index = 0; index < 11; index++)
|
||||
{
|
||||
bloom_texture[index] = NULL;
|
||||
bloom_target[index] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int bloom_size = (width < height) ? width : height;
|
||||
int bloom_index = 0;
|
||||
int bloom_width = width;
|
||||
int bloom_height = height;
|
||||
for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
|
||||
{
|
||||
bloom_width >>= 1;
|
||||
bloom_height >>= 1;
|
||||
result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
|
||||
if (result != D3D_OK)
|
||||
return false;
|
||||
(*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
|
||||
bloom_index++;
|
||||
}
|
||||
}
|
||||
|
||||
target_width = width * prescale_x;
|
||||
target_height = height * prescale_y;
|
||||
|
@ -67,11 +67,14 @@ public:
|
||||
d3d_cache_target() { }
|
||||
~d3d_cache_target();
|
||||
|
||||
bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
|
||||
bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom);
|
||||
|
||||
d3d_surface *last_target;
|
||||
d3d_texture *last_texture;
|
||||
|
||||
int target_width;
|
||||
int target_height;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@ -79,6 +82,9 @@ public:
|
||||
|
||||
d3d_cache_target *next;
|
||||
d3d_cache_target *prev;
|
||||
|
||||
d3d_surface *bloom_target[11];
|
||||
d3d_texture *bloom_texture[11];
|
||||
};
|
||||
|
||||
/* d3d_render_target is the information about a Direct3D render target chain */
|
||||
@ -89,7 +95,7 @@ public:
|
||||
d3d_render_target() { }
|
||||
~d3d_render_target();
|
||||
|
||||
bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
|
||||
bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom = false);
|
||||
|
||||
int target_width;
|
||||
int target_height;
|
||||
@ -109,6 +115,9 @@ public:
|
||||
|
||||
d3d_render_target *next;
|
||||
d3d_render_target *prev;
|
||||
|
||||
d3d_surface *bloom_target[11];
|
||||
d3d_texture *bloom_texture[11];
|
||||
};
|
||||
|
||||
/* d3d_info is the information about Direct3D for the current screen */
|
||||
|
@ -375,6 +375,7 @@ const options_entry windows_options::s_option_entries[] =
|
||||
{ WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0",OPTION_STRING, "signal floor level" },
|
||||
{ WINOPTION_PHOSPHOR";fs_phosphor", "0.0,0.0,0.0",OPTION_STRING, "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
|
||||
/* NTSC simulation below this line */
|
||||
{ NULL, NULL, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
|
||||
{ WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable YIQ-space HLSL post-processing" },
|
||||
{ WINOPTION_YIQ_CCVALUE";yiqcc", "3.59754545",OPTION_FLOAT, "Color Carrier frequency for NTSC signal processing" },
|
||||
{ WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for NTSC signal processing" },
|
||||
@ -387,6 +388,14 @@ const options_entry windows_options::s_option_entries[] =
|
||||
{ WINOPTION_YIQ_QVALUE";yiqq", "0.6", OPTION_FLOAT, "Q filter cutoff frequency for NTSC signal processing" },
|
||||
{ WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "Horizontal scanline duration for NTSC signal processing (in usec)" },
|
||||
{ WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for NTSC signal processing" },
|
||||
{ WINOPTION_YIQ_SCAN_TIME";yiqsc", "52.6", OPTION_FLOAT, "Horizontal scanline duration for NTSC signal processing (in usec)" },
|
||||
{ WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for NTSC signal processing" },
|
||||
/* Vector simulation below this line */
|
||||
{ NULL, NULL, OPTION_HEADER, "VECTOR POST-PROCESSING OPTIONS" },
|
||||
{ WINOPTION_VECTOR_TIME_SCALE";vectime", "0.0", OPTION_FLOAT, "How much the fade rate affects vector fade" },
|
||||
{ WINOPTION_VECTOR_TIME_PERIOD";vecperiod", "0.1", OPTION_FLOAT, "Vector fade rate versus screen refresh rate" },
|
||||
{ WINOPTION_VECTOR_LENGTH_SCALE";veclength", "0.9", OPTION_FLOAT, "How much length affects vector fade" },
|
||||
{ WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "4.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
|
||||
|
||||
// per-window options
|
||||
{ NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" },
|
||||
|
@ -1,4 +1,4 @@
|
||||
//============================================================
|
||||
//============================================================
|
||||
//
|
||||
// winmain.h - Win32 main program and core headers
|
||||
//
|
||||
@ -130,6 +130,10 @@
|
||||
#define WINOPTION_YIQ_QVALUE "yiq_q"
|
||||
#define WINOPTION_YIQ_SCAN_TIME "yiq_scan_time"
|
||||
#define WINOPTION_YIQ_PHASE_COUNT "yiq_phase_count"
|
||||
#define WINOPTION_VECTOR_TIME_SCALE "vector_time_scale"
|
||||
#define WINOPTION_VECTOR_TIME_PERIOD "vector_time_period"
|
||||
#define WINOPTION_VECTOR_LENGTH_SCALE "vector_length_scale"
|
||||
#define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio"
|
||||
|
||||
// per-window options
|
||||
#define WINOPTION_SCREEN "screen"
|
||||
@ -239,6 +243,10 @@ public:
|
||||
float screen_yiq_q() const { return float_value(WINOPTION_YIQ_QVALUE); }
|
||||
float screen_yiq_scan_time() const { return float_value(WINOPTION_YIQ_SCAN_TIME); }
|
||||
int screen_yiq_phase_count() const { return int_value(WINOPTION_YIQ_PHASE_COUNT); }
|
||||
float screen_vector_time_scale() const { return float_value(WINOPTION_VECTOR_TIME_SCALE); }
|
||||
float screen_vector_time_period() const { return float_value(WINOPTION_VECTOR_TIME_PERIOD); }
|
||||
float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); }
|
||||
float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); }
|
||||
const char *screen_offset() const { return value(WINOPTION_OFFSET); }
|
||||
const char *screen_scale() const { return value(WINOPTION_SCALE); }
|
||||
const char *screen_power() const { return value(WINOPTION_POWER); }
|
||||
|
Loading…
Reference in New Issue
Block a user