wined3d: Store the index buffer in the wined3d_stateblock_state structure.
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:
parent
26fce5ed9e
commit
cc88fb0b69
|
@ -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)
|
||||
|
@ -5232,11 +5242,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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -2970,6 +2970,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];
|
||||
|
|
Loading…
Reference in New Issue