Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d9] Fix a bunch of Wine test failures #3895

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

K0bin
Copy link
Collaborator

@K0bin K0bin commented Mar 6, 2024

Fixes the following Wine test failures:

StretchRect, lighting, specular_lighting

visual.c:4451: Test failed: Test 6, got unexpected hr 0.
visual.c:4451: Test failed: Test 7, got unexpected hr 0.
visual.c:4451: Test failed: Test 8, got unexpected hr 0.
visual.c:4451: Test failed: Test 9, got unexpected hr 0.
visual.c:4451: Test failed: Test 14, got unexpected hr 0.
visual.c:4451: Test failed: Test 15, got unexpected hr 0.
visual.c:4451: Test failed: Test 16, got unexpected hr 0.
visual.c:4451: Test failed: Test 17, got unexpected hr 0.
visual.c:4451: Test failed: Test 22, got unexpected hr 0.
visual.c:4451: Test failed: Test 23, got unexpected hr 0.
visual.c:4451: Test failed: Test 24, got unexpected hr 0.
visual.c:4451: Test failed: Test 25, got unexpected hr 0.
visual.c:4451: Test failed: Test 30, got unexpected hr 0.
visual.c:4451: Test failed: Test 31, got unexpected hr 0.
visual.c:4451: Test failed: Test 32, got unexpected hr 0.
visual.c:4451: Test failed: Test 36, got unexpected hr 0.
visual.c:4451: Test failed: Test 38, got unexpected hr 0.
visual.c:4451: Test failed: Test 39, got unexpected hr 0.
visual.c:4451: Test failed: Test 40, got unexpected hr 0.
visual.c:4451: Test failed: Test 41, got unexpected hr 0.
visual.c:4451: Test failed: Test 42, got unexpected hr 0.
visual.c:4451: Test failed: Test 43, got unexpected hr 0.
visual.c:4451: Test failed: Test 44, got unexpected hr 0.
visual.c:4451: Test failed: Test 46, got unexpected hr 0.
visual.c:4451: Test failed: Test 47, got unexpected hr 0.
visual.c:4451: Test failed: Test 49, got unexpected hr 0.
visual.c:4451: Test failed: Test 51, got unexpected hr 0.
visual.c:4451: Test failed: Test 53, got unexpected hr 0.

visual.c:15446: Test failed: Got hr 0.
visual.c:15462: Test failed: Got hr 0.
visual.c:15466: Test failed: Got hr 0.
visual.c:15468: Test failed: Got hr 0.

visual.c:1126: Test failed: Expected color 0x00000000 at location (160, 120), got 0x00ffffff, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (320, 120), got 0x00adadad, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (480, 120), got 0x005a5a5a, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (160, 240), got 0x00ffffff, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (320, 240), got 0x00d1d1d1, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (480, 240), got 0x00636363, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (160, 360), got 0x00ffffff, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (320, 360), got 0x00adadad, case 7.
visual.c:1126: Test failed: Expected color 0x00000000 at location (480, 360), got 0x005a5a5a, case 7.

Actually matches the documentation here: https://learn.microsoft.com/en-us/windows/win32/api/d3d9/nf-d3d9-idirect3ddevice9-stretchrect

@K0bin K0bin added the d3d9 label Mar 6, 2024
@mrdeathjr28
Copy link

hi

which apps are affected with this?

@K0bin
Copy link
Collaborator Author

K0bin commented Mar 7, 2024

I don't know if any apps are affected. I want to make DXVK play nice with the Wine tests.

@K0bin K0bin marked this pull request as draft March 7, 2024 16:03
@K0bin K0bin changed the title [d3d9] Fix Wine test failures in StretchRect [d3d9] Fix a bunch of Wine test failures Mar 7, 2024
src/d3d9/d3d9_device.cpp Outdated Show resolved Hide resolved
@K0bin K0bin force-pushed the wine-test branch 2 times, most recently from cd2b68b to 90eb194 Compare March 11, 2024 18:16
@K0bin
Copy link
Collaborator Author

K0bin commented Mar 12, 2024

229 failures left in the visual category.
dxvk_test_result_2024_03_12.txt

@K0bin
Copy link
Collaborator Author

K0bin commented Mar 13, 2024

82d8:stateblock: 14738 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped.

We now pass all state block tests.

@K0bin K0bin force-pushed the wine-test branch 2 times, most recently from 8fc6d83 to ae512ba Compare March 13, 2024 18:31
@K0bin K0bin marked this pull request as ready for review March 27, 2024 22:57
@K0bin
Copy link
Collaborator Author

K0bin commented Mar 27, 2024

I think I'll try to land this first batch before looking into more of the tests.

src/d3d9/d3d9_device.cpp Outdated Show resolved Hide resolved
src/util/util_matrix.cpp Outdated Show resolved Hide resolved
rs[D3DRS_POINTSPRITEENABLE] = FALSE;
rs[D3DRS_POINTSCALEENABLE] = FALSE;
rs[D3DRS_POINTSCALE_A] = bit::cast<DWORD>(1.0f);
rs[D3DRS_POINTSCALE_B] = bit::cast<DWORD>(0.0f);
rs[D3DRS_POINTSCALE_C] = bit::cast<DWORD>(0.0f);
rs[D3DRS_POINTSIZE] = bit::cast<DWORD>(1.0f);
rs[D3DRS_POINTSIZE_MIN] = bit::cast<DWORD>(1.0f);
rs[D3DRS_POINTSIZE_MAX] = bit::cast<DWORD>(64.0f);
rs[D3DRS_POINTSIZE_MAX] = bit::cast<DWORD>(limits.pointSizeRange[1]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The default render state value has to match what we report in the device caps."

And does that match what any DX9 implementation exposes? We should check that.

Copy link
Collaborator Author

@K0bin K0bin Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaxPointSize is 8192 in the D3D8 dump that Winter did. (With a NVIDIA GeForce4 Ti 4800 SE).

The Vulkan max point size range is generally much lower unless you're using an AMD GPU.
https://vulkan.gpuinfo.org/displaydevicelimit.php?name=pointSizeRange[1]&platform=linux

So considering that setting the max to 64.0 hasn't caused any issue so far, this should be fine?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth that still is the case for Nvidia, namely MaxPointSize is 8192 even with modern drivers/cards. AMD sets it somewhat lower, e.g. 256 on @Blisto91's 7900 XTX.

src/d3d9/d3d9_swvp_emu.h Outdated Show resolved Hide resolved
@K0bin K0bin force-pushed the wine-test branch 2 times, most recently from 8ac8246 to 6a1cd59 Compare April 23, 2024 16:15
Copy link
Owner

@doitsujin doitsujin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple questions.

In general I'd prefer to have unrelated fixes to be PR'd separately though, even if it means a fair bit of PR spam. Makes it easier to review and most of the commits in here would be good to go as-is anyway.

@@ -531,7 +533,7 @@ namespace dxvk {
// Max Vertex Blend Matrix Index
pCaps->MaxVertexBlendMatrixIndex = 0;
// Max Point Size
pCaps->MaxPointSize = 256.0f;
pCaps->MaxPointSize = limits.pointSizeRange[1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are games going to be fine with this not being an integer value / power-of-two? Vulkan drivers will report the upper limit of their fixed-point representation here, which is generally something of the format (2^n - 1)/(2^m).

Copy link
Collaborator Author

@K0bin K0bin May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pCaps->MaxPointSize is a float, so you'd hope that games are fine if that's not an integer value. At least I don't have anything indicating they wouldn't be. We could ofc round it down to the nearest integer or power of two but right now I don't see any reason to do that so I'd prefer to wait until we hit a game that actually needs it.

Before we also reported a value that was potentially larger than what the Vulkan driver supports and didn't encounter any problem with that in a game either, so I don't think games actually check this value.

@@ -205,6 +205,10 @@ namespace dxvk {
Vector4 dot0 = { m[0] * row0 };
float dot1 = (dot0.x + dot0.y) + (dot0.z + dot0.w);

if (unlikely(std::abs(dot1) <= 0.000001f)) {
Copy link
Owner

@doitsujin doitsujin May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of the API relies on this and do we have a way to verify native behaviour?

Not the biggest fan of the design here since this is a utility function and we're not giving feedback to the caller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's specifically about calculating the normal matrix from the world matrix.

Wine tests what D3D9 does with a singular matrix here.

Would you prefer it if I check the determinant separately even if that means calculating it twice?

bool srcIsSurface = srcTextureInfo->GetType() == D3DRTYPE_SURFACE;
bool dstIsSurface = dstTextureInfo->GetType() == D3DRTYPE_SURFACE;
bool srcHasRTUsage = (srcTextureInfo->Desc()->Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
if (unlikely(!dstHasRTUsage && (!dstIsSurface || !srcIsSurface || srcHasRTUsage)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly does the D3DRTYPE_SURFACE requirement accomplish here? What about textures with only one mip?

Copy link
Collaborator Author

@K0bin K0bin May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implementing the no stretching table:

table
Coming from the docs

Checking surface && !usage_rt && !usage_ds is the easiest way to check for offscreen plain surfaces.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added a comment explaining it.

K0bin added 5 commits May 28, 2024 00:53
Fixes the Wine test "test_specular_lighting".
Fixes a Wine test and matches further testing on Windows.
The default render state value has to match what we report in the device caps.
Fixes a Wine stateblock test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants