Previous 199869 Revisions Next

r20381 Monday 21st January, 2013 at 02:40:48 UTC by Ryan Holtz
d3dhlsl.c: Add preliminary vector post-processing. [MooglyGuy]
[hlsl]bloom.fx* downsample.fx* focus.fx phosphor.fx post.fx primary.fx vector.fx
[src/emu]inpttype.h render.c
[src/osd/windows]d3dcomm.h d3dhlsl.c d3dhlsl.h drawd3d.c drawd3d.h winmain.c winmain.h

trunk/hlsl/focus.fx
r20380r20381
6060uniform float TargetWidth;
6161uniform float TargetHeight;
6262
63uniform float WidthRatio;
64uniform float HeightRatio;
65
6663uniform float2 Defocus = float2(0.0f, 0.0f);
67uniform float FocusEnable;
6864
6965float2 Coord0Offset = float2( 0.0f,  0.0f);
7066float2 Coord1Offset = float2(-0.2f, -0.6f);
trunk/hlsl/phosphor.fx
r20380r20381
6161uniform float TargetWidth;
6262uniform float TargetHeight;
6363
64uniform float RawWidth;
65uniform float RawHeight;
66
67uniform float WidthRatio;
68uniform float HeightRatio;
69
7064uniform float TextureWidth;
7165uniform float TextureHeight;
7266
r20380r20381
8680   Output.Color = Input.Color;
8781   
8882   float2 InvTexSize = float2(1.0f / TextureWidth, 1.0f / TextureHeight);
89   Output.TexCoord = Input.TexCoord + float2(0.5f, 0.5f) * InvTexSize;
83   Output.TexCoord = Input.TexCoord + float2(1.0f, 1.0f) * InvTexSize;
9084   Output.PrevCoord = Output.TexCoord;
9185   
9286   return Output;
trunk/hlsl/vector.fx
r20380r20381
22// Effect File Variables
33//-----------------------------------------------------------------------------
44
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
185//-----------------------------------------------------------------------------
196// Vertex Definitions
207//-----------------------------------------------------------------------------
r20380r20381
4532
4633uniform float TargetWidth;
4734uniform float TargetHeight;
35uniform float2 TimeParams;
36uniform float3 LengthParams;
4837
4938VS_OUTPUT vs_main(VS_INPUT Input)
5039{
r20380r20381
5746   Output.Position.x -= 0.5f;
5847   Output.Position.y -= 0.5f;
5948   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
60   Output.Color = float4(0.0f, 0.0f, Input.Color.z, 1.0f);
49   Output.Color = Input.Color;
6150   Output.TexCoord = Input.Position.xy / float2(TargetWidth, TargetHeight);
6251
6352   return Output;
r20380r20381
6756// Simple Pixel Shader
6857//-----------------------------------------------------------------------------
6958
59// TimeParams.x: Frame time of the vector
60// TimeParams.y: How much frame time affects the vector's fade
61// LengthParams.x: Length of the vector
62// LengthParams.y: How much length affects the vector's fade
63// LengthParams.z: Size at which fade is maximum
7064float4 ps_main(PS_INPUT Input) : COLOR
7165{
72   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
73   return BaseTexel * Input.Color;
66   float timeModulate = lerp(1.0f, TimeParams.x, TimeParams.y) * 2.0;
67
68   float lengthModulate = clamp(1.0f - LengthParams.x / LengthParams.z, 0.0f, 1.0f);
69   lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y) * 2.0;
70
71   float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 2.5;
72   return outColor;
7473}
7574
7675//-----------------------------------------------------------------------------
r20380r20381
8382   {
8483      Lighting = FALSE;
8584
86      //Sampler[0] = <DiffuseSampler>;
87
8885      VertexShader = compile vs_2_0 vs_main();
8986      PixelShader  = compile ps_2_0 ps_main();
9087   }
trunk/hlsl/primary.fx
r20380r20381
4747uniform float TargetHeight;
4848uniform float PostPass;
4949uniform float FixedAlpha;
50uniform float Brighten;
5051
5152VS_OUTPUT vs_main(VS_INPUT Input)
5253{
r20380r20381
7273float4 ps_main(PS_INPUT Input) : COLOR
7374{
7475   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
75   return BaseTexel * Input.Color;
76   return BaseTexel * (Input.Color + float4(Brighten, Brighten, Brighten, 0.0f));
7677}
7778
7879//-----------------------------------------------------------------------------
trunk/hlsl/post.fx
r20380r20381
180180   Output.r = pow(Output.r, Power.r);
181181   Output.g = pow(Output.g, Power.g);
182182   Output.b = pow(Output.b, Power.b);
183   Output.a = 1.0f;
183184
184185   return Output;
185186}
trunk/hlsl/bloom.fx
r0r20381
1//-----------------------------------------------------------------------------
2// Effect File Variables
3//-----------------------------------------------------------------------------
4
5texture DiffuseA;
6texture DiffuseB;
7texture DiffuseC;
8texture DiffuseD;
9texture DiffuseE;
10texture DiffuseF;
11texture DiffuseG;
12texture DiffuseH;
13texture DiffuseI;
14texture DiffuseJ;
15texture DiffuseK;
16
17sampler DiffuseSampler0 = sampler_state
18{
19   Texture   = <DiffuseA>;
20   MipFilter = LINEAR;
21   MinFilter = LINEAR;
22   MagFilter = LINEAR;
23   AddressU = CLAMP;
24   AddressV = CLAMP;
25   AddressW = CLAMP;
26};
27
28sampler DiffuseSampler1 = sampler_state
29{
30   Texture   = <DiffuseB>;
31   MipFilter = LINEAR;
32   MinFilter = LINEAR;
33   MagFilter = LINEAR;
34   AddressU = CLAMP;
35   AddressV = CLAMP;
36   AddressW = CLAMP;
37};
38
39sampler DiffuseSampler2 = sampler_state
40{
41   Texture   = <DiffuseC>;
42   MipFilter = LINEAR;
43   MinFilter = LINEAR;
44   MagFilter = LINEAR;
45   AddressU = CLAMP;
46   AddressV = CLAMP;
47   AddressW = CLAMP;
48};
49
50sampler DiffuseSampler3 = sampler_state
51{
52   Texture   = <DiffuseD>;
53   MipFilter = LINEAR;
54   MinFilter = LINEAR;
55   MagFilter = LINEAR;
56   AddressU = CLAMP;
57   AddressV = CLAMP;
58   AddressW = CLAMP;
59};
60
61sampler DiffuseSampler4 = sampler_state
62{
63   Texture   = <DiffuseE>;
64   MipFilter = LINEAR;
65   MinFilter = LINEAR;
66   MagFilter = LINEAR;
67   AddressU = CLAMP;
68   AddressV = CLAMP;
69   AddressW = CLAMP;
70};
71
72sampler DiffuseSampler5 = sampler_state
73{
74   Texture   = <DiffuseF>;
75   MipFilter = LINEAR;
76   MinFilter = LINEAR;
77   MagFilter = LINEAR;
78   AddressU = CLAMP;
79   AddressV = CLAMP;
80   AddressW = CLAMP;
81};
82
83sampler DiffuseSampler6 = sampler_state
84{
85   Texture   = <DiffuseG>;
86   MipFilter = LINEAR;
87   MinFilter = LINEAR;
88   MagFilter = LINEAR;
89   AddressU = CLAMP;
90   AddressV = CLAMP;
91   AddressW = CLAMP;
92};
93
94sampler DiffuseSampler7 = sampler_state
95{
96   Texture   = <DiffuseH>;
97   MipFilter = LINEAR;
98   MinFilter = LINEAR;
99   MagFilter = LINEAR;
100   AddressU = CLAMP;
101   AddressV = CLAMP;
102   AddressW = CLAMP;
103};
104
105sampler DiffuseSampler8 = sampler_state
106{
107   Texture   = <DiffuseI>;
108   MipFilter = LINEAR;
109   MinFilter = LINEAR;
110   MagFilter = LINEAR;
111   AddressU = CLAMP;
112   AddressV = CLAMP;
113   AddressW = CLAMP;
114};
115
116sampler DiffuseSampler9 = sampler_state
117{
118   Texture   = <DiffuseJ>;
119   MipFilter = LINEAR;
120   MinFilter = LINEAR;
121   MagFilter = LINEAR;
122   AddressU = CLAMP;
123   AddressV = CLAMP;
124   AddressW = CLAMP;
125};
126
127sampler DiffuseSampler10 = sampler_state
128{
129   Texture   = <DiffuseK>;
130   MipFilter = LINEAR;
131   MinFilter = LINEAR;
132   MagFilter = LINEAR;
133   AddressU = CLAMP;
134   AddressV = CLAMP;
135   AddressW = CLAMP;
136};
137
138//-----------------------------------------------------------------------------
139// Vertex Definitions
140//-----------------------------------------------------------------------------
141
142struct VS_OUTPUT
143{
144   float4 Position : POSITION;
145   float4 Color : COLOR0;
146   float2 TexCoord : TEXCOORD0;
147};
148
149struct VS_INPUT
150{
151   float3 Position : POSITION;
152   float4 Color : COLOR0;
153   float2 TexCoord : TEXCOORD0;
154};
155
156struct PS_INPUT
157{
158   float4 Color : COLOR0;
159   float2 TexCoord : TEXCOORD0;
160};
161
162//-----------------------------------------------------------------------------
163// Bloom Vertex Shader
164//-----------------------------------------------------------------------------
165
166uniform float2 TargetSize;
167
168uniform float DiffuseScaleA;
169uniform float DiffuseScaleB;
170uniform float DiffuseScaleC;
171uniform float DiffuseScaleD;
172uniform float DiffuseScaleE;
173uniform float DiffuseScaleF;
174uniform float DiffuseScaleG;
175uniform float DiffuseScaleH;
176uniform float DiffuseScaleI;
177uniform float DiffuseScaleJ;
178uniform float DiffuseScaleK;
179
180VS_OUTPUT vs_main(VS_INPUT Input)
181{
182   VS_OUTPUT Output = (VS_OUTPUT)0;
183   
184   Output.Position = float4(Input.Position.xyz, 1.0f);
185   Output.Position.xy /= TargetSize;
186   Output.Position.y = 1.0f - Output.Position.y;
187   Output.Position.xy -= float2(0.5f, 0.5f);
188   Output.Position.xy *= float2(2.0f, 2.0f);
189   Output.Color = Input.Color;
190   float2 inversePixel = 1.0f / TargetSize;
191   Output.TexCoord = Input.Position.xy * inversePixel;
192
193   return Output;
194}
195
196//-----------------------------------------------------------------------------
197// Bloom Pixel Shader
198//-----------------------------------------------------------------------------
199
200float4 ps_main(PS_INPUT Input) : COLOR
201{
202   float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb * DiffuseScaleA * 1.00f;
203   float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb * DiffuseScaleB * 0.95f;
204   float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb * DiffuseScaleC * 0.85f;
205   float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb * DiffuseScaleD * 0.75f;
206   float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb * DiffuseScaleE * 0.65f;
207   float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb * DiffuseScaleF * 0.55f;
208   float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb * DiffuseScaleG * 0.45f;
209   float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb * DiffuseScaleH * 0.35f;
210   float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb * DiffuseScaleI * 0.25f;
211   float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb * DiffuseScaleJ * 0.15f;
212   float3 texel10 = tex2D(DiffuseSampler10, Input.TexCoord).rgb * DiffuseScaleK * 0.10f;
213   return float4(texel0 + texel1 + texel2 + texel3 + texel4 +
214           texel5 + texel6 + texel7 + texel8 + texel9 + texel10, 1.0f);
215}
216
217//-----------------------------------------------------------------------------
218// Downsample Effect
219//-----------------------------------------------------------------------------
220
221technique TestTechnique
222{
223   pass Pass0
224   {
225      Lighting = FALSE;
226
227      Sampler[0] = <DiffuseSampler0>; // 2048x2048
228      Sampler[1] = <DiffuseSampler1>; // 1024x1024
229      Sampler[2] = <DiffuseSampler2>; // 512x512
230      Sampler[3] = <DiffuseSampler3>; // 256x256
231      Sampler[4] = <DiffuseSampler4>; // 128x128
232      Sampler[5] = <DiffuseSampler5>; // 64x64
233      Sampler[6] = <DiffuseSampler6>; // 32x32
234      Sampler[7] = <DiffuseSampler7>; // 16x16
235      Sampler[8] = <DiffuseSampler8>; // 8x8
236      Sampler[9] = <DiffuseSampler9>; // 4x4
237      Sampler[10] = <DiffuseSampler10>; // 2x2
238
239      VertexShader = compile vs_3_0 vs_main();
240      PixelShader  = compile ps_3_0 ps_main();
241   }
242}
Property changes on: trunk/hlsl/bloom.fx
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/hlsl/downsample.fx
r0r20381
1//-----------------------------------------------------------------------------
2// Effect File Variables
3//-----------------------------------------------------------------------------
4
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
18//-----------------------------------------------------------------------------
19// Vertex Definitions
20//-----------------------------------------------------------------------------
21
22struct VS_OUTPUT
23{
24   float4 Position : POSITION;
25   float4 Color : COLOR0;
26   float4 TexCoord01 : TEXCOORD0;
27   float4 TexCoord23 : TEXCOORD1;
28   float4 TexCoord45 : TEXCOORD2;
29   float4 TexCoord67 : TEXCOORD3;
30   float4 TexCoord89 : TEXCOORD4;
31};
32
33struct VS_INPUT
34{
35   float3 Position : POSITION;
36   float4 Color : COLOR0;
37   float2 TexCoord : TEXCOORD0;
38};
39
40struct PS_INPUT
41{
42   float4 Color : COLOR0;
43   float4 TexCoord01 : TEXCOORD0;
44   float4 TexCoord23 : TEXCOORD1;
45   float4 TexCoord45 : TEXCOORD2;
46   float4 TexCoord67 : TEXCOORD3;
47   float4 TexCoord89 : TEXCOORD4;
48};
49
50//-----------------------------------------------------------------------------
51// Downsample Vertex Shader
52//-----------------------------------------------------------------------------
53
54uniform float2 TargetSize;
55uniform float2 SourceSize;
56
57uniform float2 Defocus = float2(0.0f, 0.0f);
58
59uniform float Brighten;
60
61VS_OUTPUT vs_main(VS_INPUT Input)
62{
63   VS_OUTPUT Output = (VS_OUTPUT)0;
64   
65   Output.Position = float4(Input.Position.xyz, 1.0f);
66   Output.Position.xy /= TargetSize;
67   Output.Position.y = 1.0f - Output.Position.y;
68   Output.Position.xy -= float2(0.5f, 0.5f);
69   Output.Position.xy *= float2(2.0f, 2.0f);
70   Output.Color = Input.Color;
71   float2 inversePixel = 1.0f / TargetSize;
72   Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.75f - 0.5f, 0.32f - 0.5f) * inversePixel;
73   Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(0.35f - 0.5f, 0.65f - 0.5f) * inversePixel;
74   Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.31f - 0.5f, 1.25f - 0.5f) * inversePixel;
75   Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(0.58f - 0.5f, 1.61f - 0.5f) * inversePixel;
76   Output.TexCoord45.xy = Input.Position.xy * inversePixel + float2(1.00f - 0.5f, 1.75f - 0.5f) * inversePixel;
77   Output.TexCoord45.zw = Input.Position.xy * inversePixel + float2(1.35f - 0.5f, 1.64f - 0.5f) * inversePixel;
78   Output.TexCoord67.xy = Input.Position.xy * inversePixel + float2(1.65f - 0.5f, 1.32f - 0.5f) * inversePixel;
79   Output.TexCoord67.zw = Input.Position.xy * inversePixel + float2(1.72f - 0.5f, 0.93f - 0.5f) * inversePixel;
80   Output.TexCoord89.xy = Input.Position.xy * inversePixel + float2(1.57f - 0.5f, 0.57f - 0.5f) * inversePixel;
81   Output.TexCoord89.zw = Input.Position.xy * inversePixel + float2(1.25f - 0.5f, 0.33f - 0.5f) * inversePixel;
82
83   return Output;
84}
85
86//-----------------------------------------------------------------------------
87// Downsample Pixel Shader
88//-----------------------------------------------------------------------------
89
90float4 ps_main(PS_INPUT Input) : COLOR
91{
92   float4 texel0 = tex2D(DiffuseSampler, Input.TexCoord01.xy);
93   float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw);
94   float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
95   float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
96   float4 texel4 = tex2D(DiffuseSampler, Input.TexCoord45.xy);
97   float4 texel5 = tex2D(DiffuseSampler, Input.TexCoord45.zw);
98   float4 texel6 = tex2D(DiffuseSampler, Input.TexCoord67.xy);
99   float4 texel7 = tex2D(DiffuseSampler, Input.TexCoord67.zw);
100   float4 texel8 = tex2D(DiffuseSampler, Input.TexCoord89.xy);
101   float4 texel9 = tex2D(DiffuseSampler, Input.TexCoord89.zw);
102   float4 outTexel = (texel0 + texel1 + texel2 + texel3 + texel4 + texel5 + texel6 + texel7 + texel8 + texel9) * 0.1f;
103   return float4(outTexel.rgb, 1.0f);
104}
105
106//-----------------------------------------------------------------------------
107// Downsample Effect
108//-----------------------------------------------------------------------------
109
110technique TestTechnique
111{
112   pass Pass0
113   {
114      Lighting = FALSE;
115
116      Sampler[0] = <DiffuseSampler>;
117
118      VertexShader = compile vs_2_0 vs_main();
119      PixelShader  = compile ps_2_0 ps_main();
120   }
121}
Property changes on: trunk/hlsl/downsample.fx
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/osd/windows/d3dcomm.h
r20380r20381
8686      UINT32                  flags;                      // rendering flags
8787      DWORD                   modmode;                    // texture modulation mode
8888      d3d_texture_info *      texture;                    // pointer to texture info
89        float                   line_time;                  // used by vectors
90        float                   line_length;                // used by vectors
8991};
9092
9193
trunk/src/osd/windows/winmain.c
r20380r20381
375375   { WINOPTION_FLOOR";fs_floor",                               "0.0,0.0,0.0",OPTION_STRING,    "signal floor level" },
376376   { WINOPTION_PHOSPHOR";fs_phosphor",                         "0.0,0.0,0.0",OPTION_STRING,    "phosphorescence decay rate (0.0 is instant, 1.0 is forever)" },
377377   /* NTSC simulation below this line */
378    { NULL,                                                     NULL,        OPTION_HEADER,     "NTSC POST-PROCESSING OPTIONS" },
378379   { WINOPTION_YIQ_ENABLE";yiq",                               "0",         OPTION_BOOLEAN,    "enable YIQ-space HLSL post-processing" },
379380   { WINOPTION_YIQ_CCVALUE";yiqcc",                            "3.59754545",OPTION_FLOAT,      "Color Carrier frequency for NTSC signal processing" },
380381   { WINOPTION_YIQ_AVALUE";yiqa",                              "0.5",       OPTION_FLOAT,      "A value for NTSC signal processing" },
r20380r20381
387388   { WINOPTION_YIQ_QVALUE";yiqq",                              "0.6",       OPTION_FLOAT,      "Q filter cutoff frequency for NTSC signal processing" },
388389   { WINOPTION_YIQ_SCAN_TIME";yiqsc",                          "52.6",      OPTION_FLOAT,      "Horizontal scanline duration for NTSC signal processing (in usec)" },
389390   { WINOPTION_YIQ_PHASE_COUNT";yiqp",                         "2",         OPTION_INTEGER,    "Phase Count value for NTSC signal processing" },
391    { WINOPTION_YIQ_SCAN_TIME";yiqsc",                          "52.6",      OPTION_FLOAT,      "Horizontal scanline duration for NTSC signal processing (in usec)" },
392    { WINOPTION_YIQ_PHASE_COUNT";yiqp",                         "2",         OPTION_INTEGER,    "Phase Count value for NTSC signal processing" },
393    /* Vector simulation below this line */
394    { NULL,                                                     NULL,        OPTION_HEADER,     "VECTOR POST-PROCESSING OPTIONS" },
395    { WINOPTION_VECTOR_TIME_SCALE";vectime",                    "0.0",       OPTION_FLOAT,      "How much the fade rate affects vector fade" },
396    { WINOPTION_VECTOR_TIME_PERIOD";vecperiod",                 "0.1",       OPTION_FLOAT,      "Vector fade rate versus screen refresh rate" },
397    { WINOPTION_VECTOR_LENGTH_SCALE";veclength",                "0.9",       OPTION_FLOAT,      "How much length affects vector fade" },
398    { WINOPTION_VECTOR_LENGTH_RATIO";vecsize",                  "4.0",       OPTION_FLOAT,      "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
390399
391400   // per-window options
392401   { NULL,                                           NULL,       OPTION_HEADER,     "PER-WINDOW VIDEO OPTIONS" },
trunk/src/osd/windows/winmain.h
r20380r20381
1//============================================================
1 //============================================================
22//
33//  winmain.h - Win32 main program and core headers
44//
r20380r20381
130130#define WINOPTION_YIQ_QVALUE                "yiq_q"
131131#define WINOPTION_YIQ_SCAN_TIME             "yiq_scan_time"
132132#define WINOPTION_YIQ_PHASE_COUNT           "yiq_phase_count"
133#define WINOPTION_VECTOR_TIME_SCALE         "vector_time_scale"
134#define WINOPTION_VECTOR_TIME_PERIOD        "vector_time_period"
135#define WINOPTION_VECTOR_LENGTH_SCALE       "vector_length_scale"
136#define WINOPTION_VECTOR_LENGTH_RATIO       "vector_length_ratio"
133137
134138// per-window options
135139#define WINOPTION_SCREEN                "screen"
r20380r20381
239243   float screen_yiq_q() const { return float_value(WINOPTION_YIQ_QVALUE); }
240244   float screen_yiq_scan_time() const { return float_value(WINOPTION_YIQ_SCAN_TIME); }
241245   int screen_yiq_phase_count() const { return int_value(WINOPTION_YIQ_PHASE_COUNT); }
246    float screen_vector_time_scale() const { return float_value(WINOPTION_VECTOR_TIME_SCALE); }
247    float screen_vector_time_period() const { return float_value(WINOPTION_VECTOR_TIME_PERIOD); }
248    float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); }
249    float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); }
242250   const char *screen_offset() const { return value(WINOPTION_OFFSET); }
243251   const char *screen_scale() const { return value(WINOPTION_SCALE); }
244252   const char *screen_power() const { return value(WINOPTION_POWER); }
trunk/src/osd/windows/drawd3d.c
r20380r20381
365365static int update_window_size(win_window_info *window);
366366
367367// drawing
368static void draw_line(d3d_info *d3d, const render_primitive *prim);
368static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time);
369369static void draw_quad(d3d_info *d3d, const render_primitive *prim);
370370
371371// primitives
r20380r20381
499499}
500500
501501
502
502503//============================================================
503504//  drawd3d_window_destroy
504505//============================================================
r20380r20381
598599   result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
599600   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
600601
601   d3d->hlsl->record_texture();
602   d3d->hlsl->begin_frame();
602603
603604   // first update any textures
604605   window->primlist->acquire_lock();
r20380r20381
610611      }
611612      else if(d3d->hlsl->vector_enabled() && PRIMFLAG_GET_VECTORBUF(prim->flags))
612613      {
613         if (!d3d->hlsl->get_vector_target(d3d))
614         if (!d3d->hlsl->get_vector_target())
614615         {
615            d3d->hlsl->create_vector_target(d3d, prim);
616            d3d->hlsl->create_vector_target(prim);
616617         }
617618      }
618619   }
r20380r20381
624625
625626   d3d->lockedbuf = NULL;
626627
627   // loop over primitives
628   if(d3d->hlsl->enabled())
629   {
630      d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
631      d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
632   }
628    // loop over primitives
629    if(d3d->hlsl->enabled())
630    {
631        d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
632        d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
633    }
633634
635mtlog_add("drawd3d_window_draw: count lines");
636    int line_count = 0;
637    for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
638        if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags))
639            line_count++;
640
634641mtlog_add("drawd3d_window_draw: primitive loop begin");
642    // Rotating index for vector time offsets
643    static int start_index = 0;
644    int line_index = 0;
645    windows_options &options = downcast<windows_options &>(window->machine().options());
646    float period = options.screen_vector_time_period();
635647   for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
648    {
636649      switch (prim->type)
637650      {
638651         case render_primitive::LINE:
639            draw_line(d3d, prim);
652                if (PRIMFLAG_GET_VECTOR(prim->flags))
653                {
654                    if (period == 0.0f || line_count == 0)
655                    {
656                        draw_line(d3d, prim, 1.0f);
657                    }
658                    else
659                    {
660                        draw_line(d3d, prim, (float)(start_index + line_index) / ((float)line_count * period));
661                        line_index++;
662                    }
663                }
664                else
665                {
666                    draw_line(d3d, prim, 0.0f);
667                }
640668            break;
641669
642670         case render_primitive::QUAD:
r20380r20381
646674         default:
647675            throw emu_fatalerror("Unexpected render_primitive type");
648676      }
677    }
678    start_index += (int)((float)line_index * period);
679    if (line_count > 0)
680    {
681        start_index %= line_count;
682    }
649683mtlog_add("drawd3d_window_draw: primitive loop end");
650684   window->primlist->release_lock();
651685
r20380r20381
654688   primitive_flush_pending(d3d);
655689mtlog_add("drawd3d_window_draw: flush_pending end");
656690
691   d3d->hlsl->end_frame();
692
657693   // finish the scene
658694mtlog_add("drawd3d_window_draw: end_scene begin");
659695   result = (*d3dintf->device.end_scene)(d3d->device);
r20380r20381
666702mtlog_add("drawd3d_window_draw: present end");
667703   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device present call\n", (int)result);
668704
669   d3d->hlsl->frame_complete();
670
671705   return 0;
672706}
673707
r20380r20381
14461480//  draw_line
14471481//============================================================
14481482
1449static void draw_line(d3d_info *d3d, const render_primitive *prim)
1483static void draw_line(d3d_info *d3d, const render_primitive *prim, float line_time)
14501484{
14511485   const line_aa_step *step = line_aa_4step;
14521486   render_bounds b0, b1;
r20380r20381
15461580      poly->flags = prim->flags;
15471581      poly->modmode = D3DTOP_MODULATE;
15481582      poly->texture = d3d->vector_texture;
1583        poly->line_time = line_time;
1584        poly->line_length = 1.0f;
1585        if (PRIMFLAG_GET_VECTOR(poly->flags))
1586        {
1587            float dx = fabs(prim->bounds.x1 - prim->bounds.x0);
1588            float dy = fabs(prim->bounds.y1 - prim->bounds.y0);
1589            float length2 = dx * dx + dy * dy;
1590            if (length2 > 0.0f)
1591            {
1592                poly->line_length = sqrt(length2);
1593            }
1594            else
1595            {
1596                // use default length of 1.0f from above
1597            }
1598        }
15491599   }
15501600}
15511601
r20380r20381
16401690   poly->flags = prim->flags;
16411691   poly->modmode = modmode;
16421692   poly->texture = texture;
1693    //poly->
16431694}
16441695
16451696
r20380r20381
16531704
16541705   // if we're going to overflow, flush
16551706   if (d3d->lockedbuf != NULL && d3d->numverts + numverts >= VERTEX_BUFFER_SIZE)
1707   {
16561708      primitive_flush_pending(d3d);
16571709
1710      if(d3d->hlsl->enabled())
1711      {
1712         d3d->hlsl_buf = (void*)primitive_alloc(d3d, 6);
1713         d3d->hlsl->init_fsfx_quad(d3d->hlsl_buf);
1714      }
1715   }
1716
16581717   // if we don't have a lock, grab it now
16591718   if (d3d->lockedbuf == NULL)
16601719   {
r20380r20381
16981757   result = (*d3dintf->device.set_stream_source)(d3d->device, 0, d3d->vertexbuf, sizeof(d3d_vertex));
16991758   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_stream_source call\n", (int)result);
17001759
1701   d3d->hlsl->begin();
1760   d3d->hlsl->begin_draw();
17021761
1703   // first remember the original render target in case we need to set a new one
1704   if(d3d->hlsl->enabled() && d3dintf->post_fx_available)
1705   {
1706      vertnum = 6;
1707   }
1708   else
1709   {
1710      vertnum = 0;
1711   }
1762    if (d3d->hlsl->enabled())
1763    {
1764        vertnum = 6;
1765    }
1766    else
1767    {
1768        vertnum = 0;
1769    }
17121770
17131771   // now do the polys
17141772   for (polynum = 0; polynum < d3d->numpolys; polynum++)
r20380r20381
17531811      vertnum += poly->numverts;
17541812   }
17551813
1756   d3d->hlsl->end();
1814   d3d->hlsl->end_draw();
17571815
17581816   // reset the vertex count
17591817   d3d->numverts = 0;
r20380r20381
26602718
26612719d3d_cache_target::~d3d_cache_target()
26622720{
2721    for (int index = 0; index < 11; index++)
2722    {
2723        if (bloom_texture[index] != NULL)
2724        {
2725            (*d3dintf->texture.release)(bloom_texture[index]);
2726            bloom_texture[index] = NULL;
2727        }
2728        if (bloom_target[index] != NULL)
2729        {
2730            (*d3dintf->surface.release)(bloom_target[index]);
2731            bloom_target[index] = NULL;
2732        }
2733    }
2734
26632735   if (last_texture != NULL)
26642736   {
26652737      (*d3dintf->texture.release)(last_texture);
r20380r20381
26772749//  d3d_cache_target::init - initializes a target cache
26782750//============================================================
26792751
2680bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
2752bool d3d_cache_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
26812753{
2754    if (bloom)
2755    {
2756        int bloom_size = (width * prescale_x < height * prescale_y) ? width * prescale_x : height * prescale_y;
2757        int bloom_index = 0;
2758        int bloom_width = width * prescale_x;
2759        int bloom_height = height * prescale_y;
2760        for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
2761        {
2762            printf("%d: %d, %d\n", bloom_index, bloom_width, bloom_height);
2763            bloom_width >>= 1;
2764            bloom_height >>= 1;
2765            HRESULT result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
2766            if (result != D3D_OK)
2767            {
2768                return false;
2769            }
2770            (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
2771            bloom_index++;
2772        }
2773    }
2774
26822775   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &last_texture);
26832776   if (result != D3D_OK)
26842777      return false;
26852778   (*d3dintf->texture.get_surface_level)(last_texture, 0, &last_target);
26862779
2780    target_width = width * prescale_x;
2781    target_height = height * prescale_y;
2782
26872783   return true;
26882784}
26892785
r20380r20381
26932789
26942790d3d_render_target::~d3d_render_target()
26952791{
2792    for (int index = 0; index < 11; index++)
2793    {
2794        if (bloom_texture[index] != NULL)
2795        {
2796            (*d3dintf->texture.release)(bloom_texture[index]);
2797            bloom_texture[index] = NULL;
2798        }
2799        if (bloom_target[index] != NULL)
2800        {
2801            (*d3dintf->surface.release)(bloom_target[index]);
2802            bloom_target[index] = NULL;
2803        }
2804    }
2805
26962806   for (int index = 0; index < 5; index++)
26972807   {
26982808      if (texture[index] != NULL)
r20380r20381
27352845//  d3d_render_target::init - initializes a render target
27362846//============================================================
27372847
2738bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y)
2848bool d3d_render_target::init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom)
27392849{
2740   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[0]);
2850   D3DFORMAT format = bloom ? D3DFMT_A16B16G16R16F : D3DFMT_A8R8G8B8;
2851
2852   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[0]);
27412853   if (result != D3D_OK)
27422854      return false;
27432855   (*d3dintf->texture.get_surface_level)(texture[0], 0, &target[0]);
27442856
2745   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[1]);
2857   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[1]);
27462858   if (result != D3D_OK)
27472859      return false;
27482860   (*d3dintf->texture.get_surface_level)(texture[1], 0, &target[1]);
27492861
2750   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[2]);
2862   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &texture[2]);
27512863   if (result != D3D_OK)
27522864      return false;
27532865   (*d3dintf->texture.get_surface_level)(texture[2], 0, &target[2]);
27542866
2755   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
2756   if (result != D3D_OK)
2757      return false;
2758   (*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
2867   if (!bloom)
2868   {
2869      result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[3]);
2870      if (result != D3D_OK)
2871         return false;
2872      (*d3dintf->texture.get_surface_level)(texture[3], 0, &target[3]);
27592873
2760   result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
2761   if (result != D3D_OK)
2762      return false;
2763   (*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
2874      result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture[4]);
2875      if (result != D3D_OK)
2876         return false;
2877      (*d3dintf->texture.get_surface_level)(texture[4], 0, &target[4]);
27642878
2765   result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
2766   if (result != D3D_OK)
2767      return false;
2768   (*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
2879      result = (*d3dintf->device.create_texture)(d3d->device, width, height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &smalltexture);
2880      if (result != D3D_OK)
2881         return false;
2882      (*d3dintf->texture.get_surface_level)(smalltexture, 0, &smalltarget);
27692883
2770   result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
2771   if (result != D3D_OK)
2772      return false;
2773   (*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
2884      result = (*d3dintf->device.create_texture)(d3d->device, width * prescale_x, height * prescale_y, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &prescaletexture);
2885      if (result != D3D_OK)
2886         return false;
2887      (*d3dintf->texture.get_surface_level)(prescaletexture, 0, &prescaletarget);
27742888
2889        for (int index = 0; index < 11; index++)
2890        {
2891            bloom_texture[index] = NULL;
2892            bloom_target[index] = NULL;
2893        }
2894   }
2895   else
2896    {
2897        int bloom_size = (width < height) ? width : height;
2898        int bloom_index = 0;
2899        int bloom_width = width;
2900        int bloom_height = height;
2901        for (; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
2902        {
2903            bloom_width >>= 1;
2904            bloom_height >>= 1;
2905            result = (*d3dintf->device.create_texture)(d3d->device, bloom_width, bloom_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bloom_texture[bloom_index]);
2906            if (result != D3D_OK)
2907                return false;
2908            (*d3dintf->texture.get_surface_level)(bloom_texture[bloom_index], 0, &bloom_target[bloom_index]);
2909            bloom_index++;
2910        }
2911    }
2912
27752913   target_width = width * prescale_x;
27762914   target_height = height * prescale_y;
27772915
trunk/src/osd/windows/d3dhlsl.c
r20380r20381
466466
467467
468468//============================================================
469//  hlsl_info::frame_complete
470//============================================================
471
472void hlsl_info::frame_complete()
473{
474   if (!master_enable || !d3dintf->post_fx_available)
475      return;
476
477   if(render_snap && snap_rendered)
478   {
479      render_snapshot(snap_target);
480   }
481}
482
483
484//============================================================
485469//  hlsl_info::end_hlsl_avi_recording
486470//============================================================
487471
r20380r20381
510494      {
511495         delete_resources(false);
512496      }
497      master_enable = !master_enable;
513498   }
514499   else
515500   {
516501      if (!initialized)
517502      {
518         create_resources(false);
503         bool success = create_resources(false);
504         master_enable = (success ? !master_enable : false);
519505      }
506      else
507      {
508         master_enable = !master_enable;
509      }
520510   }
521
522   master_enable = !master_enable;
523511}
524512
525513//============================================================
r20380r20381
740728
741729   snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width();
742730   snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height();
743
744731   prescale_force_x = 0;
745732   prescale_force_y = 0;
746733
r20380r20381
922909
923910            ini_file.gets(buf, 1024);
924911            sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count);
912
913                ini_file.gets(buf, 1024);
914                sscanf(buf, "vector_time_scale %f\n", &options->vector_time_scale);
915
916                ini_file.gets(buf, 1024);
917                sscanf(buf, "vector_time_period %f\n", &options->vector_time_period);
918
919                ini_file.gets(buf, 1024);
920                sscanf(buf, "vector_length_scale %f\n", &options->vector_length_scale);
921
922                ini_file.gets(buf, 1024);
923                sscanf(buf, "vector_length_ratio %f\n", &options->vector_length_ratio);
925924         }
926925      }
927926   }
r20380r20381
976975      options->yiq_q = winoptions.screen_yiq_q();
977976      options->yiq_scan_time = winoptions.screen_yiq_scan_time();
978977      options->yiq_phase_count = winoptions.screen_yiq_phase_count();
978        options->vector_time_scale = winoptions.screen_vector_time_scale();
979        options->vector_time_period = winoptions.screen_vector_time_period();
980        options->vector_length_scale = winoptions.screen_vector_length_scale();
981        options->vector_length_ratio = winoptions.screen_vector_length_ratio();
979982   }
980983
981984   options->params_dirty = true;
r20380r20381
987990}
988991
989992
993
990994//============================================================
991995//  hlsl_info::init_fsfx_quad
992996//============================================================
993997
994998void hlsl_info::init_fsfx_quad(void *vertbuf)
995999{
996   if (!master_enable || !d3dintf->post_fx_available)
997      return;
1000    // Called at the start of each frame by the D3D code in order to reserve two triangles
1001    // that are guaranteed to be at a fixed position so as to simply use D3DPT_TRIANGLELIST, 0, 2
1002    // instead of having to do bookkeeping about a specific screen quad
1003    if (!master_enable || !d3dintf->post_fx_available)
1004        return;
9981005
999   d3d_info *d3d = (d3d_info *)window->drawdata;
1006    d3d_info *d3d = (d3d_info *)window->drawdata;
10001007
1001   // get a pointer to the vertex buffer
1002   fsfx_vertices = (d3d_vertex *)vertbuf;
1003   if (fsfx_vertices == NULL)
1004      return;
1008    // get a pointer to the vertex buffer
1009    fsfx_vertices = (d3d_vertex *)vertbuf;
1010    if (fsfx_vertices == NULL)
1011        return;
10051012
1006   // fill in the vertexes clockwise
1007   fsfx_vertices[0].x = 0.0f;
1008   fsfx_vertices[0].y = 0.0f;
1009   fsfx_vertices[1].x = d3d->width;
1010   fsfx_vertices[1].y = 0.0f;
1011   fsfx_vertices[2].x = 0.0f;
1012   fsfx_vertices[2].y = d3d->height;
1013   fsfx_vertices[3].x = d3d->width;
1014   fsfx_vertices[3].y = 0.0f;
1015   fsfx_vertices[4].x = 0.0f;
1016   fsfx_vertices[4].y = d3d->height;
1017   fsfx_vertices[5].x = d3d->width;
1018   fsfx_vertices[5].y = d3d->height;
1013    // fill in the vertexes clockwise
1014    fsfx_vertices[0].x = 0.0f;
1015    fsfx_vertices[0].y = 0.0f;
1016    fsfx_vertices[1].x = d3d->width;
1017    fsfx_vertices[1].y = 0.0f;
1018    fsfx_vertices[2].x = 0.0f;
1019    fsfx_vertices[2].y = d3d->height;
1020    fsfx_vertices[3].x = d3d->width;
1021    fsfx_vertices[3].y = 0.0f;
1022    fsfx_vertices[4].x = 0.0f;
1023    fsfx_vertices[4].y = d3d->height;
1024    fsfx_vertices[5].x = d3d->width;
1025    fsfx_vertices[5].y = d3d->height;
10191026
1020   fsfx_vertices[0].u0 = 0.0f;
1021   fsfx_vertices[0].v0 = 0.0f;
1027    fsfx_vertices[0].u0 = 0.0f;
1028    fsfx_vertices[0].v0 = 0.0f;
10221029
1023   fsfx_vertices[1].u0 = 1.0f;
1024   fsfx_vertices[1].v0 = 0.0f;
1030    fsfx_vertices[1].u0 = 1.0f;
1031    fsfx_vertices[1].v0 = 0.0f;
10251032
1026   fsfx_vertices[2].u0 = 0.0f;
1027   fsfx_vertices[2].v0 = 1.0f;
1033    fsfx_vertices[2].u0 = 0.0f;
1034    fsfx_vertices[2].v0 = 1.0f;
10281035
1029   fsfx_vertices[3].u0 = 1.0f;
1030   fsfx_vertices[3].v0 = 0.0f;
1036    fsfx_vertices[3].u0 = 1.0f;
1037    fsfx_vertices[3].v0 = 0.0f;
10311038
1032   fsfx_vertices[4].u0 = 0.0f;
1033   fsfx_vertices[4].v0 = 1.0f;
1039    fsfx_vertices[4].u0 = 0.0f;
1040    fsfx_vertices[4].v0 = 1.0f;
10341041
1035   fsfx_vertices[5].u0 = 1.0f;
1036   fsfx_vertices[5].v0 = 1.0f;
1042    fsfx_vertices[5].u0 = 1.0f;
1043    fsfx_vertices[5].v0 = 1.0f;
10371044
1038   // set the color, Z parameters to standard values
1039   for (int i = 0; i < 6; i++)
1040   {
1041      fsfx_vertices[i].z = 0.0f;
1042      fsfx_vertices[i].rhw = 1.0f;
1043      fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
1044   }
1045    // set the color, Z parameters to standard values
1046    for (int i = 0; i < 6; i++)
1047    {
1048        fsfx_vertices[i].z = 0.0f;
1049        fsfx_vertices[i].rhw = 1.0f;
1050        fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255);
1051    }
10451052}
10461053
10471054
1055
10481056//============================================================
10491057//  hlsl_info::create_resources
10501058//============================================================
10511059
10521060int hlsl_info::create_resources(bool reset)
10531061{
1062    printf("create_resources enter\n"); fflush(stdout);
10541063   initialized = true;
10551064
10561065   if (!master_enable || !d3dintf->post_fx_available)
r20380r20381
10581067
10591068   d3d_info *d3d = (d3d_info *)window->drawdata;
10601069
1061   HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
1070    HRESULT result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer);
1071    if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
1072
1073    result = (*d3dintf->device.create_texture)(d3d->device, 4, 4, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &black_texture);
1074    if (result != D3D_OK)
1075    {
1076        mame_printf_verbose("Direct3D: Unable to init video-memory target for black texture (%08x)\n", (UINT32)result);
1077        return 1;
1078    }
1079    (*d3dintf->texture.get_surface_level)(black_texture, 0, &black_surface);
1080    result = (*d3dintf->device.set_render_target)(d3d->device, 0, black_surface);
1081    if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1082    result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
1083    if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
1084    result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
1085    if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1086
1087   result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture);
10621088   if (result != D3D_OK)
10631089   {
10641090      mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result);
r20380r20381
10911117      shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32));
10921118   }
10931119
1120    printf("load shaders enter\n"); fflush(stdout);
1121
10941122   const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
10951123
10961124   // Replace all this garbage with a proper data-driven system
r20380r20381
12161244
12171245   // create the vector shader
12181246#if HLSL_VECTOR
1219   char vector_cstr[1024];
1220   sprintf(vector_cstr, "%s\\vector.fx", fx_dir);
1221   TCHAR *vector_name = tstring_from_utf8(vector_cstr);
1247    char bloom_cstr[1024];
1248    sprintf(bloom_cstr, "%s\\bloom.fx", fx_dir);
1249    TCHAR *bloom_name = tstring_from_utf8(bloom_cstr);
12221250
1251    result = (*d3dintf->device.create_effect)(d3d->device, bloom_name, &bloom_effect);
1252    if(result != D3D_OK)
1253    {
1254        mame_printf_verbose("Direct3D: Unable to load bloom.fx\n");
1255        return 1;
1256    }
1257    if (bloom_name)
1258        osd_free(bloom_name);
1259
1260    char downsample_cstr[1024];
1261    sprintf(downsample_cstr, "%s\\downsample.fx", fx_dir);
1262    TCHAR *downsample_name = tstring_from_utf8(downsample_cstr);
1263
1264    result = (*d3dintf->device.create_effect)(d3d->device, downsample_name, &downsample_effect);
1265    if(result != D3D_OK)
1266    {
1267        mame_printf_verbose("Direct3D: Unable to load downsample.fx\n");
1268        return 1;
1269    }
1270    if (downsample_name)
1271        osd_free(downsample_name);
1272
1273    char vector_cstr[1024];
1274    sprintf(vector_cstr, "%s\\vector.fx", fx_dir);
1275    TCHAR *vector_name = tstring_from_utf8(vector_cstr);
1276
12231277   result = (*d3dintf->device.create_effect)(d3d->device, vector_name, &vector_effect);
12241278   if(result != D3D_OK)
12251279   {
r20380r20381
12511305   if (yiq_decode_name)
12521306      osd_free(yiq_decode_name);
12531307
1308    printf("load shaders exit\n"); fflush(stdout);
1309
12541310   return 0;
12551311}
12561312
12571313
12581314//============================================================
1259//  hlsl_info::begin
1315//  hlsl_info::begin_draw
12601316//============================================================
12611317
1262void hlsl_info::begin()
1318void hlsl_info::begin_draw()
12631319{
12641320   if (!master_enable || !d3dintf->post_fx_available)
12651321      return;
r20380r20381
12841340
12851341
12861342//============================================================
1343//  hlsl_info::begin_frame
1344//============================================================
1345
1346void hlsl_info::begin_frame()
1347{
1348   record_texture();
1349
1350   /*d3d_info *d3d = (d3d_info *)window->drawdata;
1351
1352   d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
1353   if (rt == NULL)
1354   {
1355      return;
1356   }
1357
1358   HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
1359   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1360   result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
1361   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
1362   result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
1363   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/
1364}
1365
1366
1367//============================================================
1368//  hlsl_info::blit
1369//============================================================
1370
1371void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type,
1372                     UINT32 prim_index, UINT32 prim_count, int dstw, int dsth)
1373{
1374    d3d_info *d3d = (d3d_info *)window->drawdata;
1375
1376    HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst);
1377    if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1378
1379    curr_effect = effect;
1380
1381    (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src);
1382
1383    (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)dstw);
1384    (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)dsth);
1385    (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
1386    (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
1387    (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f);
1388
1389    unsigned int num_passes = 0;
1390    (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
1391
1392    for (UINT pass = 0; pass < num_passes; pass++)
1393    {
1394        (*d3dintf->effect.begin_pass)(curr_effect, pass);
1395        // add the primitives
1396        HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count);
1397        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
1398        (*d3dintf->effect.end_pass)(curr_effect);
1399    }
1400
1401    (*d3dintf->effect.end)(curr_effect);
1402
1403    if (new_dst)
1404    {
1405        HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst);
1406        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1407    }
1408}
1409
1410
1411
1412//============================================================
1413//  hlsl_info::blit
1414//============================================================
1415
1416void hlsl_info::blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst, D3DPRIMITIVETYPE prim_type,
1417                UINT32 prim_index, UINT32 prim_count)
1418{
1419   d3d_info *d3d = (d3d_info *)window->drawdata;
1420
1421   HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, dst);
1422   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1423
1424   curr_effect = effect;
1425
1426   d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
1427   if (rt == NULL)
1428   {
1429      return;
1430   }
1431
1432   (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", src);
1433
1434    (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
1435    (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
1436    (*d3dintf->effect.set_float)(curr_effect, "ScreenWidth", (float)d3d->width);
1437    (*d3dintf->effect.set_float)(curr_effect, "ScreenHeight", (float)d3d->height);
1438   (*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
1439   (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
1440   (*d3dintf->effect.set_float)(curr_effect, "Brighten", 1.0f);
1441
1442   unsigned int num_passes = 0;
1443   (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
1444
1445   for (UINT pass = 0; pass < num_passes; pass++)
1446   {
1447      (*d3dintf->effect.begin_pass)(curr_effect, pass);
1448      // add the primitives
1449      HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, prim_type, prim_index, prim_count);
1450      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
1451      (*d3dintf->effect.end_pass)(curr_effect);
1452   }
1453
1454   (*d3dintf->effect.end)(curr_effect);
1455
1456   (*d3dintf->effect.set_float)(curr_effect, "Brighten", 0.0f);
1457
1458   if (new_dst)
1459   {
1460      HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, new_dst);
1461      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1462   }
1463}
1464
1465//============================================================
1466//  hlsl_info::end_frame
1467//============================================================
1468
1469void hlsl_info::end_frame()
1470{
1471   if (!master_enable || !d3dintf->post_fx_available)
1472      return;
1473
1474   if(render_snap && snap_rendered)
1475   {
1476      render_snapshot(snap_target);
1477   }
1478
1479    if (!lines_pending)
1480        return;
1481
1482    lines_pending = false;
1483    /*d3d_info *d3d = (d3d_info *)window->drawdata;
1484
1485    d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
1486    if (!rt)
1487        return;
1488
1489    blit(backbuffer, rt->texture[0], NULL, vecbuf_type, vecbuf_index, vecbuf_count);*/
1490
1491   /*d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
1492   if (rt == NULL)
1493   {
1494      return;
1495   }
1496
1497   blit(backbuffer, rt->texture[1], NULL, vecbuf_type, vecbuf_index, vecbuf_count);
1498
1499   HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
1500   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
1501   result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
1502   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
1503   result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
1504   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);*/
1505}
1506
1507
1508//============================================================
12871509//  hlsl_info::init_effect_info
12881510//============================================================
12891511
r20380r20381
13131535         (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
13141536         (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
13151537         (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
1316         (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
1317         (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
13181538         (*d3dintf->effect.set_vector)(curr_effect, "Floor", 3, options->floor);
13191539         (*d3dintf->effect.set_float)(curr_effect, "SnapX", snap_width);
13201540         (*d3dintf->effect.set_float)(curr_effect, "SnapY", snap_height);
r20380r20381
14141634   UINT num_passes = 0;
14151635   d3d_info *d3d = (d3d_info *)window->drawdata;
14161636
1417#if HLSL_VECTOR
1418   if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
1419   {
1420      lines_pending = true;
1421   }
1422   else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable)
1423   {
1424   }
1425#endif
1426
14271637   if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
14281638   {
14291639      d3d_render_target *rt = find_render_target(poly->texture);
r20380r20381
16441854
16451855         (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
16461856         (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
1647         (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
1648         (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
1649         (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
1650         (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
16511857         (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]);
1652         (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
16531858
16541859         (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
16551860
r20380r20381
16751880
16761881         (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
16771882         (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
1678         (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
1679         (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
1680         (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);
1681         (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);
1682         (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[0]);
1683         (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
1883         (*d3dintf->effect.set_vector)(curr_effect, "Defocus", 2, &options->defocus[1]);
16841884
16851885         (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
16861886
r20380r20381
17081908      {
17091909         (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
17101910         (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
1711         (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
1712         (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
1713         (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f / (poly->texture->ustop - poly->texture->ustart));
1714         (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart));
17151911         (*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor);
17161912      }
17171913      (*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)rt->target_width);
r20380r20381
17641960
17651961      (*d3dintf->effect.end)(curr_effect);
17661962
1963        curr_effect = post_effect;
1964        (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
1965        (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
1966
17671967      /* Scanlines and shadow mask, at high res for AVI logging*/
17681968      if(avi_output_file != NULL)
17691969      {
1770         curr_effect = post_effect;
1771
17721970         (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
17731971
17741972         result = (*d3dintf->device.set_render_target)(d3d->device, 0, avi_final_target);
r20380r20381
17901988
17911989      if(render_snap)
17921990      {
1793         curr_effect = post_effect;
1794
17951991         (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
17961992
17971993         result = (*d3dintf->device.set_render_target)(d3d->device, 0, snap_target);
r20380r20381
18132009         snap_rendered = true;
18142010      }
18152011
1816      /* Scanlines and shadow mask */
1817      curr_effect = post_effect;
2012        /* Scanlines and shadow mask */
2013        curr_effect = post_effect;
18182014
1819      (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
2015        (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
18202016
1821      result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
1822      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2017        (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)rt->target_width);
2018        (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)rt->target_height);
18232019
2020#if HLSL_VECTOR
2021        result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
2022#else
2023        result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2024#endif
2025        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2026
2027        (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2028
2029        for (UINT pass = 0; pass < num_passes; pass++)
2030        {
2031            (*d3dintf->effect.begin_pass)(curr_effect, pass);
2032            // add the primitives
2033            result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
2034            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2035            (*d3dintf->effect.end_pass)(curr_effect);
2036        }
2037
2038        (*d3dintf->effect.end)(curr_effect);
2039
2040#if HLSL_VECTOR
2041        /* Bloom */
2042        curr_effect = downsample_effect;
2043
2044        (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]);
2045
2046        int bloom_size = (rt->target_width < rt->target_height) ? rt->target_width : rt->target_height;
2047        int bloom_index = 0;
2048        int bloom_width = rt->target_width;
2049        int bloom_height = rt->target_height;
2050        for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
2051        {
2052            float source_size[2] = { bloom_width, bloom_height };
2053            float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
2054            (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
2055            (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
2056
2057            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2058
2059            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[1] : ct->bloom_texture[bloom_index - 1]);
2060
2061            if (ct->bloom_target[bloom_index] == NULL)
2062            {
2063                (*d3dintf->effect.end)(curr_effect);
2064                break;
2065            }
2066
2067            HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, ct->bloom_target[bloom_index]);
2068            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7:%d\n", (int)result, bloom_size);
2069            //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2070            //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2071
2072            for (UINT pass = 0; pass < num_passes; pass++)
2073            {
2074                (*d3dintf->effect.begin_pass)(curr_effect, pass);
2075                // add the primitives
2076                result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
2077                if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2078                (*d3dintf->effect.end_pass)(curr_effect);
2079            }
2080
2081            (*d3dintf->effect.end)(curr_effect);
2082
2083            bloom_index++;
2084            bloom_width >>= 1;
2085            bloom_height >>= 1;
2086        }
2087
2088        /* Bloom composite pass*/
2089        curr_effect = bloom_effect;
2090
2091        float target_size[2] = { rt->target_width, rt->target_height };
2092        (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
2093
2094        (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[1]);
2095        (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f);
2096
2097        char name[9] = "Diffuse*";
2098        char scale[14] = "DiffuseScale*";
2099        for(int index = 1; index < bloom_index; index++)
2100        {
2101            name[7] = 'A' + index;
2102            scale[12] = 'A' + index;
2103            (*d3dintf->effect.set_texture)(curr_effect, name, ct->bloom_texture[index - 1]);
2104            (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f);
2105        }
2106        for(int index = bloom_index; index < 11; index++)
2107        {
2108            name[7] = 'A' + index;
2109            scale[12] = 'A' + index;
2110            (*d3dintf->effect.set_texture)(curr_effect, name, black_texture);
2111            (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f);
2112        }
2113
2114        (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2115
2116        result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[2]);
2117        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 8\n", (int)result);
2118
2119        for (UINT pass = 0; pass < num_passes; pass++)
2120        {
2121            (*d3dintf->effect.begin_pass)(curr_effect, pass);
2122            // add the primitives
2123            result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
2124            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2125            (*d3dintf->effect.end_pass)(curr_effect);
2126        }
2127
2128        (*d3dintf->effect.end)(curr_effect);
2129
2130        curr_effect = effect;
2131
2132        //(*d3dintf->effect.set_float)(curr_effect, "PostPass", 1.0f);
2133
2134        //blit(backbuffer, ct->last_texture, NULL, poly->type, vertnum, poly->count, d3d->width, d3d->height);
2135
2136        result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2137        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 9\n", (int)result);
2138
2139        (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[2]);
2140
2141        (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
2142        (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
2143        (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2144        (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2145        (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2146        (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2147        (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
2148        (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", options->pincushion);
2149
2150        (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2151
2152        for (UINT pass = 0; pass < num_passes; pass++)
2153        {
2154            (*d3dintf->effect.begin_pass)(curr_effect, pass);
2155            // add the primitives
2156            HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2157            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2158            (*d3dintf->effect.end_pass)(curr_effect);
2159        }
2160
2161        (*d3dintf->effect.end)(curr_effect);
2162#endif
2163
2164      poly->texture->cur_frame++;
2165      poly->texture->cur_frame %= options->yiq_phase_count;
2166
2167      options->params_dirty = false;
2168   }
2169#if HLSL_VECTOR
2170    else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
2171    {
2172        d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
2173        if (rt == NULL)
2174        {
2175            return;
2176        }
2177
2178        lines_pending = true;
2179
2180        curr_effect = vector_effect;
2181        //curr_effect = effect;
2182
2183        if(options->params_dirty)
2184        {
2185            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2186            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2187        }
2188
2189        float time_params[2] = { poly->line_time, options->vector_time_scale };
2190        float length_params[3] = { poly->line_length, options->vector_length_scale, options->vector_length_ratio };
2191        (*d3dintf->effect.set_vector)(curr_effect, "TimeParams", 2, time_params);
2192        (*d3dintf->effect.set_vector)(curr_effect, "LengthParams", 3, length_params);
2193
2194        (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2195
2196        HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
2197        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2198
2199        for (UINT pass = 0; pass < num_passes; pass++)
2200        {
2201            (*d3dintf->effect.begin_pass)(curr_effect, pass);
2202            // add the primitives
2203            HRESULT result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2204            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2205            (*d3dintf->effect.end_pass)(curr_effect);
2206        }
2207
2208        (*d3dintf->effect.end)(curr_effect);
2209        result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2210        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2211
2212        curr_effect = effect;
2213
2214        (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
2215    }
2216    else if (PRIMFLAG_GET_VECTORBUF(poly->flags) && vector_enable)
2217    {
2218        //if (!lines_pending)
2219            //return;
2220        //lines_pending = false;
2221
2222        d3d_info *d3d = (d3d_info *)window->drawdata;
2223
2224        d3d_render_target *rt = find_render_target(d3d->width, d3d->height, 0, 0);
2225        if (rt == NULL)
2226        {
2227            return;
2228        }
2229
2230        /* Bloom */
2231        curr_effect = downsample_effect;
2232
2233        (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[0]);
2234
2235        int bloom_size = (d3d->width < d3d->height) ? d3d->width : d3d->height;
2236        int bloom_index = 0;
2237        int bloom_width = d3d->width;
2238        int bloom_height = d3d->height;
2239        for(; bloom_size >= 2 && bloom_index < 11; bloom_size >>= 1)
2240        {
2241            float source_size[2] = { bloom_width, bloom_height };
2242            float target_size[2] = { bloom_width >> 1, bloom_height >> 1 };
2243            (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
2244            (*d3dintf->effect.set_vector)(curr_effect, "SourceSize", 2, source_size);
2245
2246            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2247
2248            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", (bloom_index == 0) ? rt->texture[0] : rt->bloom_texture[bloom_index - 1]);
2249
2250            HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->bloom_target[bloom_index]);
2251            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
2252            //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2253            //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2254
2255            for (UINT pass = 0; pass < num_passes; pass++)
2256            {
2257                (*d3dintf->effect.begin_pass)(curr_effect, pass);
2258                // add the primitives
2259                result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2260                if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2261                (*d3dintf->effect.end_pass)(curr_effect);
2262            }
2263
2264            (*d3dintf->effect.end)(curr_effect);
2265
2266            bloom_index++;
2267            bloom_width >>= 1;
2268            bloom_height >>= 1;
2269        }
2270
2271        /* Bloom composite pass*/
2272        curr_effect = bloom_effect;
2273
2274        float target_size[2] = { d3d->width, d3d->height };
2275        (*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
2276
2277        (*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->texture[0]);
2278        (*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f);
2279
2280        char name[9] = "Diffuse*";
2281        char scale[14] = "DiffuseScale*";
2282        for(int index = 1; index < bloom_index; index++)
2283        {
2284            name[7] = 'A' + index;
2285            scale[12] = 'A' + index;
2286            (*d3dintf->effect.set_texture)(curr_effect, name, rt->bloom_texture[index - 1]);
2287            (*d3dintf->effect.set_float)(curr_effect, scale, 1.0f);
2288        }
2289        for(int index = bloom_index; index < 11; index++)
2290        {
2291            name[7] = 'A' + index;
2292            scale[12] = 'A' + index;
2293            (*d3dintf->effect.set_texture)(curr_effect, name, black_texture);
2294            (*d3dintf->effect.set_float)(curr_effect, scale, 0.0f);
2295        }
2296
2297        (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2298
2299        HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[1]);
2300        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
2301        //result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2302        //if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2303
2304        for (UINT pass = 0; pass < num_passes; pass++)
2305        {
2306            (*d3dintf->effect.begin_pass)(curr_effect, pass);
2307            // add the primitives
2308            result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2309            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2310            (*d3dintf->effect.end_pass)(curr_effect);
2311        }
2312
2313        (*d3dintf->effect.end)(curr_effect);
2314
2315      /* Phosphor */
2316      curr_effect = phosphor_effect;
2317
2318      if(options->params_dirty)
2319      {
2320         (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2321         (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2322         (*d3dintf->effect.set_vector)(curr_effect, "Phosphor", 3, options->phosphor);
2323      }
2324      (*d3dintf->effect.set_float)(curr_effect, "TextureWidth", (float)d3d->width);
2325      (*d3dintf->effect.set_float)(curr_effect, "TextureHeight", (float)d3d->height);
2326      (*d3dintf->effect.set_float)(curr_effect, "Passthrough", 0.0f);
2327
2328      (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->texture[1]);
2329      (*d3dintf->effect.set_texture)(curr_effect, "LastPass", rt->texture[2]);
2330
2331      result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
2332      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result);
2333      result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2334      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2335
18242336      (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
18252337
18262338      for (UINT pass = 0; pass < num_passes; pass++)
18272339      {
18282340         (*d3dintf->effect.begin_pass)(curr_effect, pass);
18292341         // add the primitives
1830         result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2342         result = (*d3dintf->device.draw_primitive)(d3d->device, D3DPT_TRIANGLELIST, 0, 2);
18312343         if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
18322344         (*d3dintf->effect.end_pass)(curr_effect);
18332345      }
18342346
18352347      (*d3dintf->effect.end)(curr_effect);
18362348
1837      poly->texture->cur_frame++;
1838      poly->texture->cur_frame %= options->yiq_phase_count;
2349        curr_effect = effect;
18392350
1840      options->params_dirty = false;
1841   }
1842#if HLSL_VECTOR
1843   else if(PRIMFLAG_GET_VECTOR(poly->flags) && vector_enable)
1844   {
1845   }
2351        //blit(backbuffer, rt->bloom_texture[5], NULL, poly->type, vertnum, poly->count);
2352        blit(rt->target[2], rt->texture[0], NULL, poly->type, vertnum, poly->count);
2353        blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count);
2354        //blit(backbuffer, rt->texture[0], NULL, poly->type, vertnum, poly->count);
2355
2356        result = (*d3dintf->device.set_render_target)(d3d->device, 0, rt->target[0]);
2357        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2358        result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2359        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2360        result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2361        if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2362
2363        vecbuf_type = poly->type;
2364        vecbuf_index = vertnum;
2365        vecbuf_count = poly->count;
2366    }
18462367#endif
18472368   else
18482369   {
1849      (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
1850      (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
1851      (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
1852      (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2370      (*d3dintf->effect.set_float)(curr_effect, "RawWidth", d3d->width);//poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
2371      (*d3dintf->effect.set_float)(curr_effect, "RawHeight", d3d->height);//poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
2372      (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2373      (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);//poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
18532374      (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
18542375      (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
18552376      (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
r20380r20381
18732394
18742395
18752396//============================================================
1876//  hlsl_info::end
2397//  hlsl_info::end_draw
18772398//============================================================
18782399
1879void hlsl_info::end()
2400void hlsl_info::end_draw()
18802401{
18812402   if (!master_enable || !d3dintf->post_fx_available)
18822403      return;
r20380r20381
19022423{
19032424   d3d_cache_target* target = (d3d_cache_target*)global_alloc_clear(d3d_cache_target);
19042425
1905   if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale))
2426   if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, true))
19062427   {
19072428      global_free(target);
19082429      return false;
19092430   }
19102431
1911   target->width = info->texinfo.width;
1912   target->height = info->texinfo.height;
2432   if (info != NULL)
2433   {
2434      target->width = info->texinfo.width;
2435      target->height = info->texinfo.height;
2436   }
2437   else
2438   {
2439      target->width = d3d->width;
2440      target->height = d3d->height;
2441   }
19132442
19142443   target->next = cachehead;
19152444   target->prev = NULL;
r20380r20381
19252454   return true;
19262455}
19272456
1928d3d_render_target* hlsl_info::get_vector_target(d3d_info *d3d)
2457d3d_render_target* hlsl_info::get_vector_target()
19292458{
19302459#if HLSL_VECTOR
19312460   if (!vector_enable)
r20380r20381
19332462      return false;
19342463   }
19352464
2465   d3d_info *d3d = (d3d_info *)window->drawdata;
2466
19362467   return find_render_target(d3d->width, d3d->height, 0, 0);
19372468#endif
19382469   return NULL;
19392470}
19402471
1941void hlsl_info::create_vector_target(d3d_info *d3d, render_primitive *prim)
2472void hlsl_info::create_vector_target(render_primitive *prim)
19422473{
19432474#if HLSL_VECTOR
1944   if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1))
2475   d3d_info *d3d = (d3d_info *)window->drawdata;
2476   if (!add_render_target(d3d, NULL, d3d->width, d3d->height, 1, 1, true))
19452477   {
19462478      vector_enable = false;
19472479   }
r20380r20381
19522484//  hlsl_info::add_render_target - register a render target
19532485//============================================================
19542486
1955bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale)
2487bool hlsl_info::add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom)
19562488{
19572489   UINT32 screen_index = 0;
19582490   UINT32 page_index = 0;
19592491   if (info != NULL)
19602492   {
1961      if (find_render_target(info))
2493      d3d_render_target *existing_target = find_render_target(info);
2494      if (existing_target != NULL)
19622495      {
1963         remove_render_target(info);
2496         remove_render_target(existing_target);
19642497      }
19652498
19662499      UINT32 screen_index_data = (UINT32)info->texinfo.osddata;
19672500      screen_index = screen_index_data >> 1;
19682501      page_index = screen_index_data & 1;
19692502   }
2503   else
2504   {
2505      d3d_render_target *existing_target = find_render_target(d3d->width, d3d->height, 0, 0);
2506      if (existing_target != NULL)
2507      {
2508         remove_render_target(existing_target);
2509      }
2510   }
19702511
19712512   d3d_render_target* target = (d3d_render_target*)global_alloc_clear(d3d_render_target);
19722513
1973   if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale))
2514   if (!target->init(d3d, d3dintf, width, height, xprescale, yprescale, bloom))
19742515   {
19752516      global_free(target);
19762517      return false;
r20380r20381
19872528      target->height = d3d->height;
19882529   }
19892530
2531   HRESULT result = (*d3dintf->device.set_render_target)(d3d->device, 0, target->target[0]);
2532   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2533   result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2534   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2535   result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2536   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2537
19902538   target->screen_index = screen_index;
19912539   target->page_index = page_index;
19922540
r20380r20381
21452693      file.printf("yiq_q                  %f\n", options->yiq_q);
21462694      file.printf("yiq_scan_time          %f\n", options->yiq_scan_time);
21472695      file.printf("yiq_phase_count        %d\n", options->yiq_phase_count);
2696        file.printf("vector_time_scale      %f\n", options->vector_time_scale);
2697        file.printf("vector_time_period     %f\n", options->vector_time_period);
2698        file.printf("vector_length_scale    %f\n", options->vector_length_scale);
2699        file.printf("vector_length_ratio    %f\n", options->vector_length_ratio);
21482700   }
21492701
21502702   while (targethead != NULL)
r20380r20381
21522704      remove_render_target(targethead);
21532705   }
21542706
2707#if HLSL_VECTOR
2708    if (downsample_effect != NULL)
2709    {
2710        (*d3dintf->effect.release)(downsample_effect);
2711        downsample_effect = NULL;
2712    }
2713    if (bloom_effect != NULL)
2714    {
2715        (*d3dintf->effect.release)(bloom_effect);
2716        bloom_effect = NULL;
2717    }
2718#endif
21552719   if (effect != NULL)
21562720   {
21572721      (*d3dintf->effect.release)(effect);
r20380r20381
22032767      yiq_decode_effect = NULL;
22042768   }
22052769
2770    if (black_texture != NULL)
2771    {
2772        (*d3dintf->texture.release)(black_texture);
2773        black_texture = NULL;
2774    }
2775
22062776   if (avi_copy_texture != NULL)
22072777   {
22082778      (*d3dintf->texture.release)(avi_copy_texture);
trunk/src/osd/windows/drawd3d.h
r20380r20381
6767   d3d_cache_target() { }
6868   ~d3d_cache_target();
6969
70   bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
70   bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom);
7171
7272   d3d_surface *last_target;
7373   d3d_texture *last_texture;
7474
75    int target_width;
76    int target_height;
77
7578   int width;
7679   int height;
7780
r20380r20381
7982
8083   d3d_cache_target *next;
8184   d3d_cache_target *prev;
85
86    d3d_surface *bloom_target[11];
87    d3d_texture *bloom_texture[11];
8288};
8389
8490/* d3d_render_target is the information about a Direct3D render target chain */
r20380r20381
8995   d3d_render_target() { }
9096   ~d3d_render_target();
9197
92   bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y);
98   bool init(d3d_info *d3d, d3d_base *d3dintf, int width, int height, int prescale_x, int prescale_y, bool bloom = false);
9399
94100   int target_width;
95101   int target_height;
r20380r20381
109115
110116   d3d_render_target *next;
111117   d3d_render_target *prev;
118
119    d3d_surface *bloom_target[11];
120    d3d_texture *bloom_texture[11];
112121};
113122
114123/* d3d_info is the information about Direct3D for the current screen */
trunk/src/osd/windows/d3dhlsl.h
r20380r20381
4848//  CONSTANTS
4949//============================================================
5050
51#define HLSL_VECTOR         (0)
51#define HLSL_VECTOR         (0)
5252
5353//============================================================
5454//  TYPE DEFINITIONS
r20380r20381
9191   float                   floor[3];
9292   float                   phosphor[3];
9393   float                   saturation;
94
95    // NTSC
9496   bool                    yiq_enable;
9597   float                   yiq_cc;
9698   float                   yiq_a;
r20380r20381
103105   float                   yiq_q;
104106   float                   yiq_scan_time;
105107   int                     yiq_phase_count;
108
109    // Vectors
110    float                   vector_time_scale;
111    float                   vector_time_period;
112    float                   vector_length_scale;
113    float                   vector_length_ratio;
106114};
107115
108116class hlsl_info
r20380r20381
113121   ~hlsl_info();
114122
115123   void init(d3d_base *d3dintf, win_window_info *window);
116   void init_fsfx_quad(void *vertbuf);
117124
118125   bool enabled() { return master_enable; }
119126   void toggle();
120127
121   bool vector_enabled() { return vector_enable && (bool)HLSL_VECTOR; }
122   d3d_render_target* get_vector_target(d3d_info *d3d);
123   void create_vector_target(d3d_info *d3d, render_primitive *prim);
128   bool vector_enabled() { return master_enable && vector_enable && (bool)HLSL_VECTOR; }
129   d3d_render_target* get_vector_target();
130   void create_vector_target(render_primitive *prim);
124131
125   void begin();
132   void begin_frame();
133   void end_frame();
134
135   void begin_draw();
136   void end_draw();
137
126138   void init_effect_info(d3d_poly_info *poly);
127139   void render_quad(d3d_poly_info *poly, int vertnum);
128   void end();
129140
130141   bool register_texture(d3d_texture_info *texture);
131142   bool register_prescaled_texture(d3d_texture_info *texture);
132   bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale);
143   bool add_render_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, bool bloom = false);
133144   bool add_cache_target(d3d_info* d3d, d3d_texture_info* info, int width, int height, int xprescale, int yprescale, int screen_index);
134145
135146   void window_save();
r20380r20381
139150   void avi_update_snap(d3d_surface *surface);
140151   void render_snapshot(d3d_surface *surface);
141152   void record_texture();
153    void init_fsfx_quad(void *vertbuf);
142154
143   void frame_complete();
144
145155   void                    set_texture(d3d_texture_info *texture);
146156   d3d_render_target *     find_render_target(d3d_texture_info *info);
147157   void                    remove_render_target(d3d_texture_info *texture);
r20380r20381
155165   slider_state *init_slider_list();
156166
157167private:
168   void               blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
169                         D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count,
170                                 int dstw, int dsth);
171    void                    blit(d3d_surface *dst, d3d_texture *src, d3d_surface *new_dst,
172                                 D3DPRIMITIVETYPE prim_type, UINT32 prim_index, UINT32 prim_count);
158173   void                    enumerate_screens();
159174
160175   void                    end_avi_recording();
r20380r20381
186201   bitmap_argb32           shadow_bitmap;              // shadow mask bitmap for post-processing shader
187202   d3d_texture_info *      shadow_texture;             // shadow mask texture for post-processing shader
188203   hlsl_options *          options;                    // current uniform state
204   D3DPRIMITIVETYPE      vecbuf_type;
205   UINT32               vecbuf_index;
206   UINT32               vecbuf_count;
189207
190208   avi_file *              avi_output_file;            // AVI file
191209   bitmap_rgb32            avi_snap;                   // AVI snapshot
r20380r20381
197215   d3d_surface *           avi_final_target;           // AVI upscaled surface
198216   d3d_texture *           avi_final_texture;          // AVI upscaled texture
199217
218    d3d_surface *           black_surface;              // black dummy surface
219    d3d_texture *           black_texture;              // black dummy texture
220
200221   bool                    render_snap;                // whether or not to take HLSL post-render snapshot
201222   bool                    snap_rendered;              // whether we just rendered our HLSL post-render shot or not
202223   d3d_surface *           snap_copy_target;           // snapshot destination surface in system memory
r20380r20381
223244   d3d_effect *            yiq_encode_effect;          // pointer to the YIQ encoder effect object
224245   d3d_effect *            yiq_decode_effect;          // pointer to the YIQ decoder effect object
225246#if HLSL_VECTOR
247    d3d_effect *            bloom_effect;               // pointer to the bloom composite effect
248    d3d_effect *            downsample_effect;          // pointer to the bloom downsample effect
226249   d3d_effect *            vector_effect;              // pointer to the vector-effect object
227250#endif
228251   d3d_vertex *            fsfx_vertices;              // pointer to our full-screen-quad object
trunk/src/emu/render.c
r20380r20381
17661766
17671767            // scale the width by the minimum of X/Y scale factors
17681768            prim->width = curitem->width() * MIN(container_xform.xscale, container_xform.yscale);
1769            prim->flags = curitem->flags();
1769            prim->flags |= curitem->flags();
17701770
17711771            // clip the primitive
17721772            clipped = render_clip_line(&prim->bounds, &cliprect);
r20380r20381
18191819
18201820               // no texture -- set the basic flags
18211821               prim->texture.base = NULL;
1822               prim->flags = PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
1822               prim->flags = (curitem->flags() &~ PRIMFLAG_BLENDMODE_MASK) | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA);
18231823
18241824               // apply clipping
18251825               clipped = render_clip_quad(&prim->bounds, &cliprect, NULL);
trunk/src/emu/inpttype.h
r20380r20381
621621   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_THROTTLE,         "Throttle",               input_seq(KEYCODE_F10) )
622622   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_FAST_FORWARD,     "Fast Forward",           input_seq(KEYCODE_INSERT) )
623623   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) )
624   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_SNAPSHOT,         "Save Snapshot",          input_seq(KEYCODE_F12, input_seq::not_code, KEYCODE_LSHIFT) )
624   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) )
625625   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_RECORD_MOVIE,     "Record Movie",           input_seq(KEYCODE_F12, KEYCODE_LSHIFT) )
626626   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_TOGGLE_CHEAT,     "Toggle Cheat",           input_seq(KEYCODE_F6) )
627627   INPUT_PORT_DIGITAL_TYPE( 0, UI,      UI_UP,               "UI Up",                  input_seq(KEYCODE_UP, input_seq::or_code, JOYCODE_Y_UP_SWITCH_INDEXED(0)) )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team