DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
PIX: Emit correct input sig elements and view ID state into PSV0 when input sigs are changed by debug instrumentation
Three intertwined issues:
1: The shader-debug-instrumentation and pixel-hit-counter passes add SV_VertexId+SV_InstanceId to the input sig for a VS if they are not present, and SV_Position for the PS. The changes in PixPassHelpers.cpp centralize the SV_Position case and fix up a few missing fields whose absence was breaking PIX shader debugging on WARP.
2: However, independent of these tweaks, adding these new values means that the view id metadata would be incorrect. A long-standing assert would fire, but is herein fixed, since the above work exacerbated this problem. The assert in question is this one in CopyViewIDStateForOutputToPSV that previously fired when a debug-instrumented shader was subsequently wrapped into a container:
(IOTable.InputVectors * 4 - InputScalars < 4));
(InputScalars, which comes from the serialized state in PSV0, was too small, since it did not include the added system values.)
To fix up these data, there's a pass that can generate the view id state, but this pass by itself does not re-emit the view id state into the module's metadata and thence into PSV0 when the module is containerized. I added a pass that does nothing other than re-emit (all) metadata that PIX can then run after the build-view-id-state pass, prior to re-containerization.
3: To find the right row/column indices for SV_Position for part 1 above, the upstream shader must be examined. A pass has been added to allow the caller to retrieve a text-encoded summary of the output sig for a shader. This can then be passed back into the appropriate passes.
These changes together are sufficient to allow PIX shader debugging to operate on WARP in those cases where these system-values were not included by the application, with correct view-id metadata, and the assert is happy.
:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.
The main issue I have is the incorrect initialization of added signature elements. Can there also be a test for added signature elements which ensures the metadata is as expected?
I suspect we have a validator gap here, since an empty
IndexVectorshouldn't have been considered valid.
I think it's good now. A tale that grew in the telling...