Commit 92dd6dd1 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ddraw: Apply the device state before executing a draw call.

parent d580d2c2
...@@ -3520,6 +3520,7 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface, ...@@ -3520,6 +3520,7 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface,
size = vertex_count * stride; size = vertex_count * stride;
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d_device_prepare_vertex_buffer(device, size); hr = d3d_device_prepare_vertex_buffer(device, size);
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
...@@ -3713,6 +3714,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, ...@@ -3713,6 +3714,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
/* Set the D3DDevice's FVF */ /* Set the D3DDevice's FVF */
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d_device_prepare_vertex_buffer(device, vtx_size); hr = d3d_device_prepare_vertex_buffer(device, vtx_size);
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
...@@ -4057,6 +4059,7 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM ...@@ -4057,6 +4059,7 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM
} }
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d_device_prepare_vertex_buffer(device, dst_size); hr = d3d_device_prepare_vertex_buffer(device, dst_size);
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
...@@ -4173,6 +4176,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, ...@@ -4173,6 +4176,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d_device_prepare_vertex_buffer(device, vtx_dst_size); hr = d3d_device_prepare_vertex_buffer(device, vtx_dst_size);
if (FAILED(hr)) if (FAILED(hr))
goto done; goto done;
...@@ -4330,6 +4334,7 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE ...@@ -4330,6 +4334,7 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
} }
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_set_vertex_declaration(device->wined3d_device, vb_impl->wined3d_declaration); wined3d_device_set_vertex_declaration(device->wined3d_device, vb_impl->wined3d_declaration);
if (FAILED(hr = wined3d_device_set_stream_source(device->wined3d_device, if (FAILED(hr = wined3d_device_set_stream_source(device->wined3d_device,
0, vb_impl->wined3d_buffer, 0, stride))) 0, vb_impl->wined3d_buffer, 0, stride)))
...@@ -4452,6 +4457,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, ...@@ -4452,6 +4457,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_set_vertex_declaration(device->wined3d_device, vb_impl->wined3d_declaration); wined3d_device_set_vertex_declaration(device->wined3d_device, vb_impl->wined3d_declaration);
hr = d3d_device_prepare_index_buffer(device, index_count * sizeof(WORD)); hr = d3d_device_prepare_index_buffer(device, index_count * sizeof(WORD));
...@@ -5251,6 +5257,7 @@ static HRESULT d3d_device7_ValidateDevice(IDirect3DDevice7 *iface, DWORD *pass_c ...@@ -5251,6 +5257,7 @@ static HRESULT d3d_device7_ValidateDevice(IDirect3DDevice7 *iface, DWORD *pass_c
TRACE("iface %p, pass_count %p.\n", iface, pass_count); TRACE("iface %p, pass_count %p.\n", iface, pass_count);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_validate_device(device->wined3d_device, pass_count); hr = wined3d_device_validate_device(device->wined3d_device, pass_count);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
...@@ -5313,7 +5320,7 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count, ...@@ -5313,7 +5320,7 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count,
(color & 0xff) / 255.0f, (color & 0xff) / 255.0f,
((color >> 24) & 0xff) / 255.0f, ((color >> 24) & 0xff) / 255.0f,
}; };
struct d3d_device *This = impl_from_IDirect3DDevice7(iface); struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
HRESULT hr; HRESULT hr;
TRACE("iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.\n", TRACE("iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.\n",
...@@ -5326,7 +5333,8 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count, ...@@ -5326,7 +5333,8 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count,
} }
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_device_clear(This->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil); wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_clear(device->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return hr;
......
...@@ -74,6 +74,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d ...@@ -74,6 +74,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
case D3DOP_POINT: case D3DOP_POINT:
{ {
const D3DPOINT *p = (D3DPOINT *)instr; const D3DPOINT *p = (D3DPOINT *)instr;
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_POINTLIST, 0); wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_POINTLIST, 0);
wined3d_device_set_stream_source(device->wined3d_device, 0, wined3d_device_set_stream_source(device->wined3d_device, 0,
buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX)); buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX));
...@@ -106,6 +107,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d ...@@ -106,6 +107,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
primitive_size = 3; primitive_size = 3;
} }
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
index_count = count * primitive_size; index_count = count * primitive_size;
if (buffer->index_size < index_count) if (buffer->index_size < index_count)
{ {
...@@ -300,6 +303,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d ...@@ -300,6 +303,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
{ {
case D3DPROCESSVERTICES_TRANSFORMLIGHT: case D3DPROCESSVERTICES_TRANSFORMLIGHT:
case D3DPROCESSVERTICES_TRANSFORM: case D3DPROCESSVERTICES_TRANSFORM:
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
wined3d_device_set_stream_source(device->wined3d_device, 0, wined3d_device_set_stream_source(device->wined3d_device, 0,
buffer->src_vertex_buffer, buffer->src_vertex_pos * sizeof(D3DVERTEX), sizeof(D3DVERTEX)); buffer->src_vertex_buffer, buffer->src_vertex_pos * sizeof(D3DVERTEX), sizeof(D3DVERTEX));
wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING,
......
...@@ -1472,6 +1472,7 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT * ...@@ -1472,6 +1472,7 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
dst_surface->palette, fill_colour, &colour)) dst_surface->palette, fill_colour, &colour))
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
wined3d_device_apply_stateblock(wined3d_device, dst_surface->ddraw->state);
return wined3d_device_clear_rendertarget_view(wined3d_device, return wined3d_device_clear_rendertarget_view(wined3d_device,
ddraw_surface_get_rendertarget_view(dst_surface), ddraw_surface_get_rendertarget_view(dst_surface),
dst_rect, wined3d_flags, &colour, 0.0f, 0); dst_rect, wined3d_flags, &colour, 0.0f, 0);
...@@ -1487,6 +1488,7 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT * ...@@ -1487,6 +1488,7 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
dst_surface->palette, fill_colour, &colour)) dst_surface->palette, fill_colour, &colour))
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
wined3d_device_apply_stateblock(wined3d_device, dst_surface->ddraw->state);
return wined3d_device_clear_rendertarget_view(wined3d_device, return wined3d_device_clear_rendertarget_view(wined3d_device,
ddraw_surface_get_rendertarget_view(dst_surface), ddraw_surface_get_rendertarget_view(dst_surface),
dst_rect, wined3d_flags, NULL, colour.r, 0); dst_rect, wined3d_flags, NULL, colour.r, 0);
......
...@@ -277,6 +277,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 ...@@ -277,6 +277,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_apply_stateblock(device_impl->wined3d_device, device_impl->state);
/* WineD3D doesn't know d3d7 vertex operation, it uses /* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to * render states instead. Set the render states according to
......
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