[PATCH 2/6] d3d8: Refuse to create D3DUSAGE_WRITEONLY textures.
Matteo Bruni
mbruni at codeweavers.com
Fri Feb 1 05:59:29 CST 2019
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
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 884cdb1b8a9..ac04a6ad649 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 6f17e9da5fd..5ca69215e1e 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;
--
2.19.2
More information about the wine-devel
mailing list