[PATCH] WineD3D: The final luminance factor is clamped=0A=

Stefan Doesinger stefan at codeweavers.com
Wed Aug 20 10:23:25 CDT 2008


=0A=
---=0A=
 dlls/d3d9/tests/visual.c          |   44 =
++++++++++++++++++++++++++++++++++++-=0A=
 dlls/wined3d/arb_program_shader.c |    5 ++-=0A=
 2 files changed, 46 insertions(+), 3 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c=0A=
index 6562187..d36411f 100644=0A=
--- a/dlls/d3d9/tests/visual.c=0A=
+++ b/dlls/d3d9/tests/visual.c=0A=
@@ -7860,7 +7860,49 @@ static void =
fixed_function_bumpmap_test(IDirect3DDevice9 *device)=0A=
      * green: 0.5  * (0.25 * 2.0 + 0.1) =3D 0.5  * 0.6 =3D 0.3  =3D 0x4c=0A=
      * green: 0.75 * (0.25 * 2.0 + 0.1) =3D 0.75 * 0.6 =3D 0.45 =3D 0x72=0A=
      */=0A=
-    ok(color_match(color, 0x00994c72, 2), "bumpmap failed: Got color =
0x%08x, expected 0x00ffffff.\n", color);=0A=
+    ok(color_match(color, 0x00994c72, 3), "bumpmap failed: Got color =
0x%08x, expected 0x00994c72.\n", color);=0A=
+=0A=
+    /* Check a result scale factor > 1.0 */=0A=
+    scale =3D 10;=0A=
+    hr =3D IDirect3DDevice9_SetTextureStageState(device, 0, =
D3DTSS_BUMPENVLSCALE, *((DWORD *)&scale));=0A=
+    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);=0A=
+    offset =3D 10;=0A=
+    hr =3D IDirect3DDevice9_SetTextureStageState(device, 0, =
D3DTSS_BUMPENVLOFFSET, *((DWORD *)&offset));=0A=
+    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);=0A=
+=0A=
+    hr =3D IDirect3DDevice9_BeginScene(device);=0A=
+    ok(SUCCEEDED(hr), "BeginScene failed (0x%08x)\n", hr);=0A=
+    if(SUCCEEDED(hr)) {=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));=0A=
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (0x%08x)\n", hr);=0A=
+        hr =3D IDirect3DDevice9_EndScene(device);=0A=
+        ok(SUCCEEDED(hr), "EndScene failed (0x%08x)\n", hr);=0A=
+    }=0A=
+    hr =3D IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);=0A=
+    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);=0A=
+    color =3D getPixelColor(device, 320, 240);=0A=
+    ok(color_match(color, 0x00ff80c0, 1), "bumpmap failed: Got color =
0x%08x, expected 0x00ff80c0.\n", color);=0A=
+=0A=
+    /* Check clamping in the scale factor calculation */=0A=
+    scale =3D 1000;=0A=
+    hr =3D IDirect3DDevice9_SetTextureStageState(device, 0, =
D3DTSS_BUMPENVLSCALE, *((DWORD *)&scale));=0A=
+    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);=0A=
+    offset =3D -1;=0A=
+    hr =3D IDirect3DDevice9_SetTextureStageState(device, 0, =
D3DTSS_BUMPENVLOFFSET, *((DWORD *)&offset));=0A=
+    ok(SUCCEEDED(hr), "SetTextureStageState failed (%08x)\n", hr);=0A=
+=0A=
+    hr =3D IDirect3DDevice9_BeginScene(device);=0A=
+    ok(SUCCEEDED(hr), "BeginScene failed (0x%08x)\n", hr);=0A=
+    if(SUCCEEDED(hr)) {=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_TRIANGLESTRIP, 2, &quad[0], sizeof(quad[0]));=0A=
+        ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (0x%08x)\n", hr);=0A=
+        hr =3D IDirect3DDevice9_EndScene(device);=0A=
+        ok(SUCCEEDED(hr), "EndScene failed (0x%08x)\n", hr);=0A=
+    }=0A=
+    hr =3D IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);=0A=
+    ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);=0A=
+    color =3D getPixelColor(device, 320, 240);=0A=
+    ok(color_match(color, 0x00ff80c0, 1), "bumpmap failed: Got color =
0x%08x, expected 0x00ff80c0.\n", color);=0A=
 =0A=
     hr =3D IDirect3DDevice9_SetTexture(device, 0, NULL);=0A=
     ok(SUCCEEDED(hr), "IDirect3DDevice9_SetTexture failed (%08x)\n", =
hr);=0A=
diff --git a/dlls/wined3d/arb_program_shader.c =
b/dlls/wined3d/arb_program_shader.c=0A=
index 0d8c4eb..99cc130 100644=0A=
--- a/dlls/wined3d/arb_program_shader.c=0A=
+++ b/dlls/wined3d/arb_program_shader.c=0A=
@@ -2555,7 +2555,8 @@ static void gen_ffp_instr(SHADER_BUFFER *buffer, =
unsigned int stage, BOOL color,=0A=
             break;=0A=
 =0A=
         case WINED3DTOP_BLENDTEXTUREALPHAPM:=0A=
-            shader_addline(buffer, "SUB arg0.a, const.x, %s;\n", arg1);=0A=
+            arg0 =3D get_argreg(buffer, 0, stage, WINED3DTA_TEXTURE);=0A=
+            shader_addline(buffer, "SUB arg0.a, const.x, %s.a;\n", =
arg0);=0A=
             shader_addline(buffer, "MAD_SAT %s%s, %s, arg0.a, %s;\n", =
dstreg, dstmask, arg2, arg1);=0A=
             break;=0A=
 =0A=
@@ -2776,7 +2777,7 @@ static GLuint gen_arbfp_ffp_shader(struct =
ffp_settings *settings, IWineD3DStateB=0A=
             shader_addline(&buffer, "TEX%s tex%u, ret, texture[%u], =
%s;\n",=0A=
                             sat, stage, stage, textype);=0A=
             if(settings->op[stage - 1].cop =3D=3D =
WINED3DTOP_BUMPENVMAPLUMINANCE) {=0A=
-                shader_addline(&buffer, "MAD ret.r, tex%u.b, =
luminance%u.r, luminance%u.g;\n",=0A=
+                shader_addline(&buffer, "MAD_SAT ret.r, tex%u.b, =
luminance%u.r, luminance%u.g;\n",=0A=
                                stage - 1, stage - 1, stage - 1);=0A=
                 shader_addline(&buffer, "MUL tex%u, tex%u, ret.r;\n", =
stage, stage);=0A=
             }=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_000F_01C90695.93843A60--




More information about the wine-patches mailing list