spirv: Add support for DerivativeGroup capabilities
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 28 Mar 2019 17:23:02 +0000 (10:23 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 9 Apr 2019 02:29:33 +0000 (19:29 -0700)
As defined in SPV_NV_compute_shader_derivatives. These control how the
invocations are arranged in a CS when doing derivative and related
operations (which are also enabled by the extension).

Since we expect valid SPIR-V, we don't need to do more work at SPIR-V
level to enable the derivative and related operations to be called.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/shader_info.h
src/compiler/spirv/spirv_to_nir.c

index 78f4032362a51cf39c90969397d735dfa8362cfb..0b67082a7324aa1c03b2fb5f8128b61049116673 100644 (file)
@@ -35,6 +35,7 @@ extern "C" {
 struct spirv_supported_capabilities {
    bool address;
    bool atomic_storage;
+   bool derivative_group;
    bool descriptor_array_dynamic_indexing;
    bool device_group;
    bool draw_parameters;
index 8c2b995be8f0becc13b46ad1872717f2f5d26a18..98205a1b8b26e5dbc9ec89c7f1e3055277328ec9 100644 (file)
@@ -3776,6 +3776,11 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
          spv_check_supported(physical_storage_buffer_address, cap);
          break;
 
+      case SpvCapabilityComputeDerivativeGroupQuadsNV:
+      case SpvCapabilityComputeDerivativeGroupLinearNV:
+         spv_check_supported(derivative_group, cap);
+         break;
+
       default:
          vtn_fail("Unhandled capability");
       }
@@ -4019,6 +4024,16 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
       vtn_assert(b->shader->info.stage == MESA_SHADER_FRAGMENT);
       break;
 
+   case SpvExecutionModeDerivativeGroupQuadsNV:
+      vtn_assert(b->shader->info.stage == MESA_SHADER_COMPUTE);
+      b->shader->info.cs.derivative_group = DERIVATIVE_GROUP_QUADS;
+      break;
+
+   case SpvExecutionModeDerivativeGroupLinearNV:
+      vtn_assert(b->shader->info.stage == MESA_SHADER_COMPUTE);
+      b->shader->info.cs.derivative_group = DERIVATIVE_GROUP_LINEAR;
+      break;
+
    default:
       vtn_fail("Unhandled execution mode");
    }