Module: wine Branch: master Commit: 4e3ce8c1f0cfb18b2c9e09d4f22c32ec7de9314b URL: https://source.winehq.org/git/wine.git/?a=commit;h=4e3ce8c1f0cfb18b2c9e09d4f...
Author: Matteo Bruni mbruni@codeweavers.com Date: Fri Feb 1 12:59:29 2019 +0100
d3d8: Refuse to create D3DUSAGE_WRITEONLY textures.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3d8/tests/device.c | 15 +++++++++++++++ dlls/d3d8/texture.c | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 884cdb1..ac04a6a 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -5163,6 +5163,11 @@ static void test_lockrect_invalid(void) ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
IDirect3DTexture8_Release(texture); + + hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 1, D3DUSAGE_WRITEONLY, + D3DFMT_A8R8G8B8, resources[r].pool, &texture); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n", + hr, resources[r].name); }
if (cube_texture) @@ -5203,6 +5208,11 @@ static void test_lockrect_invalid(void) ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
IDirect3DTexture8_Release(cube_texture); + + hr = IDirect3DDevice8_CreateCubeTexture(device, 128, 1, D3DUSAGE_WRITEONLY, D3DFMT_A8R8G8B8, + resources[r].pool, &cube_texture); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n", + hr, resources[r].name); } }
@@ -6949,6 +6959,11 @@ static void test_lockbox_invalid(void) ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
IDirect3DVolumeTexture8_Release(texture); + + hr = IDirect3DDevice8_CreateVolumeTexture(device, 4, 4, 2, 1, D3DUSAGE_WRITEONLY, + D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + refcount = IDirect3DDevice8_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); IDirect3D8_Release(d3d); diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index 6f17e9d..5ca6921 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -1117,6 +1117,12 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.depth = 1; desc.size = 0;
+ if (usage & D3DUSAGE_WRITEONLY) + { + WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flag, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + if (!levels) levels = wined3d_log2i(max(width, height)) + 1;
@@ -1162,6 +1168,12 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic desc.depth = 1; desc.size = 0;
+ if (usage & D3DUSAGE_WRITEONLY) + { + WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flag, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + if (!levels) levels = wined3d_log2i(edge_length) + 1;
@@ -1209,6 +1221,12 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.depth = depth; desc.size = 0;
+ if (usage & D3DUSAGE_WRITEONLY) + { + WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flags, returning D3DERR_INVALIDCALL.\n"); + return D3DERR_INVALIDCALL; + } + if (!levels) levels = wined3d_log2i(max(max(width, height), depth)) + 1;