From d157249cb74fe849effaef21c1676a8cf17474e4 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Mon, 21 Jan 2013 02:40:48 +0000 Subject: [PATCH] d3dhlsl.c: Add preliminary vector post-processing. [MooglyGuy] --- .gitattributes | 2 + hlsl/bloom.fx | 242 ++++++++++ hlsl/downsample.fx | 121 +++++ hlsl/focus.fx | 4 - hlsl/phosphor.fx | 8 +- hlsl/post.fx | 1 + hlsl/primary.fx | 3 +- hlsl/vector.fx | 33 +- src/emu/inpttype.h | 2 +- src/emu/render.c | 4 +- src/osd/windows/d3dcomm.h | 2 + src/osd/windows/d3dhlsl.c | 948 ++++++++++++++++++++++++++++++-------- src/osd/windows/d3dhlsl.h | 43 +- src/osd/windows/drawd3d.c | 230 +++++++-- src/osd/windows/drawd3d.h | 13 +- src/osd/windows/winmain.c | 9 + src/osd/windows/winmain.h | 10 +- 17 files changed, 1394 insertions(+), 281 deletions(-) create mode 100644 hlsl/bloom.fx create mode 100644 hlsl/downsample.fx diff --git a/.gitattributes b/.gitattributes index 73e1aa6a58f..9eee004e3a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx new file mode 100644 index 00000000000..cf8b603cece --- /dev/null +++ b/hlsl/bloom.fx @@ -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 = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler1 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler2 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler3 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler4 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler5 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler6 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler7 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler8 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler9 = sampler_state +{ + Texture = ; + MipFilter = LINEAR; + MinFilter = LINEAR; + MagFilter = LINEAR; + AddressU = CLAMP; + AddressV = CLAMP; + AddressW = CLAMP; +}; + +sampler DiffuseSampler10 = sampler_state +{ + Texture = ; + 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] = ; // 2048x2048 + Sampler[1] = ; // 1024x1024 + Sampler[2] = ; // 512x512 + Sampler[3] = ; // 256x256 + Sampler[4] = ; // 128x128 + Sampler[5] = ; // 64x64 + Sampler[6] = ; // 32x32 + Sampler[7] = ; // 16x16 + Sampler[8] = ; // 8x8 + Sampler[9] = ; // 4x4 + Sampler[10] = ; // 2x2 + + VertexShader = compile vs_3_0 vs_main(); + PixelShader = compile ps_3_0 ps_main(); + } +} diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx new file mode 100644 index 00000000000..5e0de0ca46d --- /dev/null +++ b/hlsl/downsample.fx @@ -0,0 +1,121 @@ +//----------------------------------------------------------------------------- +// Effect File Variables +//----------------------------------------------------------------------------- + +texture Diffuse; + +sampler DiffuseSampler = sampler_state +{ + Texture = ; + 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] = ; + + VertexShader = compile vs_2_0 vs_main(); + PixelShader = compile ps_2_0 ps_main(); + } +} diff --git a/hlsl/focus.fx b/hlsl/focus.fx index de660af7d24..37079af55a2 100644 --- a/hlsl/focus.fx +++ b/hlsl/focus.fx @@ -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); diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx index 40d97cbf3ee..f6ba4573c49 100644 --- a/hlsl/phosphor.fx +++ b/hlsl/phosphor.fx @@ -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; diff --git a/hlsl/post.fx b/hlsl/post.fx index 94c039219e6..4176a78b197 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -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; } diff --git a/hlsl/primary.fx b/hlsl/primary.fx index b2f9d0f6826..53653cfba16 100644 --- a/hlsl/primary.fx +++ b/hlsl/primary.fx @@ -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)); } //----------------------------------------------------------------------------- diff --git a/hlsl/vector.fx b/hlsl/vector.fx index 066d7df1889..8b9aa6333f3 100644 --- a/hlsl/vector.fx +++ b/hlsl/vector.fx @@ -2,19 +2,6 @@ // Effect File Variables //----------------------------------------------------------------------------- -texture Diffuse; - -sampler DiffuseSampler = sampler_state -{ - Texture = ; - 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] = ; - VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h index 76c9d057a2f..7caa47334a8 100644 --- a/src/emu/inpttype.h +++ b/src/emu/inpttype.h @@ -621,7 +621,7 @@ void construct_core_types(simple_list &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)) ) diff --git a/src/emu/render.c b/src/emu/render.c index 52b0d6d9765..1f6c6578ee2 100644 --- a/src/emu/render.c +++ b/src/emu/render.c @@ -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); diff --git a/src/osd/windows/d3dcomm.h b/src/osd/windows/d3dcomm.h index 806e4aa7a17..2ac96074006 100644 --- a/src/osd/windows/d3dcomm.h +++ b/src/osd/windows/d3dcomm.h @@ -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 }; diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c index 7cbb665b093..14dc76b55cf 100644 --- a/src/osd/windows/d3dhlsl.c +++ b/src/osd/windows/d3dhlsl.c @@ -465,22 +465,6 @@ void hlsl_info::record_texture() } -//============================================================ -// hlsl_info::frame_complete -//============================================================ - -void hlsl_info::frame_complete() -{ - if (!master_enable || !d3dintf->post_fx_available) - return; - - if(render_snap && snap_rendered) - { - render_snapshot(snap_target); - } -} - - //============================================================ // hlsl_info::end_hlsl_avi_recording //============================================================ @@ -510,16 +494,20 @@ void hlsl_info::toggle() { delete_resources(false); } + master_enable = !master_enable; } else { if (!initialized) { - create_resources(false); + bool success = create_resources(false); + master_enable = (success ? !master_enable : false); + } + else + { + master_enable = !master_enable; } } - - master_enable = !master_enable; } //============================================================ @@ -740,7 +728,6 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window) snap_width = downcast(window->machine().options()).d3d_snap_width(); snap_height = downcast(window->machine().options()).d3d_snap_height(); - prescale_force_x = 0; prescale_force_y = 0; @@ -922,6 +909,18 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window) ini_file.gets(buf, 1024); sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count); + + ini_file.gets(buf, 1024); + sscanf(buf, "vector_time_scale %f\n", &options->vector_time_scale); + + ini_file.gets(buf, 1024); + sscanf(buf, "vector_time_period %f\n", &options->vector_time_period); + + ini_file.gets(buf, 1024); + sscanf(buf, "vector_length_scale %f\n", &options->vector_length_scale); + + ini_file.gets(buf, 1024); + sscanf(buf, "vector_length_ratio %f\n", &options->vector_length_ratio); } } } @@ -976,6 +975,10 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window) options->yiq_q = winoptions.screen_yiq_q(); options->yiq_scan_time = winoptions.screen_yiq_scan_time(); options->yiq_phase_count = winoptions.screen_yiq_phase_count(); + options->vector_time_scale = winoptions.screen_vector_time_scale(); + options->vector_time_period = winoptions.screen_vector_time_period(); + options->vector_length_scale = winoptions.screen_vector_length_scale(); + options->vector_length_ratio = winoptions.screen_vector_length_ratio(); } options->params_dirty = true; @@ -987,70 +990,76 @@ void hlsl_info::init(d3d_base *d3dintf, win_window_info *window) } + //============================================================ // hlsl_info::init_fsfx_quad //============================================================ void hlsl_info::init_fsfx_quad(void *vertbuf) { - if (!master_enable || !d3dintf->post_fx_available) - return; + // Called at the start of each frame by the D3D code in order to reserve two triangles + // that are guaranteed to be at a fixed position so as to simply use D3DPT_TRIANGLELIST, 0, 2 + // instead of having to do bookkeeping about a specific screen quad + if (!master_enable || !d3dintf->post_fx_available) + return; - d3d_info *d3d = (d3d_info *)window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; - // get a pointer to the vertex buffer - fsfx_vertices = (d3d_vertex *)vertbuf; - if (fsfx_vertices == NULL) - return; + // get a pointer to the vertex buffer + fsfx_vertices = (d3d_vertex *)vertbuf; + if (fsfx_vertices == NULL) + return; - // fill in the vertexes clockwise - fsfx_vertices[0].x = 0.0f; - fsfx_vertices[0].y = 0.0f; - fsfx_vertices[1].x = d3d->width; - fsfx_vertices[1].y = 0.0f; - fsfx_vertices[2].x = 0.0f; - fsfx_vertices[2].y = d3d->height; - fsfx_vertices[3].x = d3d->width; - fsfx_vertices[3].y = 0.0f; - fsfx_vertices[4].x = 0.0f; - fsfx_vertices[4].y = d3d->height; - fsfx_vertices[5].x = d3d->width; - fsfx_vertices[5].y = d3d->height; + // fill in the vertexes clockwise + fsfx_vertices[0].x = 0.0f; + fsfx_vertices[0].y = 0.0f; + fsfx_vertices[1].x = d3d->width; + fsfx_vertices[1].y = 0.0f; + fsfx_vertices[2].x = 0.0f; + fsfx_vertices[2].y = d3d->height; + fsfx_vertices[3].x = d3d->width; + fsfx_vertices[3].y = 0.0f; + fsfx_vertices[4].x = 0.0f; + fsfx_vertices[4].y = d3d->height; + fsfx_vertices[5].x = d3d->width; + fsfx_vertices[5].y = d3d->height; - fsfx_vertices[0].u0 = 0.0f; - fsfx_vertices[0].v0 = 0.0f; + fsfx_vertices[0].u0 = 0.0f; + fsfx_vertices[0].v0 = 0.0f; - fsfx_vertices[1].u0 = 1.0f; - fsfx_vertices[1].v0 = 0.0f; + fsfx_vertices[1].u0 = 1.0f; + fsfx_vertices[1].v0 = 0.0f; - fsfx_vertices[2].u0 = 0.0f; - fsfx_vertices[2].v0 = 1.0f; + fsfx_vertices[2].u0 = 0.0f; + fsfx_vertices[2].v0 = 1.0f; - fsfx_vertices[3].u0 = 1.0f; - fsfx_vertices[3].v0 = 0.0f; + fsfx_vertices[3].u0 = 1.0f; + fsfx_vertices[3].v0 = 0.0f; - fsfx_vertices[4].u0 = 0.0f; - fsfx_vertices[4].v0 = 1.0f; + fsfx_vertices[4].u0 = 0.0f; + fsfx_vertices[4].v0 = 1.0f; - fsfx_vertices[5].u0 = 1.0f; - fsfx_vertices[5].v0 = 1.0f; + fsfx_vertices[5].u0 = 1.0f; + fsfx_vertices[5].v0 = 1.0f; - // set the color, Z parameters to standard values - for (int i = 0; i < 6; i++) - { - fsfx_vertices[i].z = 0.0f; - fsfx_vertices[i].rhw = 1.0f; - fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255); - } + // set the color, Z parameters to standard values + for (int i = 0; i < 6; i++) + { + fsfx_vertices[i].z = 0.0f; + fsfx_vertices[i].rhw = 1.0f; + fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255); + } } + //============================================================ // hlsl_info::create_resources //============================================================ int hlsl_info::create_resources(bool reset) { + printf("create_resources enter\n"); fflush(stdout); initialized = true; if (!master_enable || !d3dintf->post_fx_available) @@ -1058,7 +1067,24 @@ int hlsl_info::create_resources(bool reset) d3d_info *d3d = (d3d_info *)window->drawdata; - HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture); + HRESULT result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result); + + result = (*d3dintf->device.create_texture)(d3d->device, 4, 4, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &black_texture); + if (result != D3D_OK) + { + mame_printf_verbose("Direct3D: Unable to init video-memory target for black texture (%08x)\n", (UINT32)result); + return 1; + } + (*d3dintf->texture.get_surface_level)(black_texture, 0, &black_surface); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, black_surface); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + 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); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture); if (result != D3D_OK) { mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result); @@ -1091,6 +1117,8 @@ int hlsl_info::create_resources(bool reset) shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); } + printf("load shaders enter\n"); fflush(stdout); + const char *fx_dir = downcast(window->machine().options()).screen_post_fx_dir(); // Replace all this garbage with a proper data-driven system @@ -1216,9 +1244,35 @@ int hlsl_info::create_resources(bool reset) // create the vector shader #if HLSL_VECTOR - char vector_cstr[1024]; - sprintf(vector_cstr, "%s\\vector.fx", fx_dir); - TCHAR *vector_name = tstring_from_utf8(vector_cstr); + char bloom_cstr[1024]; + sprintf(bloom_cstr, "%s\\bloom.fx", fx_dir); + TCHAR *bloom_name = tstring_from_utf8(bloom_cstr); + + result = (*d3dintf->device.create_effect)(d3d->device, bloom_name, &bloom_effect); + if(result != D3D_OK) + { + mame_printf_verbose("Direct3D: Unable to load bloom.fx\n"); + return 1; + } + if (bloom_name) + osd_free(bloom_name); + + char downsample_cstr[1024]; + sprintf(downsample_cstr, "%s\\downsample.fx", fx_dir); + TCHAR *downsample_name = tstring_from_utf8(downsample_cstr); + + result = (*d3dintf->device.create_effect)(d3d->device, downsample_name, &downsample_effect); + if(result != D3D_OK) + { + mame_printf_verbose("Direct3D: Unable to load downsample.fx\n"); + return 1; + } + if (downsample_name) + osd_free(downsample_name); + + char vector_cstr[1024]; + sprintf(vector_cstr, "%s\\vector.fx", fx_dir); + TCHAR *vector_name = tstring_from_utf8(vector_cstr); result = (*d3dintf->device.create_effect)(d3d->device, vector_name, &vector_effect); if(result != D3D_OK) @@ -1251,15 +1305,17 @@ int hlsl_info::create_resources(bool reset) if (yiq_decode_name) osd_free(yiq_decode_name); + printf("load shaders exit\n"); fflush(stdout); + return 0; } //============================================================ -// hlsl_info::begin +// hlsl_info::begin_draw //============================================================ -void hlsl_info::begin() +void hlsl_info::begin_draw() { if (!master_enable || !d3dintf->post_fx_available) return; @@ -1283,6 +1339,172 @@ void hlsl_info::begin() } +//============================================================ +// hlsl_info::begin_frame +//============================================================ + +void hlsl_info::begin_frame() +{ + record_texture(); + + /*d3d_info *d3d = (d3d_info *)window->drawdata; + + d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (rt == NULL) + { + return; + } + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + 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); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/ +} + + +//============================================================ +// hlsl_info::blit +//============================================================ + +void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type, + UINT32 prim_index, UINT32 prim_count, int dstw, int dsth) +{ + d3d_info *d3d = (d3d_info *)window->drawdata; + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + curr_effect = effect; + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src); + + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)dstw); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)dsth); + (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f); + (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion); + (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f); + + unsigned int num_passes = 0; + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + if (new_dst) + { + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + } +} + + + +//============================================================ +// hlsl_info::blit +//============================================================ + +void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type, + UINT32 prim_index, UINT32 prim_count) +{ + d3d_info *d3d = (d3d_info *)window->drawdata; + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + curr_effect = effect; + + d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (rt == NULL) + { + return; + } + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src); + + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + (*d3dintf->effect.set_float)(curr_effect, "ScreenWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "ScreenHeight", (float)d3d->height); + (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f); + (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion); + (*d3dintf->effect.set_float)(curr_effect, "Brighten", 1.0f); + + unsigned int num_passes = 0; + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f); + + if (new_dst) + { + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + } +} + +//============================================================ +// hlsl_info::end_frame +//============================================================ + +void hlsl_info::end_frame() +{ + if (!master_enable || !d3dintf->post_fx_available) + return; + + if(render_snap && snap_rendered) + { + render_snapshot(snap_target); + } + + if (!lines_pending) + return; + + lines_pending = false; + /*d3d_info *d3d = (d3d_info *)window->drawdata; + + d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (!rt) + return; + + blit(backbuffer, rt->texture[0], NULL, vecbuf_type, vecbuf_index, vecbuf_count);*/ + + /*d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (rt == NULL) + { + return; + } + + blit(backbuffer, rt->texture[1], NULL, vecbuf_type, vecbuf_index, vecbuf_count); + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + 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); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/ +} + + //============================================================ // hlsl_info::init_effect_info //============================================================ @@ -1313,8 +1535,6 @@ void hlsl_info::init_effect_info(d3d_poly_info *poly) (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight); (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart)); (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart)); - (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); - (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); (*d3dintf->effect.set_vector)(curr_effect, "Floor", 3, options->floor); (*d3dintf->effect.set_float)(curr_effect, "SnapX", snap_width); (*d3dintf->effect.set_float)(curr_effect, "SnapY", snap_height); @@ -1414,16 +1634,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) UINT num_passes = 0; d3d_info *d3d = (d3d_info *)window->drawdata; -#if HLSL_VECTOR - if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable) - { - lines_pending = true; - } - else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable) - { - } -#endif - if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL) { d3d_render_target *rt = find_render_target(poly->texture); @@ -1644,12 +1854,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); - (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth); - (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight); - (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f); - (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f); (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]); - (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f); (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); @@ -1675,12 +1880,7 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); - (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth); - (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight); - (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f); - (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f); - (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]); - (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f); + (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[1]); (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); @@ -1708,10 +1908,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) { (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); - (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth); - (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight); - (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart)); - (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart)); (*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor); } (*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)rt->target_width); @@ -1764,11 +1960,13 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) (*d3dintf->effect.end)(curr_effect); + curr_effect = post_effect; + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + /* Scanlines and shadow mask, at high res for AVI logging*/ if(avi_output_file != NULL) { - curr_effect = post_effect; - (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]); result = (*d3dintf->device.set_render_target)(d3d->device, 0, avi_final_target); @@ -1790,8 +1988,6 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) if(render_snap) { - curr_effect = post_effect; - (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]); result = (*d3dintf->device.set_render_target)(d3d->device, 0, snap_target); @@ -1813,26 +2009,157 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) snap_rendered = true; } - /* Scanlines and shadow mask */ - curr_effect = post_effect; + /* Scanlines and shadow mask */ + curr_effect = post_effect; - (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]); + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]); - result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); - if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)rt->target_width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)rt->target_height); - (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); +#if HLSL_VECTOR + result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]); +#else + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); +#endif + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); - for (UINT pass = 0; pass < num_passes; pass++) - { - (*d3dintf->effect.begin_pass)(curr_effect, pass); - // add the primitives - result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count); - if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); - (*d3dintf->effect.end_pass)(curr_effect); - } + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); - (*d3dintf->effect.end)(curr_effect); + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + +#if HLSL_VECTOR + /* Bloom */ + curr_effect = downsample_effect; + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]); + + int bloom_size = (rt->target_width < rt->target_height) ? rt->target_width : rt->target_height; + int bloom_index = 0; + int bloom_width = rt->target_width; + int bloom_height = rt->target_height; + for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1) + { + float source_size[2] = { bloom_width, bloom_height }; + float target_size[2] = { bloom_width >> 1, bloom_height >> 1 }; + (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size); + (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size); + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[1] : ct->bloom_texture[bloom_index - 1]); + + if (ct->bloom_target[bloom_index] == NULL) + { + (*d3dintf->effect.end)(curr_effect); + break; + } + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, ct->bloom_target[bloom_index]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7:%d\n", (int)result, bloom_size); + //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); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + bloom_index++; + bloom_width >>= 1; + bloom_height >>= 1; + } + + /* Bloom composite pass*/ + curr_effect = bloom_effect; + + float target_size[2] = { rt->target_width, rt->target_height }; + (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size); + + (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[1]); + (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f); + + char name[9] = "Diffuse*"; + char scale[14] = "DiffuseScale*"; + for(int index = 1; index < bloom_index; index++) + { + name[7] = 'A' + index; + scale[12] = 'A' + index; + (*d3dintf->effect.set_texture)(curr_effect, name, ct->bloom_texture[index - 1]); + (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f); + } + for(int index = bloom_index; index < 11; index++) + { + name[7] = 'A' + index; + scale[12] = 'A' + index; + (*d3dintf->effect.set_texture)(curr_effect, name, black_texture); + (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f); + } + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[2]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 8\n", (int)result); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + curr_effect = effect; + + //(*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f); + + //blit(backbuffer, ct->last_texture, NULL, poly->type, vertnum, poly->count, d3d->width, d3d->height); + + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 9\n", (int)result); + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[2]); + + (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f); + (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f); + (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f); + (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f); + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f); + (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion); + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); +#endif poly->texture->cur_frame++; poly->texture->cur_frame %= options->yiq_phase_count; @@ -1840,16 +2167,210 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) options->params_dirty = false; } #if HLSL_VECTOR - else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable) - { - } + else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable) + { + d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (rt == NULL) + { + return; + } + + lines_pending = true; + + curr_effect = vector_effect; + //curr_effect = effect; + + if(options->params_dirty) + { + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + } + + float time_params[2] = { poly->line_time, options->vector_time_scale }; + float length_params[3] = { poly->line_length, options->vector_length_scale, options->vector_length_ratio }; + (*d3dintf->effect.set_vector)(curr_effect, "TimeParams", 2, time_params); + (*d3dintf->effect.set_vector)(curr_effect, "LengthParams", 3, length_params); + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + curr_effect = effect; + + (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f); + } + else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable) + { + //if (!lines_pending) + //return; + //lines_pending = false; + + d3d_info *d3d = (d3d_info *)window->drawdata; + + d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0); + if (rt == NULL) + { + return; + } + + /* Bloom */ + curr_effect = downsample_effect; + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]); + + int bloom_size = (d3d->width < d3d->height) ? d3d->width : d3d->height; + int bloom_index = 0; + int bloom_width = d3d->width; + int bloom_height = d3d->height; + for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1) + { + float source_size[2] = { bloom_width, bloom_height }; + float target_size[2] = { bloom_width >> 1, bloom_height >> 1 }; + (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size); + (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size); + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[0] : rt->bloom_texture[bloom_index - 1]); + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->bloom_target[bloom_index]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result); + //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); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + bloom_index++; + bloom_width >>= 1; + bloom_height >>= 1; + } + + /* Bloom composite pass*/ + curr_effect = bloom_effect; + + float target_size[2] = { d3d->width, d3d->height }; + (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size); + + (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[0]); + (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f); + + char name[9] = "Diffuse*"; + char scale[14] = "DiffuseScale*"; + for(int index = 1; index < bloom_index; index++) + { + name[7] = 'A' + index; + scale[12] = 'A' + index; + (*d3dintf->effect.set_texture)(curr_effect, name, rt->bloom_texture[index - 1]); + (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f); + } + for(int index = bloom_index; index < 11; index++) + { + name[7] = 'A' + index; + scale[12] = 'A' + index; + (*d3dintf->effect.set_texture)(curr_effect, name, black_texture); + (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f); + } + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result); + //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); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + /* Phosphor */ + curr_effect = phosphor_effect; + + if(options->params_dirty) + { + (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + (*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor); + } + (*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)d3d->width); + (*d3dintf->effect.set_float)(curr_effect, "TextureHeight", (float)d3d->height); + (*d3dintf->effect.set_float)(curr_effect, "Passthrough", 0.0f); + + (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]); + (*d3dintf->effect.set_texture)(curr_effect, "LastPass", rt->texture[2]); + + result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result); + 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); + + (*d3dintf->effect.begin)(curr_effect, &num_passes, 0); + + for (UINT pass = 0; pass < num_passes; pass++) + { + (*d3dintf->effect.begin_pass)(curr_effect, pass); + // add the primitives + result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result); + (*d3dintf->effect.end_pass)(curr_effect); + } + + (*d3dintf->effect.end)(curr_effect); + + curr_effect = effect; + + //blit(backbuffer, rt->bloom_texture[5], NULL, poly->type, vertnum, poly->count); + blit(rt->target[2], rt->texture[0], NULL, poly->type, vertnum, poly->count); + blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count); + //blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count); + + result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + 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); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + + vecbuf_type = poly->type; + vecbuf_index = vertnum; + vecbuf_count = poly->count; + } #endif else { - (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f); - (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f); - (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f); - (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f); + (*d3dintf->effect.set_float)(curr_effect, "RawWidth", d3d->width);//poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f); + (*d3dintf->effect.set_float)(curr_effect, "RawHeight", d3d->height);//poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f); + (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f); + (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f); (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f); @@ -1873,10 +2394,10 @@ void hlsl_info::render_quad(d3d_poly_info *poly, int vertnum) //============================================================ -// hlsl_info::end +// hlsl_info::end_draw //============================================================ -void hlsl_info::end() +void hlsl_info::end_draw() { if (!master_enable || !d3dintf->post_fx_available) return; @@ -1902,75 +2423,7 @@ bool hlsl_info::add_cache_target(d3d_info* d3d, d3d_texture_info* info, int widt { d3d_cache_target* target = (d3d_cache_target*)global_alloc_clear(d3d_cache_target); - if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale)) - { - global_free(target); - return false; - } - - target->width = info->texinfo.width; - target->height = info->texinfo.height; - - target->next = cachehead; - target->prev = NULL; - - target->screen_index = screen_index; - - if (cachehead != NULL) - { - cachehead->prev = target; - } - cachehead = target; - - return true; -} - -d3d_render_target* hlsl_info::get_vector_target(d3d_info *d3d) -{ -#if HLSL_VECTOR - if (!vector_enable) - { - return false; - } - - return find_render_target(d3d->width, d3d->height, 0, 0); -#endif - return NULL; -} - -void hlsl_info::create_vector_target(d3d_info *d3d, render_primitive *prim) -{ -#if HLSL_VECTOR - if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1)) - { - vector_enable = false; - } -#endif -} - -//============================================================ -// hlsl_info::add_render_target - register a render target -//============================================================ - -bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale) -{ - UINT32 screen_index = 0; - UINT32 page_index = 0; - if (info != NULL) - { - if (find_render_target(info)) - { - remove_render_target(info); - } - - UINT32 screen_index_data = (UINT32)info->texinfo.osddata; - screen_index = screen_index_data >> 1; - page_index = screen_index_data & 1; - } - - d3d_render_target* target = (d3d_render_target*)global_alloc_clear(d3d_render_target); - - if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale)) + if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, true)) { global_free(target); return false; @@ -1987,6 +2440,101 @@ bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int wid target->height = d3d->height; } + target->next = cachehead; + target->prev = NULL; + + target->screen_index = screen_index; + + if (cachehead != NULL) + { + cachehead->prev = target; + } + cachehead = target; + + return true; +} + +d3d_render_target* hlsl_info::get_vector_target() +{ +#if HLSL_VECTOR + if (!vector_enable) + { + return false; + } + + d3d_info *d3d = (d3d_info *)window->drawdata; + + return find_render_target(d3d->width, d3d->height, 0, 0); +#endif + return NULL; +} + +void hlsl_info::create_vector_target(render_primitive *prim) +{ +#if HLSL_VECTOR + d3d_info *d3d = (d3d_info *)window->drawdata; + if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1, true)) + { + vector_enable = false; + } +#endif +} + +//============================================================ +// hlsl_info::add_render_target - register a render target +//============================================================ + +bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom) +{ + UINT32 screen_index = 0; + UINT32 page_index = 0; + if (info != NULL) + { + d3d_render_target *existing_target = find_render_target(info); + if (existing_target != NULL) + { + remove_render_target(existing_target); + } + + UINT32 screen_index_data = (UINT32)info->texinfo.osddata; + screen_index = screen_index_data >> 1; + page_index = screen_index_data & 1; + } + else + { + d3d_render_target *existing_target = find_render_target(d3d->width, d3d->height, 0, 0); + if (existing_target != NULL) + { + remove_render_target(existing_target); + } + } + + d3d_render_target* target = (d3d_render_target*)global_alloc_clear(d3d_render_target); + + if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, bloom)) + { + global_free(target); + return false; + } + + if (info != NULL) + { + target->width = info->texinfo.width; + target->height = info->texinfo.height; + } + else + { + target->width = d3d->width; + target->height = d3d->height; + } + + HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target->target[0]); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + 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); + result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer); + if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result); + target->screen_index = screen_index; target->page_index = page_index; @@ -2145,6 +2693,10 @@ void hlsl_info::delete_resources(bool reset) file.printf("yiq_q %f\n", options->yiq_q); file.printf("yiq_scan_time %f\n", options->yiq_scan_time); file.printf("yiq_phase_count %d\n", options->yiq_phase_count); + file.printf("vector_time_scale %f\n", options->vector_time_scale); + file.printf("vector_time_period %f\n", options->vector_time_period); + file.printf("vector_length_scale %f\n", options->vector_length_scale); + file.printf("vector_length_ratio %f\n", options->vector_length_ratio); } while (targethead != NULL) @@ -2152,6 +2704,18 @@ void hlsl_info::delete_resources(bool reset) remove_render_target(targethead); } +#if HLSL_VECTOR + if (downsample_effect != NULL) + { + (*d3dintf->effect.release)(downsample_effect); + downsample_effect = NULL; + } + if (bloom_effect != NULL) + { + (*d3dintf->effect.release)(bloom_effect); + bloom_effect = NULL; + } +#endif if (effect != NULL) { (*d3dintf->effect.release)(effect); @@ -2203,6 +2767,12 @@ void hlsl_info::delete_resources(bool reset) yiq_decode_effect = NULL; } + if (black_texture != NULL) + { + (*d3dintf->texture.release)(black_texture); + black_texture = NULL; + } + if (avi_copy_texture != NULL) { (*d3dintf->texture.release)(avi_copy_texture); diff --git a/src/osd/windows/d3dhlsl.h b/src/osd/windows/d3dhlsl.h index 52bad0062ad..7d508ddb2a1 100644 --- a/src/osd/windows/d3dhlsl.h +++ b/src/osd/windows/d3dhlsl.h @@ -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 diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 6d9572685a0..a8d4949cbd4 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -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(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; diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h index 0d1adff5f57..7cca9fee099 100644 --- a/src/osd/windows/drawd3d.h +++ b/src/osd/windows/drawd3d.h @@ -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 */ diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 1d84d659c77..58e0232ca07 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -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" }, diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index a935d8c9c6a..167ca9ec476 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -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); }