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.

vbo.stride);
} else {
// For whatever reason, D3D9 doesn't capture the stream offset
dst->SetStreamSourceWithoutOffset(
Copy link
Owner

Choose a reason for hiding this comment

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

Where does the offset we apply to the context come from if it is never captured?

Copy link
Collaborator Author

@K0bin K0bin Apr 23, 2024

Choose a reason for hiding this comment

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

I did another round of testing the behavior of native D3D9 and it's pretty weird:

It only ignores the offset when calling IDirect3DStateBlock9::Capture.
That means, that both the initial capture when creating a state block using IDirect3DDevice9::CreateStateBlock as well as capturing the stream source by calling IDirect3DDevice9::SetStreamSource in between IDirect3DDevice9::BeginStateBlock and IDirect3DDevice9::EndStateBlock will capture the offset as one would normally expect.

IDirect3DStateBlock9::Apply only touches the stream sources if the state block has been created using IDirect3DDevice9::CreateStateBlock(D3DSBT_VERTEXSTATE) or by calling IDirect3DDevice9::SetStreamSource in between IDirect3DDevice9::BeginStateBlock and IDirect3DDevice9::EndStateBlock. Both of those capture the offset just fine.

So the only thing that does not work is updating the offset of a stream source that is capturing in a state block by calling Capture. So to answer your question: it's not strictly correct that the offset is "never captured" and the offset we apply comes from capturing it earlier. That's also the way this PR implements it.

I hope that was somewhat understandable. 😅

src/d3d9/d3d9_swvp_emu.h Outdated Show resolved Hide resolved
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