[PATCH 01/10] d3d8/tests: Add a resource access tests.
Henri Verbeet
hverbeet at codeweavers.com
Sun Nov 18 12:39:12 CST 2018
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/d3d8/tests/device.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 424 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 1bcbcf1b9a5..9f1d8167af9 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -8782,6 +8782,429 @@ static void test_get_info(void)
DestroyWindow(window);
}
+static void test_resource_access(void)
+{
+ IDirect3DSurface8 *backbuffer, *depth_stencil;
+ D3DFORMAT colour_format, depth_format, format;
+ BOOL depth_2d, depth_cube, depth_plain;
+ struct device_desc device_desc;
+ D3DSURFACE_DESC surface_desc;
+ IDirect3DDevice8 *device;
+ unsigned int i, j;
+ IDirect3D8 *d3d;
+ ULONG refcount;
+ HWND window;
+ HRESULT hr;
+
+ enum surface_type
+ {
+ SURFACE_2D,
+ SURFACE_CUBE,
+ SURFACE_RT,
+ SURFACE_DS,
+ SURFACE_IMAGE,
+ };
+
+ enum resource_format
+ {
+ FORMAT_COLOUR,
+ FORMAT_ATI2,
+ FORMAT_DEPTH,
+ };
+
+ static const struct
+ {
+ D3DPOOL pool;
+ enum resource_format format;
+ DWORD usage;
+ BOOL valid;
+ }
+ tests[] =
+ {
+ /* 0 */
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, 0, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_ATI2, 0, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, 0, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, D3DUSAGE_RENDERTARGET, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, D3DUSAGE_DEPTHSTENCIL, TRUE},
+ /* 7 */
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, D3DUSAGE_DYNAMIC, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_ATI2, D3DUSAGE_DYNAMIC, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, D3DUSAGE_DYNAMIC, TRUE},
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, D3DUSAGE_DYNAMIC | D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, D3DUSAGE_DYNAMIC | D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_DEFAULT, FORMAT_COLOUR, D3DUSAGE_DYNAMIC | D3DUSAGE_DEPTHSTENCIL, FALSE},
+ {D3DPOOL_DEFAULT, FORMAT_DEPTH, D3DUSAGE_DYNAMIC | D3DUSAGE_DEPTHSTENCIL, FALSE},
+ /* 14 */
+ {D3DPOOL_MANAGED, FORMAT_COLOUR, 0, TRUE},
+ {D3DPOOL_MANAGED, FORMAT_ATI2, 0, TRUE},
+ {D3DPOOL_MANAGED, FORMAT_DEPTH, 0, FALSE},
+ {D3DPOOL_MANAGED, FORMAT_COLOUR, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_MANAGED, FORMAT_DEPTH, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_MANAGED, FORMAT_COLOUR, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ {D3DPOOL_MANAGED, FORMAT_DEPTH, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ /* 21 */
+ {D3DPOOL_SYSTEMMEM, FORMAT_COLOUR, 0, TRUE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_ATI2, 0, TRUE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_DEPTH, 0, FALSE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_COLOUR, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_DEPTH, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_COLOUR, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ {D3DPOOL_SYSTEMMEM, FORMAT_DEPTH, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ /* 28 */
+ {D3DPOOL_SCRATCH, FORMAT_COLOUR, 0, TRUE},
+ {D3DPOOL_SCRATCH, FORMAT_ATI2, 0, TRUE},
+ {D3DPOOL_SCRATCH, FORMAT_DEPTH, 0, FALSE},
+ {D3DPOOL_SCRATCH, FORMAT_COLOUR, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_SCRATCH, FORMAT_DEPTH, D3DUSAGE_RENDERTARGET, FALSE},
+ {D3DPOOL_SCRATCH, FORMAT_COLOUR, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ {D3DPOOL_SCRATCH, FORMAT_DEPTH, D3DUSAGE_DEPTHSTENCIL, FALSE},
+ };
+ static const struct
+ {
+ const char *name;
+ enum surface_type type;
+ }
+ surface_types[] =
+ {
+ {"2D", SURFACE_2D},
+ {"CUBE", SURFACE_CUBE},
+ {"RT", SURFACE_RT},
+ {"DS", SURFACE_DS},
+ {"IMAGE", SURFACE_IMAGE},
+ };
+
+ window = create_window();
+ d3d = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create a D3D object.\n");
+
+ device_desc.device_window = window;
+ device_desc.width = 16;
+ device_desc.height = 16;
+ device_desc.flags = 0;
+ if (!(device = create_device(d3d, window, &device_desc)))
+ {
+ skip("Failed to create a D3D device.\n");
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_GetBackBuffer(device, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DSurface8_GetDesc(backbuffer, &surface_desc);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ colour_format = surface_desc.Format;
+
+ hr = IDirect3DDevice8_GetDepthStencilSurface(device, &depth_stencil);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DSurface8_GetDesc(depth_stencil, &surface_desc);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ depth_format = surface_desc.Format;
+
+ depth_2d = SUCCEEDED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, depth_format));
+ depth_cube = SUCCEEDED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, depth_format));
+ depth_plain = SUCCEEDED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_X8R8G8B8, 0, D3DRTYPE_SURFACE, depth_format));
+
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(surface_types); ++i)
+ {
+ for (j = 0; j < ARRAY_SIZE(tests); ++j)
+ {
+ IDirect3DCubeTexture8 *texture_cube;
+ IDirect3DBaseTexture8 *texture;
+ IDirect3DTexture8 *texture_2d;
+ IDirect3DSurface8 *surface;
+ HRESULT expected_hr;
+ D3DLOCKED_RECT lr;
+
+ if (tests[j].format == FORMAT_ATI2)
+ format = MAKEFOURCC('A','T','I','2');
+ else if (tests[j].format == FORMAT_DEPTH)
+ format = depth_format;
+ else
+ format = colour_format;
+
+ if (tests[j].format == FORMAT_ATI2 && FAILED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT,
+ D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, format)))
+ {
+ skip("ATI2N texture not supported.\n");
+ continue;
+ }
+
+ switch (surface_types[i].type)
+ {
+ 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 == 17 || j == 20 || j == 23 || j == 24
+ || j == 27 || j == 30 || j == 31 || j == 32 || j == 33 || j == 34)
+ 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);
+ if (FAILED(hr))
+ continue;
+
+ hr = IDirect3DTexture8_GetSurfaceLevel(texture_2d, 0, &surface);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ IDirect3DTexture8_Release(texture_2d);
+ break;
+
+ 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 == 17 || j == 20 || j == 23 || j == 24
+ || j == 27 || j == 30 || j == 31 || j == 32 || j == 33 || j == 34)
+ 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);
+ if (FAILED(hr))
+ continue;
+
+ hr = IDirect3DCubeTexture8_GetCubeMapSurface(texture_cube,
+ D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ IDirect3DCubeTexture8_Release(texture_cube);
+ break;
+
+ case SURFACE_RT:
+ hr = IDirect3DDevice8_CreateRenderTarget(device, 16, 16, format,
+ D3DMULTISAMPLE_NONE, tests[j].usage & D3DUSAGE_DYNAMIC, &surface);
+ ok(hr == (tests[j].format == FORMAT_COLOUR ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ if (FAILED(hr))
+ continue;
+ break;
+
+ case SURFACE_DS:
+ hr = IDirect3DDevice8_CreateDepthStencilSurface(device,
+ 16, 16, format, D3DMULTISAMPLE_NONE, &surface);
+ todo_wine_if(tests[j].format == FORMAT_ATI2)
+ ok(hr == (tests[j].format != FORMAT_COLOUR ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ if (FAILED(hr))
+ continue;
+ break;
+
+ case SURFACE_IMAGE:
+ hr = IDirect3DDevice8_CreateImageSurface(device, 16, 16, format, &surface);
+ ok(hr == ((tests[j].format != FORMAT_DEPTH || depth_plain) ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ if (FAILED(hr))
+ continue;
+ break;
+
+ default:
+ ok(0, "Invalid surface type %#x.\n", surface_types[i].type);
+ continue;
+ }
+
+ hr = IDirect3DSurface8_GetDesc(surface, &surface_desc);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ if (surface_types[i].type == SURFACE_RT)
+ {
+ ok(surface_desc.Usage == D3DUSAGE_RENDERTARGET, "Test %s %u: Got unexpected usage %#x.\n",
+ surface_types[i].name, j, surface_desc.Usage);
+ ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
+ surface_types[i].name, j, surface_desc.Pool);
+ }
+ else if (surface_types[i].type == SURFACE_DS)
+ {
+ ok(surface_desc.Usage == D3DUSAGE_DEPTHSTENCIL, "Test %s %u: Got unexpected usage %#x.\n",
+ surface_types[i].name, j, surface_desc.Usage);
+ ok(surface_desc.Pool == D3DPOOL_DEFAULT, "Test %s %u: Got unexpected pool %#x.\n",
+ surface_types[i].name, j, surface_desc.Pool);
+ }
+ else if (surface_types[i].type == SURFACE_IMAGE)
+ {
+ ok(!surface_desc.Usage, "Test %s %u: Got unexpected usage %#x.\n",
+ surface_types[i].name, j, surface_desc.Usage);
+ ok(surface_desc.Pool == D3DPOOL_SYSTEMMEM, "Test %s %u: Got unexpected pool %#x.\n",
+ surface_types[i].name, j, surface_desc.Pool);
+ }
+ else
+ {
+ ok(surface_desc.Usage == tests[j].usage, "Test %s %u: Got unexpected usage %#x.\n",
+ surface_types[i].name, j, surface_desc.Usage);
+ ok(surface_desc.Pool == tests[j].pool, "Test %s %u: Got unexpected pool %#x.\n",
+ surface_types[i].name, j, surface_desc.Pool);
+ }
+
+ hr = IDirect3DSurface8_LockRect(surface, &lr, NULL, 0);
+ if (surface_desc.Pool != D3DPOOL_DEFAULT || surface_desc.Usage & D3DUSAGE_DYNAMIC
+ || (surface_types[i].type == SURFACE_RT && tests[j].usage & D3DUSAGE_DYNAMIC)
+ || surface_types[i].type == SURFACE_IMAGE
+ || tests[j].format == FORMAT_ATI2)
+ expected_hr = D3D_OK;
+ else
+ expected_hr = D3DERR_INVALIDCALL;
+ todo_wine_if(j == 1 && surface_types[i].type != SURFACE_IMAGE)
+ ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ hr = IDirect3DSurface8_UnlockRect(surface);
+ todo_wine_if((expected_hr != D3D_OK && surface_types[i].type == SURFACE_2D)
+ || (j == 1 && surface_types[i].type == SURFACE_CUBE))
+ ok(hr == expected_hr, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+
+ if (SUCCEEDED(IDirect3DSurface8_GetContainer(surface, &IID_IDirect3DBaseTexture8, (void **)&texture)))
+ {
+ hr = IDirect3DDevice8_SetTexture(device, 0, texture);
+ todo_wine_if(surface_desc.Pool == D3DPOOL_SCRATCH)
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ IDirect3DBaseTexture8_Release(texture);
+ }
+
+ hr = IDirect3DDevice8_SetRenderTarget(device, surface, depth_stencil);
+ ok(hr == (surface_desc.Usage & D3DUSAGE_RENDERTARGET ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+
+ hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, surface);
+ todo_wine_if(!(surface_desc.Usage & D3DUSAGE_DEPTHSTENCIL))
+ ok(hr == (surface_desc.Usage & D3DUSAGE_DEPTHSTENCIL ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+ hr = IDirect3DDevice8_SetRenderTarget(device, backbuffer, depth_stencil);
+ ok(hr == D3D_OK, "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
+
+ IDirect3DSurface8_Release(surface);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ IDirect3DVolumeTexture8 *texture;
+ D3DVOLUME_DESC volume_desc;
+ IDirect3DVolume8 *volume;
+ HRESULT expected_hr;
+ D3DLOCKED_BOX lb;
+
+ if (tests[j].format == FORMAT_DEPTH)
+ continue;
+
+ if (tests[j].format == FORMAT_ATI2)
+ format = MAKEFOURCC('A','T','I','2');
+ else
+ format = colour_format;
+
+ hr = IDirect3DDevice8_CreateVolumeTexture(device, 16, 16, 1, 1,
+ tests[i].usage, format, tests[i].pool, &texture);
+ todo_wine_if((tests[i].usage & D3DUSAGE_DEPTHSTENCIL && tests[i].pool == D3DPOOL_SCRATCH)
+ || tests[i].usage & D3DUSAGE_RENDERTARGET)
+ ok(hr == (!(tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3D_OK : D3DERR_INVALIDCALL),
+ "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
+
+ hr = IDirect3DVolumeTexture8_GetVolumeLevel(texture, 0, &volume);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ hr = IDirect3DVolume8_GetDesc(volume, &volume_desc);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(volume_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, volume_desc.Usage);
+ ok(volume_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, volume_desc.Pool);
+
+ hr = IDirect3DVolume8_LockBox(volume, &lb, NULL, 0);
+ if (volume_desc.Pool != D3DPOOL_DEFAULT || volume_desc.Usage & D3DUSAGE_DYNAMIC)
+ expected_hr = D3D_OK;
+ else
+ expected_hr = D3DERR_INVALIDCALL;
+ ok(hr == expected_hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DVolume8_UnlockBox(volume);
+ ok(hr == expected_hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture);
+ todo_wine_if(volume_desc.Pool == D3DPOOL_SCRATCH)
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DDevice8_SetTexture(device, 0, NULL);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ IDirect3DVolume8_Release(volume);
+ IDirect3DVolumeTexture8_Release(texture);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ D3DINDEXBUFFER_DESC ib_desc;
+ IDirect3DIndexBuffer8 *ib;
+ BYTE *data;
+
+ hr = IDirect3DDevice8_CreateIndexBuffer(device, 16, tests[i].usage,
+ tests[i].format == FORMAT_COLOUR ? D3DFMT_INDEX32 : D3DFMT_INDEX16, tests[i].pool, &ib);
+ todo_wine_if(tests[i].pool == D3DPOOL_SCRATCH || tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || (tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
+
+ hr = IDirect3DIndexBuffer8_GetDesc(ib, &ib_desc);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ todo_wine_if(tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ok(ib_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, ib_desc.Usage);
+ ok(ib_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, ib_desc.Pool);
+
+ hr = IDirect3DIndexBuffer8_Lock(ib, 0, 0, &data, 0);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DIndexBuffer8_Unlock(ib);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice8_SetIndices(device, ib, 0);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DDevice8_SetIndices(device, NULL, 0);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ IDirect3DIndexBuffer8_Release(ib);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
+ D3DVERTEXBUFFER_DESC vb_desc;
+ IDirect3DVertexBuffer8 *vb;
+ BYTE *data;
+
+ hr = IDirect3DDevice8_CreateVertexBuffer(device, 16, tests[i].usage,
+ tests[i].format == FORMAT_COLOUR ? 0 : D3DFVF_XYZRHW, tests[i].pool, &vb);
+ todo_wine_if(tests[i].pool != D3DPOOL_SCRATCH && tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ok(hr == (tests[i].pool == D3DPOOL_SCRATCH || (tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ? D3DERR_INVALIDCALL : D3D_OK), "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
+
+ hr = IDirect3DVertexBuffer8_GetDesc(vb, &vb_desc);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ todo_wine_if(tests[i].usage & ~D3DUSAGE_DYNAMIC)
+ ok(vb_desc.Usage == tests[i].usage, "Test %u: Got unexpected usage %#x.\n", i, vb_desc.Usage);
+ ok(vb_desc.Pool == tests[i].pool, "Test %u: Got unexpected pool %#x.\n", i, vb_desc.Pool);
+
+ hr = IDirect3DVertexBuffer8_Lock(vb, 0, 0, &data, 0);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DVertexBuffer8_Unlock(vb);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ hr = IDirect3DDevice8_SetStreamSource(device, 0, vb, 16);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ hr = IDirect3DDevice8_SetStreamSource(device, 0, NULL, 0);
+ ok(hr == D3D_OK, "Test %u: Got unexpected hr %#x.\n", i, hr);
+
+ IDirect3DVertexBuffer8_Release(vb);
+ }
+
+ IDirect3DSurface8_Release(depth_stencil);
+ IDirect3DSurface8_Release(backbuffer);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D8_Release(d3d);
+ DestroyWindow(window);
+}
+
START_TEST(device)
{
HMODULE d3d8_handle = GetModuleHandleA("d3d8.dll");
@@ -8894,6 +9317,7 @@ START_TEST(device)
test_swapchain_multisample_reset();
test_device_caps();
test_get_info();
+ test_resource_access();
UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL));
}
--
2.11.0
More information about the wine-devel
mailing list