Henri Verbeet : wined3d: Validate constant buffer alignment.

Alexandre Julliard julliard at winehq.org
Thu May 25 14:42:16 CDT 2017


Module: wine
Branch: master
Commit: cb77e188d118ae52a24c22d485cf05aa0740c576
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cb77e188d118ae52a24c22d485cf05aa0740c576

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu May 25 12:04:03 2017 +0200

wined3d: Validate constant buffer alignment.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/buffer.c          | 10 ++++++++--
 dlls/wined3d/wined3d_private.h |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 3cf153b..ab2fea3 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1380,8 +1380,14 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
 
     if (!size)
     {
-        WARN("Size 0 requested, returning WINED3DERR_INVALIDCALL.\n");
-        return WINED3DERR_INVALIDCALL;
+        WARN("Size 0 requested, returning E_INVALIDARG.\n");
+        return E_INVALIDARG;
+    }
+
+    if (bind_flags & WINED3D_BIND_CONSTANT_BUFFER && size & (WINED3D_CONSTANT_BUFFER_ALIGNMENT - 1))
+    {
+        WARN("Size %#x is not suitably aligned for constant buffers.\n", size);
+        return E_INVALIDARG;
     }
 
     if (data && !data->data)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 321f4d5..1da788e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2894,6 +2894,7 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DEC
 
 /* Tests show that the start address of resources is 32 byte aligned */
 #define RESOURCE_ALIGNMENT 16
+#define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
 
 struct gl_texture
 {




More information about the wine-cvs mailing list