Commit bd41d53a authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d9: Check if valid vertex declaration is set before issuing draw call.

parent e8aa575f
......@@ -167,6 +167,7 @@ struct d3d9_device
LONG device_state;
BOOL in_destruction;
BOOL in_scene;
BOOL has_vertex_declaration;
UINT implicit_swapchain_count;
struct d3d9_swapchain **implicit_swapchains;
......
......@@ -2292,6 +2292,12 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface,
iface, primitive_type, start_vertex, primitive_count);
wined3d_mutex_lock();
if (!device->has_vertex_declaration)
{
wined3d_mutex_unlock();
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type);
hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex,
vertex_count_from_primitive_count(primitive_type, primitive_count));
......@@ -2313,6 +2319,12 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface
vertex_count, start_idx, primitive_count);
wined3d_mutex_lock();
if (!device->has_vertex_declaration)
{
wined3d_mutex_unlock();
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
wined3d_device_set_base_vertex_index(device->wined3d_device, base_vertex_idx);
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type);
hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, start_idx,
......@@ -2373,6 +2385,13 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
wined3d_mutex_lock();
if (!device->has_vertex_declaration)
{
wined3d_mutex_unlock();
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
hr = d3d9_device_prepare_vertex_buffer(device, size);
if (FAILED(hr))
goto done;
......@@ -2466,6 +2485,13 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_mutex_lock();
if (!device->has_vertex_declaration)
{
wined3d_mutex_unlock();
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
hr = d3d9_device_prepare_vertex_buffer(device, vtx_size);
if (FAILED(hr))
goto done;
......@@ -2579,6 +2605,7 @@ static HRESULT WINAPI d3d9_device_SetVertexDeclaration(IDirect3DDevice9Ex *iface
wined3d_mutex_lock();
wined3d_device_set_vertex_declaration(device->wined3d_device,
decl_impl ? decl_impl->wined3d_declaration : NULL);
device->has_vertex_declaration = !!decl_impl;
wined3d_mutex_unlock();
return D3D_OK;
......@@ -2702,6 +2729,7 @@ static HRESULT WINAPI d3d9_device_SetFVF(IDirect3DDevice9Ex *iface, DWORD fvf)
}
wined3d_device_set_vertex_declaration(device->wined3d_device, decl);
device->has_vertex_declaration = TRUE;
wined3d_mutex_unlock();
return D3D_OK;
......
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