=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Track SFLAG_NONPOW2 per-texture.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Feb 19 08:56:21 CST 2016


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

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Thu Feb 18 17:30:01 2016 +0100

wined3d: Track SFLAG_NONPOW2 per-texture.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/surface.c         | 17 +++--------------
 dlls/wined3d/texture.c         |  6 ++++++
 dlls/wined3d/wined3d_private.h | 22 +++++++++++-----------
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7858d15..88acca5 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -594,7 +594,7 @@ static BOOL surface_use_pbo(const struct wined3d_surface *surface)
                 && gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
                 && !texture->resource.format->convert
                 && !(texture->flags & WINED3D_TEXTURE_PIN_SYSMEM)
-                && !(surface->flags & SFLAG_NONPOW2);
+                && !(texture->flags & WINED3D_TEXTURE_COND_NP2_EMULATED);
 }
 
 static HRESULT surface_private_setup(struct wined3d_surface *surface)
@@ -635,12 +635,6 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface)
         }
     }
 
-    if (pow2Width != surface->resource.width
-            || pow2Height != surface->resource.height)
-    {
-        surface->flags |= SFLAG_NONPOW2;
-    }
-
     if ((surface->pow2Width > gl_info->limits.texture_size || surface->pow2Height > gl_info->limits.texture_size)
             && !(surface->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
     {
@@ -1321,7 +1315,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
         GLenum gl_type = format->glType;
         void *mem;
 
-        if (surface->flags & SFLAG_NONPOW2)
+        if (surface->container->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
         {
             wined3d_texture_get_pitch(surface->container, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
             wined3d_format_calculate_pitch(format, surface->resource.device->surface_alignment,
@@ -1355,7 +1349,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
             checkGLcall("glGetTexImage");
         }
 
-        if (surface->flags & SFLAG_NONPOW2)
+        if (surface->container->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
         {
             const BYTE *src_data;
             BYTE *dst_data;
@@ -1880,11 +1874,6 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
             surface->pow2Height <<= 1;
     }
 
-    if (surface->pow2Width != width || surface->pow2Height != height)
-        surface->flags |= SFLAG_NONPOW2;
-    else
-        surface->flags &= ~SFLAG_NONPOW2;
-
     if (surface->container->user_memory)
     {
         surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 804856b..c3bae83 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -663,6 +663,11 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
         wined3d_format_calculate_pitch(format, 1, width, height,
                 &texture->row_pitch, &texture->slice_pitch);
 
+    texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
+    if (((width & (width - 1)) || (height & (height - 1))) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
+            && !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
+        texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
+
     return wined3d_surface_update_desc(surface, gl_info);
 }
 
@@ -1074,6 +1079,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
             texture->pow2_matrix[0] = (((float)desc->width) / ((float)pow2_width));
             texture->pow2_matrix[5] = (((float)desc->height) / ((float)pow2_height));
             texture->flags &= ~WINED3D_TEXTURE_POW2_MAT_IDENT;
+            texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
         }
         texture->pow2_matrix[10] = 1.0f;
         texture->pow2_matrix[15] = 1.0f;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a20bc65..35ece12 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2336,16 +2336,17 @@ struct wined3d_texture_ops
 };
 
 #define WINED3D_TEXTURE_COND_NP2            0x00000001
-#define WINED3D_TEXTURE_POW2_MAT_IDENT      0x00000002
-#define WINED3D_TEXTURE_IS_SRGB             0x00000004
-#define WINED3D_TEXTURE_RGB_ALLOCATED       0x00000008
-#define WINED3D_TEXTURE_RGB_VALID           0x00000010
-#define WINED3D_TEXTURE_SRGB_ALLOCATED      0x00000020
-#define WINED3D_TEXTURE_SRGB_VALID          0x00000040
-#define WINED3D_TEXTURE_CONVERTED           0x00000080
-#define WINED3D_TEXTURE_PIN_SYSMEM          0x00000100
-#define WINED3D_TEXTURE_DYNAMIC_MAP         0x00000200
-#define WINED3D_TEXTURE_NORMALIZED_COORDS   0x00000400
+#define WINED3D_TEXTURE_COND_NP2_EMULATED   0x00000002
+#define WINED3D_TEXTURE_POW2_MAT_IDENT      0x00000004
+#define WINED3D_TEXTURE_IS_SRGB             0x00000008
+#define WINED3D_TEXTURE_RGB_ALLOCATED       0x00000010
+#define WINED3D_TEXTURE_RGB_VALID           0x00000020
+#define WINED3D_TEXTURE_SRGB_ALLOCATED      0x00000040
+#define WINED3D_TEXTURE_SRGB_VALID          0x00000080
+#define WINED3D_TEXTURE_CONVERTED           0x00000100
+#define WINED3D_TEXTURE_PIN_SYSMEM          0x00000200
+#define WINED3D_TEXTURE_DYNAMIC_MAP         0x00000400
+#define WINED3D_TEXTURE_NORMALIZED_COORDS   0x00000800
 
 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY     0x00000001
 
@@ -2596,7 +2597,6 @@ void draw_textured_quad(const struct wined3d_surface *src_surface, struct wined3
 /* Surface flags: */
 #define SFLAG_DIBSECTION        0x00000001 /* Has a DIB section attached for GetDC. */
 #define SFLAG_DISCARD           0x00000002 /* ??? */
-#define SFLAG_NONPOW2           0x00000004 /* Surface sizes are not a power of 2 */
 #define SFLAG_DCINUSE           0x00000020 /* Set between GetDC and ReleaseDC calls. */
 
 struct wined3d_sampler




More information about the wine-cvs mailing list