Skip to content
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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bob80905
Copy link
Collaborator

@bob80905 bob80905 commented Jan 9, 2025

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

Copy link
Contributor

github-actions bot commented Jan 9, 2025

⚠️ Python code formatter, darker found issues in your code. ⚠️

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,
  • Check this box to apply formatting changes to this branch.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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));
   }
 }
  • Check this box to apply formatting changes to this branch.

@bob80905 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
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

1 participant