Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/device.c | 10 +++------- dlls/d3d9/tests/device.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 5e505b4cfa..5d14ce3cbc 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3567,13 +3567,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; diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 57521a5648..97435e91a5 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -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, ¤t_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, ¤t_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);