diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index c1d86ab4a91..aec876fb745 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1991,13 +1991,17 @@ static void resolve_depth_buffer(struct wined3d_device *device) void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor) { - struct wined3d_state *state = device->update_state; + struct wined3d_state *state = &device->state; struct wined3d_blend_state *prev; 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; if (device->recording) + { device->recording->changed.blend_state = TRUE; + return; + } prev = state->blend_state; if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor))) @@ -2007,8 +2011,7 @@ void CDECL wined3d_device_set_blend_state(struct wined3d_device *device, wined3d_blend_state_incref(blend_state); state->blend_state = blend_state; state->blend_factor = *blend_factor; - if (!device->recording) - wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor); + wined3d_cs_emit_set_blend_state(device->cs, blend_state, blend_factor); if (prev) wined3d_blend_state_decref(prev); } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index ebff906d39f..fe307ae35d3 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -859,18 +859,12 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) } if (stateblock->changed.blend_state - && (src_state->blend_state != stateblock->state.blend_state - || memcmp(&src_state->blend_factor, &stateblock->state.blend_factor, - sizeof(stateblock->state.blend_factor)))) + && memcmp(&state->blend_factor, &stateblock->stateblock_state.blend_factor, + sizeof(stateblock->stateblock_state.blend_factor))) { - TRACE("Updating blend state.\n"); + TRACE("Updating blend factor.\n"); - if (src_state->blend_state) - wined3d_blend_state_incref(src_state->blend_state); - if (stateblock->state.blend_state) - wined3d_blend_state_decref(stateblock->state.blend_state); - stateblock->state.blend_state = src_state->blend_state; - stateblock->state.blend_factor = src_state->blend_factor; + stateblock->stateblock_state.blend_factor = state->blend_factor; } map = stateblock->changed.streamSource; @@ -1162,7 +1156,10 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) } if (stateblock->changed.blend_state) - wined3d_device_set_blend_state(device, stateblock->state.blend_state, &stateblock->state.blend_factor); + { + state->blend_factor = stateblock->stateblock_state.blend_factor; + wined3d_device_set_blend_state(device, NULL, &stateblock->stateblock_state.blend_factor); + } map = stateblock->changed.streamSource; for (i = 0; map; map >>= 1, ++i) @@ -1473,6 +1470,11 @@ static void stateblock_state_init_default(struct wined3d_stateblock_state *state } init_default_sampler_states(state->sampler_states); + + state->blend_factor.r = 1.0f; + state->blend_factor.g = 1.0f; + state->blend_factor.b = 1.0f; + state->blend_factor.a = 1.0f; } void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 11a0f6901bd..13fdb1c3aa1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2986,6 +2986,7 @@ struct wined3d_stateblock_state BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; DWORD rs[WINEHIGHEST_RENDER_STATE + 1]; + struct wined3d_color blend_factor; struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS]; DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];