d3d9: 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>
This commit is contained in:
Matteo Bruni 2019-02-01 12:59:28 +01:00 committed by Alexandre Julliard
parent 6e7a2bd349
commit 665fe4f1a4
2 changed files with 30 additions and 0 deletions

View File

@ -8051,6 +8051,11 @@ static void test_lockrect_invalid(void)
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
IDirect3DTexture9_Release(texture);
hr = IDirect3DDevice9_CreateTexture(device, 128, 128, 1, D3DUSAGE_WRITEONLY,
D3DFMT_A8R8G8B8, resources[r].pool, &texture, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n",
hr, resources[r].name);
}
if (cube_texture)
{
@ -8090,6 +8095,11 @@ static void test_lockrect_invalid(void)
ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x, type %s.\n", hr, resources[r].name);
IDirect3DCubeTexture9_Release(cube_texture);
hr = IDirect3DDevice9_CreateCubeTexture(device, 128, 1, D3DUSAGE_WRITEONLY, D3DFMT_A8R8G8B8,
resources[r].pool, &cube_texture, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x for type %s.\n",
hr, resources[r].name);
}
}
@ -10269,6 +10279,11 @@ static void test_lockbox_invalid(void)
ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr);
IDirect3DVolumeTexture9_Release(texture);
hr = IDirect3DDevice9_CreateVolumeTexture(device, 4, 4, 2, 1, D3DUSAGE_WRITEONLY,
D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &texture, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);

View File

@ -1330,6 +1330,11 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
if (is_gdi_compat_wined3dformat(desc.format))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
if (usage & D3DUSAGE_WRITEONLY)
{
WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flags, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
if (usage & D3DUSAGE_AUTOGENMIPMAP)
{
if (pool == D3DPOOL_SYSTEMMEM)
@ -1419,6 +1424,11 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
if (is_gdi_compat_wined3dformat(desc.format))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
if (usage & D3DUSAGE_WRITEONLY)
{
WARN("Texture can't be created with the D3DUSAGE_WRITEONLY flags, returning D3DERR_INVALIDCALL.\n");
return D3DERR_INVALIDCALL;
}
if (usage & D3DUSAGE_AUTOGENMIPMAP)
{
if (pool == D3DPOOL_SYSTEMMEM)
@ -1493,6 +1503,11 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_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 (usage & D3DUSAGE_AUTOGENMIPMAP)
{
WARN("D3DUSAGE_AUTOGENMIPMAP volume texture is not supported, returning D3DERR_INVALIDCALL.\n");