wined3d: Only allow swapchain textures to have mismatched sRGB setting in resource views.

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 2017-12-07 22:56:18 +01:00 committed by Alexandre Julliard
parent 1162d62164
commit 83a30fad0a
3 changed files with 16 additions and 7 deletions

View File

@ -8540,7 +8540,7 @@ static void test_swapchain_views(void)
U(srv_desc).Texture2D.MostDetailedMip = 0;
U(srv_desc).Texture2D.MipLevels = 1;
hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)test_context.backbuffer, &srv_desc, &srv);
todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D10ShaderResourceView_Release(srv);

View File

@ -11002,7 +11002,7 @@ static void test_swapchain_views(void)
U(srv_desc).Texture2D.MostDetailedMip = 0;
U(srv_desc).Texture2D.MipLevels = 1;
hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)test_context.backbuffer, &srv_desc, &srv);
todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D11ShaderResourceView_Release(srv);

View File

@ -71,7 +71,7 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info,
}
static const struct wined3d_format *validate_resource_view(const struct wined3d_view_desc *desc,
struct wined3d_resource *resource, BOOL mip_slice)
struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
{
const struct wined3d_gl_info *gl_info = &resource->device->adapter->gl_info;
const struct wined3d_format *format;
@ -129,7 +129,7 @@ static const struct wined3d_format *validate_resource_view(const struct wined3d_
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))
&& (!allow_srgb_toggle || !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));
@ -540,11 +540,20 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops)
{
BOOL allow_srgb_toggle = FALSE;
view->refcount = 1;
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, TRUE)))
if (resource->type != WINED3D_RTYPE_BUFFER)
{
struct wined3d_texture *texture = texture_from_resource(resource);
if (texture->swapchain)
allow_srgb_toggle = TRUE;
}
if (!(view->format = validate_resource_view(desc, resource, TRUE, allow_srgb_toggle)))
return E_INVALIDARG;
view->format_flags = view->format->flags[resource->gl_type];
view->desc = *desc;
@ -740,7 +749,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, FALSE)))
if (!(view->format = validate_resource_view(desc, resource, FALSE, FALSE)))
return E_INVALIDARG;
view->desc = *desc;
@ -1108,7 +1117,7 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
view->parent = parent;
view->parent_ops = parent_ops;
if (!(view->format = validate_resource_view(desc, resource, TRUE)))
if (!(view->format = validate_resource_view(desc, resource, TRUE, FALSE)))
return E_INVALIDARG;
view->desc = *desc;