From: Jeff Smith whydoubt@gmail.com
--- dlls/ddraw/tests/ddraw1.c | 63 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 2e4fc8eda42..1d1f8eea426 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -15436,10 +15436,21 @@ static void test_pick(void) { static D3DTLVERTEX tquad[] = { + /* Left half of viewport */ {{320.0f}, {480.0f}, { 1.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, {{ 0.0f}, {480.0f}, {-0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, {{320.0f}, { 0.0f}, { 1.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, {{ 0.0f}, { 0.0f}, {-0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + /* Lower-left quarter of viewport */ + {{320.0f}, {480.0f}, {-0.3f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{ 0.0f}, {480.0f}, { 1.7f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{320.0f}, {240.0f}, {-0.3f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{ 0.0f}, {240.0f}, { 1.7f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + /* Right half of lower-left quarter of viewport */ + {{320.0f}, {480.0f}, { 0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{160.0f}, {480.0f}, { 0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{320.0f}, {240.0f}, { 0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, + {{160.0f}, {240.0f}, { 0.5f}, {1.0f}, {0xff00ff00}, {0x00000000}, {0.0f}, {0.0f}}, }; IDirect3DExecuteBuffer *execute_buffer; D3DEXECUTEBUFFERDESC exec_desc; @@ -15483,15 +15494,17 @@ static void test_pick(void) ok(SUCCEEDED(hr), "Failed to lock execute buffer, hr %#lx.\n", hr); memcpy(exec_desc.lpData, tquad, sizeof(tquad)); ptr = ((BYTE *)exec_desc.lpData) + sizeof(tquad); - emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 4); + emit_process_vertices(&ptr, D3DPROCESSVERTICES_COPY, 0, 12); emit_tquad(&ptr, 0); + emit_tquad(&ptr, 4); + emit_tquad(&ptr, 8); emit_end(&ptr); inst_length = (BYTE *)ptr - (BYTE *)exec_desc.lpData; inst_length -= sizeof(tquad); hr = IDirect3DExecuteBuffer_Unlock(execute_buffer); ok(SUCCEEDED(hr), "Failed to unlock execute buffer, hr %#lx.\n", hr);
- set_execute_data(execute_buffer, 4, sizeof(tquad), inst_length); + set_execute_data(execute_buffer, 12, sizeof(tquad), inst_length);
/* Perform a number of picks, we should have a specific amount by the end. * We should get precisely equal numbers of hits and no hits since our quad @@ -15518,7 +15531,7 @@ static void test_pick(void) todo_wine ok(hits + nohits > 0, "Did not get any pick hits or misses.\n"); ok(hits == nohits, "Got a non-equal amount of pick hits/misses: %i vs %i.\n", hits, nohits);
- /* Try some specific pixel picks */ + /* Pick a pixel where no quads are present */ pick_rect.x1 = pick_rect.x2 = 480; pick_rect.y1 = pick_rect.y2 = 360; hr = IDirect3DDevice_Pick(device, execute_buffer, viewport, 0, &pick_rect); @@ -15528,6 +15541,7 @@ static void test_pick(void) ok(SUCCEEDED(hr), "Failed to get pick records, hr %#lx.\n", hr); todo_wine ok(rec_count == 0, "Got incorrect number of pick records (expected 0): %lu.\n", rec_count);
+ /* Pick a pixel where one quad is present */ pick_rect.x1 = pick_rect.x2 = 240; pick_rect.y1 = pick_rect.y2 = 120; hr = IDirect3DDevice_Pick(device, execute_buffer, viewport, 0, &pick_rect); @@ -15551,6 +15565,49 @@ static void test_pick(void) ok(compare_float(record.dvZ, 1.0, 4096), "Got incorrect dvZ: %.8e.\n", record.dvZ); }
+ /* Pick a pixel where three quads are present */ + pick_rect.x1 = pick_rect.x2 = 240; + pick_rect.y1 = pick_rect.y2 = 360; + hr = IDirect3DDevice_Pick(device, execute_buffer, viewport, 0, &pick_rect); + ok(SUCCEEDED(hr), "Failed to perform pick, hr %#lx.\n", hr); + rec_count = ~0; + hr = IDirect3DDevice_GetPickRecords(device, &rec_count, NULL); + ok(SUCCEEDED(hr), "Failed to get pick records, hr %#lx.\n", hr); + todo_wine ok(rec_count == 3, "Got incorrect number of pick records (expected 3): %lu.\n", rec_count); + + if (rec_count == 3) + { + D3DPICKRECORD record[3] = {0}; + const D3DPICKRECORD empty_record = {0}; + + /* If the count is wrong, do not populate any records */ + rec_count = 1; + hr = IDirect3DDevice_GetPickRecords(device, &rec_count, &record[0]); + ok(SUCCEEDED(hr), "Failed to get pick records, hr %#lx.\n", hr); + ok(rec_count == 3, "Got incorrect number of pick records (expected 3): %lu.\n", rec_count); + ok(memcmp(&record[0], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + ok(memcmp(&record[1], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + ok(memcmp(&record[2], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + + rec_count = 3; + hr = IDirect3DDevice_GetPickRecords(device, &rec_count, &record[0]); + ok(SUCCEEDED(hr), "Failed to get pick records, hr %#lx.\n", hr); + + /* Documentation states this list is z-ordered, but it appears that it is not. */ + ok(record[0].bOpcode == 3, "Got incorrect bOpcode: %i.\n", record[0].bOpcode); + ok(record[0].bPad == 0, "Got incorrect bPad: %i.\n", record[0].bPad); + ok(record[0].dwOffset == 24, "Got incorrect dwOffset: %lu.\n", record[0].dwOffset); + ok(compare_float(record[0].dvZ, 1.0, 4096), "Got incorrect dvZ: %.8e.\n", record[0].dvZ); + ok(record[1].bOpcode == 3, "Got incorrect bOpcode: %i.\n", record[1].bOpcode); + ok(record[1].bPad == 0, "Got incorrect bPad: %i.\n", record[1].bPad); + ok(record[1].dwOffset == 44, "Got incorrect dwOffset: %lu.\n", record[1].dwOffset); + ok(compare_float(record[1].dvZ, 0.2, 4096), "Got incorrect dvZ: %.8e.\n", record[1].dvZ); + ok(record[2].bOpcode == 3, "Got incorrect bOpcode: %i.\n", record[2].bOpcode); + ok(record[2].bPad == 0, "Got incorrect bPad: %i.\n", record[2].bPad); + ok(record[2].dwOffset == 64, "Got incorrect dwOffset: %lu.\n", record[2].dwOffset); + ok(compare_float(record[2].dvZ, 0.5, 4096), "Got incorrect dvZ: %.8e.\n", record[2].dvZ); + } + destroy_viewport(device, viewport); IDirect3DExecuteBuffer_Release(execute_buffer); IDirect3DDevice_Release(device);