<div dir="auto"><div>I much prefer this to overloading nir_compiler_options.  Thanks!  Call that an acked-by of you wish.<br><div class="gmail_extra"><br><div class="gmail_quote">On Dec 27, 2016 17:31, "Dave Airlie" <<a href="mailto:airlied@gmail.com">airlied@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
<br>
I expect over time the struct contents will change as all<br>
drivers support stuff etc, but for now this should be a good<br>
starting point.<br>
<br>
Signed-off-by: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
---<br>
 src/compiler/spirv/nir_spirv.h    |  6 ++++++<br>
 src/compiler/spirv/spirv2nir.c    |  2 +-<br>
 src/compiler/spirv/spirv_to_<wbr>nir.c | 17 +++++++++++++++--<br>
 src/compiler/spirv/vtn_<wbr>private.h  |  1 +<br>
 src/intel/vulkan/anv_pipeline.<wbr>c   |  2 +-<br>
 5 files changed, 24 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/nir_<wbr>spirv.h b/src/compiler/spirv/nir_<wbr>spirv.h<br>
index 500f2cb..d959f3f 100644<br>
--- a/src/compiler/spirv/nir_<wbr>spirv.h<br>
+++ b/src/compiler/spirv/nir_<wbr>spirv.h<br>
@@ -41,10 +41,16 @@ struct nir_spirv_specialization {<br>
    uint32_t data;<br>
 };<br>
<br>
+struct nir_spirv_supported_extensions {<br>
+   bool storage_image_extended_<wbr>formats;<br>
+   bool image_ms_array;<br>
+};<br>
+<br>
 nir_function *spirv_to_nir(const uint32_t *words, size_t word_count,<br>
                            struct nir_spirv_specialization *specializations,<br>
                            unsigned num_specializations,<br>
                            gl_shader_stage stage, const char *entry_point_name,<br>
+                           const struct nir_spirv_supported_extensions *ext,<br>
                            const nir_shader_compiler_options *options);<br>
<br>
 #ifdef __cplusplus<br>
diff --git a/src/compiler/spirv/<wbr>spirv2nir.c b/src/compiler/spirv/<wbr>spirv2nir.c<br>
index 3dc0735..0ae14fb 100644<br>
--- a/src/compiler/spirv/<wbr>spirv2nir.c<br>
+++ b/src/compiler/spirv/<wbr>spirv2nir.c<br>
@@ -73,7 +73,7 @@ int main(int argc, char **argv)<br>
    }<br>
<br>
    nir_function *func = spirv_to_nir(map, word_count, NULL, 0,<br>
-                                     MESA_SHADER_FRAGMENT, "main", NULL);<br>
+                                     MESA_SHADER_FRAGMENT, "main", NULL, NULL);<br>
    nir_print_shader(func->shader, stderr);<br>
<br>
    return 0;<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 57d0886..b8acc1e 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -2461,6 +2461,12 @@ stage_for_execution_model(<wbr>SpvExecutionModel model)<br>
    }<br>
 }<br>
<br>
+#define spv_check_supported(name, cap) do {            \<br>
+      if (!(b->ext && b->ext->name))                   \<br>
+         vtn_warn("Unsupported SPIR-V capability: %s",  \<br>
+                  spirv_capability_to_string(<wbr>cap));     \<br>
+   } while(0)<br>
+<br>
 static bool<br>
 vtn_handle_preamble_<wbr>instruction(struct vtn_builder *b, SpvOp opcode,<br>
                                 const uint32_t *w, unsigned count)<br>
@@ -2519,8 +2525,6 @@ vtn_handle_preamble_<wbr>instruction(struct vtn_builder *b, SpvOp opcode,<br>
       case SpvCapabilityInt8:<br>
       case SpvCapabilitySparseResidency:<br>
       case SpvCapabilityMinLod:<br>
-      case SpvCapabilityImageMSArray:<br>
-      case SpvCapabilityStorageImageExten<wbr>dedFormats:<br>
       case SpvCapabilityTransformFeedback<wbr>:<br>
       case SpvCapabilityStorageImageReadW<wbr>ithoutFormat:<br>
       case SpvCapabilityStorageImageWrite<wbr>WithoutFormat:<br>
@@ -2541,6 +2545,13 @@ vtn_handle_preamble_<wbr>instruction(struct vtn_builder *b, SpvOp opcode,<br>
          vtn_warn("Unsupported OpenCL-style SPIR-V capability: %s",<br>
                   spirv_capability_to_string(<wbr>cap));<br>
          break;<br>
+<br>
+      case SpvCapabilityStorageImageExten<wbr>dedFormats:<br>
+         spv_check_supported(storage_<wbr>image_extended_formats, cap);<br>
+         break;<br>
+      case SpvCapabilityImageMSArray:<br>
+         spv_check_supported(image_ms_<wbr>array, cap);<br>
+         break;<br>
       }<br>
       break;<br>
    }<br>
@@ -3015,6 +3026,7 @@ nir_function *<br>
 spirv_to_nir(const uint32_t *words, size_t word_count,<br>
              struct nir_spirv_specialization *spec, unsigned num_spec,<br>
              gl_shader_stage stage, const char *entry_point_name,<br>
+             const struct nir_spirv_supported_extensions *ext,<br>
              const nir_shader_compiler_options *options)<br>
 {<br>
    const uint32_t *word_end = words + word_count;<br>
@@ -3037,6 +3049,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count,<br>
    exec_list_make_empty(&b-><wbr>functions);<br>
    b->entry_point_stage = stage;<br>
    b->entry_point_name = entry_point_name;<br>
+   b->ext = ext;<br>
<br>
    /* Handle all the preamble instructions */<br>
    words = vtn_foreach_instruction(b, words, word_end,<br>
diff --git a/src/compiler/spirv/vtn_<wbr>private.h b/src/compiler/spirv/vtn_<wbr>private.h<br>
index 47579fe..9302611 100644<br>
--- a/src/compiler/spirv/vtn_<wbr>private.h<br>
+++ b/src/compiler/spirv/vtn_<wbr>private.h<br>
@@ -347,6 +347,7 @@ struct vtn_builder {<br>
<br>
    nir_shader *shader;<br>
    nir_function_impl *impl;<br>
+   const struct nir_spirv_supported_extensions *ext;<br>
    struct vtn_block *block;<br>
<br>
    /* Current file, line, and column.  Useful for debugging.  Set<br>
diff --git a/src/intel/vulkan/anv_<wbr>pipeline.c b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
index e2fbcab..db35d70 100644<br>
--- a/src/intel/vulkan/anv_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
@@ -124,7 +124,7 @@ anv_shader_compile_to_nir(<wbr>struct anv_device *device,<br>
    nir_function *entry_point =<br>
       spirv_to_nir(spirv, module->size / 4,<br>
                    spec_entries, num_spec_entries,<br>
-                   stage, entrypoint_name, nir_options);<br>
+                   stage, entrypoint_name, NULL, nir_options);<br>
    nir_shader *nir = entry_point->shader;<br>
    assert(nir->stage == stage);<br>
    nir_validate_shader(nir);<br>
<font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br></div></div></div>