-
Notifications
You must be signed in to change notification settings - Fork 714
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
[Error Handling] Fix DxcContainerBuilder error handling #7056
base: main
Are you sure you want to change the base?
[Error Handling] Fix DxcContainerBuilder error handling #7056
Conversation
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.
If this succeeded testing without the suggested change to check valHR
before hashing, we are missing a test that makes sure it doesn't hash the shader even when validation fails.
You can test this locally with the following command:git-clang-format --diff 070d0d5a2beacef9eeb51037a9b04665716fd6f3 9194c5300d03c3163779108d8d27c86dce6afd4b -- lib/DxilContainer/DxcContainerBuilder.cpp tools/clang/tools/dxclib/dxc.cpp tools/clang/unittests/HLSL/ValidationTest.cpp View the diff from clang-format here.diff --git a/tools/clang/unittests/HLSL/ValidationTest.cpp b/tools/clang/unittests/HLSL/ValidationTest.cpp
index cb2a5ce28..e7d3bfaeb 100644
--- a/tools/clang/unittests/HLSL/ValidationTest.cpp
+++ b/tools/clang/unittests/HLSL/ValidationTest.cpp
@@ -1228,7 +1228,7 @@ TEST_F(ValidationTest, ValidationFailNoHash) {
VERIFY_IS_NOT_NULL(pHeader);
BYTE ZeroHash[DxilContainerHashSize] = {0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0};
+ 0, 0, 0, 0, 0, 0, 0, 0};
// Should be equal, this proves the hash isn't written when validation fails
VERIFY_ARE_EQUAL(memcmp(ZeroHash, pHeader->Hash.Digest, sizeof(ZeroHash)), 0);
|
return; | ||
CComPtr<IDxcBlob> pProgram; | ||
|
||
// we need any shader that will pass compilation but fail validation |
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.
Nit: the comment could say why the shader is expected to fail validation, otherwise it might not be obvious. That was the initial issue that tripped me up when reading the test code.
I still would have preferred we assembled IR instead of compiled HLSL, since that's what we should be using in validation tests.
// we need any shader that will pass compilation but fail validation | |
// We need any shader that will pass compilation but fail validation. | |
// This shader reads from uninitialized 'float a', which works for now. |
pProgram->GetBufferPointer(), pProgram->GetBufferSize()); | ||
VERIFY_IS_NOT_NULL(pHeader); | ||
|
||
BYTE Result[DxilContainerHashSize] = {0, 0, 0, 0, 0, 0, 0, 0, |
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.
Nit: I think Result
should be renamed to be clear that it's zeros, like ZeroHash
. That way if you had a failure in the VERIFY macro, you would see that it's comparing with ZeroHash
and understand what was expected without having to read this source code.
BYTE Result[DxilContainerHashSize] = {0, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0}; | ||
// ComputeHashRetail(DataToHash, AmountToHash, Result); | ||
// Should be unequal, this proves the hash isn't written when validation fails |
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.
Nit: Comment out of date.
// Should be unequal, this proves the hash isn't written when validation fails | |
// Should be equal, this proves the hash isn't written when validation fails |
Some error handling changes were incorrectly made to the container assembler, as described in the issue below.
This is bad because the API protocol for error handling must remain consistent across all functions. This PR
aims to restore the correct semantic meaning of returning bad HR values.
Fixes #7051