From 2843e4d3cf119e60329391740fbda5f9fd08febd Mon Sep 17 00:00:00 2001
From: Henri Verbeet <hverbeet@codeweavers.com>
Date: Tue, 20 Nov 2018 16:36:42 +0330
Subject: [PATCH] d3d9: Disallow index buffers in the scratch pool.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 dlls/d3d9/buffer.c       | 3 +++
 dlls/d3d9/tests/device.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c
index ea98ef4242f..b870107830c 100644
--- a/dlls/d3d9/buffer.c
+++ b/dlls/d3d9/buffer.c
@@ -572,6 +572,9 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de
     struct wined3d_buffer_desc desc;
     HRESULT hr;
 
+    if (pool == D3DPOOL_SCRATCH)
+        return D3DERR_INVALIDCALL;
+
     desc.byte_width = size;
     desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL;
     if (pool == D3DPOOL_SCRATCH)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 9f293a81802..d0e566033f8 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -12967,7 +12967,7 @@ static void test_resource_access(void)
 
         hr = IDirect3DDevice9_CreateIndexBuffer(device, 16, tests[i].usage,
                 tests[i].format == FORMAT_COLOUR ? D3DFMT_INDEX32 : D3DFMT_INDEX16, tests[i].pool, &ib, NULL);
-        todo_wine_if(tests[i].pool == D3DPOOL_SCRATCH || tests[i].usage & ~D3DUSAGE_DYNAMIC)
+        todo_wine_if(tests[i].pool != D3DPOOL_SCRATCH && tests[i].usage & ~D3DUSAGE_DYNAMIC)
             ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || (tests[i].usage & ~D3DUSAGE_DYNAMIC)
                     ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#x.\n", i, hr);
         if (FAILED(hr))
-- 
GitLab