Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/device.c | 48 +++++++++++++++++++------------------- dlls/ddraw/executebuffer.c | 23 +++++++++--------- dlls/ddraw/vertexbuffer.c | 29 +++++++++++------------ 3 files changed, 49 insertions(+), 51 deletions(-)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 7fd78e6234..e18c2c7853 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -3513,7 +3513,6 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface, size = vertex_count * stride;
wined3d_mutex_lock(); - wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d_device_prepare_vertex_buffer(device, size); if (FAILED(hr)) goto done; @@ -3536,12 +3535,13 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface, wined3d_resource_unmap(vb, 0); device->vertex_buffer_pos = vb_pos + size;
- hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, stride); + hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer, 0, stride); if (FAILED(hr)) goto done;
- wined3d_device_set_vertex_declaration(device->wined3d_device, ddraw_find_decl(device->ddraw, fvf)); + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf)); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / stride, vertex_count);
done: @@ -3706,7 +3706,6 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, /* Set the D3DDevice's FVF */ wined3d_mutex_lock();
- wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d_device_prepare_vertex_buffer(device, vtx_size); if (FAILED(hr)) goto done; @@ -3746,14 +3745,15 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface, wined3d_resource_unmap(ib, 0); device->index_buffer_pos = ib_pos + idx_size;
- hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, stride); + hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer, 0, stride); if (FAILED(hr)) goto done; - wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer, WINED3DFMT_R16_UINT, 0); + wined3d_stateblock_set_index_buffer(device->state, device->index_buffer, WINED3DFMT_R16_UINT);
- wined3d_device_set_vertex_declaration(device->wined3d_device, ddraw_find_decl(device->ddraw, fvf)); + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf)); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); - wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos / stride); + wined3d_stateblock_set_base_vertex_index(device->state, vb_pos / stride); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(*indices), index_count);
done: @@ -4051,7 +4051,6 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM }
wined3d_mutex_lock(); - wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d_device_prepare_vertex_buffer(device, dst_size); if (FAILED(hr)) goto done; @@ -4074,12 +4073,13 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM wined3d_resource_unmap(vb, 0); device->vertex_buffer_pos = vb_pos + dst_size;
- hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, dst_stride); + hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer, 0, dst_stride); if (FAILED(hr)) goto done; - wined3d_device_set_vertex_declaration(device->wined3d_device, ddraw_find_decl(device->ddraw, fvf)); + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf));
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / dst_stride, vertex_count);
done: @@ -4168,7 +4168,6 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
wined3d_mutex_lock();
- wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d_device_prepare_vertex_buffer(device, vtx_dst_size); if (FAILED(hr)) goto done; @@ -4208,14 +4207,15 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface, wined3d_resource_unmap(ib, 0); device->index_buffer_pos = ib_pos + idx_size;
- hr = wined3d_device_set_stream_source(device->wined3d_device, 0, device->vertex_buffer, 0, vtx_dst_stride); + hr = wined3d_stateblock_set_stream_source(device->state, 0, device->vertex_buffer, 0, vtx_dst_stride); if (FAILED(hr)) goto done; - wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer, WINED3DFMT_R16_UINT, 0); - wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos / vtx_dst_stride); + wined3d_stateblock_set_index_buffer(device->state, device->index_buffer, WINED3DFMT_R16_UINT); + wined3d_stateblock_set_base_vertex_index(device->state, vb_pos / vtx_dst_stride);
- wined3d_device_set_vertex_declaration(device->wined3d_device, ddraw_find_decl(device->ddraw, fvf)); + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf)); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(WORD), index_count);
done: @@ -4326,9 +4326,8 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE }
wined3d_mutex_lock(); - wined3d_device_apply_stateblock(device->wined3d_device, device->state); - wined3d_device_set_vertex_declaration(device->wined3d_device, vb_impl->wined3d_declaration); - if (FAILED(hr = wined3d_device_set_stream_source(device->wined3d_device, + wined3d_stateblock_set_vertex_declaration(device->state, vb_impl->wined3d_declaration); + if (FAILED(hr = wined3d_stateblock_set_stream_source(device->state, 0, vb_impl->wined3d_buffer, 0, stride))) { WARN("Failed to set stream source, hr %#x.\n", hr); @@ -4338,6 +4337,7 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
/* Now draw the primitives */ wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex, vertex_count);
wined3d_mutex_unlock(); @@ -4449,8 +4449,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
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_stateblock_set_vertex_declaration(device->state, vb_impl->wined3d_declaration);
hr = d3d_device_prepare_index_buffer(device, index_count * sizeof(WORD)); if (FAILED(hr)) @@ -4479,11 +4478,11 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, device->index_buffer_pos = ib_pos + index_count * sizeof(WORD);
/* Set the index stream */ - wined3d_device_set_base_vertex_index(device->wined3d_device, start_vertex); - wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer, WINED3DFMT_R16_UINT, 0); + wined3d_stateblock_set_base_vertex_index(device->state, start_vertex); + wined3d_stateblock_set_index_buffer(device->state, device->index_buffer, WINED3DFMT_R16_UINT);
/* Set the vertex stream source */ - if (FAILED(hr = wined3d_device_set_stream_source(device->wined3d_device, + if (FAILED(hr = wined3d_stateblock_set_stream_source(device->state, 0, vb_impl->wined3d_buffer, 0, stride))) { ERR("(%p) IDirect3DDevice::SetStreamSource failed with hr = %08x\n", device, hr); @@ -4492,6 +4491,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface, }
wined3d_device_set_primitive_type(device->wined3d_device, primitive_type, 0); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(WORD), index_count);
wined3d_mutex_unlock(); diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c index 0d1726ed7f..1b680f627e 100644 --- a/dlls/ddraw/executebuffer.c +++ b/dlls/ddraw/executebuffer.c @@ -74,13 +74,13 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d case D3DOP_POINT: { 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_stream_source(device->wined3d_device, 0, + wined3d_stateblock_set_stream_source(device->state, 0, buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX)); - wined3d_device_set_vertex_declaration(device->wined3d_device, + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state); for (i = 0; i < count; ++i) wined3d_device_draw_primitive(device->wined3d_device, p[i].wFirst, p[i].wCount);
@@ -107,8 +107,6 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d primitive_size = 3; }
- wined3d_device_apply_stateblock(device->wined3d_device, device->state); - index_count = count * primitive_size; if (buffer->index_size < index_count) { @@ -185,11 +183,12 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->index_buffer), 0);
- wined3d_device_set_stream_source(device->wined3d_device, 0, + wined3d_stateblock_set_stream_source(device->state, 0, buffer->dst_vertex_buffer, 0, sizeof(D3DTLVERTEX)); - wined3d_device_set_vertex_declaration(device->wined3d_device, + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX)); - wined3d_device_set_index_buffer(device->wined3d_device, buffer->index_buffer, WINED3DFMT_R16_UINT, 0); + wined3d_stateblock_set_index_buffer(device->state, buffer->index_buffer, WINED3DFMT_R16_UINT); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); wined3d_device_draw_indexed_primitive(device->wined3d_device, index_pos, index_count);
buffer->index_pos = index_pos + index_count; @@ -303,14 +302,14 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d { case D3DPROCESSVERTICES_TRANSFORMLIGHT: case D3DPROCESSVERTICES_TRANSFORM: - wined3d_device_apply_stateblock(device->wined3d_device, device->state); - wined3d_device_set_stream_source(device->wined3d_device, 0, + wined3d_stateblock_set_stream_source(device->state, 0, buffer->src_vertex_buffer, buffer->src_vertex_pos * sizeof(D3DVERTEX), sizeof(D3DVERTEX)); - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_LIGHTING, + wined3d_stateblock_set_render_state(device->state, WINED3D_RS_LIGHTING, op == D3DPROCESSVERTICES_TRANSFORMLIGHT && !!device->material); - wined3d_device_set_vertex_declaration(device->wined3d_device, + wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, op == D3DPROCESSVERTICES_TRANSFORMLIGHT ? D3DFVF_VERTEX : D3DFVF_LVERTEX)); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); wined3d_device_process_vertices(device->wined3d_device, ci->wStart, ci->wDest, ci->dwCount, buffer->dst_vertex_buffer, NULL, 0, D3DFVF_TLVERTEX); break; diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c index 1e3d25f6cb..afd798cb9f 100644 --- a/dlls/ddraw/vertexbuffer.c +++ b/dlls/ddraw/vertexbuffer.c @@ -80,17 +80,13 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface)
if (!ref) { - struct wined3d_buffer *vb = NULL; - UINT offset, stride; - /* D3D7 vertex buffers don't stay bound in the device, they are passed * as a parameter to DrawPrimitiveVB. DrawPrimitiveVB sets them as the * stream source in wined3d and they should get unset there before * they are destroyed. */ wined3d_mutex_lock(); - wined3d_device_get_stream_source(buffer->ddraw->wined3d_device, 0, &vb, &offset, &stride); - if (vb == buffer->wined3d_buffer) - wined3d_device_set_stream_source(buffer->ddraw->wined3d_device, 0, NULL, 0, 0); + if (wined3d_stateblock_get_state(buffer->ddraw->state)->streams[0].buffer == buffer->wined3d_buffer) + wined3d_stateblock_set_stream_source(buffer->ddraw->state, 0, NULL, 0, 0);
wined3d_vertex_declaration_decref(buffer->wined3d_declaration); wined3d_buffer_decref(buffer->wined3d_buffer); @@ -258,6 +254,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 ? unsafe_impl_from_IDirect3DDevice7(device) : unsafe_impl_from_IDirect3DDevice3((IDirect3DDevice3 *)device); BOOL old_clip, do_clip, old_lighting, do_lighting; + const struct wined3d_stateblock_state *state; HRESULT hr;
TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n", @@ -277,18 +274,19 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); - wined3d_device_apply_stateblock(device_impl->wined3d_device, device_impl->state); + + state = wined3d_stateblock_get_state(device_impl->state);
/* WineD3D doesn't know d3d7 vertex operation, it uses * render states instead. Set the render states according to * the vertex ops */ do_clip = !!(vertex_op & D3DVOP_CLIP); - old_clip = !!wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING); + old_clip = !!state->rs[WINED3D_RS_CLIPPING]; if (do_clip != old_clip) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, do_clip); + wined3d_stateblock_set_render_state(device_impl->state, WINED3D_RS_CLIPPING, do_clip);
- old_lighting = !!wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING); + old_lighting = !!state->rs[WINED3D_RS_LIGHTING]; if (dst_buffer_impl->version == 3) do_lighting = device_impl->material && (src_buffer_impl->fvf & D3DFVF_NORMAL) && (vertex_op & D3DVOP_LIGHT); @@ -296,19 +294,20 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 do_lighting = old_lighting && (vertex_op & D3DVOP_LIGHT);
if (do_lighting != old_lighting) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING, do_lighting); + wined3d_stateblock_set_render_state(device_impl->state, WINED3D_RS_LIGHTING, do_lighting);
- wined3d_device_set_stream_source(device_impl->wined3d_device, + wined3d_stateblock_set_stream_source(device_impl->state, 0, src_buffer_impl->wined3d_buffer, 0, get_flexible_vertex_size(src_buffer_impl->fvf)); - wined3d_device_set_vertex_declaration(device_impl->wined3d_device, src_buffer_impl->wined3d_declaration); + wined3d_stateblock_set_vertex_declaration(device_impl->state, src_buffer_impl->wined3d_declaration); + wined3d_device_apply_stateblock(device_impl->wined3d_device, device_impl->state); hr = wined3d_device_process_vertices(device_impl->wined3d_device, src_idx, dst_idx, count, dst_buffer_impl->wined3d_buffer, NULL, flags, dst_buffer_impl->fvf);
/* Restore the states if needed */ if (do_clip != old_clip) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, old_clip); + wined3d_stateblock_set_render_state(device_impl->state, WINED3D_RS_CLIPPING, old_clip); if (do_lighting != old_lighting) - wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_LIGHTING, old_lighting); + wined3d_stateblock_set_render_state(device_impl->state, WINED3D_RS_LIGHTING, old_lighting);
wined3d_mutex_unlock();