Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 32 +++++++++++++++--------- dlls/wined3d/stateblock.c | 45 ++++++++++++++++++++++------------ dlls/wined3d/wined3d_private.h | 4 +++ 3 files changed, 54 insertions(+), 27 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index bce2a3519d..e7ad5441eb 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1865,24 +1865,32 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, TRACE("device %p, buffer %p, format %s, offset %u.\n", device, buffer, debug_d3dformat(format_id), offset);
- prev_buffer = device->update_state->index_buffer; - prev_format = device->update_state->index_format; - prev_offset = device->update_state->index_offset; + prev_buffer = device->state.index_buffer; + prev_format = device->state.index_format; + prev_offset = device->state.index_offset;
- device->update_state->index_buffer = buffer; - device->update_state->index_format = format_id; - device->update_state->index_offset = 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 (device->recording) + { device->recording->changed.indices = TRUE; + return; + }
if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset) return;
if (buffer) wined3d_buffer_incref(buffer); - if (!device->recording) - wined3d_cs_emit_set_index_buffer(device->cs, buffer, format_id, offset); + device->state.index_buffer = buffer; + device->state.index_format = format_id; + device->state.index_offset = offset; + wined3d_cs_emit_set_index_buffer(device->cs, buffer, format_id, offset); if (prev_buffer) wined3d_buffer_decref(prev_buffer); } @@ -1902,7 +1910,9 @@ 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_state->base_vertex_index = base_index; + device->update_stateblock_state->base_vertex_index = base_index; + if (!device->recording) + device->state.base_vertex_index = base_index; }
INT CDECL wined3d_device_get_base_vertex_index(const struct wined3d_device *device) @@ -5219,11 +5229,11 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso device->state.index_buffer = NULL; }
- if (device->recording && &device->update_state->index_buffer->resource == resource) + if (device->recording && &device->update_stateblock_state->index_buffer->resource == resource) { ERR("Buffer resource %p is still in use by stateblock %p as index buffer.\n", resource, device->recording); - device->update_state->index_buffer = NULL; + device->update_stateblock_state->index_buffer = NULL; } break;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 037357c975..4b76b38326 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -524,9 +524,16 @@ void state_unbind_resources(struct wined3d_state *state) void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) { struct wined3d_texture *texture; + struct wined3d_buffer *buffer; struct wined3d_shader *shader; unsigned int i;
+ if ((buffer = state->index_buffer)) + { + state->index_buffer = NULL; + wined3d_buffer_decref(buffer); + } + if ((shader = state->vs)) { state->vs = NULL; @@ -791,22 +798,20 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) }
if (stateblock->changed.indices - && ((stateblock->state.index_buffer != src_state->index_buffer) - || (stateblock->state.base_vertex_index != src_state->base_vertex_index) - || (stateblock->state.index_format != src_state->index_format) - || (stateblock->state.index_offset != src_state->index_offset))) + && ((stateblock->stateblock_state.index_buffer != state->index_buffer) + || (stateblock->stateblock_state.base_vertex_index != state->base_vertex_index) + || (stateblock->stateblock_state.index_format != state->index_format))) { TRACE("Updating index buffer to %p, base vertex index to %d.\n", - src_state->index_buffer, src_state->base_vertex_index); + state->index_buffer, state->base_vertex_index);
- if (src_state->index_buffer) - wined3d_buffer_incref(src_state->index_buffer); - if (stateblock->state.index_buffer) - wined3d_buffer_decref(stateblock->state.index_buffer); - stateblock->state.index_buffer = src_state->index_buffer; - stateblock->state.base_vertex_index = src_state->base_vertex_index; - stateblock->state.index_format = src_state->index_format; - stateblock->state.index_offset = src_state->index_offset; + if (state->index_buffer) + wined3d_buffer_incref(state->index_buffer); + if (stateblock->stateblock_state.index_buffer) + wined3d_buffer_decref(stateblock->stateblock_state.index_buffer); + stateblock->stateblock_state.index_buffer = state->index_buffer; + stateblock->stateblock_state.base_vertex_index = state->base_vertex_index; + stateblock->stateblock_state.index_format = state->index_format; }
if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration) @@ -1106,9 +1111,17 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
if (stateblock->changed.indices) { - wined3d_device_set_index_buffer(device, stateblock->state.index_buffer, - stateblock->state.index_format, stateblock->state.index_offset); - wined3d_device_set_base_vertex_index(device, stateblock->state.base_vertex_index); + if (stateblock->stateblock_state.index_buffer) + wined3d_buffer_incref(stateblock->stateblock_state.index_buffer); + if (state->index_buffer) + wined3d_buffer_decref(state->index_buffer); + state->index_buffer = stateblock->stateblock_state.index_buffer; + state->index_format = stateblock->stateblock_state.index_format; + state->base_vertex_index = stateblock->stateblock_state.base_vertex_index; + + wined3d_device_set_index_buffer(device, stateblock->stateblock_state.index_buffer, + stateblock->stateblock_state.index_format, 0); + wined3d_device_set_base_vertex_index(device, stateblock->stateblock_state.base_vertex_index); }
if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index df116cef1c..87e0b23596 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2967,6 +2967,10 @@ struct wined3d_dummy_textures
struct wined3d_stateblock_state { + struct wined3d_buffer *index_buffer; + enum wined3d_format_id index_format; + int base_vertex_index; + struct wined3d_shader *vs; struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]; struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 16 ++++++++++++---- dlls/wined3d/stateblock.c | 32 +++++++++++++++++++++++--------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e7ad5441eb..bf357cb001 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2199,21 +2199,29 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device, void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { - struct wined3d_vertex_declaration *prev = device->update_state->vertex_declaration; + struct wined3d_vertex_declaration *prev = device->state.vertex_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 (device->recording) + { device->recording->changed.vertexDecl = TRUE; + return; + }
if (declaration == prev) return;
if (declaration) wined3d_vertex_declaration_incref(declaration); - device->update_state->vertex_declaration = declaration; - if (!device->recording) - wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); + device->state.vertex_declaration = declaration; + wined3d_cs_emit_set_vertex_declaration(device->cs, declaration); if (prev) wined3d_vertex_declaration_decref(prev); } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 4b76b38326..f0ad07e0a8 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -523,11 +523,18 @@ void state_unbind_resources(struct wined3d_state *state)
void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) { + struct wined3d_vertex_declaration *decl; struct wined3d_texture *texture; struct wined3d_buffer *buffer; struct wined3d_shader *shader; unsigned int i;
+ if ((decl = state->vertex_declaration)) + { + state->vertex_declaration = NULL; + wined3d_vertex_declaration_decref(decl); + } + if ((buffer = state->index_buffer)) { state->index_buffer = NULL; @@ -814,16 +821,16 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) stateblock->stateblock_state.index_format = state->index_format; }
- if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration) + if (stateblock->changed.vertexDecl && stateblock->stateblock_state.vertex_declaration != state->vertex_declaration) { TRACE("Updating vertex declaration from %p to %p.\n", - stateblock->state.vertex_declaration, src_state->vertex_declaration); + stateblock->stateblock_state.vertex_declaration, state->vertex_declaration);
- if (src_state->vertex_declaration) - wined3d_vertex_declaration_incref(src_state->vertex_declaration); - if (stateblock->state.vertex_declaration) - wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration); - stateblock->state.vertex_declaration = src_state->vertex_declaration; + if (state->vertex_declaration) + wined3d_vertex_declaration_incref(state->vertex_declaration); + if (stateblock->stateblock_state.vertex_declaration) + wined3d_vertex_declaration_decref(stateblock->stateblock_state.vertex_declaration); + stateblock->stateblock_state.vertex_declaration = state->vertex_declaration; }
if (stateblock->changed.material @@ -1124,8 +1131,15 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) wined3d_device_set_base_vertex_index(device, stateblock->stateblock_state.base_vertex_index); }
- if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration) - wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration); + if (stateblock->changed.vertexDecl && stateblock->stateblock_state.vertex_declaration) + { + if (stateblock->stateblock_state.vertex_declaration) + wined3d_vertex_declaration_incref(stateblock->stateblock_state.vertex_declaration); + if (state->vertex_declaration) + wined3d_vertex_declaration_decref(state->vertex_declaration); + state->vertex_declaration = stateblock->stateblock_state.vertex_declaration; + wined3d_device_set_vertex_declaration(device, stateblock->stateblock_state.vertex_declaration); + }
if (stateblock->changed.material) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 87e0b23596..dc2896a614 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2967,6 +2967,7 @@ struct wined3d_dummy_textures
struct wined3d_stateblock_state { + struct wined3d_vertex_declaration *vertex_declaration; struct wined3d_buffer *index_buffer; enum wined3d_format_id index_format; int base_vertex_index;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 9 ++++++--- dlls/wined3d/stateblock.c | 24 +++++++++++++----------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index bf357cb001..7a843ed107 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 f0ad07e0a8..ff6a92448d 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 dc2896a614..6004e129b4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2983,6 +2983,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];
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 38 +++++++++++++------ dlls/wined3d/stateblock.c | 67 ++++++++++++++++++++++------------ dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 72 insertions(+), 34 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 7a843ed107..de653fa762 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1379,11 +1379,21 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI return WINED3DERR_INVALIDCALL; }
- stream = &device->update_state->streams[stream_idx]; + 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; + if (device->recording) + { device->recording->changed.streamSource |= 1u << stream_idx; + return WINED3D_OK; + }
if (prev_buffer == buffer && stream->stride == stride @@ -1398,9 +1408,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI stream->offset = offset; if (buffer) wined3d_buffer_incref(buffer); - - if (!device->recording) - wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride); + wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride); if (prev_buffer) wined3d_buffer_decref(prev_buffer);
@@ -1432,8 +1440,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);
@@ -1454,16 +1462,24 @@ HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *devic return WINED3DERR_INVALIDCALL; }
- stream = &device->update_state->streams[stream_idx]; + stream = &device->state.streams[stream_idx]; old_flags = stream->flags; old_freq = stream->frequency;
- stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA); - stream->frequency = divider & 0x7fffff; + 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; if (device->recording) + { device->recording->changed.streamFreq |= 1u << stream_idx; - else if (stream->frequency != old_freq || stream->flags != old_flags) + return WINED3D_OK; + } + + stream->flags = flags; + stream->frequency = freq; + if (stream->frequency != old_freq || stream->flags != old_flags) wined3d_cs_emit_set_stream_source_freq(device->cs, stream_idx, stream->frequency, stream->flags);
return WINED3D_OK; @@ -5226,11 +5242,11 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso device->state.streams[i].buffer = NULL; }
- if (device->recording && &device->update_state->streams[i].buffer->resource == resource) + if (device->recording && &device->update_stateblock_state->streams[i].buffer->resource == resource) { ERR("Buffer resource %p is still in use by stateblock %p, stream %u.\n", resource, device->recording, i); - device->update_state->streams[i].buffer = NULL; + device->update_stateblock_state->streams[i].buffer = NULL; } }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index ff6a92448d..9e3eb23cc9 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -535,6 +535,15 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) wined3d_vertex_declaration_decref(decl); }
+ for (i = 0; i < MAX_STREAMS; ++i) + { + if ((buffer = state->streams[i].buffer)) + { + state->streams[i].buffer = NULL; + wined3d_buffer_decref(buffer); + } + } + if ((buffer = state->index_buffer)) { state->index_buffer = NULL; @@ -872,19 +881,19 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { if (!(map & 1)) continue;
- if (stateblock->state.streams[i].stride != src_state->streams[i].stride - || stateblock->state.streams[i].buffer != src_state->streams[i].buffer) + if (stateblock->stateblock_state.streams[i].stride != state->streams[i].stride + || stateblock->stateblock_state.streams[i].buffer != state->streams[i].buffer) { TRACE("Updating stream source %u to %p, stride to %u.\n", - i, src_state->streams[i].buffer, - src_state->streams[i].stride); - - stateblock->state.streams[i].stride = src_state->streams[i].stride; - if (src_state->streams[i].buffer) - wined3d_buffer_incref(src_state->streams[i].buffer); - if (stateblock->state.streams[i].buffer) - wined3d_buffer_decref(stateblock->state.streams[i].buffer); - stateblock->state.streams[i].buffer = src_state->streams[i].buffer; + i, state->streams[i].buffer, + state->streams[i].stride); + + stateblock->stateblock_state.streams[i].stride = state->streams[i].stride; + if (state->streams[i].buffer) + wined3d_buffer_incref(state->streams[i].buffer); + if (stateblock->stateblock_state.streams[i].buffer) + wined3d_buffer_decref(stateblock->stateblock_state.streams[i].buffer); + stateblock->stateblock_state.streams[i].buffer = state->streams[i].buffer; } }
@@ -893,14 +902,14 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock) { if (!(map & 1)) continue;
- if (stateblock->state.streams[i].frequency != src_state->streams[i].frequency - || stateblock->state.streams[i].flags != src_state->streams[i].flags) + if (stateblock->stateblock_state.streams[i].frequency != state->streams[i].frequency + || stateblock->stateblock_state.streams[i].flags != state->streams[i].flags) { TRACE("Updating stream frequency %u to %u flags to %#x.\n", - i, src_state->streams[i].frequency, src_state->streams[i].flags); + i, state->streams[i].frequency, state->streams[i].flags);
- stateblock->state.streams[i].frequency = src_state->streams[i].frequency; - stateblock->state.streams[i].flags = src_state->streams[i].flags; + stateblock->stateblock_state.streams[i].frequency = state->streams[i].frequency; + stateblock->stateblock_state.streams[i].flags = state->streams[i].flags; } }
@@ -1164,18 +1173,30 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock) map = stateblock->changed.streamSource; for (i = 0; map; map >>= 1, ++i) { - if (map & 1) - wined3d_device_set_stream_source(device, i, - stateblock->state.streams[i].buffer, - 0, stateblock->state.streams[i].stride); + if (!(map & 1)) continue; + + state->streams[i].stride = stateblock->stateblock_state.streams[i].stride; + if (stateblock->stateblock_state.streams[i].buffer) + wined3d_buffer_incref(stateblock->stateblock_state.streams[i].buffer); + if (state->streams[i].buffer) + wined3d_buffer_decref(state->streams[i].buffer); + state->streams[i].buffer = stateblock->stateblock_state.streams[i].buffer; + + wined3d_device_set_stream_source(device, i, + stateblock->stateblock_state.streams[i].buffer, + 0, stateblock->stateblock_state.streams[i].stride); }
map = stateblock->changed.streamFreq; for (i = 0; map; map >>= 1, ++i) { - if (map & 1) - wined3d_device_set_stream_source_freq(device, i, - stateblock->state.streams[i].frequency | stateblock->state.streams[i].flags); + if (!(map & 1)) continue; + + state->streams[i].frequency = stateblock->stateblock_state.streams[i].frequency; + state->streams[i].flags = stateblock->stateblock_state.streams[i].flags; + + wined3d_device_set_stream_source_freq(device, i, + stateblock->stateblock_state.streams[i].frequency | stateblock->stateblock_state.streams[i].flags); }
map = stateblock->changed.textures; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 6004e129b4..1f034506c7 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2968,6 +2968,7 @@ struct wined3d_dummy_textures struct wined3d_stateblock_state { struct wined3d_vertex_declaration *vertex_declaration; + struct wined3d_stream_state streams[MAX_STREAMS + 1]; struct wined3d_buffer *index_buffer; enum wined3d_format_id index_format; int base_vertex_index;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com