Browse Source

Enable validation of rawbufferload/rawbufferstore (#2300)

The validation code was written for these but never ran due to this omission.
Tristan Labelle 6 years ago
parent
commit
c0cf2018e6

+ 2 - 2
docs/DXIL.rst

@@ -2974,8 +2974,8 @@ INSTR.OPCONSTRANGE                       Constant values must be in-range for op
 INSTR.OPERANDRANGE                       DXIL intrinsic operand must be within defined range
 INSTR.PTRBITCAST                         Pointer type bitcast must be have same size
 INSTR.RESOURCECLASSFORLOAD               load can only run on UAV/SRV resource
-INSTR.RESOURCECLASSFORSAMPLERGATHER      sample, lod and gather should on srv resource.
-INSTR.RESOURCECLASSFORUAVSTORE           store should on uav resource.
+INSTR.RESOURCECLASSFORSAMPLERGATHER      sample, lod and gather should be on srv resource.
+INSTR.RESOURCECLASSFORUAVSTORE           store should be on uav resource.
 INSTR.RESOURCECOORDINATEMISS             coord uninitialized
 INSTR.RESOURCECOORDINATETOOMANY          out of bound coord must be undef
 INSTR.RESOURCEKINDFORBUFFERLOADSTORE     buffer load/store only works on Raw/Typed/StructuredBuffer

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

@@ -102,8 +102,8 @@ enum class ValidationRule : unsigned {
   InstrOperandRange, // DXIL intrinsic operand must be within defined range
   InstrPtrBitCast, // Pointer type bitcast must be have same size
   InstrResourceClassForLoad, // load can only run on UAV/SRV resource
-  InstrResourceClassForSamplerGather, // sample, lod and gather should on srv resource.
-  InstrResourceClassForUAVStore, // store should on uav resource.
+  InstrResourceClassForSamplerGather, // sample, lod and gather should be on srv resource.
+  InstrResourceClassForUAVStore, // store should be on uav resource.
   InstrResourceCoordinateMiss, // coord uninitialized
   InstrResourceCoordinateTooMany, // out of bound coord must be undef
   InstrResourceKindForBufferLoadStore, // buffer load/store only works on Raw/Typed/StructuredBuffer

+ 4 - 2
lib/HLSL/DxilValidation.cpp

@@ -166,8 +166,8 @@ const char *hlsl::GetValidationRuleText(ValidationRule value) {
     case hlsl::ValidationRule::InstrResourceKindForTextureStore: return "texture store only works on Texture1D/1DArray/2D/2DArray/3D";
     case hlsl::ValidationRule::InstrResourceKindForGetDim: return "Invalid resource kind on GetDimensions";
     case hlsl::ValidationRule::InstrResourceKindForTextureLoad: return "texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray";
-    case hlsl::ValidationRule::InstrResourceClassForSamplerGather: return "sample, lod and gather should on srv resource.";
-    case hlsl::ValidationRule::InstrResourceClassForUAVStore: return "store should on uav resource.";
+    case hlsl::ValidationRule::InstrResourceClassForSamplerGather: return "sample, lod and gather should be on srv resource.";
+    case hlsl::ValidationRule::InstrResourceClassForUAVStore: return "store should be on uav resource.";
     case hlsl::ValidationRule::InstrResourceClassForLoad: return "load can only run on UAV/SRV resource";
     case hlsl::ValidationRule::InstrResourceMapToSingleEntry: return "Fail to map resource to resource table";
     case hlsl::ValidationRule::InstrResourceUser: return "Resource should only used by Load/GEP/Call";
@@ -2275,6 +2275,8 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
   case DXIL::OpCode::TextureLoad:
   case DXIL::OpCode::CBufferLoad:
   case DXIL::OpCode::CBufferLoadLegacy:
+  case DXIL::OpCode::RawBufferLoad:
+  case DXIL::OpCode::RawBufferStore:
     ValidateResourceDxilOp(CI, opcode, ValCtx);
     break;
   // Input output.

+ 0 - 0
tools/clang/test/CodeGenHLSL/batch/validation/array1.hlsl → tools/clang/test/CodeGenHLSL/batch/declarations/resources/constant_buffers/array1.hlsl


+ 6 - 0
tools/clang/test/CodeGenHLSL/batch/validation/rawbufferstore_uav.hlsl

@@ -0,0 +1,6 @@
+// RUN: %dxc -T vs_6_2 -E main %s | FileCheck %s
+
+// CHECK: store should be on uav resource
+
+StructuredBuffer<int> buf;
+void main() { buf[0] = 0; }

+ 1 - 1
tools/clang/unittests/HLSL/ValidationTest.cpp

@@ -861,7 +861,7 @@ TEST_F(ValidationTest, SamplerKindFail) {
       {"Invalid sampler mode",
        "require sampler declared in comparison mode",
        "requires sampler declared in default mode",
-       "should on srv resource"});
+       "should be on srv resource"});
 }
 TEST_F(ValidationTest, SemaOverlapFail) {
   RewriteAssemblyCheckMsg(

+ 2 - 2
utils/hct/hctdb.py

@@ -1997,8 +1997,8 @@ class db_dxil(object):
         self.add_valrule("Instr.ResourceKindForTextureStore", "texture store only works on Texture1D/1DArray/2D/2DArray/3D")
         self.add_valrule("Instr.ResourceKindForGetDim", "Invalid resource kind on GetDimensions")
         self.add_valrule("Instr.ResourceKindForTextureLoad", "texture load only works on Texture1D/1DArray/2D/2DArray/3D/MS2D/MS2DArray")
-        self.add_valrule("Instr.ResourceClassForSamplerGather", "sample, lod and gather should on srv resource.")
-        self.add_valrule("Instr.ResourceClassForUAVStore", "store should on uav resource.")
+        self.add_valrule("Instr.ResourceClassForSamplerGather", "sample, lod and gather should be on srv resource.")
+        self.add_valrule("Instr.ResourceClassForUAVStore", "store should be on uav resource.")
         self.add_valrule("Instr.ResourceClassForLoad", "load can only run on UAV/SRV resource")
         self.add_valrule("Instr.ResourceMapToSingleEntry", "Fail to map resource to resource table")
         self.add_valrule("Instr.ResourceUser", "Resource should only used by Load/GEP/Call")