wined3d: Get rid of the "update_stateblock_state" field from struct wined3d_device.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-11-26 22:58:27 -06:00 committed by Alexandre Julliard
parent da6ea7ddc0
commit 7431e65c68
2 changed files with 3 additions and 98 deletions

View File

@ -1271,14 +1271,6 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
stream = &device->state.streams[stream_idx]; stream = &device->state.streams[stream_idx];
prev_buffer = stream->buffer; prev_buffer = stream->buffer;
if (buffer)
wined3d_buffer_incref(buffer);
if (device->update_stateblock_state->streams[stream_idx].buffer)
wined3d_buffer_decref(device->update_stateblock_state->streams[stream_idx].buffer);
device->update_stateblock_state->streams[stream_idx].buffer = buffer;
device->update_stateblock_state->streams[stream_idx].stride = stride;
device->update_stateblock_state->streams[stream_idx].offset = offset;
if (prev_buffer == buffer if (prev_buffer == buffer
&& stream->stride == stride && stream->stride == stride
&& stream->offset == offset) && stream->offset == offset)
@ -1324,8 +1316,8 @@ HRESULT CDECL wined3d_device_get_stream_source(const struct wined3d_device *devi
HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider) HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider)
{ {
UINT old_flags, old_freq, flags, freq;
struct wined3d_stream_state *stream; struct wined3d_stream_state *stream;
UINT old_flags, old_freq;
TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider); TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider);
@ -1350,14 +1342,8 @@ HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *devic
old_flags = stream->flags; old_flags = stream->flags;
old_freq = stream->frequency; old_freq = stream->frequency;
flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA); stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
freq = divider & 0x7fffff; stream->frequency = divider & 0x7fffff;
device->update_stateblock_state->streams[stream_idx].flags = flags;
device->update_stateblock_state->streams[stream_idx].frequency = freq;
stream->flags = flags;
stream->frequency = freq;
if (stream->frequency != old_freq || stream->flags != old_flags) if (stream->frequency != old_freq || stream->flags != old_flags)
wined3d_cs_emit_set_stream_source_freq(device->cs, stream_idx, stream->frequency, stream->flags); wined3d_cs_emit_set_stream_source_freq(device->cs, stream_idx, stream->frequency, stream->flags);
@ -1389,9 +1375,6 @@ void CDECL wined3d_device_set_transform(struct wined3d_device *device,
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34); TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44); TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
/* Handle recording of state blocks. */
device->update_stateblock_state->transforms[d3dts] = *matrix;
/* If the new matrix is the same as the current one, /* If the new matrix is the same as the current one,
* we cut off any further processing. this seems to be a reasonable * we cut off any further processing. this seems to be a reasonable
* optimization because as was noticed, some apps (warcraft3 for example) * optimization because as was noticed, some apps (warcraft3 for example)
@ -1481,9 +1464,6 @@ HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if (FAILED(hr = wined3d_light_state_set_light(&device->update_stateblock_state->light_state, light_idx, light, &object)))
return hr;
if (FAILED(hr = wined3d_light_state_set_light(&device->state.light_state, light_idx, light, &object))) if (FAILED(hr = wined3d_light_state_set_light(&device->state.light_state, light_idx, light, &object)))
return hr; return hr;
@ -1598,19 +1578,9 @@ HRESULT CDECL wined3d_device_get_light(const struct wined3d_device *device,
HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable) HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
{ {
struct wined3d_light_info *light_info; struct wined3d_light_info *light_info;
HRESULT hr;
TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable); TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
if (!(light_info = wined3d_light_state_get_light(&device->update_stateblock_state->light_state, light_idx)))
{
if (FAILED(hr = wined3d_light_state_set_light(&device->update_stateblock_state->light_state, light_idx,
&WINED3D_default_light, &light_info)))
return hr;
}
wined3d_light_state_enable_light(&device->update_stateblock_state->light_state,
&device->adapter->d3d_info, light_info, enable);
/* Special case - enabling an undefined light creates one with a strict set of parameters. */ /* Special case - enabling an undefined light creates one with a strict set of parameters. */
if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx))) if (!(light_info = wined3d_light_state_get_light(&device->state.light_state, light_idx)))
{ {
@ -1657,8 +1627,6 @@ HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device,
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
device->update_stateblock_state->clip_planes[plane_idx] = *plane;
if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane))) if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane)))
{ {
TRACE("Application is setting old values over, nothing to do.\n"); TRACE("Application is setting old values over, nothing to do.\n");
@ -1714,8 +1682,6 @@ void CDECL wined3d_device_set_material(struct wined3d_device *device, const stru
{ {
TRACE("device %p, material %p.\n", device, material); TRACE("device %p, material %p.\n", device, material);
device->update_stateblock_state->material = *material;
device->state.material = *material; device->state.material = *material;
wined3d_cs_emit_set_material(device->cs, material); wined3d_cs_emit_set_material(device->cs, material);
} }
@ -1747,13 +1713,6 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
prev_format = device->state.index_format; prev_format = device->state.index_format;
prev_offset = device->state.index_offset; prev_offset = device->state.index_offset;
if (buffer)
wined3d_buffer_incref(buffer);
if (device->update_stateblock_state->index_buffer)
wined3d_buffer_decref(device->update_stateblock_state->index_buffer);
device->update_stateblock_state->index_buffer = buffer;
device->update_stateblock_state->index_format = format_id;
if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset) if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset)
return; return;
@ -1782,7 +1741,6 @@ void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, I
{ {
TRACE("device %p, base_index %d.\n", device, base_index); TRACE("device %p, base_index %d.\n", device, base_index);
device->update_stateblock_state->base_vertex_index = base_index;
device->state.base_vertex_index = base_index; device->state.base_vertex_index = base_index;
} }
@ -1806,9 +1764,6 @@ void CDECL wined3d_device_set_viewports(struct wined3d_device *device, unsigned
viewports[i].width, viewports[i].height, viewports[i].min_z, viewports[i].max_z); viewports[i].width, viewports[i].height, viewports[i].min_z, viewports[i].max_z);
} }
if (viewport_count)
device->update_stateblock_state->viewport = viewports[0];
if (viewport_count) if (viewport_count)
memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports)); memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports));
else else
@ -1859,8 +1814,6 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device,
TRACE("device %p, blend_state %p, blend_factor %s.\n", device, blend_state, debug_color(blend_factor)); TRACE("device %p, blend_state %p, blend_factor %s.\n", device, blend_state, debug_color(blend_factor));
device->update_stateblock_state->blend_factor = *blend_factor;
prev = state->blend_state; prev = state->blend_state;
if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor))) if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)))
return; return;
@ -1922,8 +1875,6 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
return; return;
} }
device->update_stateblock_state->rs[state] = value;
if (value == device->state.render_states[state]) if (value == device->state.render_states[state])
TRACE("Application is setting the old value over, nothing to do.\n"); TRACE("Application is setting the old value over, nothing to do.\n");
else else
@ -1961,8 +1912,6 @@ void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device,
return; /* Windows accepts overflowing this array ... we do not. */ return; /* Windows accepts overflowing this array ... we do not. */
} }
device->update_stateblock_state->sampler_states[sampler_idx][state] = value;
if (value == device->state.sampler_states[sampler_idx][state]) if (value == device->state.sampler_states[sampler_idx][state])
{ {
TRACE("Application is setting the old value over, nothing to do.\n"); TRACE("Application is setting the old value over, nothing to do.\n");
@ -2003,9 +1952,6 @@ void CDECL wined3d_device_set_scissor_rects(struct wined3d_device *device, unsig
TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i])); TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i]));
} }
if (rect_count)
device->update_stateblock_state->scissor_rect = rects[0];
if (device->state.scissor_rect_count == rect_count if (device->state.scissor_rect_count == rect_count
&& !memcmp(device->state.scissor_rects, rects, rect_count * sizeof(*rects))) && !memcmp(device->state.scissor_rects, rects, rect_count * sizeof(*rects)))
{ {
@ -2042,12 +1988,6 @@ void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
TRACE("device %p, declaration %p.\n", device, declaration); TRACE("device %p, declaration %p.\n", device, declaration);
if (declaration)
wined3d_vertex_declaration_incref(declaration);
if (device->update_stateblock_state->vertex_declaration)
wined3d_vertex_declaration_decref(device->update_stateblock_state->vertex_declaration);
device->update_stateblock_state->vertex_declaration = declaration;
if (declaration == prev) if (declaration == prev)
return; return;
@ -2072,12 +2012,6 @@ void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struc
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
if (shader)
wined3d_shader_incref(shader);
if (device->update_stateblock_state->vs)
wined3d_shader_decref(device->update_stateblock_state->vs);
device->update_stateblock_state->vs = shader;
if (shader == prev) if (shader == prev)
return; return;
@ -2262,8 +2196,6 @@ HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_B - start_idx) if (count > WINED3D_MAX_CONSTS_B - start_idx)
count = WINED3D_MAX_CONSTS_B - start_idx; count = WINED3D_MAX_CONSTS_B - start_idx;
memcpy(&device->update_stateblock_state->vs_consts_b[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.vs_consts_b[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.vs_consts_b[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -2306,8 +2238,6 @@ HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_I - start_idx) if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx; count = WINED3D_MAX_CONSTS_I - start_idx;
memcpy(&device->update_stateblock_state->vs_consts_i[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.vs_consts_i[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.vs_consts_i[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -2348,8 +2278,6 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
|| count > d3d_info->limits.vs_uniform_count - start_idx) || count > d3d_info->limits.vs_uniform_count - start_idx)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&device->update_stateblock_state->vs_consts_f[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.vs_consts_f[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.vs_consts_f[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -2385,12 +2313,6 @@ void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct
TRACE("device %p, shader %p.\n", device, shader); TRACE("device %p, shader %p.\n", device, shader);
if (shader)
wined3d_shader_incref(shader);
if (device->update_stateblock_state->ps)
wined3d_shader_decref(device->update_stateblock_state->ps);
device->update_stateblock_state->ps = shader;
if (shader == prev) if (shader == prev)
return; return;
@ -2453,8 +2375,6 @@ HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_B - start_idx) if (count > WINED3D_MAX_CONSTS_B - start_idx)
count = WINED3D_MAX_CONSTS_B - start_idx; count = WINED3D_MAX_CONSTS_B - start_idx;
memcpy(&device->update_stateblock_state->ps_consts_b[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.ps_consts_b[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.ps_consts_b[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -2497,8 +2417,6 @@ HRESULT CDECL wined3d_device_set_ps_consts_i(struct wined3d_device *device,
if (count > WINED3D_MAX_CONSTS_I - start_idx) if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx; count = WINED3D_MAX_CONSTS_I - start_idx;
memcpy(&device->update_stateblock_state->ps_consts_i[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.ps_consts_i[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.ps_consts_i[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -2540,8 +2458,6 @@ HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device,
|| count > d3d_info->limits.ps_uniform_count - start_idx) || count > d3d_info->limits.ps_uniform_count - start_idx)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
memcpy(&device->update_stateblock_state->ps_consts_f[start_idx], constants, count * sizeof(*constants));
memcpy(&device->state.ps_consts_f[start_idx], constants, count * sizeof(*constants)); memcpy(&device->state.ps_consts_f[start_idx], constants, count * sizeof(*constants));
if (TRACE_ON(d3d)) if (TRACE_ON(d3d))
{ {
@ -3836,8 +3752,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
return; return;
} }
device->update_stateblock_state->texture_states[stage][state] = value;
if (value == device->state.texture_states[stage][state]) if (value == device->state.texture_states[stage][state])
{ {
TRACE("Application is setting the old value over, nothing to do.\n"); TRACE("Application is setting the old value over, nothing to do.\n");
@ -3881,12 +3795,6 @@ void CDECL wined3d_device_set_texture(struct wined3d_device *device,
return; return;
} }
if (texture)
wined3d_texture_incref(texture);
if (device->update_stateblock_state->textures[stage])
wined3d_texture_decref(device->update_stateblock_state->textures[stage]);
device->update_stateblock_state->textures[stage] = texture;
prev = device->state.textures[stage]; prev = device->state.textures[stage];
TRACE("Previous texture %p.\n", prev); TRACE("Previous texture %p.\n", prev);
@ -5403,7 +5311,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
state_init(&device->state, &device->fb, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); state_init(&device->state, &device->fb, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
memset(&device->stateblock_state, 0, sizeof(device->stateblock_state)); memset(&device->stateblock_state, 0, sizeof(device->stateblock_state));
wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT); wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT);
device->update_stateblock_state = &device->stateblock_state;
device_init_swapchain_state(device, swapchain); device_init_swapchain_state(device, swapchain);
if (wined3d_settings.logo) if (wined3d_settings.logo)
@ -5653,7 +5560,6 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
state_init(&device->state, &device->fb, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT); state_init(&device->state, &device->fb, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT); wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT);
device->update_stateblock_state = &device->stateblock_state;
device->max_frame_latency = 3; device->max_frame_latency = 3;

View File

@ -3283,7 +3283,6 @@ struct wined3d_device
struct wined3d_state state; struct wined3d_state state;
struct wined3d_stateblock_state stateblock_state; struct wined3d_stateblock_state stateblock_state;
struct wined3d_stateblock_state *update_stateblock_state;
/* Internal use fields */ /* Internal use fields */
struct wined3d_device_creation_parameters create_parms; struct wined3d_device_creation_parameters create_parms;