Stefan Dösinger : d3d9: Move the vertex buffer alignment test into buffer.c.
Alexandre Julliard
julliard at winehq.org
Tue Feb 2 10:45:30 CST 2010
Module: wine
Branch: master
Commit: 8912b372ed97dfa4ce1cb56ce77eca1f92a311e5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8912b372ed97dfa4ce1cb56ce77eca1f92a311e5
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Sat Jan 30 12:15:40 2010 +0100
d3d9: Move the vertex buffer alignment test into buffer.c.
---
dlls/d3d9/tests/buffer.c | 51 +++++++++++++++++++++++++++++++
dlls/d3d9/tests/device.c | 76 ----------------------------------------------
2 files changed, 51 insertions(+), 76 deletions(-)
diff --git a/dlls/d3d9/tests/buffer.c b/dlls/d3d9/tests/buffer.c
index c2e22c2..a10cefd 100644
--- a/dlls/d3d9/tests/buffer.c
+++ b/dlls/d3d9/tests/buffer.c
@@ -111,6 +111,56 @@ static void lock_flag_test(IDirect3DDevice9 *device)
IDirect3DVertexBuffer9_Release(buffer);
}
+static inline const char *debug_d3dpool(D3DPOOL pool)
+{
+ switch(pool)
+ {
+ case D3DPOOL_DEFAULT: return "D3DPOOL_DEFAULT";
+ case D3DPOOL_SYSTEMMEM: return "D3DPOOL_SYSTEMMEM";
+ case D3DPOOL_SCRATCH: return "D3DPOOL_SCRATCH";
+ case D3DPOOL_MANAGED: return "D3DPOOL_MANAGED";
+ default:
+ return "unknown pool";
+ }
+}
+
+static void test_vertex_buffer_alignment(IDirect3DDevice9 *device)
+{
+ IDirect3DVertexBuffer9 *buffer = NULL;
+ HRESULT hr;
+ D3DPOOL pools[] = {D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH, D3DPOOL_MANAGED};
+ DWORD sizes[] = {1, 4, 16, 17, 32, 33, 64, 65, 1024, 1025, 1048576, 1048577};
+ unsigned int i, j;
+ void *data;
+
+ for(i = 0; i < (sizeof(sizes) / sizeof(sizes[0])); i++)
+ {
+ for(j = 0; j < (sizeof(pools) / sizeof(pools[0])); j++)
+ {
+ hr = IDirect3DDevice9_CreateVertexBuffer(device, sizes[i], 0, 0, pools[j], &buffer, NULL);
+ if(pools[j] == D3DPOOL_SCRATCH)
+ {
+ ok(hr == D3DERR_INVALIDCALL, "Creating a D3DPOOL_SCRATCH buffer returned (0x%08x)\n", hr);
+ }
+ else
+ {
+ ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexBuffer failed (0x%08x). Pool = %s, size %d\n", hr,
+ debug_d3dpool(pools[j]), sizes[i]);
+ }
+ if(FAILED(hr)) continue;
+
+ hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, 0);
+ ok(SUCCEEDED(hr), "IDirect3DVertexBuffer9_Lock failed (0x%08x)\n", hr);
+ ok(((DWORD_PTR) data & 31) == 0, "Vertex buffer start address is not 32 byte aligned(size: %d, pool: %s, data: %p)\n",
+ sizes[i], debug_d3dpool(pools[j]), data);
+ hr = IDirect3DVertexBuffer9_Unlock(buffer);
+ ok(SUCCEEDED(hr), "IDirect3DVertexBuffer9_Unlock failed (0x%08x)\n", hr);
+
+ if(buffer) IDirect3DVertexBuffer9_Release(buffer);
+ }
+ }
+}
+
START_TEST(buffer)
{
IDirect3DDevice9 *device_ptr;
@@ -127,6 +177,7 @@ START_TEST(buffer)
if (!device_ptr) return;
lock_flag_test(device_ptr);
+ test_vertex_buffer_alignment(device_ptr);
refcount = IDirect3DDevice9_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 1e58008..de46082 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -1902,81 +1902,6 @@ cleanup:
if(d3d9) IDirect3D9_Release(d3d9);
}
-static inline const char *debug_d3dpool(D3DPOOL pool) {
- switch(pool) {
- case D3DPOOL_DEFAULT: return "D3DPOOL_DEFAULT";
- case D3DPOOL_SYSTEMMEM: return "D3DPOOL_SYSTEMMEM";
- case D3DPOOL_SCRATCH: return "D3DPOOL_SCRATCH";
- case D3DPOOL_MANAGED: return "D3DPOOL_MANAGED";
- default:
- return "unknown pool";
- }
-}
-
-static void test_vertex_buffer_alignment(void)
-{
- IDirect3DVertexBuffer9 *buffer = NULL;
- D3DPRESENT_PARAMETERS present_parameters;
- IDirect3DDevice9 *device = NULL;
- IDirect3D9 *d3d9;
- HWND hwnd;
- HRESULT hr;
- D3DPOOL pools[] = {D3DPOOL_DEFAULT, D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH, D3DPOOL_MANAGED};
- DWORD sizes[] = {1, 4, 16, 17, 32, 33, 64, 65, 1024, 1025, 1048576, 1048577};
- unsigned int i, j;
- void *data;
-
- d3d9 = pDirect3DCreate9( D3D_SDK_VERSION );
- ok(d3d9 != NULL, "Failed to create IDirect3D9 object\n");
- hwnd = CreateWindow( "static", "d3d9_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL );
- ok(hwnd != NULL, "Failed to create window\n");
- if (!d3d9 || !hwnd) goto cleanup;
-
- ZeroMemory(&present_parameters, sizeof(present_parameters));
- present_parameters.Windowed = TRUE;
- present_parameters.hDeviceWindow = hwnd;
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
-
- hr = IDirect3D9_CreateDevice( d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL /* no NULLREF here */, hwnd,
- D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device );
- ok(hr == D3D_OK || hr == D3DERR_NOTAVAILABLE, "IDirect3D9_CreateDevice failed with %08x\n", hr);
- if(!device)
- {
- skip("Failed to create a d3d device\n");
- goto cleanup;
- }
-
- for(i = 0; i < (sizeof(sizes) / sizeof(sizes[0])); i++) {
- for(j = 0; j < (sizeof(pools) / sizeof(pools[0])); j++) {
- hr = IDirect3DDevice9_CreateVertexBuffer(device, sizes[i], 0, 0, pools[j], &buffer, NULL);
- if(pools[j] == D3DPOOL_SCRATCH) {
- ok(hr == D3DERR_INVALIDCALL, "Creating a D3DPOOL_SCRATCH buffer returned (0x%08x)\n", hr);
- } else {
- ok(SUCCEEDED(hr), "IDirect3DDevice9_CreateVertexBuffer failed (0x%08x). Pool = %s, size %d\n", hr,
- debug_d3dpool(pools[j]), sizes[i]);
- }
- if(FAILED(hr)) continue;
-
- hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, 0);
- ok(SUCCEEDED(hr), "IDirect3DVertexBuffer9_Lock failed (0x%08x)\n", hr);
- ok(((DWORD_PTR) data & 31) == 0, "Vertex buffer start address is not 32 byte aligned(size: %d, pool: %s, data: %p)\n",
- sizes[i], debug_d3dpool(pools[j]), data);
- hr = IDirect3DVertexBuffer9_Unlock(buffer);
- ok(SUCCEEDED(hr), "IDirect3DVertexBuffer9_Unlock failed (0x%08x)\n", hr);
-
- if(buffer) IDirect3DVertexBuffer9_Release(buffer);
- }
- }
-
-cleanup:
- if (device)
- {
- UINT refcount = IDirect3DDevice9_Release(device);
- ok(!refcount, "Device has %u references left.\n", refcount);
- }
- if (d3d9) IDirect3D9_Release(d3d9);
-}
-
static void test_lights(void)
{
D3DPRESENT_PARAMETERS present_parameters;
@@ -2660,7 +2585,6 @@ START_TEST(device)
test_depthstenciltest();
test_draw_indexed();
test_null_stream();
- test_vertex_buffer_alignment();
test_lights();
test_set_stream_source();
test_scissor_size();
More information about the wine-cvs
mailing list