Commit 21c7b94c authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

wined3d: Refuse to create texture views changing format from non-typeless.

parent 7afbeb5d
......@@ -3815,6 +3815,20 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
return slice_pitch * depth;
}
BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1, enum wined3d_format_id format2)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_srgb_info); ++i)
{
if (format1 == format_srgb_info[i].srgb_format_id)
return format2 == format_srgb_info[i].base_format_id;
if (format1 == format_srgb_info[i].base_format_id)
return format2 == format_srgb_info[i].srgb_format_id;
}
return FALSE;
}
/*****************************************************************************
* Trace formatting of useful values
*/
......
......@@ -128,6 +128,14 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
struct wined3d_texture *texture = texture_from_resource(resource);
unsigned int depth_or_layer_count;
if (resource->format->id != format->id && !wined3d_format_is_typeless(resource->format)
&& !wined3d_formats_are_srgb_variants(resource->format->id, format->id))
{
WARN("Trying to create incompatible view for non typeless format %s.\n",
debug_d3dformat(format->id));
return NULL;
}
if (mip_slice && resource->type == WINED3D_RTYPE_TEXTURE_3D)
depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx);
else
......
......@@ -4251,6 +4251,8 @@ BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
enum wined3d_format_id format2) DECLSPEC_HIDDEN;
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment