wined3d: Don't call glPixelParameter with a random context.

Matteo Bruni matteo.mystral at gmail.com
Fri Jan 7 07:41:55 CST 2011


-------------- next part --------------
From 7c1586082b6031588fa247d5ffe66ce25209fcf2 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Fri, 7 Jan 2011 01:16:18 +0100
Subject: wined3d: Don't call glPixelParameter with a random context.

---
 dlls/wined3d/context.c         |   37 +------------------------------------
 dlls/wined3d/state.c           |   32 ++++++++++++++++++++++++++++++++
 dlls/wined3d/utils.c           |    2 ++
 dlls/wined3d/wined3d_private.h |    5 ++++-
 4 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index f9b99b9..8edcf66 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1575,23 +1575,6 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
         checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
     }
 
-    if (gl_info->supported[WINED3D_GL_VERSION_2_0])
-    {
-        /* Windows doesn't support to query the glPointParameteri function pointer, so use the
-         * NV_POINT_SPRITE extension.
-         */
-        if (glPointParameteri)
-        {
-            glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT);
-            checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
-        }
-        else if (gl_info->supported[NV_POINT_SPRITE])
-        {
-            GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT));
-            checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, GL_UPPER_LEFT)");
-        }
-    }
-
     if (gl_info->supported[ARB_PROVOKING_VERTEX])
     {
         GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
@@ -2019,27 +2002,9 @@ void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer)
 static inline void context_set_render_offscreen(struct wined3d_context *context, const struct StateEntry *StateTable,
         BOOL offscreen)
 {
-    const struct wined3d_gl_info *gl_info = context->gl_info;
-
     if (context->render_offscreen == offscreen) return;
 
-    if (gl_info->supported[WINED3D_GL_VERSION_2_0])
-    {
-        /* Windows doesn't support to query the glPointParameteri function pointer, so use the
-         * NV_POINT_SPRITE extension.
-         */
-        if (glPointParameteri)
-        {
-            glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT);
-            checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
-        }
-        else if (gl_info->supported[NV_POINT_SPRITE])
-        {
-            GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT));
-            checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
-        }
-    }
-
+    Context_MarkStateDirty(context, STATE_POINTSPRITECOORDORIGIN, StateTable);
     Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
     Context_MarkStateDirty(context, STATE_VDECL, StateTable);
     Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 843541f..a34ac4f 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4963,6 +4963,34 @@ static void frontface(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
     }
 }
 
+static void psorigin_w(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    static BOOL warned;
+
+    if (!warned)
+    {
+        WARN("Point sprite coordinate origin switching not supported.\n");
+        warned = TRUE;
+    }
+}
+
+static void psorigin(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
+{
+    const struct wined3d_gl_info *gl_info = context->gl_info;
+    GLint origin = context->render_offscreen ? GL_LOWER_LEFT : GL_UPPER_LEFT;
+
+    if (glPointParameteri)
+    {
+        glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, origin);
+        checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
+    }
+    else if (gl_info->supported[NV_POINT_SPRITE])
+    {
+        GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, origin));
+        checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
+    }
+}
+
 const struct StateEntryTemplate misc_state_template[] = {
     { STATE_RENDER(WINED3DRS_SRCBLEND),                   { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3DRS_DESTBLEND),                  { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE),           NULL                }, WINED3D_GL_EXT_NONE             },
@@ -4978,6 +5006,9 @@ const struct StateEntryTemplate misc_state_template[] = {
     { STATE_VDECL,                                        { STATE_VDECL,                                        streamsrc           }, WINED3D_GL_EXT_NONE             },
     { STATE_FRONTFACE,                                    { STATE_FRONTFACE,                                    frontface           }, WINED3D_GL_EXT_NONE             },
     { STATE_SCISSORRECT,                                  { STATE_SCISSORRECT,                                  scissorrect         }, WINED3D_GL_EXT_NONE             },
+    { STATE_POINTSPRITECOORDORIGIN,                       { STATE_POINTSPRITECOORDORIGIN,                       psorigin            }, WINED3D_GL_VERSION_2_0          },
+    { STATE_POINTSPRITECOORDORIGIN,                       { STATE_POINTSPRITECOORDORIGIN,                       psorigin_w          }, WINED3D_GL_EXT_NONE             },
+
     /* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
      * vshader loadings are untied from each other
      */
@@ -5810,6 +5841,7 @@ static void validate_state_table(struct StateEntry *state_table)
         STATE_VIEWPORT,
         STATE_SCISSORRECT,
         STATE_FRONTFACE,
+        STATE_POINTSPRITECOORDORIGIN,
     };
     unsigned int i, current;
 
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 4d04271..15ff298 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2212,6 +2212,8 @@ const char *debug_d3dstate(DWORD state)
         return "STATE_MATERIAL";
     if (STATE_IS_FRONTFACE(state))
         return "STATE_FRONTFACE";
+    if (STATE_IS_POINTSPRITECOORDORIGIN(state))
+        return "STATE_POINTSPRITECOORDORIGIN";
 
     return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state);
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d6de00e..c6b1413 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -992,7 +992,10 @@ extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC
 #define STATE_FRONTFACE (STATE_MATERIAL + 1)
 #define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
 
-#define STATE_HIGHEST (STATE_FRONTFACE)
+#define STATE_POINTSPRITECOORDORIGIN  (STATE_FRONTFACE + 1)
+#define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
+
+#define STATE_HIGHEST (STATE_POINTSPRITECOORDORIGIN)
 
 enum fogsource {
     FOGSOURCE_FFP,
-- 
1.7.2.2


More information about the wine-patches mailing list