[PATCH 1/4] wined3d: Retrieve the GL texture through a function.

Henri Verbeet hverbeet at codeweavers.com
Thu Mar 3 02:24:08 CST 2011


---
 dlls/wined3d/basetexture.c     |   10 ++--------
 dlls/wined3d/context.c         |   13 +++++--------
 dlls/wined3d/cubetexture.c     |    9 +++++----
 dlls/wined3d/texture.c         |    9 +++++----
 dlls/wined3d/wined3d_private.h |    5 +++++
 5 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index 20685e4..09e9ff3 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -248,10 +248,7 @@ HRESULT basetexture_bind(IWineD3DBaseTextureImpl *texture, BOOL srgb, BOOL *set_
     TRACE("texture %p, srgb %#x, set_surface_desc %p.\n", texture, srgb, set_surface_desc);
 
     texture->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
-    if (srgb)
-        gl_tex = &texture->baseTexture.texture_srgb;
-    else
-        gl_tex = &texture->baseTexture.texture_rgb;
+    gl_tex = basetexture_get_gl_texture(texture, srgb);
 
     textureDimensions = texture->baseTexture.target;
 
@@ -377,10 +374,7 @@ void basetexture_apply_state_changes(IWineD3DBaseTextureImpl *texture,
 
     TRACE("texture %p, samplerStates %p\n", texture, samplerStates);
 
-    if (texture->baseTexture.is_srgb)
-        gl_tex = &texture->baseTexture.texture_srgb;
-    else
-        gl_tex = &texture->baseTexture.texture_rgb;
+    gl_tex = basetexture_get_gl_texture(texture, texture->baseTexture.is_srgb);
 
     /* This function relies on the correct texture being bound and loaded. */
 
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 9ace3b2..4f3cd67 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -117,7 +117,7 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
     /* Update base texture states array */
     if (surface->container.type == WINED3D_CONTAINER_TEXTURE)
     {
-        IWineD3DBaseTextureImpl *texture_impl = surface->container.u.texture;
+        IWineD3DBaseTextureImpl *texture = surface->container.u.texture;
         IWineD3DDeviceImpl *device = surface->resource.device;
         BOOL update_minfilter = FALSE;
         BOOL update_magfilter = FALSE;
@@ -126,16 +126,13 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
         switch (location)
         {
             case SFLAG_INTEXTURE:
-                gl_tex = &texture_impl->baseTexture.texture_rgb;
-                break;
-
             case SFLAG_INSRGBTEX:
-                gl_tex = &texture_impl->baseTexture.texture_srgb;
+                gl_tex = basetexture_get_gl_texture(texture, location == SFLAG_INSRGBTEX);
                 break;
 
             default:
                 ERR("Unsupported location %s (%#x).\n", debug_surflocation(location), location);
-                IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
+                IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture);
                 return;
         }
 
@@ -153,10 +150,10 @@ static void context_apply_attachment_filter_states(IWineD3DSurfaceImpl *surface,
             update_magfilter = TRUE;
         }
 
-        if (texture_impl->baseTexture.bindCount)
+        if (texture->baseTexture.bindCount)
         {
             WARN("Render targets should not be bound to a sampler\n");
-            IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture_impl->baseTexture.sampler));
+            IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(texture->baseTexture.sampler));
         }
 
         if (update_minfilter || update_magfilter)
diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c
index 47dcc2b..0d6d20e 100644
--- a/dlls/wined3d/cubetexture.c
+++ b/dlls/wined3d/cubetexture.c
@@ -61,8 +61,8 @@ static void cubetexture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSR
     UINT sub_count = texture->baseTexture.level_count * texture->baseTexture.layer_count;
     IWineD3DDeviceImpl *device = texture->resource.device;
     struct wined3d_context *context = NULL;
+    struct gl_texture *gl_tex;
     BOOL srgb_mode;
-    BOOL *dirty;
     UINT i;
 
     TRACE("texture %p, srgb %#x.\n", texture, srgb);
@@ -85,7 +85,8 @@ static void cubetexture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSR
             srgb_mode = texture->baseTexture.is_srgb;
             break;
     }
-    dirty = srgb_mode ? &texture->baseTexture.texture_srgb.dirty : &texture->baseTexture.texture_rgb.dirty;
+
+    gl_tex = basetexture_get_gl_texture(texture, srgb_mode);
 
     /* We only have to activate a context for gl when we're not drawing.
      * In most cases PreLoad will be called during draw and a context was
@@ -118,7 +119,7 @@ static void cubetexture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSR
 
     /* If the texture is marked dirty or the srgb sampler setting has changed
      * since the last load then reload the surfaces. */
-    if (*dirty)
+    if (gl_tex->dirty)
     {
         for (i = 0; i < sub_count; ++i)
         {
@@ -131,7 +132,7 @@ static void cubetexture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSR
     }
 
     /* No longer dirty. */
-    *dirty = FALSE;
+    gl_tex->dirty = FALSE;
 
     if (context) context_release(context);
 }
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 32ff66b..c575e2b 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -90,9 +90,9 @@ static void texture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB s
 {
     IWineD3DDeviceImpl *device = texture->resource.device;
     struct wined3d_context *context = NULL;
+    struct gl_texture *gl_tex;
     unsigned int i;
     BOOL srgb_mode;
-    BOOL *dirty;
 
     TRACE("texture %p, srgb %#x.\n", texture, srgb);
 
@@ -114,7 +114,8 @@ static void texture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB s
             srgb_mode = texture->baseTexture.is_srgb;
             break;
     }
-    dirty = srgb_mode ? &texture->baseTexture.texture_srgb.dirty : &texture->baseTexture.texture_rgb.dirty;
+
+    gl_tex = basetexture_get_gl_texture(texture, srgb_mode);
 
     if (!device->isInDraw)
     {
@@ -142,7 +143,7 @@ static void texture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB s
 
     /* If the texture is marked dirty or the srgb sampler setting has changed
      * since the last load then reload the surfaces. */
-    if (*dirty)
+    if (gl_tex->dirty)
     {
         for (i = 0; i < texture->baseTexture.level_count; ++i)
         {
@@ -157,7 +158,7 @@ static void texture_preload(IWineD3DBaseTextureImpl *texture, enum WINED3DSRGB s
     if (context) context_release(context);
 
     /* No longer dirty. */
-    *dirty = FALSE;
+    gl_tex->dirty = FALSE;
 }
 
 /* Do not call while under the GL lock. */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 32a2189..87d5c48 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1908,6 +1908,11 @@ static inline IWineD3DBaseTextureImpl *basetexture_from_resource(struct wined3d_
     return CONTAINING_RECORD(resource, IWineD3DBaseTextureImpl, resource);
 }
 
+static inline struct gl_texture *basetexture_get_gl_texture(IWineD3DBaseTextureImpl *texture, BOOL srgb)
+{
+    return srgb ? &texture->baseTexture.texture_srgb : &texture->baseTexture.texture_rgb;
+}
+
 void basetexture_apply_state_changes(IWineD3DBaseTextureImpl *texture,
         const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
         const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
-- 
1.7.3.4




More information about the wine-patches mailing list