[PATCH v2 4/5] wined3d: Add texture flag for mipmap generation.

Matteo Bruni mbruni at codeweavers.com
Fri Nov 24 16:30:00 CST 2017


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
v2: Make use of the new flag in
wined3d_texture_generate_mipmaps(). Don't set the flag if the format
is not renderable or filterable.

This still keeps the separate usage flag for automatic mipmap
generation for the time being. That will be removed entirely later on,
when the whole handling of AUTOGENMIPMAP textures will move to d3d9 on
top of manual mipmap generation.

 dlls/wined3d/texture.c         | 16 +++++++++++++++-
 dlls/wined3d/wined3d_private.h |  1 +
 include/wine/wined3d.h         |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index ef8545d003..7a8e1fb7d1 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -384,6 +384,15 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
         texture->flags |= WINED3D_TEXTURE_GET_DC;
     if (flags & WINED3D_TEXTURE_CREATE_DISCARD)
         texture->flags |= WINED3D_TEXTURE_DISCARD;
+    if (flags & WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS)
+    {
+        if (~format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
+                & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))
+            WARN("Format doesn't support mipmaps generation, "
+                    "ignoring WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS flag.\n");
+        else
+            texture->flags |= WINED3D_TEXTURE_GENERATE_MIPMAPS;
+    }
 
     return WINED3D_OK;
 }
@@ -1573,8 +1582,13 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
 
 void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
 {
-    /* TODO: Implement filters using GL_SGI_generate_mipmaps. */
     FIXME("texture %p stub!\n", texture);
+
+    if (!(texture->flags & WINED3D_TEXTURE_GENERATE_MIPMAPS))
+    {
+        WARN("Texture without the WINED3D_TEXTURE_GENERATE_MIPMAPS flag, ignoring.\n");
+        return;
+    }
 }
 
 static struct wined3d_texture_sub_resource *wined3d_texture_get_sub_resource(struct wined3d_texture *texture,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3a9ac2e181..16afd346fb 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3074,6 +3074,7 @@ struct wined3d_texture_ops
 #define WINED3D_TEXTURE_DC_IN_USE           0x00001000
 #define WINED3D_TEXTURE_DISCARD             0x00002000
 #define WINED3D_TEXTURE_GET_DC              0x00004000
+#define WINED3D_TEXTURE_GENERATE_MIPMAPS    0x00008000
 
 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY     0x00000001
 
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index f35d9806e3..a0ac7ba02f 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1538,6 +1538,7 @@ enum wined3d_shader_byte_code_format
 #define WINED3D_TEXTURE_CREATE_DISCARD                          0x00000002
 #define WINED3D_TEXTURE_CREATE_GET_DC_LENIENT                   0x00000004
 #define WINED3D_TEXTURE_CREATE_GET_DC                           0x00000008
+#define WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS                 0x00000010
 
 #define WINED3D_APPEND_ALIGNED_ELEMENT                          0xffffffff
 
-- 
2.13.6




More information about the wine-devel mailing list