From b511775b1b8712d3f8f6200b7b73b472c9602608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= <jkucia@codeweavers.com> Date: Thu, 16 Jun 2016 11:59:37 +0200 Subject: [PATCH] wined3d: Forbid creating typeless render target views. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> --- dlls/wined3d/view.c | 9 ++++++++- dlls/wined3d/wined3d_private.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index ae58b62d78d..52e3f1e0d8b 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -98,6 +98,13 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view * view->format = wined3d_get_format(gl_info, desc->format_id); view->format_flags = view->format->flags[resource->gl_type]; + + if (wined3d_format_is_typeless(view->format)) + { + WARN("Trying to create view for typeless format %s.\n", debug_d3dformat(view->format->id)); + return E_INVALIDARG; + } + if (resource->type == WINED3D_RTYPE_BUFFER) { view->sub_resource_idx = 0; @@ -277,7 +284,7 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_ const struct wined3d_format *view_format; view_format = wined3d_get_format(gl_info, desc->format_id); - if (view_format->id == view_format->typeless_id) + if (wined3d_format_is_typeless(view_format)) { WARN("Trying to create view for typeless format %s.\n", debug_d3dformat(view_format->id)); return E_INVALIDARG; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7e46e479b83..0ef2414a073 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3574,6 +3574,11 @@ void wined3d_format_get_float_color_key(const struct wined3d_format *format, const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion( const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN; +static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format) +{ + return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN; +} + static inline void *wined3d_calloc(SIZE_T count, SIZE_T size) { if (count > ~(SIZE_T)0 / size)