-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix D3D12 pixel history MSAA test issues. #3193
Conversation
Actually looking back the D3D11 method, this appears to work in D3D12 as well. If the stencil's texture resource in the copy shader is instead declared as a Texture2DMSArray of uint2 and then we explicitly use the second component, that works as well. So that's another option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for chasing this down to get a fix. I think both approaches are achieving the same goal which is to read the green (second component) from the texture.
My opinion (and it is subjective and not objective and looking to have a discussion on the topic) is changing the D3D12 shader to match the D3D11 shader is more consistent instead of using SRV shader component mapping.
It achieves the same effect, locally I did this change and it also fixed the problem (locally I have re-enabled the MSAA tests and they are now passing)
diff --git a/renderdoc/data/hlsl/d3d12_pixelhistory.hlsl b/renderdoc/data/hlsl/d3d12_pixelhistory.hlsl
index deb79b61e..af7206f28 100644
--- a/renderdoc/data/hlsl/d3d12_pixelhistory.hlsl
+++ b/renderdoc/data/hlsl/d3d12_pixelhistory.hlsl
@@ -40,7 +40,7 @@ Texture2DArray<float> copyin_depth : register(t0);
Texture2DArray<uint> copyin_stencil : register(t1);
Texture2DMSArray<float> copyin_depth_ms : register(t2);
-Texture2DMSArray<uint> copyin_stencil_ms : register(t3);
+Texture2DMSArray<uint2> copyin_stencil_ms : register(t3);
Texture2DArray<float4> copyin_float : register(t4);
Texture2DMSArray<float4> copyin_float_ms : register(t5);
@@ -70,7 +70,7 @@ RWBuffer<int> copyout_int : register(u4);
}
else if(copy_stencil)
{
- uint val = copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)];
+ uint val = copyin_stencil_ms.sample[src_coord.z][uint3(src_coord.xy, src_coord.w)].g;
copyout_stencil[dst_slot] = val;
}
else
Perhaps not for this PR but I wonder if changing the non-MSAA stencil read in the shader to use uint2
and be more like D3D11 is worthwhile
b3a9f00
to
567fa25
Compare
* Add missing resource transitions for the dispatch copy to fix validation issues encountered while running the test. * Adjust the MSAA copy path to use the second channel for stencil to fix copies failing to output anything, which manifested as the fragment only showing one primitive without correct output data.
567fa25
to
3e0473b
Compare
I agree that the second option is preferable and have updated the commit. As for the non-MSAA path, that's currently unused because the dispatch copy path is only used for MSAA targets so I'm not sure it has been verified to work as written. It's a bit odd to me to have both the CopyTextureRegion path and the dispatch copy path if the latter could handle both. |
* Performing pixel history on an MSAA depth target caused a memory stomp due to the depth and stencil copies being mis-identified as a 4-component operation, stomping the following 12 bytes. For the depth, this stomped the stencil and the following padding, but when the missing stencil copy was added in 4815ada it stomped dsWithoutShaderDiscard as well. This triggered an assert due to a clear event appearing to have frags associated with it.
I identified an additional problem using this sample when attempting to get history on the depth stencil, and have added a fix for that. It's a knock-on from my my previous fix to copy the stencil value on depth-stencil history. There's no before because without the fix it asserts. I hope I'm not interrupting your holidays, I don't mind at all if these PRs sit in the queue until things resume in the new year. |
Thank you for the follow up fix for the memory stomp. I walked the code and checked other instances of I will enable the MSAA automated tests for D3D12 Pixel History now |
Description
Before:
![d3d12_pixel_history_before](https://private-user-images.githubusercontent.com/1256627/293478923-3545c7e5-a6f5-48e9-8fad-cc015fd9eacf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODQ2NDAsIm5iZiI6MTczOTI4NDM0MCwicGF0aCI6Ii8xMjU2NjI3LzI5MzQ3ODkyMy0zNTQ1YzdlNS1hNmY1LTQ4ZTktOGZhZC1jYzAxNWZkOWVhY2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0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
After:
Sampling stencil via an SRV was different in D3D11 and I've had trouble finding information about how this is intended to be done in D3D12, the shader component mapping is the best I've come up with thus far. It appears that the plane slice works for a Texture2D, but Texture2DMS does not provide such a specifier. I'm happy to change it if there is a different preferred method.