Commit a40185f1 authored by Kolbjørn Fredheim's avatar Kolbjørn Fredheim Committed by Alexandre Julliard

ddraw: Don't clear the return value anymore, we fill the fields anyway, also a…

ddraw: Don't clear the return value anymore, we fill the fields anyway, also a test for the behaviour.
parent 3e30e298
......@@ -1530,6 +1530,67 @@ static void TextureLoadTest(void)
if (Texture2) IDirect3DTexture_Release(Texture2);
}
static void VertexBufferDescTest(void)
{
HRESULT rc;
D3DVERTEXBUFFERDESC desc;
union mem_t
{
D3DVERTEXBUFFERDESC desc2;
unsigned char buffer[512];
} mem;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwCaps = 0;
desc.dwFVF = D3DFVF_XYZ;
desc.dwNumVertices = 1;
rc = IDirect3D7_CreateVertexBuffer(lpD3D, &desc, &lpVBufSrc, 0);
ok(rc==D3D_OK || rc==E_OUTOFMEMORY, "CreateVertexBuffer returned: %x\n", rc);
if (!lpVBufSrc)
{
trace("IDirect3D7::CreateVertexBuffer() failed with an error %x\n", rc);
goto out;
}
memset(mem.buffer, 0x12, sizeof(mem.buffer));
mem.desc2.dwSize = sizeof(D3DVERTEXBUFFERDESC)*2;
rc = IDirect3DVertexBuffer7_GetVertexBufferDesc(lpVBufSrc, &mem.desc2);
if(rc != D3D_OK)
skip("GetVertexBuffer Failed!\n");
ok( mem.desc2.dwSize == sizeof(D3DVERTEXBUFFERDESC)*2, "Size returned from GetVertexBufferDesc does not match the value put in\n" );
ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was double the size of the struct)\n");
ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x \n", mem.desc2.dwCaps, desc.dwCaps);
ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x \n", mem.desc2.dwFVF, desc.dwFVF);
ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
memset(mem.buffer, 0x12, sizeof(mem.buffer));
mem.desc2.dwSize = 0;
rc = IDirect3DVertexBuffer7_GetVertexBufferDesc(lpVBufSrc, &mem.desc2);
if(rc != D3D_OK)
skip("GetVertexBuffer Failed!\n");
ok( mem.desc2.dwSize == 0, "Size returned from GetVertexBufferDesc does not match the value put in\n" );
ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was 0)\n");
ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x \n", mem.desc2.dwCaps, desc.dwCaps);
ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x \n", mem.desc2.dwFVF, desc.dwFVF);
ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
memset(mem.buffer, 0x12, sizeof(mem.buffer));
mem.desc2.dwSize = sizeof(D3DVERTEXBUFFERDESC);
rc = IDirect3DVertexBuffer7_GetVertexBufferDesc(lpVBufSrc, &mem.desc2);
if(rc != D3D_OK)
skip("GetVertexBuffer Failed!\n");
ok( mem.desc2.dwSize == sizeof(D3DVERTEXBUFFERDESC), "Size returned from GetVertexBufferDesc does not match the value put in\n" );
ok( mem.buffer[sizeof(D3DVERTEXBUFFERDESC)] == 0x12, "GetVertexBufferDesc cleared outside of the struct! (dwSize was the size of the struct)\n");
ok( mem.desc2.dwCaps == desc.dwCaps, "dwCaps returned differs. Got %x, expected %x \n", mem.desc2.dwCaps, desc.dwCaps);
ok( mem.desc2.dwFVF == desc.dwFVF, "dwFVF returned differs. Got %x, expected %x \n", mem.desc2.dwFVF, desc.dwFVF);
ok (mem.desc2.dwNumVertices == desc.dwNumVertices, "dwNumVertices returned differs. Got %x, expected %x\n", mem.desc2.dwNumVertices, desc.dwNumVertices);
out:
IDirect3DVertexBuffer7_Release(lpVBufSrc);
}
START_TEST(d3d)
{
init_function_pointers();
......@@ -1548,6 +1609,7 @@ START_TEST(d3d)
LimitTest();
D3D7EnumTest();
CapsTest();
VertexBufferDescTest();
ReleaseDirect3D();
}
......
......@@ -454,7 +454,6 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
WINED3DVERTEXBUFFER_DESC WDesc;
HRESULT hr;
DWORD size;
TRACE("(%p)->(%p)\n", This, Desc);
if(!Desc) return DDERR_INVALIDPARAMS;
......@@ -469,12 +468,7 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
return hr;
}
/* Clear the return value of garbage */
size = Desc->dwSize;
memset(Desc, 0, size);
/* Now fill the Desc structure */
Desc->dwSize = size;
Desc->dwCaps = This->Caps;
Desc->dwFVF = WDesc.FVF;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
......
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