diff --git a/hlsl/color.fx b/hlsl/color.fx index 95881d71c2c..728e88ab85f 100644 --- a/hlsl/color.fx +++ b/hlsl/color.fx @@ -44,8 +44,7 @@ struct PS_INPUT // Post-Processing Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float2 RawDims; @@ -57,11 +56,9 @@ VS_OUTPUT vs_main(VS_INPUT Input) float2 invDims = 1.0f / RawDims; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; Output.TexCoord = Input.TexCoord + 0.5f * invDims; diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx index 1478dd23418..bcf3b2ee5a7 100644 --- a/hlsl/deconverge.fx +++ b/hlsl/deconverge.fx @@ -57,8 +57,7 @@ struct PS_INPUT uniform float3 ConvergeX = float3(0.0f, 0.0f, 0.0f); uniform float3 ConvergeY = float3(0.0f, 0.0f, 0.0f); -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float2 RawDims; @@ -76,11 +75,9 @@ VS_OUTPUT vs_main(VS_INPUT Input) float2 invDims = 1.0f / RawDims; float2 Ratios = SizeRatio; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; float2 TexCoord = Input.TexCoord; @@ -95,9 +92,6 @@ VS_OUTPUT vs_main(VS_INPUT Input) Output.CoordX = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RadialConvergeX / RawDims.x) + 0.5f) * Ratios.x + ConvergeX * invDims.x; Output.CoordY = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RadialConvergeY / RawDims.y) + 0.5f) * Ratios.y + ConvergeY * invDims.y; - //Output.RedCoord = (ScaledRatio * (1.0f + RadialRed / RawDims) + 0.5f) * SizeRatio + ConvergeRed * invDims; - //Output.GrnCoord = (ScaledRatio * (1.0f + RadialGrn / RawDims) + 0.5f) * SizeRatio + ConvergeGrn * invDims; - //Output.BluCoord = (ScaledRatio * (1.0f + RadialBlu / RawDims) + 0.5f) * SizeRatio + ConvergeBlu * invDims; Output.TexCoord = TexCoord; return Output; @@ -110,14 +104,10 @@ VS_OUTPUT vs_main(VS_INPUT Input) float4 ps_main(PS_INPUT Input) : COLOR { float Alpha = tex2D(DiffuseSampler, Input.TexCoord).a; - //float RedTexel = tex2D(DiffuseSampler, Input.RedCoord).r; - //float GrnTexel = tex2D(DiffuseSampler, Input.GrnCoord).g; - //float BluTexel = tex2D(DiffuseSampler, Input.BluCoord).b; float RedTexel = tex2D(DiffuseSampler, float2(Input.CoordX.x, Input.CoordY.x)).r; float GrnTexel = tex2D(DiffuseSampler, float2(Input.CoordX.y, Input.CoordY.y)).g; float BluTexel = tex2D(DiffuseSampler, float2(Input.CoordX.z, Input.CoordY.z)).b; - //return float4(Input.TexCoord, 0.0f, 1.0f); return float4(RedTexel, GrnTexel, BluTexel, Alpha); } diff --git a/hlsl/focus.fx b/hlsl/focus.fx index f51957d630c..6cb8cbdc56f 100644 --- a/hlsl/focus.fx +++ b/hlsl/focus.fx @@ -58,9 +58,7 @@ struct PS_INPUT // Simple Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; - +uniform float2 ScreenDims; uniform float2 Defocus = float2(0.0f, 0.0f); float2 Coord0Offset = float2( 0.0f, 0.0f); @@ -77,17 +75,14 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight); + float2 InvTexSize = 1.0f / ScreenDims; float2 TexCoord = Input.TexCoord; - TexCoord = TexCoord;// + float2(0.5f, -0.5f) * InvTexSize; Output.TexCoord0 = TexCoord + Coord0Offset * InvTexSize * Defocus; Output.TexCoord1 = TexCoord + Coord1Offset * InvTexSize * Defocus; Output.TexCoord2 = TexCoord + Coord2Offset * InvTexSize * Defocus; diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx index b1842fdf02a..99f7574e1f5 100644 --- a/hlsl/phosphor.fx +++ b/hlsl/phosphor.fx @@ -59,8 +59,7 @@ struct PS_INPUT // Simple Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float TextureWidth; uniform float TextureHeight; @@ -72,16 +71,14 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - float2 InvTexSize = float2(1.0f / TextureWidth, 1.0f / TextureHeight); - Output.TexCoord = Input.TexCoord + float2(0.5f, 0.5f) * InvTexSize; + float2 HalfTexOffset = 0.5f / float2(TextureWidth, TextureHeight); + Output.TexCoord = Input.TexCoord + HalfTexOffset; Output.PrevCoord = Output.TexCoord; return Output; diff --git a/hlsl/post.fx b/hlsl/post.fx index bbc924af8ed..e8213b345f2 100644 --- a/hlsl/post.fx +++ b/hlsl/post.fx @@ -57,8 +57,7 @@ struct PS_INPUT // Scanline & Shadowmask Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float2 RawDims; @@ -69,14 +68,12 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - Output.TexCoord = Input.TexCoord + 0.5f / RawDims;//float2(TargetWidth, TargetHeight); + Output.TexCoord = Input.TexCoord + 0.5f / RawDims; return Output; } @@ -120,7 +117,7 @@ float4 ps_main(PS_INPUT Input) : COLOR float PincushionR2 = pow(length(PinUnitCoord), 2.0f) / pow(length(Ratios), 2.0f); float2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2; float2 BaseCoord = Input.TexCoord; - float2 ScanCoord = BaseCoord - 0.5f / float2(TargetWidth, TargetHeight); + float2 ScanCoord = BaseCoord - 0.5f / ScreenDims; BaseCoord -= 0.5f / Ratios; BaseCoord *= 1.0f - PincushionAmount * Ratios * 0.2f; // Warning: Magic constant diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx index 3c207875ca2..c4aa19d86c0 100644 --- a/hlsl/prescale.fx +++ b/hlsl/prescale.fx @@ -42,24 +42,20 @@ struct PS_INPUT // Passthrough Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; - uniform float2 RawDims; +uniform float2 ScreenDims; VS_OUTPUT vs_main(VS_INPUT Input) { VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); - Output.TexCoord = Input.TexCoord + 0.5f / float2(TargetWidth, TargetHeight); + Output.TexCoord = Input.TexCoord + 0.5f / ScreenDims; return Output; } @@ -70,12 +66,6 @@ VS_OUTPUT vs_main(VS_INPUT Input) float4 ps_main(PS_INPUT Input) : COLOR { - //float2 TexCoord = Input.TexCoord * RawDims; - //TexCoord -= frac(TexCoord); - //TexCoord += 0.5f; - //TexCoord /= RawDims; - // - //return tex2D(DiffuseSampler, TexCoord); return tex2D(DiffuseSampler, Input.TexCoord); } diff --git a/hlsl/primary.fx b/hlsl/primary.fx index 472c2dc4692..4abf9a60f8b 100644 --- a/hlsl/primary.fx +++ b/hlsl/primary.fx @@ -44,8 +44,7 @@ struct PS_INPUT // Simple Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float PostPass; uniform float FixedAlpha; uniform float Brighten; @@ -55,14 +54,12 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - Output.TexCoord = lerp(Input.TexCoord, Input.Position.xy / float2(TargetWidth, TargetHeight), PostPass); + Output.TexCoord = lerp(Input.TexCoord, Input.Position.xy / ScreenDims, PostPass); return Output; } diff --git a/hlsl/vector.fx b/hlsl/vector.fx index 89072253e88..295a6111ceb 100644 --- a/hlsl/vector.fx +++ b/hlsl/vector.fx @@ -33,8 +33,7 @@ struct PS_INPUT // Simple Vertex Shader //----------------------------------------------------------------------------- -uniform float TargetWidth; -uniform float TargetHeight; +uniform float2 ScreenDims; uniform float2 TimeParams; uniform float3 LengthParams; @@ -43,14 +42,12 @@ VS_OUTPUT vs_main(VS_INPUT Input) VS_OUTPUT Output = (VS_OUTPUT)0; Output.Position = float4(Input.Position.xyz, 1.0f); - Output.Position.x /= TargetWidth; - Output.Position.y /= TargetHeight; + Output.Position.xy /= ScreenDims; Output.Position.y = 1.0f - Output.Position.y; - Output.Position.x -= 0.5f; - Output.Position.y -= 0.5f; + Output.Position.xy -= 0.5f; Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); Output.Color = Input.Color; - Output.TexCoord = Input.Position.xy / float2(TargetWidth, TargetHeight); + Output.TexCoord = Input.Position.xy / ScreenDims; Output.LineInfo = Input.LineInfo; return Output; } diff --git a/src/osd/windows/d3d9intf.c b/src/osd/windows/d3d9intf.c index 2e1bc29b873..828776f44e1 100644 --- a/src/osd/windows/d3d9intf.c +++ b/src/osd/windows/d3d9intf.c @@ -685,6 +685,124 @@ static const vertex_buffer_interface d3d9_vertex_buffer_interface = // Direct3DEffect interfaces //============================================================ +uniform::uniform(effect *shader, const char *name, uniform_type type) +{ + m_shader = shader; + m_type = type; + m_next = NULL; + m_prev = NULL; + m_handle = m_shader->get_parameter(NULL, name); + m_ival = 0; + memset(m_vec, 0, sizeof(float) * 4); + m_mval = NULL; + m_texture = NULL; + + switch (type) + { + case UT_INT: + case UT_FLOAT: + case UT_MATRIX: + case UT_SAMPLER: + m_count = 1; + break; + case UT_VEC2: + m_count = 2; + break; + case UT_VEC3: + m_count = 3; + break; + case UT_VEC4: + m_count = 4; + break; + default: + m_count = 1; + break; + } +} + +void uniform::set_next(uniform *next) +{ + m_next->set_prev(next); + next->set_next(m_next); + + next->set_prev(this); + m_next = next; +} + +void uniform::set_prev(uniform *prev) +{ + m_prev->set_next(prev); + prev->set_prev(m_prev); + + prev->set_next(this); + m_prev = prev; +} + +void uniform::set(float x, float y, float z, float w) +{ + m_vec[0] = x; + m_vec[1] = y; + m_vec[2] = z; + m_vec[3] = w; +} + +void uniform::set(float x, float y, float z) +{ + m_vec[0] = x; + m_vec[1] = y; + m_vec[2] = z; +} + +void uniform::set(float x, float y) +{ + m_vec[0] = x; + m_vec[1] = y; +} + +void uniform::set(float x) +{ + m_vec[0] = x; +} + +void uniform::set(int x) +{ + m_ival = x; +} + +void uniform::set(matrix *mat) +{ + m_mval = mat; +} + +void uniform::set(texture *tex) +{ + m_texture = tex; +} + +void uniform::upload() +{ + switch(m_type) + { + case UT_INT: + m_shader->set_int(m_handle, m_ival); + break; + case UT_FLOAT: + m_shader->set_float(m_handle, m_vec[0]); + break; + case UT_VEC2: + case UT_VEC3: + case UT_VEC4: + m_shader->set_vector(m_handle, m_count, m_vec); + break; + case UT_MATRIX: + m_shader->set_matrix(m_handle, m_mval); + break; + case UT_SAMPLER: + m_shader->set_texture(m_handle, m_texture); + break; + } +} + effect::effect(device *dev, const char *name, const char *path) { IDirect3DDevice9 *device = (IDirect3DDevice9 *)dev; @@ -783,6 +901,11 @@ void effect::set_texture(D3DXHANDLE param, texture *tex) m_effect->SetTexture(param, (IDirect3DTexture9*)tex); } +D3DXHANDLE effect::get_parameter(D3DXHANDLE param, const char *name) +{ + return m_effect->GetParameterByName(param, name); +} + ULONG effect::release() { return m_effect->Release(); diff --git a/src/osd/windows/d3dhlsl.c b/src/osd/windows/d3dhlsl.c index 93f5a002dfb..dd8237b729a 100644 --- a/src/osd/windows/d3dhlsl.c +++ b/src/osd/windows/d3dhlsl.c @@ -1055,8 +1055,8 @@ void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYP curr_effect->set_texture("Diffuse", src); - curr_effect->set_float("TargetWidth", (float)dstw); - curr_effect->set_float("TargetHeight", (float)dsth); + float dst_dims[2] = { (float)dstw, (float)dsth }; + curr_effect->set_vector("ScreenDims", 2, dst_dims); curr_effect->set_float("PostPass", 1.0f); curr_effect->set_float("PincushionAmount", options->pincushion); curr_effect->set_float("Brighten", 0.0f); @@ -1102,8 +1102,8 @@ void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYP curr_effect->set_texture("Diffuse", src); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_float("ScreenWidth", (float)d3d->get_width()); curr_effect->set_float("ScreenHeight", (float)d3d->get_height()); curr_effect->set_float("PostPass", 1.0f); @@ -1211,8 +1211,8 @@ void shaders::init_effect_info(poly_info *poly) vec2f delta = texture->get_uvstop() - texture->get_uvstart(); curr_effect->set_vector("RawDims", 2, &texture->get_rawdims().c.x); curr_effect->set_vector("SizeRatio", 2, &delta.c.x); - curr_effect->set_float("TargetWidth", d3d->get_width()); - curr_effect->set_float("TargetHeight", d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("Floor", 3, options->floor); curr_effect->set_float("SnapX", snap_width); curr_effect->set_float("SnapY", snap_height); @@ -1316,6 +1316,7 @@ void shaders::ntsc_pass(render_target *rt, texture_info *texture, vec2f &texsize curr_effect->set_float("HeightRatio", 1.0f / delta.c.y); curr_effect->set_float("ScreenWidth", d3d->get_width()); curr_effect->set_float("ScreenHeight", d3d->get_height()); + curr_effect->set_float("CCValue", options->yiq_cc); curr_effect->set_float("AValue", options->yiq_a); curr_effect->set_float("BValue", options->yiq_b); @@ -1358,6 +1359,7 @@ void shaders::ntsc_pass(render_target *rt, texture_info *texture, vec2f &texsize curr_effect->set_float("HeightRatio", 1.0f / delta.c.y); curr_effect->set_float("ScreenWidth", d3d->get_width()); curr_effect->set_float("ScreenHeight", d3d->get_height()); + curr_effect->set_float("CCValue", options->yiq_cc); curr_effect->set_float("AValue", options->yiq_a); curr_effect->set_float("BValue", options->yiq_b); @@ -1406,8 +1408,9 @@ void shaders::color_convolution_pass(render_target *rt, texture_info *texture, v if(options->params_dirty) { curr_effect->set_vector("RawDims", 2, &rawdims.c.x); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); + curr_effect->set_float("YIQEnable", options->yiq_enable ? 1.0f : 0.0f); curr_effect->set_vector("RedRatios", 3, options->red_ratio); curr_effect->set_vector("GrnRatios", 3, options->grn_ratio); @@ -1447,8 +1450,8 @@ void shaders::prescale_pass(render_target *rt, texture_info *texture, vec2f &tex if(options->params_dirty) { - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("RawDims", 2, &rawdims.c.x); } @@ -1481,8 +1484,8 @@ void shaders::deconverge_pass(render_target *rt, texture_info *texture, vec2f &t if(options->params_dirty) { - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("RawDims", 2, &rawdims.c.x); curr_effect->set_vector("SizeRatio", 2, &delta.c.x); curr_effect->set_vector("ConvergeX", 3, options->converge_x); @@ -1520,8 +1523,8 @@ void shaders::defocus_pass(render_target *rt, texture_info *texture, vec2f &texs curr_effect->set_texture("Diffuse", rt->render_texture[2]); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("Defocus", 2, &options->defocus[0]); curr_effect->begin(&num_passes, 0); @@ -1546,8 +1549,7 @@ void shaders::defocus_pass(render_target *rt, texture_info *texture, vec2f &texs curr_effect->set_texture("Diffuse", rt->render_texture[0]); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("Defocus", 2, &options->defocus[1]); curr_effect->begin(&num_passes, 0); @@ -1576,8 +1578,8 @@ void shaders::phosphor_pass(render_target *rt, cache_target *ct, texture_info *t if(options->params_dirty) { - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("Phosphor", 3, options->phosphor); } curr_effect->set_float("TextureWidth", (float)rt->target_width); @@ -1637,8 +1639,9 @@ void shaders::avi_post_pass(render_target *rt, texture_info *texture, vec2f &tex UINT num_passes = 0; curr_effect = post_effect; - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); // Scanlines and shadow mask, at high res for AVI logging if(avi_output_file != NULL) @@ -1696,19 +1699,15 @@ void shaders::screen_post_pass(render_target *rt, texture_info *texture, vec2f & curr_effect->set_texture("Diffuse", rt->render_texture[0]); curr_effect->set_vector("RawDims", 2, &rawdims.c.x); curr_effect->set_vector("SizeRatio", 2, &delta.c.x); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); d3d->set_wrap(D3DTADDRESS_MIRROR); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); - HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, rt->target[2]); - d3d->set_wrap(D3DTADDRESS_MIRROR); result = (*d3dintf->device.clear)(d3d->get_device(), 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result); - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); curr_effect->begin(&num_passes, 0); @@ -1743,8 +1742,8 @@ void shaders::raster_bloom_pass(render_target *rt, texture_info *texture, vec2f float prim_width = poly->get_prim_width(); float prim_height = poly->get_prim_height(); float prim_ratio[2] = { prim_width / bloom_width, prim_height / bloom_height }; - float screen_size[2] = { d3d->get_width(), d3d->get_height() }; - curr_effect->set_vector("ScreenSize", 2, screen_size); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenSize", 2, &screendims.c.x); for(; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f) { float target_size[2] = { bloom_width, bloom_height }; @@ -1779,8 +1778,7 @@ void shaders::raster_bloom_pass(render_target *rt, texture_info *texture, vec2f curr_effect = bloom_effect; - float target_size[2] = { d3d->get_width(), d3d->get_height() }; - curr_effect->set_vector("TargetSize", 2, target_size); + curr_effect->set_vector("TargetSize", 2, &screendims.c.x); float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight, options->bloom_level2_weight, options->bloom_level3_weight }; float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight, @@ -1790,7 +1788,7 @@ void shaders::raster_bloom_pass(render_target *rt, texture_info *texture, vec2f curr_effect->set_vector("Level0123Weight", 4, weight0123); curr_effect->set_vector("Level4567Weight", 4, weight4567); curr_effect->set_vector("Level89AWeight", 3, weight89A); - curr_effect->set_vector("TargetSize", 2, target_size); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_texture("DiffuseA", rt->render_texture[2]); curr_effect->set_float("DiffuseScaleA", 1.0f); @@ -1891,8 +1889,8 @@ void shaders::render_quad(poly_info *poly, int vertnum) if(options->params_dirty) { - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); } float time_params[2] = { 0.0f, 0.0f }; @@ -2043,8 +2041,8 @@ void shaders::render_quad(poly_info *poly, int vertnum) if(options->params_dirty) { - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_vector("Phosphor", 3, options->phosphor); } curr_effect->set_float("TextureWidth", (float)d3d->get_width()); @@ -2088,8 +2086,8 @@ void shaders::render_quad(poly_info *poly, int vertnum) { curr_effect = default_effect; - curr_effect->set_float("TargetWidth", (float)d3d->get_width()); - curr_effect->set_float("TargetHeight", (float)d3d->get_height()); + vec2f screendims = d3d->get_dims(); + curr_effect->set_vector("ScreenDims", 2, &screendims.c.x); curr_effect->set_float("PostPass", 0.0f); curr_effect->begin(&num_passes, 0); diff --git a/src/osd/windows/d3dintf.h b/src/osd/windows/d3dintf.h index 201d0d26d5e..a5fd1bd0314 100644 --- a/src/osd/windows/d3dintf.h +++ b/src/osd/windows/d3dintf.h @@ -77,9 +77,54 @@ struct device; struct surface; struct texture; struct vertex_buffer; +class effect; typedef D3DXVECTOR4 vector; typedef D3DMATRIX matrix; +class uniform +{ +public: + typedef enum + { + UT_VEC4, + UT_VEC3, + UT_VEC2, + UT_FLOAT, + UT_INT, + UT_MATRIX, + UT_SAMPLER, + } uniform_type; + + uniform(effect *shader, const char *name, uniform_type type); + + void set_next(uniform *next); + void set_prev(uniform *prev); + + void set(float x, float y, float z, float w); + void set(float x, float y, float z); + void set(float x, float y); + void set(float x); + void set(int x); + void set(matrix *mat); + void set(texture *tex); + + void upload(); + +protected: + uniform *m_next; + uniform *m_prev; + + float m_vec[4]; + int m_ival; + matrix *m_mval; + texture *m_texture; + int m_count; + uniform_type m_type; + + effect *m_shader; + D3DXHANDLE m_handle; +}; + class effect { public: diff --git a/src/osd/windows/drawd3d.h b/src/osd/windows/drawd3d.h index 6ab48555f21..f22838a030b 100644 --- a/src/osd/windows/drawd3d.h +++ b/src/osd/windows/drawd3d.h @@ -177,6 +177,7 @@ public: // Setters / getters int get_adapter() { return m_adapter; } int get_width() { return m_width; } + vec2f get_dims() { return vec2f(m_width, m_height); } int get_height() { return m_height; } int get_refresh() { return m_refresh; } diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 60828a1cfc7..44c0ade7d95 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -677,6 +677,7 @@ void winwindow_video_window_create(running_machine &machine, int index, win_moni // allocate a new window object window = global_alloc_clear(win_window_info(machine)); + printf("%d, %d\n", config->width, config->height); window->maxwidth = config->width; window->maxheight = config->height; window->refresh = config->refresh; diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index bf0df5348f0..c5b077f06a8 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -318,6 +318,7 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, { WINOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, { WINOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, + { WINOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, { WINOPTION_PRESCALE, "1", OPTION_INTEGER, "scale screen rendering by this amount in software" }, { WINOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, { WINOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index da482d74cc6..e84adc5425b 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -66,6 +66,7 @@ #define WINOPTION_WINDOW "window" #define WINOPTION_MAXIMIZE "maximize" #define WINOPTION_KEEPASPECT "keepaspect" +#define WINOPTION_UNEVENSTRETCH "unevenstretch" #define WINOPTION_PRESCALE "prescale" #define WINOPTION_WAITVSYNC "waitvsync" #define WINOPTION_SYNCREFRESH "syncrefresh" @@ -193,6 +194,7 @@ public: bool window() const { return bool_value(WINOPTION_WINDOW); } bool maximize() const { return bool_value(WINOPTION_MAXIMIZE); } bool keep_aspect() const { return bool_value(WINOPTION_KEEPASPECT); } + bool uneven_stretch() const { return bool_value(WINOPTION_UNEVENSTRETCH); } int prescale() const { return int_value(WINOPTION_PRESCALE); } bool wait_vsync() const { return bool_value(WINOPTION_WAITVSYNC); } bool sync_refresh() const { return bool_value(WINOPTION_SYNCREFRESH); }