-
Notifications
You must be signed in to change notification settings - Fork 908
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
Respect maxGeometryTotalOutputComponents limit #1121
Comments
The problem with this issue is that we don't know which fragment shader a geometry shader will be used with at the time we do the DXBC->SPIR-V translation. I'm concerned that performing this translation at draw time is going to make the stuttering issues that DXVK has due to pipeline compilation even worse than they already are, not to mention that doing so would require a major rework. Another option might be to patch the generated SPIR-V at the time the pipeline gets compiled and change unused output locations to private variables, but that's also rather tricky. |
We don't need to know which fragment shader a geometry shader will be used with at translation-time. We know that a geometry shader should have at least one I spent some time prototyping this out today. I'll try and get my patches for a fix cleaned up to send over to you in the next few days / week. |
The question is, what is supposed to happen if a game uses the geometry shader with a fragment shader which doesn't have the declaration? As far as I know, this is technically undefined behaviour in D3D11, but in practice, many games do rely on the exact ways things like this are handled in Windows drivers. |
838372d (currently in a side branch) should be sufficient to fix this issue, but I'll have to test if this may cause any regressions. |
I don't think that covers the case where a the |
Is that even possible? It would be extremely weird if the HLSL compiler wrote that info into the signatures but not the instruction stream, and DXVK doesn't take that into account when mapping the |
For some reason, this breaks terrain rendering in Assassin's Creed Odyssey, even with your additional patch. Not sure what's going on there just yet. |
Turns out that this is actually the problem you described, but DXVK does not load system values in TCS/GS stages. I don't think this can be fixed for those stages. Vulkan wants us to put all built-ins that are passed between stages in a block where the VS output block must be identical to the TCS input block, but we don't necessarily know which ones we need since the TCS ISGN may only be a subset of the VS OSGN. Limiting this to geometry shaders only should work though. |
Currently DXVK runs into issues with geometry shaders on some titles on NVIDIA hardware where it creates SPIR-V modules which exceed the hardware defined limit of 1024 (on all current vulkan-supported NVIDIA hardware) for maxGeometryTotalOutputComponents. This issue is can arise from two potential factors:
DXVK adds an additional Output variable
gs_vertex_out
which it associates withSV_POSITION
and that becomes a pointer to the output variable that gets created for the DXBCdcl_output_siv
forSV_POSITION
.If an application passed a DXBC blob to DXVK which violated this limit, DXVK should be able to provide a more accessible error message to the developer.
Let's dive a bit deeper on the first factor. This additional Output variable is currently generated by DXVK to cover cases where applications don't have
dcl_input_siv
directives in a fragment shader which match with thedcl_output_siv
directives in a geometry shader [1]. After a discussion that @jeffbolznv and I had with a member of our D3D team we learned that applications may additionally pass in this system value information through an ISGN entry.One of the geometry shaders in Justice (the Chinese MMO) over-extends the limit when translated through DXVK. This pipeline this shader is used in raises the same concern as above, where the geometry shader's
dcl_output_siv
forSV_POSITION
not having a matchingdcl_input_siv
in the fragment shader for the pipeline. I've written out some patches (which are available in PR #1120 ) which allow for debug-logging of the ISGN, OSGN, PSGN entries for a shader.Here's the OSGN and ISGN for the geometry and fragment shaders I was looking at in Justice. Note the systemValue, for
registerId=3
.So I think the proper fix for factor one will be to check against the ISGN and OSGN for system values (in case a geometry shader doesn't
dcl_output_siv
even though the corresponding fragment shader usesdcl_input_siv
), and then apply thespv::BuiltInPosition
decoration (or other built-ins as appropriate).Factor two will probably be much less common and practically can be covered by @jeffbolznv's change adding the
maxGeometryTotalOutputComponents
check to the validation layers.The text was updated successfully, but these errors were encountered: