Commit fd823fc2 authored by Chris Robinson's avatar Chris Robinson Committed by Alexandre Julliard

wined3d: Check for NULL vertex declarations.

parent d9a4299b
......@@ -1505,7 +1505,7 @@ static void test_draw_indexed(void)
hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
hr = IDirect3DDevice9_SetVertexDeclaration(device, NULL);
ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(quad), 0, 0, D3DPOOL_DEFAULT, &vertex_buffer, NULL);
......@@ -1538,11 +1538,19 @@ static void test_draw_indexed(void)
ok(hr == D3DERR_INVALIDCALL, "DrawIndexedPrimitive returned 0x%08x, expected D3DERR_INVALIDCALL (0x%08x)\n",
hr, D3DERR_INVALIDCALL);
/* Valid index buffer. Should succeed */
/* Valid index buffer, NULL vertex declaration. Should fail */
hr = IDirect3DDevice9_SetIndices(device, index_buffer);
ok(SUCCEEDED(hr), "SetIndices failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, 0 /* MinIndex */,
4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
ok(hr == D3DERR_INVALIDCALL, "DrawIndexedPrimitive returned 0x%08x, expected D3DERR_INVALIDCALL (0x%08x)\n",
hr, D3DERR_INVALIDCALL);
/* Valid index buffer and vertex declaration. Should succeed */
hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, 0 /* MinIndex */,
4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed (0x%08x)\n", hr);
hr = IDirect3DDevice9_EndScene(device);
......
......@@ -5165,6 +5165,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, WI
debug_d3dprimitivetype(PrimitiveType),
StartVertex, PrimitiveCount);
if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
/* The index buffer is not needed here, but restore it, otherwise it is hell to keep track of */
if(This->stateBlock->streamIsUP) {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
......@@ -5202,6 +5207,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *
return WINED3DERR_INVALIDCALL;
}
if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
if(This->stateBlock->streamIsUP) {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
This->stateBlock->streamIsUP = FALSE;
......@@ -5240,6 +5250,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
debug_d3dprimitivetype(PrimitiveType),
PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
/* Note in the following, it's not this type, but that's the purpose of streamIsUP */
vb = This->stateBlock->streamSource[0];
This->stateBlock->streamSource[0] = (IWineD3DVertexBuffer *)pVertexStreamZeroData;
......@@ -5280,6 +5295,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
MinVertexIndex, NumVertices, PrimitiveCount, pIndexData,
IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) {
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
if (IndexDataFormat == WINED3DFMT_INDEX16) {
idxStride = 2;
} else {
......
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