-
Notifications
You must be signed in to change notification settings - Fork 712
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
Add Preview Hashing sentinel value to dxil validator #7053
Draft
bob80905
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
bob80905:addPreviewHashSigning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+247
−107
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can test this locally with the following command:darker --check --diff -r 070d0d5a2beacef9eeb51037a9b04665716fd6f3..a55b66722f8a6359a9244d5a52df5635fc6834d4 utils/hct/hctdb_instrhelp.py View the diff from darker here.--- hctdb_instrhelp.py 2025-01-09 03:03:18.000000 +0000
+++ hctdb_instrhelp.py 2025-01-09 03:07:38.185354 +0000
@@ -1557,10 +1557,11 @@
highest_major,
highest_minor,
)
return result
+
def get_prerelease_shader_model():
result = """static const unsigned kPreReleaseMajor = %d;
static const unsigned kPreReleaseMinor = %d;""" % (
prerelease_major,
prerelease_minor,
|
You can test this locally with the following command:git-clang-format --diff 070d0d5a2beacef9eeb51037a9b04665716fd6f3 a55b66722f8a6359a9244d5a52df5635fc6834d4 -- include/dxc/DXIL/DxilConstants.h include/dxc/DXIL/DxilShaderModel.h lib/DXIL/DxilMetadataHelper.cpp lib/DXIL/DxilShaderModel.cpp tools/clang/tools/dxcompiler/dxcassembler.cpp tools/clang/tools/dxcvalidator/dxcvalidator.cpp View the diff from clang-format here.diff --git a/tools/clang/tools/dxcompiler/dxcassembler.cpp b/tools/clang/tools/dxcompiler/dxcassembler.cpp
index d7972a01..6764a22a 100644
--- a/tools/clang/tools/dxcompiler/dxcassembler.cpp
+++ b/tools/clang/tools/dxcompiler/dxcassembler.cpp
@@ -67,8 +67,10 @@ public:
// Assemble dxil in ll or llvm bitcode to dxbc container.
HRESULT STDMETHODCALLTYPE DxcAssembler::AssembleToContainer(
- IDxcBlob *pShader, // Shader to assemble.
- IDxcOperationResult **ppResult // Assemble output status, buffer, and errors) { // inputs used to assemble the container
+ IDxcBlob *pShader, // Shader to assemble.
+ IDxcOperationResult *
+ *ppResult // Assemble output status, buffer, and errors) { // inputs
+ // used to assemble the container
) {
if (pShader == nullptr || ppResult == nullptr)
return E_POINTER;
diff --git a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp
index f53a535a..e4e54c3c 100644
--- a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp
+++ b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp
@@ -20,12 +20,11 @@
#include "dxc/dxcapi.h"
#include "dxcvalidator.h"
+#include "dxc/DXIL/DxilShaderModel.h"
#include "dxc/DxilRootSignature/DxilRootSignature.h"
#include "dxc/Support/FileIOHelper.h"
#include "dxc/Support/Global.h"
#include "dxc/Support/dxcapi.impl.h"
-#include "dxc/DXIL/DxilShaderModel.h"
-
#ifdef _WIN32
#include "dxcetw.h"
@@ -49,12 +48,10 @@ static void HashAndUpdate(DxilContainerHeader *Container, bool isPreRelease) {
(const unsigned char *)Container + DXBCHashStartOffset;
unsigned AmountToHash = Container->ContainerSizeInBytes - DXBCHashStartOffset;
ComputeHashRetail(DataToHash, AmountToHash, Container->Hash.Digest);
-
}
static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader,
- IDxcBlob **Hashed,
- llvm::Module *DebugModule) {
+ IDxcBlob **Hashed, llvm::Module *DebugModule) {
bool isPreRelease = false;
const DxilContainerHeader *DxilContainer =
IsDxilContainerLike(Shader->GetBufferPointer(), Shader->GetBufferSize());
@@ -72,7 +69,8 @@ static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader,
}
if (Flags & DxcValidatorFlags_InPlaceEdit) {
- HashAndUpdate((DxilContainerHeader *)Shader->GetBufferPointer(), isPreRelease);
+ HashAndUpdate((DxilContainerHeader *)Shader->GetBufferPointer(),
+ isPreRelease);
*Hashed = Shader;
Shader->AddRef();
} else {
@@ -81,7 +79,8 @@ static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader,
unsigned long CB;
IFT(HashedBlobStream->Write(Shader->GetBufferPointer(),
Shader->GetBufferSize(), &CB));
- HashAndUpdate((DxilContainerHeader *)HashedBlobStream->GetPtr(), isPreRelease);
+ HashAndUpdate((DxilContainerHeader *)HashedBlobStream->GetPtr(),
+ isPreRelease);
IFT(HashedBlobStream.QueryInterface(Hashed));
}
}
|
bob80905
changed the title
Add Preview Hashing sentinal value to dxil validator
Add Preview Hashing sentinel value to dxil validator
Jan 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the dxil validator detects that the target shader model is a preview shader model that hasn't officially been released, it should sign the dxil container with a special sentinel hash: 02020202020202020202020202020202