Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 27 +++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 2 ++ 3 files changed, 30 insertions(+)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f8724da967c..dd3a38cf0f3 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1584,6 +1584,33 @@ void CDECL wined3d_stateblock_set_base_vertex_index(struct wined3d_stateblock *s stateblock->stateblock_state.base_vertex_index = base_index; }
+HRESULT CDECL wined3d_stateblock_set_stream_source(struct wined3d_stateblock *stateblock, + UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride) +{ + struct wined3d_stream_state *stream; + + TRACE("stateblock %p, stream_idx %u, buffer %p, stride %u.\n", + stateblock, stream_idx, buffer, stride); + + if (stream_idx >= WINED3D_MAX_STREAMS) + { + WARN("Stream index %u out of range.\n", stream_idx); + return WINED3DERR_INVALIDCALL; + } + + stream = &stateblock->stateblock_state.streams[stream_idx]; + + if (buffer) + wined3d_buffer_incref(buffer); + if (stream->buffer) + wined3d_buffer_decref(stream->buffer); + stream->buffer = buffer; + stream->stride = stride; + stream->offset = offset; + stateblock->changed.streamSource |= 1u << stream_idx; + return WINED3D_OK; +} + static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info) { union diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 8a9c9858e92..5ff7ab1d0cd 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -275,6 +275,7 @@ @ cdecl wined3d_stateblock_set_render_state(ptr long long) @ cdecl wined3d_stateblock_set_sampler_state(ptr long long long) @ cdecl wined3d_stateblock_set_scissor_rect(ptr ptr) +@ cdecl wined3d_stateblock_set_stream_source(ptr long ptr long long) @ cdecl wined3d_stateblock_set_texture(ptr long ptr) @ cdecl wined3d_stateblock_set_texture_stage_state(ptr long long long) @ cdecl wined3d_stateblock_set_transform(ptr long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 10e2ae70ebd..b31e9573aaf 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2688,6 +2688,8 @@ void __cdecl wined3d_stateblock_set_render_state(struct wined3d_stateblock *stat void __cdecl wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value); void __cdecl wined3d_stateblock_set_scissor_rect(struct wined3d_stateblock *stateblock, const RECT *rect); +HRESULT __cdecl wined3d_stateblock_set_stream_source(struct wined3d_stateblock *stateblock, + UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride); void __cdecl wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock, UINT stage, struct wined3d_texture *texture); void __cdecl wined3d_stateblock_set_texture_stage_state(struct wined3d_stateblock *stateblock, UINT stage, enum wined3d_texture_stage_state state, DWORD value);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 52a62edecb1..a0653d2a421 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3630,13 +3630,17 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface, else wined3d_buffer = buffer_impl->wined3d_buffer;
- hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, wined3d_buffer, offset, stride); + hr = wined3d_stateblock_set_stream_source(device->update_state, stream_idx, wined3d_buffer, offset, stride); if (SUCCEEDED(hr) && !device->recording) { - if (buffer_impl && buffer_impl->draw_buffer) - device->sysmem_vb |= (1u << stream_idx); - else - device->sysmem_vb &= ~(1u << stream_idx); + hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, wined3d_buffer, offset, stride); + if (SUCCEEDED(hr)) + { + if (buffer_impl && buffer_impl->draw_buffer) + device->sysmem_vb |= (1u << stream_idx); + else + device->sysmem_vb &= ~(1u << stream_idx); + } }
wined3d_mutex_unlock();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 5f2235fb72c..00539fdd07f 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3347,13 +3347,17 @@ static HRESULT WINAPI d3d8_device_SetStreamSource(IDirect3DDevice8 *iface, else wined3d_buffer = buffer_impl->wined3d_buffer;
- hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, wined3d_buffer, 0, stride); + hr = wined3d_stateblock_set_stream_source(device->update_state, stream_idx, wined3d_buffer, 0, stride); if (SUCCEEDED(hr) && !device->recording) { - if (buffer_impl && buffer_impl->draw_buffer) - device->sysmem_vb |= (1u << stream_idx); - else - device->sysmem_vb &= ~(1u << stream_idx); + hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx, wined3d_buffer, 0, stride); + if (SUCCEEDED(hr)) + { + if (buffer_impl && buffer_impl->draw_buffer) + device->sysmem_vb |= (1u << stream_idx); + else + device->sysmem_vb &= ~(1u << stream_idx); + } }
wined3d_mutex_unlock();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/stateblock.c | 30 ++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 32 insertions(+)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index dd3a38cf0f3..933ad46a93d 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -1611,6 +1611,36 @@ HRESULT CDECL wined3d_stateblock_set_stream_source(struct wined3d_stateblock *st return WINED3D_OK; }
+HRESULT CDECL wined3d_stateblock_set_stream_source_freq(struct wined3d_stateblock *stateblock, + UINT stream_idx, UINT divider) +{ + struct wined3d_stream_state *stream; + + TRACE("stateblock %p, stream_idx %u, divider %#x.\n", stateblock, stream_idx, divider); + + if ((divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && (divider & WINED3DSTREAMSOURCE_INDEXEDDATA)) + { + WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL.\n"); + return WINED3DERR_INVALIDCALL; + } + if ((divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && !stream_idx) + { + WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL.\n"); + return WINED3DERR_INVALIDCALL; + } + if (!divider) + { + WARN("Divider is 0, returning D3DERR_INVALIDCALL.\n"); + return WINED3DERR_INVALIDCALL; + } + + stream = &stateblock->stateblock_state.streams[stream_idx]; + stream->flags = divider & (WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA); + stream->frequency = divider & 0x7fffff; + stateblock->changed.streamFreq |= 1u << stream_idx; + return WINED3D_OK; +} + static void init_default_render_states(DWORD rs[WINEHIGHEST_RENDER_STATE + 1], const struct wined3d_d3d_info *d3d_info) { union diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 5ff7ab1d0cd..a4caebe7185 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -276,6 +276,7 @@ @ cdecl wined3d_stateblock_set_sampler_state(ptr long long long) @ cdecl wined3d_stateblock_set_scissor_rect(ptr ptr) @ cdecl wined3d_stateblock_set_stream_source(ptr long ptr long long) +@ cdecl wined3d_stateblock_set_stream_source_freq(ptr long long) @ cdecl wined3d_stateblock_set_texture(ptr long ptr) @ cdecl wined3d_stateblock_set_texture_stage_state(ptr long long long) @ cdecl wined3d_stateblock_set_transform(ptr long ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index b31e9573aaf..a05305f4d6c 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2690,6 +2690,7 @@ void __cdecl wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *sta void __cdecl wined3d_stateblock_set_scissor_rect(struct wined3d_stateblock *stateblock, const RECT *rect); HRESULT __cdecl wined3d_stateblock_set_stream_source(struct wined3d_stateblock *stateblock, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride); +HRESULT __cdecl wined3d_stateblock_set_stream_source_freq(struct wined3d_stateblock *stateblock, UINT stream_idx, UINT divider); void __cdecl wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock, UINT stage, struct wined3d_texture *texture); void __cdecl wined3d_stateblock_set_texture_stage_state(struct wined3d_stateblock *stateblock, UINT stage, enum wined3d_texture_stage_state state, DWORD value);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index a0653d2a421..df1996bf850 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3689,7 +3689,9 @@ static HRESULT WINAPI d3d9_device_SetStreamSourceFreq(IDirect3DDevice9Ex *iface, TRACE("iface %p, stream_idx %u, freq %u.\n", iface, stream_idx, freq);
wined3d_mutex_lock(); - hr = wined3d_device_set_stream_source_freq(device->wined3d_device, stream_idx, freq); + hr = wined3d_stateblock_set_stream_source_freq(device->update_state, stream_idx, freq); + if (SUCCEEDED(hr) && !device->recording) + hr = wined3d_device_set_stream_source_freq(device->wined3d_device, stream_idx, freq); wined3d_mutex_unlock();
return hr;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com