Henri Verbeet : wined3d: Replace the "stateLookup" tables with a single " wrap_lookup" table.

Alexandre Julliard julliard at winehq.org
Fri Oct 23 10:19:01 CDT 2009


Module: wine
Branch: master
Commit: 342a71b281c9ee732f65443de68db0bfcaab0fce
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=342a71b281c9ee732f65443de68db0bfcaab0fce

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Oct 23 10:26:10 2009 +0200

wined3d: Replace the "stateLookup" tables with a single "wrap_lookup" table.

---

 dlls/wined3d/basetexture.c     |   43 ++++++++++++++++++++-------------------
 dlls/wined3d/directx.c         |   36 ++++++++-------------------------
 dlls/wined3d/wined3d_private.h |    9 +-------
 3 files changed, 32 insertions(+), 56 deletions(-)

diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index b38f668..be88506 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -319,29 +319,30 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
 }
 
 /* GL locking is done by the caller */
-static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
-                              BOOL cond_np2) {
-    GLint wrapParm;
+static void apply_wrap(GLenum target, WINED3DTEXTUREADDRESS d3d_wrap, GLenum param, BOOL cond_np2)
+{
+    GLint gl_wrap;
 
-    if (state < minLookup[WINELOOKUP_WARPPARAM] || state > maxLookup[WINELOOKUP_WARPPARAM]) {
-        FIXME("Unrecognized or unsupported WINED3DTADDRESS_U value %d\n", state);
-    } else {
-        if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
-            /* Cubemaps are always set to clamp, regardless of the sampler state. */
-            wrapParm = GL_CLAMP_TO_EDGE;
-        } else if(cond_np2) {
-            if(state == WINED3DTADDRESS_WRAP) {
-                wrapParm = GL_CLAMP_TO_EDGE;
-            } else {
-                wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
-            }
-        } else {
-            wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
-        }
-        TRACE("Setting WRAP_S to %d for %x\n", wrapParm, textureDimensions);
-        glTexParameteri(textureDimensions, type, wrapParm);
-        checkGLcall("glTexParameteri(..., type, wrapParm)");
+    if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
+    {
+        FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
+        return;
     }
+
+    if (target == GL_TEXTURE_CUBE_MAP_ARB
+            || (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
+    {
+        /* Cubemaps are always set to clamp, regardless of the sampler state. */
+        gl_wrap = GL_CLAMP_TO_EDGE;
+    }
+    else
+    {
+        gl_wrap = wrap_lookup[d3d_wrap - WINED3DTADDRESS_WRAP];
+    }
+
+    TRACE("Setting param %#x to %#x for target %#x.\n", param, gl_wrap, target);
+    glTexParameteri(target, param, gl_wrap);
+    checkGLcall("glTexParameteri(target, param, gl_wrap)");
 }
 
 /* GL locking is done by the caller (state handler) */
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 2259a86..6984a57 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -160,18 +160,7 @@ static const struct fragment_pipeline *select_fragment_implementation(struct win
 static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
 static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
 
-/* lookup tables */
-const int minLookup[MAX_LOOKUPS] =
-{
-    WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
-};
-
-const int maxLookup[MAX_LOOKUPS] =
-{
-    WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
-};
-
-DWORD *stateLookup[MAX_LOOKUPS];
+GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1];
 
 const struct min_lookup minMipLookup[] =
 {
@@ -2031,21 +2020,14 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_gl_info *gl_info)
     else
         gl_info->vidmem = WINE_DEFAULT_VIDMEM;
 
-    /* Load all the lookup tables */
-    for (i = 0; i < MAX_LOOKUPS; i++) {
-        stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
-    }
-
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_WRAP   - minLookup[WINELOOKUP_WARPPARAM]] = GL_REPEAT;
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_CLAMP  - minLookup[WINELOOKUP_WARPPARAM]] = GL_CLAMP_TO_EDGE;
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
-             gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
-             gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRROR - minLookup[WINELOOKUP_WARPPARAM]] =
-             gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
-    stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRRORONCE - minLookup[WINELOOKUP_WARPPARAM]] =
-             gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
+    wrap_lookup[WINED3DTADDRESS_WRAP - WINED3DTADDRESS_WRAP] = GL_REPEAT;
+    wrap_lookup[WINED3DTADDRESS_MIRROR - WINED3DTADDRESS_WRAP] =
+            gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
+    wrap_lookup[WINED3DTADDRESS_CLAMP - WINED3DTADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
+    wrap_lookup[WINED3DTADDRESS_BORDER - WINED3DTADDRESS_WRAP] =
+            gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
+    wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP] =
+            gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
 
     /* Make sure there's an active HDC else the WGL extensions will fail */
     hdc = pwglGetCurrentDC();
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index bafdc02..cc097fb 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -148,14 +148,7 @@ void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
 #define MAX_ACTIVE_LIGHTS       8
 #define MAX_CLIPPLANES          WINED3DMAXUSERCLIPPLANES
 
-typedef enum _WINELOOKUP {
-    WINELOOKUP_WARPPARAM = 0,
-    MAX_LOOKUPS          = 1
-} WINELOOKUP;
-
-extern const int minLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
-extern const int maxLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
-extern DWORD *stateLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
+extern GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1] DECLSPEC_HIDDEN;
 
 struct min_lookup
 {




More information about the wine-cvs mailing list