Browse Source

[spirv] Document missing pow2 partitioning feature. (#937)

* [spirv] Document missing pow2 partitioning feature.
* Provide more accurate location for attributes.
Ehsan 7 years ago
parent
commit
fc52dbced0
2 changed files with 12 additions and 5 deletions
  1. 3 0
      docs/SPIR-V.rst
  2. 9 5
      tools/clang/lib/SPIRV/SPIRVEmitter.cpp

+ 3 - 0
docs/SPIR-V.rst

@@ -2338,3 +2338,6 @@ either because of no Vulkan equivalents at the moment, or because of deprecation
 * Applying ``row_major`` or ``column_major`` attributes to a stand-alone matrix will be
   ignored by the compiler because ``RowMajor`` and ``ColMajor`` decorations in SPIR-V are
   only allowed to be applied to members of structures. A warning will be issued by the compiler.
+* The Hull shader ``partitioning`` attribute may not have the ``pow2`` value. The compiler
+  will emit an error. Other attribute values are supported and described in the
+  `Hull Entry Point Attributes`_ section.

+ 9 - 5
tools/clang/lib/SPIRV/SPIRVEmitter.cpp

@@ -6702,7 +6702,7 @@ bool SPIRVEmitter::processTessellationShaderAttributes(
             .Default(ExecutionMode::Max);
     if (hsExecMode == ExecutionMode::Max) {
       emitError("unknown domain type specified for entry function",
-                decl->getLocation());
+                domain->getLocation());
       return false;
     }
     theBuilder.addExecutionMode(entryFunctionId, hsExecMode, {});
@@ -6714,9 +6714,13 @@ bool SPIRVEmitter::processTessellationShaderAttributes(
     return true;
 
   if (auto *partitioning = decl->getAttr<HLSLPartitioningAttr>()) {
-    // TODO: Could not find an equivalent of "pow2" partitioning scheme in
-    // SPIR-V.
     const auto scheme = partitioning->getScheme().lower();
+    if (scheme == "pow2") {
+      emitError("pow2 partitioning scheme is not supported since there is no "
+                "equivalent in Vulkan",
+                partitioning->getLocation());
+      return false;
+    }
     const ExecutionMode hsExecMode =
         llvm::StringSwitch<ExecutionMode>(scheme)
             .Case("fractional_even", ExecutionMode::SpacingFractionalEven)
@@ -6725,7 +6729,7 @@ bool SPIRVEmitter::processTessellationShaderAttributes(
             .Default(ExecutionMode::Max);
     if (hsExecMode == ExecutionMode::Max) {
       emitError("unknown partitioning scheme in hull shader",
-                decl->getLocation());
+                partitioning->getLocation());
       return false;
     }
     theBuilder.addExecutionMode(entryFunctionId, hsExecMode, {});
@@ -6745,7 +6749,7 @@ bool SPIRVEmitter::processTessellationShaderAttributes(
         theBuilder.addExecutionMode(entryFunctionId, hsExecMode, {});
       } else {
         emitError("unknown output topology in hull shader",
-                  decl->getLocation());
+                  outputTopology->getLocation());
         return false;
       }
     }