[PATCH 07/11] wined3d: Forbid creating typeless render target views.

Józef Kucia jkucia at codeweavers.com
Thu Jun 16 04:59:37 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 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 ae58b62..52e3f1e 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 7e46e47..0ef2414 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)
-- 
2.7.3




More information about the wine-patches mailing list