Ver Fonte

[spirv] Emit Float16 capability if float16 type is used. (#2147)

Ehsan há 6 anos atrás
pai
commit
8270b9f795

+ 1 - 4
tools/clang/lib/SPIRV/CapabilityVisitor.cpp

@@ -63,10 +63,7 @@ void CapabilityVisitor::addCapabilityForType(const SpirvType *type,
     switch (floatType->getBitwidth()) {
     case 16: {
       // Usage of a 16-bit float type.
-      // It looks like the validator does not approve of Float16
-      // capability even though we do use the necessary extension.
-      // TODO: Re-enable adding Float16 capability below.
-      // addCapability(spv::Capability::Float16);
+      addCapability(spv::Capability::Float16);
       addExtension(Extension::AMD_gpu_shader_half_float, "16-bit float", loc);
 
       // Usage of a 16-bit float type as stage I/O.

+ 1 - 0
tools/clang/test/CodeGenSPIRV/constant.scalar.16bit.enabled.hlsl

@@ -15,6 +15,7 @@
 // min16uint:  uint16_t(warning)
 // uint16_t:   uint16_t
 
+// CHECK: OpCapability Float16
 // CHECK: OpCapability Int16
 // CHECK: OpExtension "SPV_AMD_gpu_shader_half_float"
 

+ 1 - 3
tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

@@ -118,9 +118,7 @@ TEST_F(FileTest, 16BitDisabledScalarConstants) {
   runFileTest("constant.scalar.16bit.disabled.hlsl");
 }
 TEST_F(FileTest, 16BitEnabledScalarConstants) {
-  // TODO: Validator complains about Float16 capability even though we use the
-  // needed extension.
-  runFileTest("constant.scalar.16bit.enabled.hlsl", Expect::Success, false);
+  runFileTest("constant.scalar.16bit.enabled.hlsl");
 }
 TEST_F(FileTest, 16BitEnabledScalarConstantsHalfZero) {
   runFileTest("constant.scalar.16bit.enabled.half.zero.hlsl");