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

d3d9/tests: Add a test for ProcessVertices() on D3DPOOL_SYSTEMMEM buffers.

parent 9fa65a87
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
* causes visible results in games can be tested in a way that does not depend on pixel exactness * causes visible results in games can be tested in a way that does not depend on pixel exactness
*/ */
#include <limits.h>
#include <math.h> #include <math.h>
#define COBJMACROS #define COBJMACROS
...@@ -73,6 +74,30 @@ static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) ...@@ -73,6 +74,30 @@ static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
return TRUE; return TRUE;
} }
static BOOL compare_float(float f, float g, unsigned int ulps)
{
int x = *(int *)&f;
int y = *(int *)&g;
if (x < 0)
x = INT_MIN - x;
if (y < 0)
y = INT_MIN - y;
if (abs(x - y) > ulps)
return FALSE;
return TRUE;
}
static BOOL compare_vec4(const struct vec4 *vec, float x, float y, float z, float w, unsigned int ulps)
{
return compare_float(vec->x, x, ulps)
&& compare_float(vec->y, y, ulps)
&& compare_float(vec->z, z, ulps)
&& compare_float(vec->w, w, ulps);
}
static BOOL adapter_is_warp(const D3DADAPTER_IDENTIFIER9 *identifier) static BOOL adapter_is_warp(const D3DADAPTER_IDENTIFIER9 *identifier)
{ {
return !strcmp(identifier->Driver, "d3d10warp.dll"); return !strcmp(identifier->Driver, "d3d10warp.dll");
...@@ -24199,12 +24224,14 @@ static void test_color_vertex(void) ...@@ -24199,12 +24224,14 @@ static void test_color_vertex(void)
static void test_sysmem_draw(void) static void test_sysmem_draw(void)
{ {
IDirect3DVertexBuffer9 *vb, *vb_s0, *vb_s1, *dst_vb;
IDirect3DVertexDeclaration9 *vertex_declaration; IDirect3DVertexDeclaration9 *vertex_declaration;
IDirect3DVertexBuffer9 *vb, *vb_s0, *vb_s1;
IDirect3DIndexBuffer9 *ib; IDirect3DIndexBuffer9 *ib;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
struct vec4 *dst_data;
IDirect3D9 *d3d; IDirect3D9 *d3d;
D3DCOLOR colour; D3DCOLOR colour;
unsigned int i;
ULONG refcount; ULONG refcount;
HWND window; HWND window;
HRESULT hr; HRESULT hr;
...@@ -24223,10 +24250,10 @@ static void test_sysmem_draw(void) ...@@ -24223,10 +24250,10 @@ static void test_sysmem_draw(void)
} }
quad[] = quad[] =
{ {
{{-1.0f, -1.0f, 0.0f}, 0xffff0000}, {{-0.5f, -0.5f, 0.0f}, 0xffff0000},
{{-1.0f, 1.0f, 0.0f}, 0xff00ff00}, {{-0.5f, 0.5f, 0.0f}, 0xff00ff00},
{{ 1.0f, -1.0f, 0.0f}, 0xff0000ff}, {{ 0.5f, -0.5f, 0.0f}, 0xff0000ff},
{{ 1.0f, 1.0f, 0.0f}, 0xffffffff}, {{ 0.5f, 0.5f, 0.0f}, 0xffffffff},
}; };
static const struct vec3 quad_s0[] = static const struct vec3 quad_s0[] =
{ {
...@@ -24296,6 +24323,23 @@ static void test_sysmem_draw(void) ...@@ -24296,6 +24323,23 @@ static void test_sysmem_draw(void)
colour = getPixelColor(device, 320, 240); colour = getPixelColor(device, 320, 240);
ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour); ok(color_match(colour, 0x00007f7f, 1), "Got unexpected colour 0x%08x.\n", colour);
hr = IDirect3DDevice9_CreateVertexBuffer(device, ARRAY_SIZE(quad) * sizeof(*dst_data),
0, D3DFVF_XYZRHW, D3DPOOL_SYSTEMMEM, &dst_vb, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_ProcessVertices(device, 0, 0, ARRAY_SIZE(quad), dst_vb, NULL, 0);
todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer9_Lock(dst_vb, 0, 0, (void **)&dst_data, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(quad); ++i)
{
todo_wine ok(compare_vec4(&dst_data[i], quad[i].position.x * 320.0f + 320.0f,
-quad[i].position.y * 240.0f + 240.0f, 0.0f, 1.0f, 1),
"Got unexpected vertex %u {%.8e, %.8e, %.8e, %.8e}.\n",
i, dst_data[i].x, dst_data[i].y, dst_data[i].z, dst_data[i].w);
}
hr = IDirect3DVertexBuffer9_Unlock(dst_vb);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0, hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL); D3DFMT_INDEX16, D3DPOOL_SYSTEMMEM, &ib, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
...@@ -24379,6 +24423,7 @@ static void test_sysmem_draw(void) ...@@ -24379,6 +24423,7 @@ static void test_sysmem_draw(void)
IDirect3DVertexBuffer9_Release(vb_s0); IDirect3DVertexBuffer9_Release(vb_s0);
IDirect3DVertexDeclaration9_Release(vertex_declaration); IDirect3DVertexDeclaration9_Release(vertex_declaration);
IDirect3DIndexBuffer9_Release(ib); IDirect3DIndexBuffer9_Release(ib);
IDirect3DVertexBuffer9_Release(dst_vb);
IDirect3DVertexBuffer9_Release(vb); IDirect3DVertexBuffer9_Release(vb);
refcount = IDirect3DDevice9_Release(device); refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount); ok(!refcount, "Device has %u references left.\n", refcount);
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