[PATCH 5/6] wined3d: Get rid of the "update_stateblock_state" field from struct wined3d_device.

Zebediah Figura z.figura12 at gmail.com
Tue Nov 26 22:58:27 CST 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/wined3d/device.c          | 100 +--------------------------------
 dlls/wined3d/wined3d_private.h |   1 -
 2 files changed, 3 insertions(+), 98 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 562caf8900a..f19a52c884a 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1271,14 +1271,6 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
     stream = &device->state.streams[stream_idx];
     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
             && stream->stride == stride
             && 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)
 {
-    UINT old_flags, old_freq, flags, freq;
     struct wined3d_stream_state *stream;
+    UINT old_flags, old_freq;
 
     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_freq = stream->frequency;
 
-    flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
-    freq = 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;
+    stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
+    stream->frequency = divider & 0x7fffff;
     if (stream->frequency != old_freq || stream->flags != old_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->_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,
      * we cut off any further processing. this seems to be a reasonable
      * 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;
     }
 
-    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)))
         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)
 {
     struct wined3d_light_info *light_info;
-    HRESULT hr;
 
     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. */
     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;
     }
 
-    device->update_stateblock_state->clip_planes[plane_idx] = *plane;
-
     if (!memcmp(&device->state.clip_planes[plane_idx], plane, sizeof(*plane)))
     {
         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);
 
-    device->update_stateblock_state->material = *material;
-
     device->state.material = *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_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)
         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);
 
-    device->update_stateblock_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);
     }
 
-    if (viewport_count)
-        device->update_stateblock_state->viewport = viewports[0];
-
     if (viewport_count)
         memcpy(device->state.viewports, viewports, viewport_count * sizeof(*viewports));
     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));
 
-    device->update_stateblock_state->blend_factor = *blend_factor;
-
     prev = state->blend_state;
     if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)))
         return;
@@ -1922,8 +1875,6 @@ void CDECL wined3d_device_set_render_state(struct wined3d_device *device,
         return;
     }
 
-    device->update_stateblock_state->rs[state] = value;
-
     if (value == device->state.render_states[state])
         TRACE("Application is setting the old value over, nothing to do.\n");
     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. */
     }
 
-    device->update_stateblock_state->sampler_states[sampler_idx][state] = value;
-
     if (value == device->state.sampler_states[sampler_idx][state])
     {
         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]));
     }
 
-    if (rect_count)
-        device->update_stateblock_state->scissor_rect = rects[0];
-
     if (device->state.scissor_rect_count == rect_count
             && !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);
 
-    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)
         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);
 
-    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)
         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)
         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));
     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)
         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));
     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)
         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));
     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);
 
-    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)
         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)
         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));
     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)
         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));
     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)
         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));
     if (TRACE_ON(d3d))
     {
@@ -3836,8 +3752,6 @@ void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device,
         return;
     }
 
-    device->update_stateblock_state->texture_states[stage][state] = value;
-
     if (value == device->state.texture_states[stage][state])
     {
         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;
     }
 
-    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];
     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);
         memset(&device->stateblock_state, 0, sizeof(device->stateblock_state));
         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);
         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);
     wined3d_stateblock_state_init(&device->stateblock_state, device, WINED3D_STATE_INIT_DEFAULT);
-    device->update_stateblock_state = &device->stateblock_state;
 
     device->max_frame_latency = 3;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0fedd706ce7..2e2707c5bd2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3283,7 +3283,6 @@ struct wined3d_device
 
     struct wined3d_state state;
     struct wined3d_stateblock_state stateblock_state;
-    struct wined3d_stateblock_state *update_stateblock_state;
 
     /* Internal use fields  */
     struct wined3d_device_creation_parameters create_parms;
-- 
2.23.0




More information about the wine-devel mailing list