Sekiro: Shadows Die Twice depends on this for its mode switching.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com --- dlls/dxgi/output.c | 64 ++++++++++++++++++++++++++++++++++++++++++ dlls/dxgi/tests/dxgi.c | 32 ++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c index abe1aef950c..c54c8b165ed 100644 --- a/dlls/dxgi/output.c +++ b/dlls/dxgi/output.c @@ -75,6 +75,60 @@ static HRESULT dxgi_output_find_closest_matching_mode(struct dxgi_output *output return hr; }
+static int dxgi_mode_desc_compar(const void *l, const void *r) +{ + const DXGI_MODE_DESC *left = l, *right = r; + + if (left->Width < right->Width) + return -1; + + if (left->Width > right->Width) + return 1; + + if (left->Height < right->Height) + return -1; + + if (left->Height > right->Height) + return 1; + + if (left->RefreshRate.Numerator * right->RefreshRate.Denominator < + right->RefreshRate.Numerator * left->RefreshRate.Denominator) + return -1; + + if (left->RefreshRate.Numerator * right->RefreshRate.Denominator > + right->RefreshRate.Numerator * left->RefreshRate.Denominator) + return 1; + + return 0; +} + +static int dxgi_mode_desc1_compar(const void *l, const void *r) +{ + const DXGI_MODE_DESC1 *left = l, *right = r; + + if (left->Width < right->Width) + return -1; + + if (left->Width > right->Width) + return 1; + + if (left->Height < right->Height) + return -1; + + if (left->Height > right->Height) + return 1; + + if (left->RefreshRate.Numerator * right->RefreshRate.Denominator < + right->RefreshRate.Numerator * left->RefreshRate.Denominator) + return -1; + + if (left->RefreshRate.Numerator * right->RefreshRate.Denominator > + right->RefreshRate.Numerator * left->RefreshRate.Denominator) + return 1; + + return 0; +} + enum dxgi_mode_struct_version { DXGI_MODE_STRUCT_VERSION_0, @@ -151,6 +205,16 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output, } wined3d_mutex_unlock();
+ switch (struct_version) + { + case DXGI_MODE_STRUCT_VERSION_0: + qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC), dxgi_mode_desc_compar); + break; + case DXGI_MODE_STRUCT_VERSION_1: + qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC1), dxgi_mode_desc1_compar); + break; + } + return S_OK; }
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index a7517c8b0ab..be18943748c 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -1158,7 +1158,8 @@ static void test_output(void) HRESULT hr; IDXGIOutput *output; ULONG refcount; - UINT mode_count, mode_count_comp, i; + UINT mode_count, mode_count_comp, i, last_height, last_width; + double last_refresh_rate; DXGI_MODE_DESC *modes;
if (!(device = create_device(0))) @@ -1227,9 +1228,38 @@ static void test_output(void) ok(SUCCEEDED(hr), "Failed to list modes, hr %#x.\n", hr); ok(mode_count == mode_count_comp, "Got unexpected mode_count %u, expected %u.\n", mode_count, mode_count_comp);
+ last_width = last_height = 0; + last_refresh_rate = 0.; for (i = 0; i < mode_count; i++) { ok(modes[i].Height && modes[i].Width, "Proper mode was expected\n"); + + ok(modes[i].Width >= last_width, + "Modes should have been sorted, mode %u width %u < %u\n", i, modes[i].Width, last_width); + if (modes[i].Width == last_width) + { + ok(modes[i].Height >= last_height, + "Modes should have been sorted, mode %u height %u < %u\n", i, modes[i].Height, last_height); + if (modes[i].Height == last_height) + { + double refresh_rate = modes[i].RefreshRate.Numerator / (double)modes[i].RefreshRate.Denominator; + ok(refresh_rate >= last_refresh_rate, + "Modes should have been sorted, mode %u refresh rate %f < %f\n", i, refresh_rate, last_refresh_rate); + if (refresh_rate != last_refresh_rate) + last_refresh_rate = refresh_rate; + } + else + { + last_height = modes[i].Height; + last_refresh_rate = 0.; + } + } + else + { + last_width = modes[i].Width; + last_height = 0; + last_refresh_rate = 0.; + } }
mode_count += 5;
Hi,
While running your changed tests, 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=58320
Your paranoid android.
=== w1064v1809 (32 bit report) ===
dxgi: dxgi.c:4871: Test failed: Got unexpected message 0x31f, hwnd 000D02B4, wparam 0x1, lparam 0.
=== w1064v1809_2scr (32 bit report) ===
dxgi: dxgi.c:2846: Test failed: Got window rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2846: Test failed: Got client rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2846: Test failed: Got monitor rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got window rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got client rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got monitor rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2846: Test failed: Got window rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2846: Test failed: Got client rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2846: Test failed: Got monitor rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got window rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got client rect (0,0)-(1024,768), expected (0,0)-(800,600). dxgi.c:2850: Test failed: Got monitor rect (0,0)-(1024,768), expected (0,0)-(800,600).
=== w1064v1809_zh_CN (32 bit report) ===
dxgi: dxgi.c:2450: Test failed: Got unexpected hr 0x887a0022. dxgi.c:2453: Test failed: Got unexpected hr 0x887a0022.
=== w1064v1809 (64 bit report) ===
dxgi: dxgi.c:4871: Test failed: Got unexpected message 0x31f, hwnd 00000000000600E0, wparam 0x1, lparam 0.
If this patch looks OK, Gijs pointed out that it could be resent with this tag:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45433
On Wed, Oct 23, 2019 at 03:32:25PM -0500, Andrew Eikum wrote:
Sekiro: Shadows Die Twice depends on this for its mode switching.
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
dlls/dxgi/output.c | 64 ++++++++++++++++++++++++++++++++++++++++++ dlls/dxgi/tests/dxgi.c | 32 ++++++++++++++++++++- 2 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/output.c b/dlls/dxgi/output.c index abe1aef950c..c54c8b165ed 100644 --- a/dlls/dxgi/output.c +++ b/dlls/dxgi/output.c @@ -75,6 +75,60 @@ static HRESULT dxgi_output_find_closest_matching_mode(struct dxgi_output *output return hr; }
+static int dxgi_mode_desc_compar(const void *l, const void *r) +{
- const DXGI_MODE_DESC *left = l, *right = r;
- if (left->Width < right->Width)
return -1;
- if (left->Width > right->Width)
return 1;
- if (left->Height < right->Height)
return -1;
- if (left->Height > right->Height)
return 1;
- if (left->RefreshRate.Numerator * right->RefreshRate.Denominator <
right->RefreshRate.Numerator * left->RefreshRate.Denominator)
return -1;
- if (left->RefreshRate.Numerator * right->RefreshRate.Denominator >
right->RefreshRate.Numerator * left->RefreshRate.Denominator)
return 1;
- return 0;
+}
+static int dxgi_mode_desc1_compar(const void *l, const void *r) +{
- const DXGI_MODE_DESC1 *left = l, *right = r;
- if (left->Width < right->Width)
return -1;
- if (left->Width > right->Width)
return 1;
- if (left->Height < right->Height)
return -1;
- if (left->Height > right->Height)
return 1;
- if (left->RefreshRate.Numerator * right->RefreshRate.Denominator <
right->RefreshRate.Numerator * left->RefreshRate.Denominator)
return -1;
- if (left->RefreshRate.Numerator * right->RefreshRate.Denominator >
right->RefreshRate.Numerator * left->RefreshRate.Denominator)
return 1;
- return 0;
+}
enum dxgi_mode_struct_version { DXGI_MODE_STRUCT_VERSION_0, @@ -151,6 +205,16 @@ static HRESULT dxgi_output_get_display_mode_list(struct dxgi_output *output, } wined3d_mutex_unlock();
- switch (struct_version)
- {
case DXGI_MODE_STRUCT_VERSION_0:
qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC), dxgi_mode_desc_compar);
break;
case DXGI_MODE_STRUCT_VERSION_1:
qsort(modes, *mode_count, sizeof(DXGI_MODE_DESC1), dxgi_mode_desc1_compar);
break;
- }
- return S_OK;
}
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index a7517c8b0ab..be18943748c 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -1158,7 +1158,8 @@ static void test_output(void) HRESULT hr; IDXGIOutput *output; ULONG refcount;
- UINT mode_count, mode_count_comp, i;
UINT mode_count, mode_count_comp, i, last_height, last_width;
double last_refresh_rate; DXGI_MODE_DESC *modes;
if (!(device = create_device(0)))
@@ -1227,9 +1228,38 @@ static void test_output(void) ok(SUCCEEDED(hr), "Failed to list modes, hr %#x.\n", hr); ok(mode_count == mode_count_comp, "Got unexpected mode_count %u, expected %u.\n", mode_count, mode_count_comp);
last_width = last_height = 0;
last_refresh_rate = 0.; for (i = 0; i < mode_count; i++) { ok(modes[i].Height && modes[i].Width, "Proper mode was expected\n");
ok(modes[i].Width >= last_width,
"Modes should have been sorted, mode %u width %u < %u\n", i, modes[i].Width, last_width);
if (modes[i].Width == last_width)
{
ok(modes[i].Height >= last_height,
"Modes should have been sorted, mode %u height %u < %u\n", i, modes[i].Height, last_height);
if (modes[i].Height == last_height)
{
double refresh_rate = modes[i].RefreshRate.Numerator / (double)modes[i].RefreshRate.Denominator;
ok(refresh_rate >= last_refresh_rate,
"Modes should have been sorted, mode %u refresh rate %f < %f\n", i, refresh_rate, last_refresh_rate);
if (refresh_rate != last_refresh_rate)
last_refresh_rate = refresh_rate;
}
else
{
last_height = modes[i].Height;
last_refresh_rate = 0.;
}
}
else
{
last_width = modes[i].Width;
last_height = 0;
last_refresh_rate = 0.;
}
}
mode_count += 5;
-- 2.23.0