[PATCH] d3d9: test psize_min vs psize_max vs psize behavior=0A=

Stefan Doesinger stefan at codeweavers.com
Fri Nov 7 17:02:54 CST 2008


=0A=
This patch adds a test that checks what happens if D3DRS_POINTSIZE, =
D3DRS_POINTSIZE_MIN=0A=
and POINTSIZE_MAX have conflicting values. D3DRS_POINTSIZE_MAX trumps=0A=
D3DRS_POINTSIZE_MIN, and both MIN and MAX clamp the D3DRS_POINTSIZE =
value if it is=0A=
outside of their range.=0A=
=0A=
The clamping behavior already exists in opengl, but in GL =
GL_POINT_SIZE_MIN_ARB overrides=0A=
GL_POINT_SIZE_MAX_ARB(the reverse behavior of d3d), so the state =
handlers for MIN and MAX=0A=
are adjusted=0A=
---=0A=
 dlls/d3d9/tests/visual.c |   72 =
++++++++++++++++++++++++++++++++++++++++++++-=0A=
 dlls/wined3d/state.c     |   71 =
+++++++++++++++++++--------------------------=0A=
 2 files changed, 100 insertions(+), 43 deletions(-)=0A=
=0A=
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c=0A=
index 3caa08f..32031e4 100644=0A=
--- a/dlls/d3d9/tests/visual.c=0A=
+++ b/dlls/d3d9/tests/visual.c=0A=
@@ -8324,7 +8324,7 @@ static void pointsize_test(IDirect3DDevice9 =
*device)=0A=
     D3DCAPS9 caps;=0A=
     D3DMATRIX matrix;=0A=
     D3DMATRIX identity;=0A=
-    float ptsize, ptsize_orig;=0A=
+    float ptsize, ptsize_orig, ptsizemax_orig, ptsizemin_orig;=0A=
     DWORD color;=0A=
 =0A=
     const float vertices[] =3D {=0A=
@@ -8333,7 +8333,10 @@ static void pointsize_test(IDirect3DDevice9 =
*device)=0A=
         192,    64,     0.1,=0A=
         256,    64,     0.1,=0A=
         320,    64,     0.1,=0A=
-        384,    64,     0.1=0A=
+        384,    64,     0.1,=0A=
+        448,    64,     0.1,=0A=
+        512,    64,     0.1,=0A=
+        576,    64,     0.1,=0A=
     };=0A=
 =0A=
     /* Transforms the coordinate system [-1.0;1.0]x[-1.0;1.0] to =
[0.0;0.0]x[640.0;480.0]. Z is untouched */=0A=
@@ -8405,6 +8408,51 @@ static void pointsize_test(IDirect3DDevice9 =
*device)=0A=
         hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_POINTLIST, 1, &vertices[12], sizeof(float) * 3);=0A=
         ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, =
hr=3D%08x\n", hr);=0A=
 =0A=
+        hr =3D IDirect3DDevice9_GetRenderState(device, =
D3DRS_POINTSIZE_MAX, (DWORD *) (&ptsizemax_orig));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_GetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_GetRenderState(device, =
D3DRS_POINTSIZE_MAX, (DWORD *) (&ptsizemin_orig));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_GetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
+        /* What happens if point scaling is disabled, and POINTSIZE_MAX =
< POINTSIZE? */=0A=
+        ptsize =3D 16.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, =
*((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        ptsize =3D 1.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, =
D3DRS_POINTSIZE_MAX, *((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_POINTLIST, 1, &vertices[18], sizeof(float) * 3);=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
+        /* What happens if POINTSIZE_MAX < POINTSIZE_MIN?=0A=
+         * ptsize =3D 4.0, ptsize_max =3D 1.0, ptsize_min =3D 16.0=0A=
+         */=0A=
+        ptsize =3D 4.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, =
*((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        ptsize =3D 16.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, =
D3DRS_POINTSIZE_MIN, *((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_POINTLIST, 1, &vertices[21], sizeof(float) * 3);=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, =
D3DRS_POINTSIZE_MAX, *((DWORD *) (&ptsizemax_orig)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
+        /* pointsize < pointsize_min < pointsize_max?=0A=
+         * pointsize =3D 1.0, pointsize_min =3D 16.0, pointsize_max =3D =
default(usually 64.0)=0A=
+         */=0A=
+        ptsize =3D 1.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, =
*((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        ptsize =3D 16.0;=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, =
D3DRS_POINTSIZE_MIN, *((DWORD *) (&ptsize)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+        hr =3D IDirect3DDevice9_DrawPrimitiveUP(device, =
D3DPT_POINTLIST, 1, &vertices[24], sizeof(float) * 3);=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
+        hr =3D IDirect3DDevice9_SetRenderState(device, =
D3DRS_POINTSIZE_MIN, *((DWORD *) (&ptsizemin_orig)));=0A=
+        ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed, =
hr=3D%08x\n", hr);=0A=
+=0A=
         hr =3D IDirect3DDevice9_EndScene(device);=0A=
         ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_EndScene failed =
hr=3D%08x\n", hr);=0A=
     }=0A=
@@ -8483,6 +8531,26 @@ static void pointsize_test(IDirect3DDevice9 =
*device)=0A=
     color =3D getPixelColor(device, 320+1, 64+1);=0A=
     ok(color =3D=3D 0x000000ff, "pSize: Pixel (320+1),(64+1) has color =
0x%08x, expected 0x000000ff\n", color);=0A=
 =0A=
+    /* ptsize =3D 16, ptsize_max =3D 1 --> point has size 1 */=0A=
+    color =3D getPixelColor(device, 448-4, 64-4);=0A=
+    ok(color =3D=3D 0x000000ff, "pSize: Pixel (448-4),(64-4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+    color =3D getPixelColor(device, 448+4, 64+4);=0A=
+    ok(color =3D=3D 0x000000ff, "pSize: Pixel (448+4),(64+4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+=0A=
+    /* ptsize =3D 4, ptsize_max =3D 1, ptsize_min =3D 16 --> point has =
size 1 */=0A=
+    color =3D getPixelColor(device, 512-4, 64-4);=0A=
+    ok(color =3D=3D 0x000000ff, "pSize: Pixel (448-4),(64-4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+    color =3D getPixelColor(device, 512+4, 64+4);=0A=
+    ok(color =3D=3D 0x000000ff, "pSize: Pixel (448+4),(64+4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+=0A=
+    /* ptsize =3D 1, ptsize_max =3D default(64), ptsize_min =3D 16 --> =
point has size 16=0A=
+     * Don't be overly picky - just show that the point is bigger than =
1 pixel=0A=
+     */=0A=
+    color =3D getPixelColor(device, 576-4, 64-4);=0A=
+    ok(color =3D=3D 0x00ffffff, "pSize: Pixel (448-4),(64-4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+    color =3D getPixelColor(device, 576+4, 64+4);=0A=
+    ok(color =3D=3D 0x00ffffff, "pSize: Pixel (448+4),(64+4) has color =
0x%08x, expected 0x00ffffff\n", color);=0A=
+=0A=
     hr =3D IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, =
*((DWORD *) (&ptsize_orig)));=0A=
     ok(hr =3D=3D D3D_OK, "IDirect3DDevice9_SetRenderState failed =
hr=3D%08x\n", hr);=0A=
     hr =3D IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, =
&identity);=0A=
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c=0A=
index 573c23c..b9d28d4 100644=0A=
--- a/dlls/wined3d/state.c=0A=
+++ b/dlls/wined3d/state.c=0A=
@@ -1410,16 +1410,30 @@ static void state_psizemin_w(DWORD state, =
IWineD3DStateBlockImpl *stateblock, Wi=0A=
     if(tmpvalue.f !=3D 1.0) {=0A=
         FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, =
value is %f\n", tmpvalue.f);=0A=
     }=0A=
+    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
+    if(tmpvalue.f !=3D 64.0) {=0A=
+        FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, =
value is %f\n", tmpvalue.f);=0A=
+    }=0A=
+=0A=
 }=0A=
 =0A=
 static void state_psizemin_ext(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
     union {=0A=
         DWORD d;=0A=
         float f;=0A=
-    } tmpvalue;=0A=
+    } min, max;=0A=
 =0A=
-    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MIN];=0A=
-    GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);=0A=
+    min.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MIN];=0A=
+    max.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
+=0A=
+    /* Max point size trumps min point size */=0A=
+    if(min.f > max.f) {=0A=
+        min.f =3D max.f;=0A=
+    }=0A=
+=0A=
+    GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, min.f);=0A=
+    checkGLcall("glPointParameterfEXT(...)");=0A=
+    GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, max.f);=0A=
     checkGLcall("glPointParameterfEXT(...)");=0A=
 }=0A=
 =0A=
@@ -1427,45 +1441,20 @@ static void state_psizemin_arb(DWORD state, =
IWineD3DStateBlockImpl *stateblock,=0A=
     union {=0A=
         DWORD d;=0A=
         float f;=0A=
-    } tmpvalue;=0A=
+    } min, max;=0A=
 =0A=
-    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MIN];=0A=
-    GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, tmpvalue.f);=0A=
-    checkGLcall("glPointParameterfARB(...)");=0A=
-}=0A=
+    min.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MIN];=0A=
+    max.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
 =0A=
-static void state_psizemax_arb(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
-    union {=0A=
-        DWORD d;=0A=
-        float f;=0A=
-    } tmpvalue;=0A=
+    /* Max point size trumps min point size */=0A=
+    if(min.f > max.f) {=0A=
+        min.f =3D max.f;=0A=
+    }=0A=
 =0A=
-    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
-    GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, tmpvalue.f);=0A=
+    GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, min.f);=0A=
+    checkGLcall("glPointParameterfARB(...)");=0A=
+    GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, max.f);=0A=
     checkGLcall("glPointParameterfARB(...)");=0A=
-}=0A=
-=0A=
-static void state_psizemax_ext(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
-    union {=0A=
-        DWORD d;=0A=
-        float f;=0A=
-    } tmpvalue;=0A=
-=0A=
-    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
-    GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);=0A=
-    checkGLcall("glPointParameterfEXT(...)");=0A=
-}=0A=
-=0A=
-static void state_psizemax_w(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
-    union {=0A=
-        DWORD d;=0A=
-        float f;=0A=
-    } tmpvalue;=0A=
-=0A=
-    tmpvalue.d =3D stateblock->renderState[WINED3DRS_POINTSIZE_MAX];=0A=
-    if(tmpvalue.f !=3D 64.0) {=0A=
-        FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, =
value is %f\n", tmpvalue.f);=0A=
-    }=0A=
 }=0A=
 =0A=
 static void state_pscale(DWORD state, IWineD3DStateBlockImpl =
*stateblock, WineD3DContext *context) {=0A=
@@ -5320,9 +5309,9 @@ const struct StateEntryTemplate =
ffp_vertexstate_template[] =3D {=0A=
     { STATE_RENDER(WINED3DRS_POINTSCALE_A),               { =
STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        =
}, 0                               },=0A=
     { STATE_RENDER(WINED3DRS_POINTSCALE_B),               { =
STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        =
}, 0                               },=0A=
     { STATE_RENDER(WINED3DRS_POINTSCALE_C),               { =
STATE_RENDER(WINED3DRS_POINTSCALEENABLE),           state_pscale        =
}, 0                               },=0A=
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              state_psizemax_arb  =
}, ARB_POINT_PARAMETERS            },=0A=
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              state_psizemax_ext  =
}, EXT_POINT_PARAMETERS            },=0A=
-    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              state_psizemax_w    =
}, 0                               },=0A=
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_arb  =
}, ARB_POINT_PARAMETERS            },=0A=
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_ext  =
}, EXT_POINT_PARAMETERS            },=0A=
+    { STATE_RENDER(WINED3DRS_POINTSIZE_MAX),              { =
STATE_RENDER(WINED3DRS_POINTSIZE_MIN),              state_psizemin_w    =
}, 0                               },=0A=
     /* pixel shaders need a different fog input */=0A=
     { STATE_PIXELSHADER,                                  { =
STATE_PIXELSHADER,                                  apply_pshader_fog   =
}, 0                               },=0A=
     /* Samplers for NP2 texture matrix adjustions. They are not needed =
if GL_ARB_texture_non_power_of_two is supported,=0A=
-- =0A=
1.5.6.4=0A=
=0A=

------=_NextPart_000_0029_01C94A69.B4358E40--




More information about the wine-patches mailing list