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

Validate shader interface compatibility #1923

Merged

Conversation

doitsujin
Copy link
Collaborator

@doitsujin doitsujin commented Mar 2, 2024

At PSO compile time, the D3D12 runtime validates the input layout against the VS input signature, as well as the interface between each connected shader stage. This can fix some cases of invalid Vulkan usage as well if games rely on runtime validation to catch these mismatches.

Also fixes some small vkd3d-shader issues I've encountered in the process.

Draft because this needs more real-world testing to ensure we don't break existing games somehow.

We already handle this chunk type internally.

Signed-off-by: Philip Rebohle <[email protected]>
These specific SVs are included in shader signatures.

Signed-off-by: Philip Rebohle <[email protected]>
Used only for GS exporting PrimtiveID.

Signed-off-by: Philip Rebohle <[email protected]>
@Blisto91
Copy link
Contributor

Blisto91 commented Mar 3, 2024

With a RTX 4080 on 550.54.14 I've given it a 10-15 minutes test in:
Age of Empires IV
Age of Wonders 4
Atlas Fallen
Company of Heroes 3
Cyberpunk 2077
DEATHLOOP
HITMAN 3
Spider-Man Remastered
Resident Evil 4
Returnal
Starfield
The Witcher 3
Diablo IV
World of Warcraft Dragonflight

Have not found any issues

@doitsujin doitsujin force-pushed the test-shader-io-mismatch branch 2 times, most recently from a8fb5b5 to 1ae5d19 Compare March 4, 2024 14:08
@doitsujin doitsujin marked this pull request as ready for review March 4, 2024 14:13
libs/vkd3d/state.c Outdated Show resolved Hide resolved
switch (shader_stages_lut[i].stage)
{
case VK_SHADER_STAGE_VERTEX_BIT:
if ((ret = vkd3d_shader_parse_input_signature(&dxbc, &input_signature)) < 0)
if ((ret = vkd3d_shader_parse_input_signature(&dxbc, &vs_input_signature)) < 0)
Copy link
Owner

Choose a reason for hiding this comment

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

Couldn't this reuse io_input_signature?

Copy link
Collaborator Author

@doitsujin doitsujin Mar 5, 2024

Choose a reason for hiding this comment

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

We need to keep the VS input signature around to deal with the input layout, not just for validation purposes.

libs/vkd3d/state.c Outdated Show resolved Hide resolved
libs/vkd3d/state.c Show resolved Hide resolved
libs/vkd3d/state.c Show resolved Hide resolved
libs/vkd3d/state.c Outdated Show resolved Hide resolved
libs/vkd3d/state.c Outdated Show resolved Hide resolved
{
vkd3d_test_set_context("Test %u", i);

expected = so_tests[i].should_compile ? S_OK : E_INVALIDARG;
Copy link
Owner

Choose a reason for hiding this comment

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

Where do we validate stream-out signature compat?

Copy link
Collaborator Author

@doitsujin doitsujin Mar 5, 2024

Choose a reason for hiding this comment

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

We kind of don't really, I could add that too (as well as more tests), but the intention of this particular set of tests was to see how SO and especially the rasterized stream index interacts with interface compatibility (FS is removed if rasterization is disabled, which we already did, and otherwise it's kind of broken).

Copy link
Owner

@HansKristian-Work HansKristian-Work left a comment

Choose a reason for hiding this comment

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

LGTM. Only skimmed over the tests though.

@HansKristian-Work HansKristian-Work merged commit f1f1899 into HansKristian-Work:master Mar 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants