wined3d: Store stream state 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
44441feb3e
commit
1867b095a0
|
@ -1379,11 +1379,21 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
|
||||||
return WINED3DERR_INVALIDCALL;
|
return WINED3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = &device->update_state->streams[stream_idx];
|
stream = &device->state.streams[stream_idx];
|
||||||
prev_buffer = stream->buffer;
|
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)
|
if (device->recording)
|
||||||
|
{
|
||||||
device->recording->changed.streamSource |= 1u << stream_idx;
|
device->recording->changed.streamSource |= 1u << stream_idx;
|
||||||
|
return WINED3D_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (prev_buffer == buffer
|
if (prev_buffer == buffer
|
||||||
&& stream->stride == stride
|
&& stream->stride == stride
|
||||||
|
@ -1398,9 +1408,7 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
|
||||||
stream->offset = offset;
|
stream->offset = offset;
|
||||||
if (buffer)
|
if (buffer)
|
||||||
wined3d_buffer_incref(buffer);
|
wined3d_buffer_incref(buffer);
|
||||||
|
wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride);
|
||||||
if (!device->recording)
|
|
||||||
wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride);
|
|
||||||
if (prev_buffer)
|
if (prev_buffer)
|
||||||
wined3d_buffer_decref(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)
|
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;
|
struct wined3d_stream_state *stream;
|
||||||
UINT old_flags, old_freq;
|
|
||||||
|
|
||||||
TRACE("device %p, stream_idx %u, divider %#x.\n", device, stream_idx, divider);
|
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;
|
return WINED3DERR_INVALIDCALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = &device->update_state->streams[stream_idx];
|
stream = &device->state.streams[stream_idx];
|
||||||
old_flags = stream->flags;
|
old_flags = stream->flags;
|
||||||
old_freq = stream->frequency;
|
old_freq = stream->frequency;
|
||||||
|
|
||||||
stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
|
flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA);
|
||||||
stream->frequency = divider & 0x7fffff;
|
freq = divider & 0x7fffff;
|
||||||
|
|
||||||
|
device->update_stateblock_state->streams[stream_idx].flags = flags;
|
||||||
|
device->update_stateblock_state->streams[stream_idx].frequency = freq;
|
||||||
if (device->recording)
|
if (device->recording)
|
||||||
|
{
|
||||||
device->recording->changed.streamFreq |= 1u << stream_idx;
|
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);
|
wined3d_cs_emit_set_stream_source_freq(device->cs, stream_idx, stream->frequency, stream->flags);
|
||||||
|
|
||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
|
@ -5239,11 +5255,11 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
|
||||||
device->state.streams[i].buffer = NULL;
|
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",
|
ERR("Buffer resource %p is still in use by stateblock %p, stream %u.\n",
|
||||||
resource, device->recording, i);
|
resource, device->recording, i);
|
||||||
device->update_state->streams[i].buffer = NULL;
|
device->update_stateblock_state->streams[i].buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,6 +535,15 @@ void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
|
||||||
wined3d_vertex_declaration_decref(decl);
|
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))
|
if ((buffer = state->index_buffer))
|
||||||
{
|
{
|
||||||
state->index_buffer = NULL;
|
state->index_buffer = NULL;
|
||||||
|
@ -872,19 +881,19 @@ void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
|
||||||
{
|
{
|
||||||
if (!(map & 1)) continue;
|
if (!(map & 1)) continue;
|
||||||
|
|
||||||
if (stateblock->state.streams[i].stride != src_state->streams[i].stride
|
if (stateblock->stateblock_state.streams[i].stride != state->streams[i].stride
|
||||||
|| stateblock->state.streams[i].buffer != src_state->streams[i].buffer)
|
|| stateblock->stateblock_state.streams[i].buffer != state->streams[i].buffer)
|
||||||
{
|
{
|
||||||
TRACE("Updating stream source %u to %p, stride to %u.\n",
|
TRACE("Updating stream source %u to %p, stride to %u.\n",
|
||||||
i, src_state->streams[i].buffer,
|
i, state->streams[i].buffer,
|
||||||
src_state->streams[i].stride);
|
state->streams[i].stride);
|
||||||
|
|
||||||
stateblock->state.streams[i].stride = src_state->streams[i].stride;
|
stateblock->stateblock_state.streams[i].stride = state->streams[i].stride;
|
||||||
if (src_state->streams[i].buffer)
|
if (state->streams[i].buffer)
|
||||||
wined3d_buffer_incref(src_state->streams[i].buffer);
|
wined3d_buffer_incref(state->streams[i].buffer);
|
||||||
if (stateblock->state.streams[i].buffer)
|
if (stateblock->stateblock_state.streams[i].buffer)
|
||||||
wined3d_buffer_decref(stateblock->state.streams[i].buffer);
|
wined3d_buffer_decref(stateblock->stateblock_state.streams[i].buffer);
|
||||||
stateblock->state.streams[i].buffer = src_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 (!(map & 1)) continue;
|
||||||
|
|
||||||
if (stateblock->state.streams[i].frequency != src_state->streams[i].frequency
|
if (stateblock->stateblock_state.streams[i].frequency != state->streams[i].frequency
|
||||||
|| stateblock->state.streams[i].flags != src_state->streams[i].flags)
|
|| stateblock->stateblock_state.streams[i].flags != state->streams[i].flags)
|
||||||
{
|
{
|
||||||
TRACE("Updating stream frequency %u to %u flags to %#x.\n",
|
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->stateblock_state.streams[i].frequency = state->streams[i].frequency;
|
||||||
stateblock->state.streams[i].flags = src_state->streams[i].flags;
|
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;
|
map = stateblock->changed.streamSource;
|
||||||
for (i = 0; map; map >>= 1, ++i)
|
for (i = 0; map; map >>= 1, ++i)
|
||||||
{
|
{
|
||||||
if (map & 1)
|
if (!(map & 1)) continue;
|
||||||
wined3d_device_set_stream_source(device, i,
|
|
||||||
stateblock->state.streams[i].buffer,
|
state->streams[i].stride = stateblock->stateblock_state.streams[i].stride;
|
||||||
0, 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;
|
map = stateblock->changed.streamFreq;
|
||||||
for (i = 0; map; map >>= 1, ++i)
|
for (i = 0; map; map >>= 1, ++i)
|
||||||
{
|
{
|
||||||
if (map & 1)
|
if (!(map & 1)) continue;
|
||||||
wined3d_device_set_stream_source_freq(device, i,
|
|
||||||
stateblock->state.streams[i].frequency | stateblock->state.streams[i].flags);
|
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;
|
map = stateblock->changed.textures;
|
||||||
|
|
|
@ -2971,6 +2971,7 @@ struct wined3d_dummy_textures
|
||||||
struct wined3d_stateblock_state
|
struct wined3d_stateblock_state
|
||||||
{
|
{
|
||||||
struct wined3d_vertex_declaration *vertex_declaration;
|
struct wined3d_vertex_declaration *vertex_declaration;
|
||||||
|
struct wined3d_stream_state streams[MAX_STREAMS + 1];
|
||||||
struct wined3d_buffer *index_buffer;
|
struct wined3d_buffer *index_buffer;
|
||||||
enum wined3d_format_id index_format;
|
enum wined3d_format_id index_format;
|
||||||
int base_vertex_index;
|
int base_vertex_index;
|
||||||
|
|
Loading…
Reference in New Issue