d3d9: Keep previous stream source stride and offset only when setting NULL buffer.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2019-04-03 20:26:06 +03:00 committed by Alexandre Julliard
parent 28f7e4615d
commit 467199d593
2 changed files with 23 additions and 9 deletions

View File

@ -3558,13 +3558,9 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface,
iface, stream_idx, buffer, offset, stride);
wined3d_mutex_lock();
if (!stride)
{
unsigned int cur_offset;
hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer,
&cur_offset, &stride);
}
if (!buffer_impl)
wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer,
&offset, &stride);
if (!buffer_impl)
wined3d_buffer = NULL;

View File

@ -3240,7 +3240,8 @@ cleanup:
static void test_set_stream_source(void)
{
IDirect3DVertexBuffer9 *vb;
IDirect3DVertexBuffer9 *vb, *current_vb;
unsigned int offset, stride;
IDirect3DDevice9 *device;
IDirect3D9 *d3d9;
ULONG refcount;
@ -3273,7 +3274,24 @@ static void test_set_stream_source(void)
hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 3, 32);
ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 4, 32);
ok(SUCCEEDED(hr), "Failed to set the stream source, hr %#x.\n", hr);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(!current_vb, "Got unexpected vb %p.\n", current_vb);
ok(offset == 4, "Got unexpected offset %u.\n", offset);
ok(stride == 32, "Got unexpected stride %u.\n", stride);
hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(current_vb == vb, "Got unexpected vb %p.\n", current_vb);
IDirect3DVertexBuffer9_Release(current_vb);
ok(!offset, "Got unexpected offset %u.\n", offset);
ok(!stride, "Got unexpected stride %u.\n", stride);
/* Try to set the NULL buffer with an offset and stride 0 */
hr = IDirect3DDevice9_SetStreamSource(device, 0, NULL, 0, 0);