From: Zebediah Figura Subject: Re: [PATCH 1/5] wined3d: Introduce wined3d_device_apply_stateblock(). Message-Id: Date: Tue, 10 Dec 2019 12:24:28 -0600 In-Reply-To: References: <20191207161108.16688-1-z.figura12@gmail.com> On 12/10/19 2:39 AM, Matteo Bruni wrote: > On Sat, Dec 7, 2019 at 5:11 PM Zebediah Figura wrote: >> >> Signed-off-by: Zebediah Figura >> --- >> dlls/wined3d/device.c | 93 +++++++++++++++++++++++++++++++++++++++ >> dlls/wined3d/wined3d.spec | 1 + >> include/wine/wined3d.h | 1 + >> 3 files changed, 95 insertions(+) >> >> diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c >> index 0ae841d4e35..50029dfbec2 100644 >> --- a/dlls/wined3d/device.c >> +++ b/dlls/wined3d/device.c >> @@ -3829,6 +3829,99 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d >> return device->state.textures[stage]; >> } >> >> +void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, >> + struct wined3d_stateblock *stateblock) >> +{ >> + const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info; >> + const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; >> + unsigned int i, j; >> + >> + TRACE("device %p, stateblock %p.\n", device, stateblock); >> + >> + wined3d_stateblock_init_contained_states(stateblock); >> + >> + wined3d_device_set_vertex_shader(device, state->vs); >> + wined3d_device_set_pixel_shader(device, state->ps); > > Can we make use of the stateblock flags to only update the changed > states instead of all of them? I think so. I mostly didn't do it because it was less code, but it's probably worth not making lots of redundant calls to wined3d_device_set_*(). > >> + for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i) >> + wined3d_device_set_vs_consts_f(device, i, 1, &state->vs_consts_f[i]); > > Either only update the changed constants or set all of them in one go, IMO. ...good point :D > > Somewhat related, I have a few patches optimizing / improving our > handling of those flags but I don't expect them to be ready before > code freeze (and I don't want to conflict with your patches, > especially now). >