wined3d: Introduce a WINED3DFMT_FLAG_GEN_MIPMAP flag.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2018-02-13 15:54:13 +01:00 committed by Alexandre Julliard
parent 00a352a376
commit 882742e17a
4 changed files with 23 additions and 9 deletions

View File

@ -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)

View File

@ -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
@ -2684,7 +2683,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;

View File

@ -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;

View File

@ -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
{