Commit 9bac6f15 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Disallow dynamic rendertarget and depth/stencil resources.

parent 0bae2bed
......@@ -8944,7 +8944,7 @@ static void test_resource_access(void)
case SURFACE_2D:
hr = IDirect3DDevice8_CreateTexture(device, 16, 16, 1,
tests[j].usage, format, tests[j].pool, &texture_2d);
todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
? D3D_OK : D3DERR_INVALIDCALL),
"Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
......@@ -8959,7 +8959,7 @@ static void test_resource_access(void)
case SURFACE_CUBE:
hr = IDirect3DDevice8_CreateCubeTexture(device, 16, 1,
tests[j].usage, format, tests[j].pool, &texture_cube);
todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
? D3D_OK : D3DERR_INVALIDCALL),
"Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
......@@ -9091,7 +9091,8 @@ static void test_resource_access(void)
hr = IDirect3DDevice8_CreateVolumeTexture(device, 16, 16, 1, 1,
tests[i].usage, format, tests[i].pool, &texture);
todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET && tests[i].pool == D3DPOOL_DEFAULT)
todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET
&& !(tests[i].usage & D3DUSAGE_DYNAMIC) && tests[i].pool == D3DPOOL_DEFAULT)
ok(hr == (!(tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3D_OK : D3DERR_INVALIDCALL),
"Test %u: Got unexpected hr %#x.\n", i, hr);
if (FAILED(hr))
......
......@@ -12774,7 +12774,7 @@ static void test_resource_access(void)
case SURFACE_2D:
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1,
tests[j].usage, format, tests[j].pool, &texture_2d, NULL);
todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
? D3D_OK : D3DERR_INVALIDCALL),
"Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
......@@ -12789,7 +12789,7 @@ static void test_resource_access(void)
case SURFACE_CUBE:
hr = IDirect3DDevice9_CreateCubeTexture(device, 16, 1,
tests[j].usage, format, tests[j].pool, &texture_cube, NULL);
todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
? D3D_OK : D3DERR_INVALIDCALL),
"Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
......@@ -12926,7 +12926,8 @@ static void test_resource_access(void)
hr = IDirect3DDevice9_CreateVolumeTexture(device, 16, 16, 1, 1,
tests[i].usage, format, tests[i].pool, &texture, NULL);
todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET && tests[i].pool == D3DPOOL_DEFAULT)
todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET
&& !(tests[i].usage & D3DUSAGE_DYNAMIC) && tests[i].pool == D3DPOOL_DEFAULT)
ok(hr == (!(tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3D_OK : D3DERR_INVALIDCALL),
"Test %u: Got unexpected hr %#x.\n", i, hr);
if (FAILED(hr))
......
......@@ -6189,6 +6189,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
/* Videomemory adds localvidmem. This is mutually exclusive with
* systemmemory and texturemanage. */
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
/* Dynamic resources can't be written by the GPU. */
if (!(wined3d_desc.bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL)))
wined3d_desc.usage |= WINED3DUSAGE_DYNAMIC;
}
}
......
......@@ -91,14 +91,24 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
return WINED3DERR_INVALIDCALL;
}
if ((access & (WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU)) != WINED3D_RESOURCE_ACCESS_GPU
&& bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL))
if (bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL))
{
if ((access & (WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU)) != WINED3D_RESOURCE_ACCESS_GPU)
{
WARN("Bind flags %s are incompatible with resource access %s.\n",
wined3d_debug_bind_flags(bind_flags), wined3d_debug_resource_access(access));
return WINED3DERR_INVALIDCALL;
}
/* Dynamic usage is incompatible with GPU writes. */
if (usage & WINED3DUSAGE_DYNAMIC)
{
WARN("Bind flags %s are incompatible with resource usage %s.\n",
wined3d_debug_bind_flags(bind_flags), debug_d3dusage(usage));
return WINED3DERR_INVALIDCALL;
}
}
if (!size)
ERR("Attempting to create a zero-sized resource.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment