소스 검색

Merged PR 92: Enable ValidateResourceDxilOp for lib profile.

Enable ValidateResourceDxilOp for lib profile.
Xiang_Li (XBox) 7 년 전
부모
커밋
4ade2fccc0

+ 2 - 0
docs/DXIL.rst

@@ -2977,6 +2977,7 @@ INSTR.SAMPLEINDEXFORLOAD2DMS           load on Texture2DMS/2DMSArray require sam
 INSTR.SAMPLERMODEFORLOD                lod instruction requires sampler declared in default mode
 INSTR.SAMPLERMODEFORLOD                lod instruction requires sampler declared in default mode
 INSTR.SAMPLERMODEFORSAMPLE             sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode
 INSTR.SAMPLERMODEFORSAMPLE             sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode
 INSTR.SAMPLERMODEFORSAMPLEC            sample_c_*/gather_c instructions require sampler declared in comparison mode
 INSTR.SAMPLERMODEFORSAMPLEC            sample_c_*/gather_c instructions require sampler declared in comparison mode
+INSTR.SIGNATUREOPERATIONNOTINENTRY     Dxil operation for input output signature must be in entryPoints.
 INSTR.STATUS                           Resource status should only used by CheckAccessFullyMapped
 INSTR.STATUS                           Resource status should only used by CheckAccessFullyMapped
 INSTR.STRUCTBITCAST                    Bitcast on struct types is not allowed
 INSTR.STRUCTBITCAST                    Bitcast on struct types is not allowed
 INSTR.TEXTUREOFFSET                    offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7
 INSTR.TEXTUREOFFSET                    offset texture instructions must take offset which can resolve to integer literal in the range -8 to 7
@@ -3004,6 +3005,7 @@ META.INTERPMODEVALID                   Interpolation mode must be valid
 META.INVALIDCONTROLFLOWHINT            Invalid control flow hint
 META.INVALIDCONTROLFLOWHINT            Invalid control flow hint
 META.KNOWN                             Named metadata should be known
 META.KNOWN                             Named metadata should be known
 META.MAXTESSFACTOR                     Hull Shader MaxTessFactor must be [%0..%1].  %2 specified
 META.MAXTESSFACTOR                     Hull Shader MaxTessFactor must be [%0..%1].  %2 specified
+META.NOENTRYPROPSFORENTRY              EntryPoints must have entry properties.
 META.NOSEMANTICOVERLAP                 Semantics must not overlap
 META.NOSEMANTICOVERLAP                 Semantics must not overlap
 META.REQUIRED                          TODO - Required metadata missing
 META.REQUIRED                          TODO - Required metadata missing
 META.SEMAKINDMATCHESNAME               Semantic name must match system value, when defined.
 META.SEMAKINDMATCHESNAME               Semantic name must match system value, when defined.

+ 0 - 5
include/dxc/HLSL/DxilModule.h

@@ -106,11 +106,6 @@ public:
   const DxilResource &GetUAV(unsigned idx) const;
   const DxilResource &GetUAV(unsigned idx) const;
   const std::vector<std::unique_ptr<DxilResource> > &GetUAVs() const;
   const std::vector<std::unique_ptr<DxilResource> > &GetUAVs() const;
 
 
-  void CreateResourceLinkInfo();
-  struct ResourceLinkInfo;
-  const ResourceLinkInfo &GetResourceLinkInfo(DXIL::ResourceClass resClass,
-                                        unsigned rangeID) const;
-
   void LoadDxilResourceBaseFromMDNode(llvm::MDNode *MD, DxilResourceBase &R);
   void LoadDxilResourceBaseFromMDNode(llvm::MDNode *MD, DxilResourceBase &R);
   void LoadDxilResourceFromMDNode(llvm::MDNode *MD, DxilResource &R);
   void LoadDxilResourceFromMDNode(llvm::MDNode *MD, DxilResource &R);
   void LoadDxilSamplerFromMDNode(llvm::MDNode *MD, DxilSampler &S);
   void LoadDxilSamplerFromMDNode(llvm::MDNode *MD, DxilSampler &S);

+ 2 - 0
include/dxc/HLSL/DxilValidation.h

@@ -112,6 +112,7 @@ enum class ValidationRule : unsigned {
   InstrSamplerModeForLOD, // lod instruction requires sampler declared in default mode
   InstrSamplerModeForLOD, // lod instruction requires sampler declared in default mode
   InstrSamplerModeForSample, // sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode
   InstrSamplerModeForSample, // sample/_l/_d/_cl_s/gather instruction requires sampler declared in default mode
   InstrSamplerModeForSampleC, // sample_c_*/gather_c instructions require sampler declared in comparison mode
   InstrSamplerModeForSampleC, // sample_c_*/gather_c instructions require sampler declared in comparison mode
+  InstrSignatureOperationNotInEntry, // Dxil operation for input output signature must be in entryPoints.
   InstrStatus, // Resource status should only used by CheckAccessFullyMapped
   InstrStatus, // Resource status should only used by CheckAccessFullyMapped
   InstrStructBitCast, // Bitcast on struct types is not allowed
   InstrStructBitCast, // Bitcast on struct types is not allowed
   InstrTGSMRaceCond, // Race condition writing to shared memory detected, consider making this write conditional
   InstrTGSMRaceCond, // Race condition writing to shared memory detected, consider making this write conditional
@@ -141,6 +142,7 @@ enum class ValidationRule : unsigned {
   MetaInvalidControlFlowHint, // Invalid control flow hint
   MetaInvalidControlFlowHint, // Invalid control flow hint
   MetaKnown, // Named metadata should be known
   MetaKnown, // Named metadata should be known
   MetaMaxTessFactor, // Hull Shader MaxTessFactor must be [%0..%1].  %2 specified
   MetaMaxTessFactor, // Hull Shader MaxTessFactor must be [%0..%1].  %2 specified
+  MetaNoEntryPropsForEntry, // EntryPoints must have entry properties.
   MetaNoSemanticOverlap, // Semantics must not overlap
   MetaNoSemanticOverlap, // Semantics must not overlap
   MetaRequired, // TODO - Required metadata missing
   MetaRequired, // TODO - Required metadata missing
   MetaSemaKindMatchesName, // Semantic name must match system value, when defined.
   MetaSemaKindMatchesName, // Semantic name must match system value, when defined.

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 609 - 146
lib/HLSL/DxilValidation.cpp


+ 12 - 0
tools/clang/lib/CodeGen/CGHLSLMS.cpp

@@ -4496,6 +4496,18 @@ void CGMSHLSLRuntime::FinishCodeGen() {
     if (!m_bIsLib) {
     if (!m_bIsLib) {
       if (&f == m_pHLModule->GetEntryFunction() ||
       if (&f == m_pHLModule->GetEntryFunction() ||
           IsPatchConstantFunction(&f) || f.isDeclaration()) {
           IsPatchConstantFunction(&f) || f.isDeclaration()) {
+        if (f.isDeclaration() && !f.isIntrinsic() &&
+            GetHLOpcodeGroup(&f) == HLOpcodeGroup::NotHL) {
+          DiagnosticsEngine &Diags = CGM.getDiags();
+          unsigned DiagID = Diags.getCustomDiagID(
+              DiagnosticsEngine::Error,
+              "External function used in non-library profile: %0");
+          std::string escaped;
+          llvm::raw_string_ostream os(escaped);
+          dxilutil::PrintEscapedString(f.getName(), os);
+          Diags.Report(DiagID) << os.str();
+          return;
+        }
         f.setLinkage(GlobalValue::LinkageTypes::ExternalLinkage);
         f.setLinkage(GlobalValue::LinkageTypes::ExternalLinkage);
       } else {
       } else {
         f.setLinkage(GlobalValue::LinkageTypes::InternalLinkage);
         f.setLinkage(GlobalValue::LinkageTypes::InternalLinkage);

+ 11 - 3
tools/clang/test/CodeGenHLSL/quick-test/d3dreflect/lib_hs_export1.hlsl

@@ -20,6 +20,12 @@ struct HSPerPatchData
   float inside   : SV_InsideTessFactor;
   float inside   : SV_InsideTessFactor;
 };
 };
 
 
+struct HSPerPatchDataQuad
+{
+  float edges[4] : SV_TessFactor;
+  float inside[2]   : SV_InsideTessFactor;
+};
+
 // Should not be selected, since later candidate function with same name exists.
 // Should not be selected, since later candidate function with same name exists.
 // If selected, it should fail, since patch size mismatches HS function.
 // If selected, it should fail, since patch size mismatches HS function.
 HSPerPatchData HSPerPatchFunc1(
 HSPerPatchData HSPerPatchFunc1(
@@ -35,15 +41,17 @@ HSPerPatchData HSPerPatchFunc1(
   return d;
   return d;
 }
 }
 
 
-HSPerPatchData HSPerPatchFunc2(
+HSPerPatchDataQuad HSPerPatchFunc2(
   const InputPatch< PSSceneIn, 4 > points)
   const InputPatch< PSSceneIn, 4 > points)
 {
 {
-  HSPerPatchData d;
+  HSPerPatchDataQuad d;
 
 
   d.edges[0] = -5;
   d.edges[0] = -5;
   d.edges[1] = -6;
   d.edges[1] = -6;
   d.edges[2] = -7;
   d.edges[2] = -7;
-  d.inside = -8;
+  d.edges[3] = -7;
+  d.inside[0] = -8;
+  d.inside[1] = -8;
 
 
   return d;
   return d;
 }
 }

+ 2 - 2
tools/clang/test/CodeGenHLSL/quick-test/d3dreflect/reflect-lib-1.hlsl

@@ -11,7 +11,7 @@ float function0(min16float x) {
 float function1(float x, min12int i) {
 float function1(float x, min12int i) {
   return x + cbval1 + b_buf.Load(x) + tex2.Sample(samp, x).x; }
   return x + cbval1 + b_buf.Load(x) + tex2.Sample(samp, x).x; }
 [shader("vertex")]
 [shader("vertex")]
-float function2(float4 x : POSITION) : SV_Position { return x + cbval1 + cbval3.x; }
+float4 function2(float4 x : POSITION) : SV_Position { return x + cbval1 + cbval3.x; }
 
 
 
 
 // CHECK: ID3D12LibraryReflection:
 // CHECK: ID3D12LibraryReflection:
@@ -114,7 +114,7 @@ float function2(float4 x : POSITION) : SV_Position { return x + cbval1 + cbval3.
 // CHECK:         ReturnType: D3D_RETURN_TYPE_MIXED
 // CHECK:         ReturnType: D3D_RETURN_TYPE_MIXED
 // CHECK:         Dimension: D3D_SRV_DIMENSION_BUFFER
 // CHECK:         Dimension: D3D_SRV_DIMENSION_BUFFER
 // CHECK:   ID3D12FunctionReflection:
 // CHECK:   ID3D12FunctionReflection:
-// CHECK:     D3D12_FUNCTION_DESC: Name: \01?function2@@YAMV?$vector@M$03@@@Z
+// CHECK:     D3D12_FUNCTION_DESC: Name: \01?function2@@YA?AV?$vector@M$03@@V1@@Z
 // CHECK:       Shader Version: Library 6.3
 // CHECK:       Shader Version: Library 6.3
 // CHECK:       ConstantBuffers: 2
 // CHECK:       ConstantBuffers: 2
 // CHECK:       BoundResources: 2
 // CHECK:       BoundResources: 2

+ 32 - 0
tools/clang/test/CodeGenHLSL/quick-test/external_func.hlsl

@@ -0,0 +1,32 @@
+// RUN: %dxc -T cs_6_0 -E main %s | FileCheck %s
+
+// Make sure report error when external function used.
+// CHECK: External function used in non-library profile
+
+struct T {
+RWByteAddressBuffer outputBuffer;
+RWByteAddressBuffer outputBuffer2;
+};
+
+struct D {
+  float4 a;
+  int4 b;
+};
+
+struct T2 {
+   RWStructuredBuffer<D> uav;
+};
+
+T2 resStruct(T t, uint2 id);
+
+RWByteAddressBuffer outputBuffer;
+RWByteAddressBuffer outputBuffer2;
+
+[numthreads(8, 8, 1)]
+void main( uint2 id : SV_DispatchThreadID )
+{
+    T t = {outputBuffer,outputBuffer2};
+    T2 t2 = resStruct(t, id);
+    uint counter = t2.uav.IncrementCounter();
+    t2.uav[counter].b.xy = id;
+}

+ 32 - 0
tools/clang/test/CodeGenHLSL/quick-test/lib_res_param.hlsl

@@ -0,0 +1,32 @@
+// RUN: %dxc -T lib_6_3  %s | FileCheck %s
+
+// Make sure simple local resource array works.
+// CHECK: main
+
+struct T {
+RWByteAddressBuffer outputBuffer;
+RWByteAddressBuffer outputBuffer2;
+};
+
+struct D {
+  float4 a;
+  int4 b;
+};
+
+struct T2 {
+   RWStructuredBuffer<D> uav;
+};
+
+T2 resStruct(T t, uint2 id);
+
+RWByteAddressBuffer outputBuffer;
+RWByteAddressBuffer outputBuffer2;
+
+[numthreads(8, 8, 1)]
+void main( uint2 id : SV_DispatchThreadID )
+{
+    T t = {outputBuffer,outputBuffer2};
+    T2 t2 = resStruct(t, id);
+    uint counter = t2.uav.IncrementCounter();
+    t2.uav[counter].b.xy = id;
+}

+ 2 - 0
utils/hct/hctdb.py

@@ -1832,6 +1832,7 @@ class db_dxil(object):
         self.add_valrule("Meta.BarycentricsInterpolation", "SV_Barycentrics cannot be used with 'nointerpolation' type")
         self.add_valrule("Meta.BarycentricsInterpolation", "SV_Barycentrics cannot be used with 'nointerpolation' type")
         self.add_valrule("Meta.BarycentricsFloat3", "only 'float3' type is allowed for SV_Barycentrics.")
         self.add_valrule("Meta.BarycentricsFloat3", "only 'float3' type is allowed for SV_Barycentrics.")
         self.add_valrule("Meta.BarycentricsTwoPerspectives", "There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode.")
         self.add_valrule("Meta.BarycentricsTwoPerspectives", "There can only be up to two input attributes of SV_Barycentrics with different perspective interpolation mode.")
+        self.add_valrule("Meta.NoEntryPropsForEntry", "EntryPoints must have entry properties.")
 
 
         self.add_valrule("Instr.Oload", "DXIL intrinsic overload must be valid")
         self.add_valrule("Instr.Oload", "DXIL intrinsic overload must be valid")
         self.add_valrule_msg("Instr.CallOload", "Call to DXIL intrinsic must match overload signature", "Call to DXIL intrinsic '%0' does not match an allowed overload signature")
         self.add_valrule_msg("Instr.CallOload", "Call to DXIL intrinsic must match overload signature", "Call to DXIL intrinsic '%0' does not match an allowed overload signature")
@@ -1914,6 +1915,7 @@ class db_dxil(object):
         self.add_valrule("Instr.TGSMRaceCond", "Race condition writing to shared memory detected, consider making this write conditional")
         self.add_valrule("Instr.TGSMRaceCond", "Race condition writing to shared memory detected, consider making this write conditional")
         self.add_valrule("Instr.AttributeAtVertexNoInterpolation", "Attribute %0 must have nointerpolation mode in order to use GetAttributeAtVertex function.")
         self.add_valrule("Instr.AttributeAtVertexNoInterpolation", "Attribute %0 must have nointerpolation mode in order to use GetAttributeAtVertex function.")
         self.add_valrule("Instr.CreateHandleImmRangeID", "Local resource must map to global resource.")
         self.add_valrule("Instr.CreateHandleImmRangeID", "Local resource must map to global resource.")
+        self.add_valrule("Instr.SignatureOperationNotInEntry", "Dxil operation for input output signature must be in entryPoints.")
 
 
         # Some legacy rules:
         # Some legacy rules:
         # - space is only supported for shader targets 5.1 and higher
         # - space is only supported for shader targets 5.1 and higher

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.