diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 59eec656cdc..c07e98192dd 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -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)) diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index f3b9a0ae26e..9f293a81802 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -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)) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 7c13cbfa39c..819044214d5 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6189,7 +6189,9 @@ 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; - wined3d_desc.usage |= WINED3DUSAGE_DYNAMIC; + /* 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; } } diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index e5016e42e08..82e9019a0ed 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -91,12 +91,22 @@ 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)) { - 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; + 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)