Bladeren bron

Merge integration fixes (#344)

- Fixed potential null pointer access
- make existence of external directory optional
- add DxilContainerAssembler change missing from ViewID Validation changes
- fix in ShaderOpTest.h for other build tools.
Tex Riddell 8 jaren geleden
bovenliggende
commit
edb9905e69

+ 3 - 1
CMakeLists.txt

@@ -640,7 +640,9 @@ if(WITH_POLLY)
   endif()
 endif(WITH_POLLY)
 
-add_subdirectory(external) # SPIRV change
+if(EXISTS "${LLVM_MAIN_SRC_DIR}/external")
+  add_subdirectory(external) # SPIRV change
+endif()
 
 if( LLVM_INCLUDE_TOOLS )
   add_subdirectory(tools)

+ 11 - 2
lib/HLSL/DxilContainerAssembler.cpp

@@ -487,6 +487,7 @@ public:
 
     // Set DxilRuntimInfo
     PSVRuntimeInfo0* pInfo = m_PSV.GetPSVRuntimeInfo0();
+    PSVRuntimeInfo1* pInfo1 = m_PSV.GetPSVRuntimeInfo1();
     const ShaderModel* SM = m_Module.GetShaderModel();
     pInfo->MinimumExpectedWaveLaneCount = 0;
     pInfo->MaximumExpectedWaveLaneCount = (UINT)-1;
@@ -633,6 +634,14 @@ public:
     DXASSERT_NOMSG(uResIndex == m_PSVInitInfo.ResourceCount);
 
     if (m_PSVInitInfo.PSVVersion > 0) {
+      DXASSERT_NOMSG(pInfo1);
+
+      // Write MaxVertexCount
+      if (SM->IsGS()) {
+        DXASSERT_NOMSG(m_Module.GetMaxVertexCount() <= 1024);
+        pInfo1->MaxVertexCount = (uint16_t)m_Module.GetMaxVertexCount();
+      }
+
       // Write Dxil Signature Elements
       for (unsigned i = 0; i < m_PSV.GetSigInputElements(); i++) {
         PSVSignatureElement0 *pInputElement = m_PSV.GetInputElement0(i);
@@ -662,10 +671,10 @@ public:
           if (!SM->IsGS())
             break;
         }
-        if (m_Module.GetShaderModel()->IsHS()) {
+        if (SM->IsHS()) {
           const uint32_t PCScalars = *(pSrc++);
           pSrc = CopyViewIDState(pSrc, InputScalars, PCScalars, m_PSV.GetViewIDPCOutputMask(), m_PSV.GetInputToPCOutputTable());
-        } else if (m_Module.GetShaderModel()->IsDS()) {
+        } else if (SM->IsDS()) {
           const uint32_t PCScalars = *(pSrc++);
           pSrc = CopyViewIDState(pSrc, PCScalars, OutputScalars[0], PSVComponentMask(), m_PSV.GetPCInputToOutputTable());
         }

+ 1 - 1
lib/Transforms/Utils/SimplifyCFG.cpp

@@ -1328,7 +1328,7 @@ static bool SinkThenElseCodeToEnd(BranchInst *BI1) {
     // HLSL Change Begin.
     // Don't sink struct type which will generate struct PhiNode to make sure
     // struct type value only used by Extract/InsertValue.
-    if (DifferentOp1->getType()->isStructTy())
+    if (DifferentOp1 && DifferentOp1->getType()->isStructTy())
       return Changed;
     // HLSL Change End.
 

+ 1 - 1
tools/clang/unittests/HLSL/ShaderOpTest.h

@@ -88,7 +88,7 @@ private:
 #ifdef _HASH_SEQ_DEFINED
       return std::_Hash_seq((const unsigned char *)a, strlen(a));
 #else
-#error Pick a hash function for this platform.
+      return std::_Hash_array_representation((const unsigned char *)a, strlen(a));
 #endif
     }
   };