Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Just use texture->resource.format_flags.
dlls/wined3d/directx.c | 8 ++------ dlls/wined3d/texture.c | 5 ++--- dlls/wined3d/utils.c | 18 ++++++++++++++++++ dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c8f42fe253a..924cc72e773 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -5296,7 +5296,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad const struct wined3d_gl_info *gl_info = &adapter->gl_info; const struct wined3d_format *adapter_format, *format; enum wined3d_gl_resource_type gl_type, gl_type_end; - BOOL mipmap_autogen_supported; + BOOL mipmap_autogen_supported = TRUE; DWORD format_flags = 0; DWORD allowed_usage;
@@ -5410,7 +5410,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad return WINED3DERR_NOTAVAILABLE; }
- mipmap_autogen_supported = gl_info->supported[SGIS_GENERATE_MIPMAP]; for (; gl_type <= gl_type_end; ++gl_type) { if ((format->flags[gl_type] & format_flags) != format_flags) @@ -5440,11 +5439,8 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad return WINED3DERR_NOTAVAILABLE; }
- if ((format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) - != (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) - { + if (!(format->flags[gl_type] & WINED3DFMT_FLAG_GEN_MIPMAP)) mipmap_autogen_supported = FALSE; - } }
if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !mipmap_autogen_supported) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 750101fac66..5d198619c98 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -386,8 +386,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc 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)) + if (!(texture->resource.format_flags & WINED3DFMT_FLAG_GEN_MIPMAP)) WARN("Format doesn't support mipmaps generation, " "ignoring WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS flag.\n"); else @@ -2685,7 +2684,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct texture->resource.map_binding = WINED3D_LOCATION_BUFFER; }
- /* Generate all the surfaces. */ + /* Generate all the sub resources. */ for (i = 0; i < texture->level_count; ++i) { struct wined3d_texture_sub_resource *sub_resource; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6f7740deda0..960909f35b4 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -3595,6 +3595,23 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info) return TRUE; }
+static void init_format_gen_mipmap_info(struct wined3d_gl_info *gl_info) +{ + unsigned int i, j; + + if (!gl_info->supported[SGIS_GENERATE_MIPMAP] && !gl_info->fbo_ops.glGenerateMipmap) + return; + + for (i = 0; i < gl_info->format_count; ++i) + { + struct wined3d_format *format = &gl_info->formats[i]; + + for (j = 0; j < ARRAY_SIZE(format->flags); ++j) + if (!(~format->flags[j] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))) + format->flags[j] |= WINED3DFMT_FLAG_GEN_MIPMAP; + } +} + BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) { static const struct wined3d_color red = {1.0f, 0.0f, 0.0f, 1.0f}; @@ -3783,6 +3800,7 @@ BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wi init_format_fbo_compat_info(ctx); init_format_filter_info(gl_info, adapter->driver_info.vendor); if (!init_typeless_formats(gl_info)) goto fail; + init_format_gen_mipmap_info(gl_info); init_format_depth_bias_scale(ctx, &adapter->d3d_info);
return TRUE; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f1f75301d6d..8201536a5de 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4205,6 +4205,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN #define WINED3DFMT_FLAG_TEXTURE 0x00080000 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000 #define WINED3DFMT_FLAG_INTEGER 0x00200000 +#define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
struct wined3d_rational {