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

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-05-24 10:17:48 +02:00 committed by Alexandre Julliard
parent e8aa575ff6
commit bd41d53a23
2 changed files with 29 additions and 0 deletions

View File

@ -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;

View File

@ -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;