Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/device.c | 102 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 0f7bc75393..5658d10958 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -13174,6 +13174,107 @@ static void test_multiply_transform(void) DestroyWindow(window); }
+static void test_vertex_buffer_read_write(void) +{ + IDirect3DVertexBuffer9 *buffer; + IDirect3DDevice9 *device; + IDirect3D9 *d3d; + ULONG refcount; + unsigned int i; + float *data; + HWND window; + HRESULT hr; + + static const float tri[][3] = + { + {-1.0f, -1.0f, 0.0f}, + {-1.0f, 1.0f, 0.0f}, + { 1.0f, 1.0f, 0.0f}, + }; + + window = create_window(); + d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + if (!(device = create_device(d3d, window, NULL))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D9_Release(d3d); + DestroyWindow(window); + return; + } + hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(tri), + D3DUSAGE_DYNAMIC, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_DISCARD); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memcpy(data, tri, sizeof(tri)); + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + /* Draw using the buffer to make wined3d create BO. */ + hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(*tri)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + data[i] = 3.0f; + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + todo_wine ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + todo_wine ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + data[i] = 4.0f; + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + for (i = 0; i < 3; ++i) + ok(data[i] == 4.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + IDirect3DVertexBuffer9_Release(buffer); + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + START_TEST(device) { WNDCLASSA wc = {0}; @@ -13299,6 +13400,7 @@ START_TEST(device) test_device_caps(); test_resource_access(); test_multiply_transform(); + test_vertex_buffer_read_write();
UnregisterClassA("d3d9_test_wc", GetModuleHandleA(NULL)); }
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/device.c | 4 ++-- dlls/wined3d/buffer.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 5658d10958..056c39b8bd 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -13243,14 +13243,14 @@ static void test_vertex_buffer_read_write(void) hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, 0); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); for (i = 0; i < 3; ++i) - todo_wine ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); hr = IDirect3DVertexBuffer9_Unlock(buffer); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DVertexBuffer9_Lock(buffer, 0, sizeof(tri), (void **)&data, D3DLOCK_NOOVERWRITE); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); for (i = 0; i < 3; ++i) - todo_wine ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); + ok(data[i] == 3.0f, "Got unexpected value %.8e, i %u.\n", data[i], i); hr = IDirect3DVertexBuffer9_Unlock(buffer); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index fb19060d10..501e5d5e42 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1063,7 +1063,10 @@ static HRESULT wined3d_buffer_gl_map(struct wined3d_buffer_gl *buffer_gl, wined3d_buffer_load_location(&buffer_gl->b, context, WINED3D_LOCATION_BUFFER);
if (flags & WINED3D_MAP_WRITE) + { + wined3d_buffer_invalidate_location(&buffer_gl->b, WINED3D_LOCATION_SYSMEM); buffer_invalidate_bo_range(&buffer_gl->b, dirty_offset, dirty_size); + }
if ((flags & WINED3D_MAP_DISCARD) && buffer_gl->b.resource.heap_memory) wined3d_buffer_evict_sysmem(&buffer_gl->b);
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47510
Your paranoid android.
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=47509
Your paranoid android.
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
On Tue, 12 Feb 2019 at 15:50, Paul Gofman gofmanp@gmail.com wrote:
- static const float tri[][3] =
- {
{-1.0f, -1.0f, 0.0f},
{-1.0f, 1.0f, 0.0f},
{ 1.0f, 1.0f, 0.0f},
- };
It's pretty minor, but we have "struct vec3" for this kind of thing.
On 2/12/19 18:25, Henri Verbeet wrote:
On Tue, 12 Feb 2019 at 15:50, Paul Gofman gofmanp@gmail.com wrote:
- static const float tri[][3] =
- {
{-1.0f, -1.0f, 0.0f},
{-1.0f, 1.0f, 0.0f},
{ 1.0f, 1.0f, 0.0f},
- };
It's pretty minor, but we have "struct vec3" for this kind of thing.
I would change this declaration but keep 'float *data' to avoid component wise comparisons and test output. Or do you think it is better to use vec3 for that too?
On Tue, 12 Feb 2019 at 19:39, Paul Gofman gofmanp@gmail.com wrote:
On 2/12/19 18:25, Henri Verbeet wrote:
On Tue, 12 Feb 2019 at 15:50, Paul Gofman gofmanp@gmail.com wrote:
- static const float tri[][3] =
- {
{-1.0f, -1.0f, 0.0f},
{-1.0f, 1.0f, 0.0f},
{ 1.0f, 1.0f, 0.0f},
- };
It's pretty minor, but we have "struct vec3" for this kind of thing.
I would change this declaration but keep 'float *data' to avoid component wise comparisons and test output. Or do you think it is better to use vec3 for that too?
"float *data" is fine.