[PATCH 1/5] ddraw: Set the primary stateblock when executing draw calls.
Signed-off-by: Zebediah Figura <z.figura12(a)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(); -- 2.25.0
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/device.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 4ecd83d006..088092830c 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -68,6 +68,7 @@ struct FvfToDecl | WINED3D_LEGACY_CUBEMAP_FILTERING) #define DDRAW_MAX_ACTIVE_LIGHTS 32 +#define DDRAW_MAX_TEXTURES 8 enum ddraw_device_state { diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index e18c2c7853..575050acd2 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2462,7 +2462,7 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface, *value = 0; wined3d_mutex_lock(); - if ((tex = wined3d_device_get_texture(device->wined3d_device, 0))) + if ((tex = wined3d_stateblock_get_state(device->state)->textures[0])) { /* The parent of the texture is the IDirectDrawSurface7 * interface of the ddraw surface. */ @@ -2699,7 +2699,7 @@ static void fixup_texture_alpha_op(struct d3d_device *device) if (!(device->legacyTextureBlending && device->texture_map_blend == D3DTBLEND_MODULATE)) return; - if ((tex = wined3d_device_get_texture(device->wined3d_device, 0))) + if ((tex = wined3d_stateblock_get_state(device->state)->textures[0])) { struct wined3d_resource_desc desc; @@ -4759,8 +4759,15 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface, if (!texture) return DDERR_INVALIDPARAMS; + if (stage >= DDRAW_MAX_TEXTURES) + { + WARN("Invalid stage %u.\n", stage); + *texture = NULL; + return D3D_OK; + } + wined3d_mutex_lock(); - if (!(wined3d_texture = wined3d_device_get_texture(device->wined3d_device, stage))) + if (!(wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[stage])) { *texture = NULL; wined3d_mutex_unlock(); -- 2.25.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=65884 Your paranoid android. === debian10 (32 bit report) === ddraw: ddraw4: Timeout ddraw7: Timeout ddrawmodes: Timeout dsurface: Timeout === debian10 (build log) === The task timed out
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/ddraw/device.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 575050acd2..f189d32d95 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2758,7 +2758,6 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface, if (value == 0) { wined3d_stateblock_set_texture(device->state, 0, NULL); - wined3d_device_set_texture(device->wined3d_device, 0, NULL); hr = D3D_OK; break; } @@ -4849,8 +4848,6 @@ static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface, wined3d_mutex_lock(); wined3d_stateblock_set_texture(device->update_state, stage, wined3d_texture); - if (!device->recording) - wined3d_device_set_texture(device->wined3d_device, stage, wined3d_texture); wined3d_mutex_unlock(); return D3D_OK; -- 2.25.0
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/ddraw/device.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index f189d32d95..ec9997c6cb 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2317,9 +2317,8 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, { case D3DRENDERSTATE_TEXTUREMAG: { - enum wined3d_texture_filter_type tex_mag; + enum wined3d_texture_filter_type tex_mag = device_state->sampler_states[0][WINED3D_SAMP_MAG_FILTER]; - tex_mag = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MAG_FILTER); switch (tex_mag) { case WINED3D_TEXF_POINT: @@ -2340,8 +2339,8 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, enum wined3d_texture_filter_type tex_min; enum wined3d_texture_filter_type tex_mip; - tex_min = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MIN_FILTER); - tex_mip = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_MIP_FILTER); + tex_min = device_state->sampler_states[0][WINED3D_SAMP_MIN_FILTER]; + tex_mip = device_state->sampler_states[0][WINED3D_SAMP_MIP_FILTER]; switch (tex_min) { case WINED3D_TEXF_POINT: @@ -2390,10 +2389,10 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface, case D3DRENDERSTATE_TEXTUREADDRESS: case D3DRENDERSTATE_TEXTUREADDRESSU: - *value = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_ADDRESS_U); + *value = device_state->sampler_states[0][WINED3D_SAMP_ADDRESS_U]; break; case D3DRENDERSTATE_TEXTUREADDRESSV: - *value = wined3d_device_get_sampler_state(device->wined3d_device, 0, WINED3D_SAMP_ADDRESS_V); + *value = device_state->sampler_states[0][WINED3D_SAMP_ADDRESS_V]; break; case D3DRENDERSTATE_BORDERCOLOR: @@ -4951,6 +4950,7 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface, DWORD stage, D3DTEXTURESTAGESTATETYPE state, DWORD *value) { struct d3d_device *device = impl_from_IDirect3DDevice7(iface); + const struct wined3d_stateblock_state *device_state; const struct tss_lookup *l; TRACE("iface %p, stage %u, state %#x, value %p.\n", @@ -4965,13 +4965,22 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface, return DD_OK; } + if (stage >= DDRAW_MAX_TEXTURES) + { + WARN("Invalid stage %u.\n", stage); + *value = 0; + return D3D_OK; + } + l = &tss_lookup[state]; wined3d_mutex_lock(); + device_state = wined3d_stateblock_get_state(device->state); + if (l->sampler_state) { - *value = wined3d_device_get_sampler_state(device->wined3d_device, stage, l->u.sampler_state); + *value = device_state->sampler_states[stage][l->u.sampler_state]; switch (state) { @@ -5031,7 +5040,7 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface, } else { - *value = wined3d_device_get_texture_stage_state(device->wined3d_device, stage, l->u.texture_state); + *value = device_state->texture_states[stage][l->u.texture_state]; } wined3d_mutex_unlock(); -- 2.25.0
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/ddraw/device.c | 87 ++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 53 deletions(-) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index ec9997c6cb..92c726c10d 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -2501,14 +2501,6 @@ static HRESULT WINAPI d3d_device2_GetRenderState(IDirect3DDevice2 *iface, return IDirect3DDevice3_GetRenderState(&device->IDirect3DDevice3_iface, state, value); } -static void d3d_device_set_sampler_state(struct d3d_device *device, - UINT sampler_idx, enum wined3d_sampler_state state, DWORD value) -{ - wined3d_stateblock_set_sampler_state(device->update_state, sampler_idx, state, value); - if (!device->recording) - wined3d_device_set_sampler_state(device->wined3d_device, sampler_idx, state, value); -} - /***************************************************************************** * IDirect3DDevice7::SetRenderState * @@ -2569,7 +2561,7 @@ static HRESULT d3d_device7_SetRenderState(IDirect3DDevice7 *iface, break; } - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_MAG_FILTER, tex_mag); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_MAG_FILTER, tex_mag); break; } @@ -2612,19 +2604,19 @@ static HRESULT d3d_device7_SetRenderState(IDirect3DDevice7 *iface, break; } - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_MIP_FILTER, tex_mip); - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_MIN_FILTER, tex_min); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_MIP_FILTER, tex_mip); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_MIN_FILTER, tex_min); break; } case D3DRENDERSTATE_TEXTUREADDRESS: - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_ADDRESS_V, value); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_ADDRESS_V, value); /* Drop through */ case D3DRENDERSTATE_TEXTUREADDRESSU: - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_ADDRESS_U, value); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_ADDRESS_U, value); break; case D3DRENDERSTATE_TEXTUREADDRESSV: - d3d_device_set_sampler_state(device, 0, WINED3D_SAMP_ADDRESS_V, value); + wined3d_stateblock_set_sampler_state(device->state, 0, WINED3D_SAMP_ADDRESS_V, value); break; case D3DRENDERSTATE_BORDERCOLOR: @@ -2680,13 +2672,6 @@ static HRESULT WINAPI d3d_device7_SetRenderState_FPUPreserve(IDirect3DDevice7 *i return hr; } -static void d3d_device_set_texture_stage_state(struct d3d_device *device, - UINT stage, enum wined3d_texture_stage_state state, DWORD value) -{ - wined3d_stateblock_set_texture_stage_state(device->state, stage, state, value); - wined3d_device_set_texture_stage_state(device->wined3d_device, stage, state, value); -} - static void fixup_texture_alpha_op(struct d3d_device *device) { /* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states. @@ -2710,7 +2695,7 @@ static void fixup_texture_alpha_op(struct d3d_device *device) } /* Args 1 and 2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */ - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_OP, tex_alpha ? WINED3D_TOP_SELECT_ARG1 : WINED3D_TOP_SELECT_ARG2); } @@ -2792,69 +2777,69 @@ static HRESULT WINAPI d3d_device3_SetRenderState(IDirect3DDevice3 *iface, { fixup_texture_alpha_op(device); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_OP, WINED3D_TOP_MODULATE); break; } case D3DTBLEND_ADD: - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_OP, WINED3D_TOP_ADD); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_OP, WINED3D_TOP_SELECT_ARG2); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG2, WINED3DTA_CURRENT); break; case D3DTBLEND_MODULATEALPHA: - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_OP, WINED3D_TOP_MODULATE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_OP, WINED3D_TOP_MODULATE); break; case D3DTBLEND_COPY: case D3DTBLEND_DECAL: - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_OP, WINED3D_TOP_SELECT_ARG1); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_OP, WINED3D_TOP_SELECT_ARG1); break; case D3DTBLEND_DECALALPHA: - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_OP, WINED3D_TOP_BLEND_TEXTURE_ALPHA); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG1, WINED3DTA_TEXTURE); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_COLOR_ARG2, WINED3DTA_CURRENT); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_OP, WINED3D_TOP_SELECT_ARG2); - d3d_device_set_texture_stage_state(device, + wined3d_stateblock_set_texture_stage_state(device->state, 0, WINED3D_TSS_ALPHA_ARG2, WINED3DTA_CURRENT); break; @@ -5170,21 +5155,17 @@ static HRESULT d3d_device7_SetTextureStageState(IDirect3DDevice7 *iface, } case D3DTSS_ADDRESS: - d3d_device_set_sampler_state(device, stage, WINED3D_SAMP_ADDRESS_V, value); + wined3d_stateblock_set_sampler_state(device->state, stage, WINED3D_SAMP_ADDRESS_V, value); break; default: break; } - d3d_device_set_sampler_state(device, stage, l->u.sampler_state, value); + wined3d_stateblock_set_sampler_state(device->state, stage, l->u.sampler_state, value); } else - { wined3d_stateblock_set_texture_stage_state(device->update_state, stage, l->u.texture_state, value); - if (!device->recording) - wined3d_device_set_texture_stage_state(device->wined3d_device, stage, l->u.texture_state, value); - } wined3d_mutex_unlock(); -- 2.25.0
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
participants (3)
-
Henri Verbeet -
Marvin -
Zebediah Figura