HLSL Updates: [Ryan Holtz, Bat Country Entertainment, austere, SoltanGris42]

- Added the ability to render screenshots at arbitrary resolutions.
- Added the ability to record AVI videos (albeit with no audio) at arbitrary resolutions.
- Added a 43-tap-wide FIR-based NTSC filter with tunable Y, I and Q frequency response.
- Updated scanlines to have a user-tunable pixel-height ratio in addition to the current screen-height ratio.
- Fixed a VRAM leak that was causing many dynamic-resolution drivers to run out of memory mid-run.
This commit is contained in:
Ryan Holtz 2011-05-30 21:10:23 +00:00
parent e532e74a8a
commit 796e691522
19 changed files with 1504 additions and 348 deletions

1
.gitattributes vendored
View File

@ -16,6 +16,7 @@ hlsl/focus.fx svneol=native#text/plain
hlsl/phosphor.fx svneol=native#text/plain
hlsl/pincushion.fx svneol=native#text/plain
hlsl/post.fx svneol=native#text/plain
hlsl/prescale.fx svneol=native#text/plain
hlsl/primary.fx svneol=native#text/plain
hlsl/yiq_decode.fx svneol=native#text/plain
hlsl/yiq_encode.fx svneol=native#text/plain

View File

@ -98,6 +98,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.BluCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + BluRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
Output.TexCoord = TexCoord;
return Output;
}
@ -124,9 +125,13 @@ float4 ps_main(PS_INPUT Input) : COLOR
GrnCoord.y = GrnCoord.y - frac(GrnCoord.y);
BluCoord.y = BluCoord.y - frac(BluCoord.y);
float RedTexel = tex2D(DiffuseSampler, lerp(TexCoord, RedCoord, Deconverge) / RawDims + 0.5f / RawDims).r;
float GrnTexel = tex2D(DiffuseSampler, lerp(TexCoord, GrnCoord, Deconverge) / RawDims + 0.5f / RawDims).g;
float BluTexel = tex2D(DiffuseSampler, lerp(TexCoord, BluCoord, Deconverge) / RawDims + 0.5f / RawDims).b;
RedCoord = lerp(TexCoord, RedCoord, Deconverge) / RawDims;
GrnCoord = lerp(TexCoord, GrnCoord, Deconverge) / RawDims;
BluCoord = lerp(TexCoord, BluCoord, Deconverge) / RawDims;
float RedTexel = tex2D(DiffuseSampler, RedCoord + float2(0.0f, 0.5f) / RawDims).r;
float GrnTexel = tex2D(DiffuseSampler, GrnCoord + float2(0.0f, 0.5f) / RawDims).g;
float BluTexel = tex2D(DiffuseSampler, BluCoord + float2(0.0f, 0.5f) / RawDims).b;
//RedTexel *= Input.RedCoord.x < (WidthRatio / RawWidth) ? 0.0f : 1.0f;
//RedTexel *= Input.RedCoord.y < (HeightRatio / RawHeight) ? 0.0f : 1.0f;

View File

@ -99,6 +99,7 @@ uniform float ScanlineScale = 1.0f;
uniform float ScanlineBrightScale = 1.0f;
uniform float ScanlineBrightOffset = 1.0f;
uniform float ScanlineOffset = 1.0f;
uniform float ScanlineHeight = 0.5f;
uniform float UseShadow = 0.0f;
uniform float ShadowBrightness = 1.0f;
@ -155,8 +156,8 @@ float4 ps_main(PS_INPUT Input) : COLOR
// -- Scanline Simulation --
float InnerSine = BaseCoord.y * RawHeight * ScanlineScale;
float3 ScanBrightness = lerp(1.0f, abs(sin(InnerSine * PI + ScanlineOffset * RawHeight)) * ScanlineBrightScale + 1.0f, ScanlineAmount);
//float3 Scanned = BaseTexel.rgb * ScanBrightness;
float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * RawHeight);
float3 ScanBrightness = lerp(1.0f, pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f, ScanlineAmount);
float3 Scanned = BaseTexel.rgb * ScanBrightness;
float2 ShadowDims = float2(ShadowWidth, ShadowHeight);
@ -164,7 +165,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 ShadowMaskSize = float2(ShadowMaskSizeX, ShadowMaskSizeY);
float2 ShadowFrac = frac(BaseCoord * ShadowMaskSize * 0.5f);
float2 ShadowCoord = ShadowFrac * ShadowUV + float2(1.5f / ShadowWidth, 1.5f / ShadowHeight);
float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord), UseShadow);
float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord).rgb, UseShadow);
// -- Final Pixel --
float4 Output = float4(Scanned * lerp(1.0f, ShadowTexel, ShadowBrightness), BaseTexel.a) * Input.Color;

90
hlsl/prescale.fx Normal file
View File

@ -0,0 +1,90 @@
//-----------------------------------------------------------------------------
// Passthrough Effect
//-----------------------------------------------------------------------------
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;
float2 TexCoord : TEXCOORD0;
};
struct VS_INPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 TexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float2 TexCoord : TEXCOORD0;
};
//-----------------------------------------------------------------------------
// Passthrough Vertex Shader
//-----------------------------------------------------------------------------
float TargetWidth;
float TargetHeight;
float RawWidth;
float RawHeight;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.x /= TargetWidth;
Output.Position.y /= TargetHeight;
Output.Position.y = 1.0f - Output.Position.y;
Output.Position.x -= 0.5f;
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
Output.TexCoord = Input.TexCoord + 0.5f / float2(RawWidth, RawHeight);
return Output;
}
//-----------------------------------------------------------------------------
// Passthrough Pixel Shader
//-----------------------------------------------------------------------------
float4 ps_main(PS_INPUT Input) : COLOR
{
float4 Center = tex2D(DiffuseSampler, Input.TexCoord);
return Center;
}
//-----------------------------------------------------------------------------
// Passthrough Effect
//-----------------------------------------------------------------------------
technique DeconvergeTechnique
{
pass Pass0
{
Lighting = FALSE;
VertexShader = compile vs_3_0 vs_main();
PixelShader = compile ps_3_0 ps_main();
}
}

View File

@ -20,9 +20,9 @@ texture Diffuse;
sampler DiffuseSampler = sampler_state
{
Texture = <Diffuse>;
MipFilter = POINT;
MinFilter = POINT;
MagFilter = POINT;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
@ -35,15 +35,7 @@ sampler DiffuseSampler = sampler_state
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float4 Coord0 : TEXCOORD0;
float4 Coord1 : TEXCOORD1;
float4 Coord2 : TEXCOORD2;
float4 Coord3 : TEXCOORD3;
float4 Coord4 : TEXCOORD4;
float4 Coord5 : TEXCOORD5;
float4 Coord6 : TEXCOORD6;
float4 Coord7 : TEXCOORD7;
};
struct VS_INPUT
@ -55,15 +47,7 @@ struct VS_INPUT
struct PS_INPUT
{
float4 Color : COLOR0;
float4 Coord0 : TEXCOORD0;
float4 Coord1 : TEXCOORD1;
float4 Coord2 : TEXCOORD2;
float4 Coord3 : TEXCOORD3;
float4 Coord4 : TEXCOORD4;
float4 Coord5 : TEXCOORD5;
float4 Coord6 : TEXCOORD6;
float4 Coord7 : TEXCOORD7;
};
//-----------------------------------------------------------------------------
@ -79,8 +63,6 @@ uniform float RawHeight;
uniform float WidthRatio;
uniform float HeightRatio;
uniform float FscValue;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
@ -88,25 +70,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.x /= TargetWidth;
Output.Position.y /= TargetHeight;
//Output.Position.x /= WidthRatio;
//Output.Position.y /= HeightRatio;
Output.Position.y = 1.0f - Output.Position.y;
Output.Position.x -= 0.5f;
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
Output.Color = Input.Color;
Output.Coord0.xy = Input.TexCoord + float2(0.00f / RawWidth, 0.0f);
Output.Coord1.xy = Input.TexCoord + float2(0.25f / RawWidth, 0.0f);
Output.Coord2.xy = Input.TexCoord + float2(0.50f / RawWidth, 0.0f);
Output.Coord3.xy = Input.TexCoord + float2(0.75f / RawWidth, 0.0f);
Output.Coord4.xy = Input.TexCoord + float2(1.00f / RawWidth, 0.0f);
Output.Coord5.xy = Input.TexCoord + float2(1.25f / RawWidth, 0.0f);
Output.Coord6.xy = Input.TexCoord + float2(1.50f / RawWidth, 0.0f);
Output.Coord7.xy = Input.TexCoord + float2(1.75f / RawWidth, 0.0f);
Output.Coord0.zw = Input.TexCoord + float2(2.00f / RawWidth, 0.0f);
Output.Coord1.zw = Input.TexCoord + float2(2.25f / RawWidth, 0.0f);
Output.Coord2.zw = Input.TexCoord + float2(2.50f / RawWidth, 0.0f);
Output.Coord3.zw = Input.TexCoord + float2(2.75f / RawWidth, 0.0f);
Output.Coord0.xy = Input.TexCoord + 0.5f / float2(RawWidth, RawHeight);
Output.Coord0.zw = float2(1.0f / RawWidth, 0.0f);
return Output;
}
@ -115,95 +84,67 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// YIQ Decode Pixel Shader
//-----------------------------------------------------------------------------
uniform float YSubsampleLength = 3.0f;
uniform float ISubsampleLength = 3.0f;
uniform float QSubsampleLength = 3.0f;
uniform float AValue = 0.0f;
uniform float BValue = 0.0f;
uniform float CCValue = 3.04183f;
uniform float PValue = 1.0f;
uniform float OValue = 0.0f;
uniform float ScanTime = 52.6f;
uniform float WValue;
uniform float AValue;
uniform float BValue;
uniform float YFreqResponse = 3.0f;
uniform float IFreqResponse = 1.2f;
uniform float QFreqResponse = 0.6f;
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 RawDims = float2(RawWidth, RawHeight);
float4 BaseTexel = tex2D(DiffuseSampler, Input.Coord0.xy + float2(0.5f, 0.5f) / RawDims);
float4 OrigC = tex2D(CompositeSampler, Input.Coord0.xy + float2(0.5f, 0.5f) / RawDims);
float4 OrigC2 = tex2D(CompositeSampler, Input.Coord4.xy + float2(0.5f, 0.5f) / RawDims);
float4 OrigC3 = tex2D(CompositeSampler, Input.Coord0.zw + float2(0.5f, 0.5f) / RawDims);
float4 C = OrigC;
float4 C2 = OrigC2;
float4 C3 = OrigC3;
float4 BaseTexel = tex2D(DiffuseSampler, Input.Coord0.xy + 0.5f / RawDims);
// YIQ convolution: N coefficients each
float4 YAccum = 0.0f;
float4 IAccum = 0.0f;
float4 QAccum = 0.0f;
float MaxC = 2.1183f;
float MinC = -1.1183f;
float CRange = MaxC - MinC;
C = C * CRange + MinC;
C2 = C2 * CRange + MinC;
float2 Coord0 = Input.Coord0.xy * RawDims;
float2 Coord1 = Input.Coord1.xy * RawDims;
float2 Coord2 = Input.Coord2.xy * RawDims;
float2 Coord3 = Input.Coord3.xy * RawDims;
float2 Coord4 = Input.Coord4.xy * RawDims;
float2 Coord5 = Input.Coord5.xy * RawDims;
float2 Coord6 = Input.Coord6.xy * RawDims;
float2 Coord7 = Input.Coord7.xy * RawDims;
float2 Coord8 = Input.Coord0.zw * RawDims;
float2 Coord9 = Input.Coord1.zw * RawDims;
float2 CoordA = Input.Coord2.zw * RawDims;
float2 CoordB = Input.Coord3.zw * RawDims;
float W = WValue * 2.0f;
float T0 = Coord0.x + AValue * Coord0.y + BValue;
float T1 = Coord1.x + AValue * Coord1.y + BValue;
float T2 = Coord2.x + AValue * Coord2.y + BValue;
float T3 = Coord3.x + AValue * Coord3.y + BValue;
float T4 = Coord4.x + AValue * Coord4.y + BValue;
float T5 = Coord5.x + AValue * Coord5.y + BValue;
float T6 = Coord6.x + AValue * Coord6.y + BValue;
float T7 = Coord7.x + AValue * Coord7.y + BValue;
float T8 = Coord8.x + AValue * Coord8.y + BValue;
float T9 = Coord9.x + AValue * Coord9.y + BValue;
float TA = CoordA.x + AValue * CoordA.y + BValue;
float TB = CoordB.x + AValue * CoordB.y + BValue;
float4 Tc = float4(T0, T1, T2, T3);
float4 Tc2 = float4(T4, T5, T6, T7);
float4 Tc3 = float4(T8, T9, TA, TB);
float Yvals[8];
Yvals[0] = C.r; Yvals[1] = C.g; Yvals[2] = C.b; Yvals[3] = C.a; Yvals[4] = C2.r; Yvals[5] = C2.g; Yvals[6] = C2.b; Yvals[7] = C2.a;
float Ytotal = 0.0f;
for(uint idx = 0; idx < FscValue * 4.0f; idx++ )
float Fc_y = YFreqResponse * ScanTime / (RawWidth * 4.0f / WidthRatio);
float Fc_i = IFreqResponse * ScanTime / (RawWidth * 4.0f / WidthRatio);
float Fc_q = QFreqResponse * ScanTime / (RawWidth * 4.0f / WidthRatio);
float PI = 3.1415926535897932384626433832795;
float PI2 = 2.0f * PI;
float PI2Length = PI2 / 42.0f;
for(float n = -21.0f; n < 22.0f; n += 4.0f)
{
Ytotal = Ytotal + Yvals[idx];
}
float Yavg = Ytotal / (FscValue * 4.0f);
float4 n4 = float4(n + 0.0f, n + 1.0f, n + 2.0f, n + 3.0f);
float4 CoordX = Input.Coord0.x + Input.Coord0.z * n4 * 0.25f;
float4 CoordY = Input.Coord0.y;
float4 C = tex2D(CompositeSampler, float2(CoordX.r, CoordY.r)) * CRange + MinC;
float4 WT = PI2 * CCValue * ScanTime * (CoordX * WidthRatio + AValue * CoordY * 2.0f * (RawHeight / HeightRatio) + BValue) + OValue;
float4 I = (C - Yavg) * sin(W * Tc);
float4 Q = (C - Yavg) * cos(W * Tc);
float4 I2 = (C2 - Yavg) * sin(W * Tc2);
float4 Q2 = (C2 - Yavg) * cos(W * Tc2);
float4 I3 = (C3 - Yavg) * sin(W * Tc3);
float4 Q3 = (C3 - Yavg) * cos(W * Tc3);
float Itotal = 0.0f;
float Qtotal = 0.0f;
float Ivals[8];
float Qvals[8];
Ivals[0] = I.r; Ivals[1] = I.g; Ivals[2] = I.b; Ivals[3] = I.a; Ivals[4] = I2.r; Ivals[5] = I2.g; Ivals[6] = I2.b; Ivals[7] = I2.a;
Qvals[0] = Q.r; Qvals[1] = Q.g; Qvals[2] = Q.b; Qvals[3] = Q.a; Qvals[4] = Q2.r; Qvals[5] = Q2.g; Qvals[6] = Q2.b; Qvals[7] = Q2.a;
for(uint idx = 0; idx < FscValue * 4.0f; idx++ )
{
Itotal = Itotal + Ivals[idx];
Qtotal = Qtotal + Qvals[idx];
float4 SincYIn = PI2 * Fc_y * n4;
float4 IdealY = 2.0f * Fc_y * ((SincYIn != 0.0f) ? (sin(SincYIn) / SincYIn) : 1.0f);
float4 FilterY = (0.54f + 0.46f * cos(PI2Length * n4)) * IdealY;
float4 SincIIn = PI2 * Fc_i * n4;
float4 IdealI = 2.0f * Fc_i * ((SincIIn != 0.0f) ? (sin(SincIIn) / SincIIn) : 1.0f);
float4 FilterI = (0.54f + 0.46f * cos(PI2Length * n4)) * IdealI;
float4 SincQIn = PI2 * Fc_q * n4;
float4 IdealQ = 2.0f * Fc_q * ((SincQIn != 0.0f) ? (sin(SincQIn) / SincQIn) : 1.0f);
float4 FilterQ = (0.54f + 0.46f * cos(PI2Length * n4)) * IdealQ;
YAccum = YAccum + C * FilterY;
IAccum = IAccum + C * cos(WT) * FilterI;
QAccum = QAccum + C * sin(WT) * FilterQ;
}
float Iavg = Itotal / (FscValue * 3.0f);
float Qavg = Qtotal / (FscValue * 3.0f);
float3 YIQ = float3(Yavg, Iavg * 1.5f, Qavg);
float Y = YAccum.r + YAccum.g + YAccum.b + YAccum.a;
float I = (IAccum.r + IAccum.g + IAccum.b + IAccum.a) * 2.0f;
float Q = (QAccum.r + QAccum.g + QAccum.b + QAccum.a) * 2.0f;
float3 YIQ = float3(Y, I, Q);
float3 OutRGB = float3(dot(YIQ, float3(1.0f, 0.956f, 0.621f)), dot(YIQ, float3(1.0f, -0.272f, -0.647f)), dot(YIQ, float3(1.0f, -1.106f, 1.703f)));
return float4(OutRGB, BaseTexel.a);

View File

@ -82,35 +82,32 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// YIQ Encode Pixel Shader
//-----------------------------------------------------------------------------
uniform float YSubsampleLength = 3.0f;
uniform float ISubsampleLength = 3.0f;
uniform float QSubsampleLength = 3.0f;
uniform float WValue;
uniform float AValue;
uniform float BValue;
uniform float FscScale;
uniform float AValue = 0.0f;
uniform float BValue = 0.0f;
uniform float CCValue = 3.04183f;
uniform float PValue = 1.0f;
uniform float ScanTime = 52.6f;
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 Scaler = float2(RawWidth, RawHeight);
float2 InvRatios = float2(1.0f / WidthRatio, 1.0f / HeightRatio);
float3 Texel0 = tex2D(DiffuseSampler, Input.Coord0 + float2(FscScale * 0.00f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel1 = tex2D(DiffuseSampler, Input.Coord1 + float2(FscScale * 0.25f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel2 = tex2D(DiffuseSampler, Input.Coord2 + float2(FscScale * 0.50f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel3 = tex2D(DiffuseSampler, Input.Coord3 + float2(FscScale * 0.75f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel0 = tex2D(DiffuseSampler, Input.Coord0 + float2(PValue * 0.00f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel1 = tex2D(DiffuseSampler, Input.Coord1 + float2(PValue * 0.25f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel2 = tex2D(DiffuseSampler, Input.Coord2 + float2(PValue * 0.50f + 0.5f, 0.5f) / Scaler).rgb;
float3 Texel3 = tex2D(DiffuseSampler, Input.Coord3 + float2(PValue * 0.75f + 0.5f, 0.5f) / Scaler).rgb;
float2 Coord0 = (Input.Coord0.xy + float2(0.00f / RawWidth, 0.0f)) * Scaler;
float2 Coord1 = (Input.Coord1.xy + float2(0.25f / RawWidth, 0.0f)) * Scaler;
float2 Coord2 = (Input.Coord2.xy + float2(0.50f / RawWidth, 0.0f)) * Scaler;
float2 Coord3 = (Input.Coord3.xy + float2(0.75f / RawWidth, 0.0f)) * Scaler;
float2 Coord0 = (Input.Coord0.xy + float2(0.00f / RawWidth, 0.0f));
float2 Coord1 = (Input.Coord1.xy + float2(0.25f / RawWidth, 0.0f));
float2 Coord2 = (Input.Coord2.xy + float2(0.50f / RawWidth, 0.0f));
float2 Coord3 = (Input.Coord3.xy + float2(0.75f / RawWidth, 0.0f));
float W = WValue * 2.0f;
float T0 = Coord0.x + AValue * Coord0.y + BValue;
float T1 = Coord1.x + AValue * Coord1.y + BValue;
float T2 = Coord2.x + AValue * Coord2.y + BValue;
float T3 = Coord3.x + AValue * Coord3.y + BValue;
float PI = 3.1415926535897932384626433832795;
float W = PI * 2.0f * CCValue * ScanTime;
float T0 = Coord0.x * WidthRatio + AValue * Coord0.y * 2.0f * (RawHeight / HeightRatio) + BValue;
float T1 = Coord1.x * WidthRatio + AValue * Coord1.y * 2.0f * (RawHeight / HeightRatio) + BValue;
float T2 = Coord2.x * WidthRatio + AValue * Coord2.y * 2.0f * (RawHeight / HeightRatio) + BValue;
float T3 = Coord3.x * WidthRatio + AValue * Coord3.y * 2.0f * (RawHeight / HeightRatio) + BValue;
float Y0 = dot(Texel0, float3(0.299f, 0.587f, 0.114f));
float I0 = dot(Texel0, float3(0.595716f, -0.274453f, -0.321263f));
@ -132,10 +129,10 @@ float4 ps_main(PS_INPUT Input) : COLOR
float MinC = -1.1183f;
float CRange = MaxC - MinC;
float C0 = Y0 + I0 * sin(T0 * W) + Q0 * cos(T0 * W);
float C1 = Y1 + I1 * sin(T1 * W) + Q1 * cos(T1 * W);
float C2 = Y2 + I2 * sin(T2 * W) + Q2 * cos(T2 * W);
float C3 = Y3 + I3 * sin(T3 * W) + Q3 * cos(T3 * W);
float C0 = Y0 + I0 * cos(T0 * W) + Q0 * sin(T0 * W);
float C1 = Y1 + I1 * cos(T1 * W) + Q1 * sin(T1 * W);
float C2 = Y2 + I2 * cos(T2 * W) + Q2 * sin(T2 * W);
float C3 = Y3 + I3 * cos(T3 * W) + Q3 * sin(T3 * W);
C0 = (C0 - MinC) / CRange;
C1 = (C1 - MinC) / CRange;
C2 = (C2 - MinC) / CRange;

View File

@ -360,6 +360,13 @@ static HRESULT d3d_device_get_render_target(d3d_device *dev, DWORD index, d3d_su
}
static HRESULT d3d_device_get_render_target_data(d3d_device *dev, d3d_surface *rendertarget, d3d_surface *destsurface)
{
assert(false);
return D3D_OK;
}
static HRESULT d3d_device_present(d3d_device *dev, const RECT *source, const RECT *dest, HWND override, RGNDATA *dirty, DWORD flags)
{
IDirect3DDevice8 *device = (IDirect3DDevice8 *)dev;
@ -470,6 +477,7 @@ static const d3d_device_interface d3d8_device_interface =
d3d_device_end_scene,
d3d_device_get_raster_status,
d3d_device_get_render_target,
d3d_device_get_render_target_data,
d3d_device_present,
d3d_device_release,
d3d_device_reset,

View File

@ -398,6 +398,13 @@ static HRESULT d3d_device_get_render_target(d3d_device *dev, DWORD index, d3d_su
}
static HRESULT d3d_device_get_render_target_data(d3d_device *dev, d3d_surface *rendertarget, d3d_surface *destsurface)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
return IDirect3DDevice9_GetRenderTargetData(device, (IDirect3DSurface9 *)rendertarget, (IDirect3DSurface9 *)destsurface);
}
static HRESULT d3d_device_present(d3d_device *dev, const RECT *source, const RECT *dest, HWND override, RGNDATA *dirty, DWORD flags)
{
IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev;
@ -544,6 +551,7 @@ static const d3d_device_interface d3d9_device_interface =
d3d_device_end_scene,
d3d_device_get_raster_status,
d3d_device_get_render_target,
d3d_device_get_render_target_data,
d3d_device_present,
d3d_device_release,
d3d_device_reset,

View File

@ -190,6 +190,7 @@ struct _d3d_device_interface
HRESULT (*end_scene)(d3d_device *dev);
HRESULT (*get_raster_status)(d3d_device *dev, D3DRASTER_STATUS *status);
HRESULT (*get_render_target)(d3d_device *dev, DWORD index, d3d_surface **surface);
HRESULT (*get_render_target_data)(d3d_device *dev, d3d_surface *rendertarget, d3d_surface *destsurface);
HRESULT (*present)(d3d_device *dev, const RECT *source, const RECT *dest, HWND override, RGNDATA *dirty, DWORD flags);
ULONG (*release)(d3d_device *dev);
HRESULT (*reset)(d3d_device *dev, d3d_present_parameters *params);

File diff suppressed because it is too large Load Diff

View File

@ -251,6 +251,8 @@ int drawdd_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_init = drawdd_window_init;
callbacks->window_get_primitives = drawdd_window_get_primitives;
callbacks->window_draw = drawdd_window_draw;
callbacks->window_save = NULL;
callbacks->window_record = NULL;
callbacks->window_destroy = drawdd_window_destroy;
mame_printf_verbose("DirectDraw: Using DirectDraw 7\n");

View File

@ -94,6 +94,8 @@ int drawgdi_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_init = drawgdi_window_init;
callbacks->window_get_primitives = drawgdi_window_get_primitives;
callbacks->window_draw = drawgdi_window_draw;
callbacks->window_save = NULL;
callbacks->window_record = NULL;
callbacks->window_destroy = drawgdi_window_destroy;
return 0;
}

View File

@ -75,6 +75,8 @@ int drawnone_init(running_machine &machine, win_draw_callbacks *callbacks)
callbacks->window_init = drawnone_window_init;
callbacks->window_get_primitives = drawnone_window_get_primitives;
callbacks->window_draw = drawnone_window_draw;
callbacks->window_save = NULL;
callbacks->window_record = NULL;
callbacks->window_destroy = drawnone_window_destroy;
return 0;
}

View File

@ -781,6 +781,20 @@ void windows_osd_interface::customize_input_type_list(simple_list<input_type_ent
entry->name = "Toggle Fullscreen";
entry->defseq[SEQ_TYPE_STANDARD].set(KEYCODE_LALT, KEYCODE_ENTER);
break;
// alt-F12 for fullscreen snap
case IPT_OSD_2:
entry->token = "RENDER_SNAP";
entry->name = "Take Rendered Snapshot";
entry->defseq[SEQ_TYPE_STANDARD].set(KEYCODE_LALT, KEYCODE_F12);
break;
// alt-F11 for fullscreen video
case IPT_OSD_3:
entry->token = "RENDER_AVI";
entry->name = "Record Rendered Video";
entry->defseq[SEQ_TYPE_STANDARD].set(KEYCODE_LALT, KEYCODE_F11);
break;
}
}

View File

@ -364,6 +364,14 @@ static void check_osd_inputs(running_machine &machine)
// check for toggling fullscreen mode
if (ui_input_pressed(machine, IPT_OSD_1))
winwindow_toggle_full_screen();
// check for taking fullscreen snap
if (ui_input_pressed(machine, IPT_OSD_2))
winwindow_take_snap();
// check for taking fullscreen video
if (ui_input_pressed(machine, IPT_OSD_3))
winwindow_take_video();
}

View File

@ -498,6 +498,52 @@ void winwindow_dispatch_message(running_machine &machine, MSG *message)
//============================================================
// winwindow_take_snap
// (main thread)
//============================================================
void winwindow_take_snap(void)
{
if (draw.window_record == NULL)
return;
win_window_info *window;
assert(GetCurrentThreadId() == main_threadid);
// iterate over windows and request a snap
for (window = win_window_list; window != NULL; window = window->next)
{
(*draw.window_save)(window);
}
}
//============================================================
// winwindow_take_video
// (main thread)
//============================================================
void winwindow_take_video(void)
{
if (draw.window_record == NULL)
return;
win_window_info *window;
assert(GetCurrentThreadId() == main_threadid);
// iterate over windows and request a snap
for (window = win_window_list; window != NULL; window = window->next)
{
(*draw.window_record)(window);
}
}
//============================================================
// winwindow_toggle_full_screen
// (main thread)

View File

@ -122,6 +122,8 @@ struct _win_draw_callbacks
int (*window_init)(win_window_info *window);
render_primitive_list *(*window_get_primitives)(win_window_info *window);
int (*window_draw)(win_window_info *window, HDC dc, int update);
void (*window_save)(win_window_info *window);
void (*window_record)(win_window_info *window);
void (*window_destroy)(win_window_info *window);
};
@ -155,6 +157,8 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar
extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
void winwindow_toggle_full_screen(void);
void winwindow_take_snap(void);
void winwindow_take_video(void);
void winwindow_process_events_periodic(running_machine &machine);
void winwindow_process_events(running_machine &machine, int ingame);

View File

@ -328,9 +328,15 @@ const options_entry windows_options::s_option_entries[] =
// post-processing options
{ NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
{ WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
{ WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" },
{ WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" },
{ WINOPTION_HLSL_PRESCALE";hlsl_prescale", "0", OPTION_BOOLEAN, "enable HLSL scaling pre-pass (for 'x' filters)" },
{ WINOPTION_HLSL_PRESCALE_SIZE, "2", OPTION_INTEGER, "HLSL scaling pre-pass factor (usually 2 or 3)" },
{ WINOPTION_HLSL_PRESET";(-1-5)", "-1", OPTION_INTEGER, "HLSL preset to use (0-5)" },
{ WINOPTION_HLSL_WRITE, NULL, OPTION_STRING, "enable HLSL AVI writing (huge disk bandwidth suggested)" },
{ WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" },
{ WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" },
{ WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
{ WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)", "aperture.png", OPTION_STRING, "shadow mask texture name" },
{ WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww", "640", OPTION_INTEGER, "shadow mask width, in phosphor dots" },
{ WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh", "480", OPTION_INTEGER, "shadow mask height, in phosphor dots" },
@ -345,6 +351,7 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_PINCUSHION";fs_pin(0.0-4.0)", "0.0", OPTION_FLOAT, "pincushion amount" },
{ WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" },
{ WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" },
{ WINOPTION_SCANLINE_HEIGHT";fs_scanh(0.0-4.0)", "0.5", OPTION_FLOAT, "individual height scaling value for scanlines" },
{ WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" },
{ WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.6", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" },
{ WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" },
@ -396,12 +403,16 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_BLUE_PHOSPHOR";fs_grnpho(0.0-1.0)", "0.0", OPTION_FLOAT, "blue phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
/* NTSC simulation below this line */
{ WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable YIQ-space HLSL post-processing" },
{ WINOPTION_YIQ_WVALUE";yiqw", "4.1187867", OPTION_FLOAT, "W value for YIQ signal processing" },
{ WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for YIQ signal processing" },
{ WINOPTION_YIQ_BVALUE";yiqb", "0.5", OPTION_FLOAT, "B value for YIQ signal processing" },
{ WINOPTION_YIQ_FSCVALUE";yiqfsc", "1.5", OPTION_FLOAT, "Fsc value for YIQ signal processing" },
{ WINOPTION_YIQ_FSCSCALE";yiqfscs", "1.0", OPTION_FLOAT, "Incoming Fsc scaling value for YIQ signal processing" },
{ WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for YIQ signal 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" },
{ WINOPTION_YIQ_BVALUE";yiqb", "0.5", OPTION_FLOAT, "B value for NTSC signal processing" },
{ WINOPTION_YIQ_OVALUE";yiqo", "0.0", OPTION_FLOAT, "Outgoing Color Carrier phase offset for NTSC signal processing" },
{ WINOPTION_YIQ_PVALUE";yiqp", "1.0", OPTION_FLOAT, "Incoming Pixel Clock scaling value for NTSC signal processing" },
{ WINOPTION_YIQ_YVALUE";yiqy", "3.0", OPTION_FLOAT, "Y filter cutoff frequency for NTSC signal processing" },
{ WINOPTION_YIQ_IVALUE";yiqi", "1.2", OPTION_FLOAT, "I filter cutoff frequency for NTSC signal processing" },
{ 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" },
// per-window options
{ NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" },

View File

@ -81,6 +81,12 @@
// core post-processing options
#define WINOPTION_HLSL_ENABLE "hlsl_enable"
#define WINOPTION_HLSLPATH "hlslpath"
#define WINOPTION_HLSL_PRESCALE "hlsl_prescale"
#define WINOPTION_HLSL_PRESCALE_SIZE "hlsl_prescale_size"
#define WINOPTION_HLSL_PRESET "hlsl_preset"
#define WINOPTION_HLSL_WRITE "hlsl_write"
#define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width"
#define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height"
#define WINOPTION_SHADOW_MASK_ALPHA "shadow_mask_alpha"
#define WINOPTION_SHADOW_MASK_TEXTURE "shadow_mask_texture"
#define WINOPTION_SHADOW_MASK_COUNT_X "shadow_mask_x_count"
@ -95,6 +101,7 @@
#define WINOPTION_OVERSAMPLE_Y "oversample_y"
#define WINOPTION_SCANLINE_AMOUNT "scanline_alpha"
#define WINOPTION_SCANLINE_SCALE "scanline_size"
#define WINOPTION_SCANLINE_HEIGHT "scanline_height"
#define WINOPTION_SCANLINE_BRIGHT_SCALE "scanline_bright_scale"
#define WINOPTION_SCANLINE_BRIGHT_OFFSET "scanline_bright_offset"
#define WINOPTION_SCANLINE_OFFSET "scanline_jitter"
@ -138,11 +145,15 @@
#define WINOPTION_BLUE_PHOSPHOR "blue_phosphor_life"
#define WINOPTION_SATURATION "saturation"
#define WINOPTION_YIQ_ENABLE "yiq_enable"
#define WINOPTION_YIQ_WVALUE "yiq_w"
#define WINOPTION_YIQ_CCVALUE "yiq_cc"
#define WINOPTION_YIQ_AVALUE "yiq_a"
#define WINOPTION_YIQ_BVALUE "yiq_b"
#define WINOPTION_YIQ_FSCVALUE "yiq_fsc"
#define WINOPTION_YIQ_FSCSCALE "yiq_fsc_scale"
#define WINOPTION_YIQ_OVALUE "yiq_o"
#define WINOPTION_YIQ_PVALUE "yiq_p"
#define WINOPTION_YIQ_YVALUE "yiq_y"
#define WINOPTION_YIQ_IVALUE "yiq_i"
#define WINOPTION_YIQ_QVALUE "yiq_q"
#define WINOPTION_YIQ_SCAN_TIME "yiq_scan_time"
#define WINOPTION_YIQ_PHASE_COUNT "yiq_phase_count"
// per-window options
@ -210,16 +221,23 @@ public:
// core post-processing options
const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); }
bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); }
const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); }
bool d3d_hlsl_prescale() const { return bool_value(WINOPTION_HLSL_PRESCALE); }
int d3d_hlsl_prescale_size() const { return int_value(WINOPTION_HLSL_PRESCALE_SIZE); }
int d3d_hlsl_preset() const { return int_value(WINOPTION_HLSL_PRESET); }
int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); }
int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); }
float screen_shadow_mask_alpha() const { return float_value(WINOPTION_SHADOW_MASK_ALPHA); }
const char *screen_shadow_mask_texture() const { return value(WINOPTION_SHADOW_MASK_TEXTURE); }
float screen_shadow_mask_count_x() const { return float_value(WINOPTION_SHADOW_MASK_COUNT_X); }
float screen_shadow_mask_count_y() const { return float_value(WINOPTION_SHADOW_MASK_COUNT_Y); }
int screen_shadow_mask_count_x() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_X); }
int screen_shadow_mask_count_y() const { return int_value(WINOPTION_SHADOW_MASK_COUNT_Y); }
float screen_shadow_mask_u_size() const { return float_value(WINOPTION_SHADOW_MASK_USIZE); }
float screen_shadow_mask_v_size() const { return float_value(WINOPTION_SHADOW_MASK_VSIZE); }
float screen_oversample_x() const { return float_value(WINOPTION_OVERSAMPLE_X); }
float screen_oversample_y() const { return float_value(WINOPTION_OVERSAMPLE_Y); }
float screen_scanline_amount() const { return float_value(WINOPTION_SCANLINE_AMOUNT); }
float screen_scanline_scale() const { return float_value(WINOPTION_SCANLINE_SCALE); }
float screen_scanline_height() const { return float_value(WINOPTION_SCANLINE_HEIGHT); }
float screen_scanline_bright_scale() const { return float_value(WINOPTION_SCANLINE_BRIGHT_SCALE); }
float screen_scanline_bright_offset() const { return float_value(WINOPTION_SCANLINE_BRIGHT_OFFSET); }
float screen_scanline_offset() const { return float_value(WINOPTION_SCANLINE_OFFSET); }
@ -251,11 +269,15 @@ public:
float screen_blue_from_green() const { return float_value(WINOPTION_BLUE_MATRIX_G); }
float screen_blue_from_blue() const { return float_value(WINOPTION_BLUE_MATRIX_B); }
bool screen_yiq_enable() const { return bool_value(WINOPTION_YIQ_ENABLE); }
float screen_yiq_w() const { return float_value(WINOPTION_YIQ_WVALUE); }
float screen_yiq_cc() const { return float_value(WINOPTION_YIQ_CCVALUE); }
float screen_yiq_a() const { return float_value(WINOPTION_YIQ_AVALUE); }
float screen_yiq_b() const { return float_value(WINOPTION_YIQ_BVALUE); }
float screen_yiq_fsc() const { return float_value(WINOPTION_YIQ_FSCVALUE); }
float screen_yiq_fsc_scale() const { return float_value(WINOPTION_YIQ_FSCSCALE); }
float screen_yiq_o() const { return float_value(WINOPTION_YIQ_OVALUE); }
float screen_yiq_p() const { return float_value(WINOPTION_YIQ_PVALUE); }
float screen_yiq_y() const { return float_value(WINOPTION_YIQ_YVALUE); }
float screen_yiq_i() const { return float_value(WINOPTION_YIQ_IVALUE); }
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_red_offset() const { return float_value(WINOPTION_RED_OFFSET); }
float screen_green_offset() const { return float_value(WINOPTION_GREEN_OFFSET); }