nir/spirv: handle ContractionOff execution mode
authorKarol Herbst <kherbst@redhat.com>
Mon, 3 Dec 2018 18:08:41 +0000 (19:08 +0100)
committerKarol Herbst <kherbst@redhat.com>
Mon, 21 Jan 2019 19:36:41 +0000 (20:36 +0100)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/spirv/spirv_info.h
src/compiler/spirv/spirv_info_c.py
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_alu.c
src/compiler/spirv/vtn_cfg.c
src/compiler/spirv/vtn_private.h

index 121ffd2febb04ead4f04685fd110c3a39cf7c716..a03c2ef8eb02f4093c331054b0bd5cd63d49d690 100644 (file)
@@ -28,6 +28,7 @@
 
 const char *spirv_capability_to_string(SpvCapability cap);
 const char *spirv_decoration_to_string(SpvDecoration dec);
+const char *spirv_executionmode_to_string(SpvExecutionMode mode);
 const char *spirv_op_to_string(SpvOp op);
 
 #endif /* SPIRV_INFO_H */
index ff7942bcd3a8cf68799d189099e370d9ac4c5a69..6880d3e329d6da10f9bbcdb119fbfd2005d1d87c 100644 (file)
@@ -90,6 +90,7 @@ if __name__ == "__main__":
     info = [
         collect_data(spirv_info, "Capability"),
         collect_data(spirv_info, "Decoration"),
+        collect_data(spirv_info, "ExecutionMode"),
         collect_opcodes(spirv_info),
     ]
 
index 19e4319bd24ef6877c36ae730ba32dd48b138c90..5013a9c30aedfa0220aa46e501bd36039320851d 100644 (file)
@@ -3865,9 +3865,16 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
       break;
 
    case SpvExecutionModeVecTypeHint:
-   case SpvExecutionModeContractionOff:
       break; /* OpenCL */
 
+   case SpvExecutionModeContractionOff:
+      if (b->shader->info.stage != MESA_SHADER_KERNEL)
+         vtn_warn("ExectionMode only allowed for CL-style kernels: %s",
+                  spirv_executionmode_to_string(mode->exec_mode));
+      else
+         b->exact = true;
+      break;
+
    case SpvExecutionModeStencilRefReplacingEXT:
       vtn_assert(b->shader->info.stage == MESA_SHADER_FRAGMENT);
       break;
index dc6fedc9129674ef5303e809e366de9e38de6c64..f910630acfbf522ec095e818faf7a5f25bb69d42 100644 (file)
@@ -395,7 +395,7 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
    if (glsl_type_is_matrix(vtn_src[0]->type) ||
        (num_inputs >= 2 && glsl_type_is_matrix(vtn_src[1]->type))) {
       vtn_handle_matrix_alu(b, opcode, val, vtn_src[0], vtn_src[1]);
-      b->nb.exact = false;
+      b->nb.exact = b->exact;
       return;
    }
 
@@ -661,5 +661,5 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
    } /* default */
    }
 
-   b->nb.exact = false;
+   b->nb.exact = b->exact;
 }
index 36dbb540463c763c9a66b1383af23289700214f7..c32d54e9006fef2b3998df479b2cce4bcfe2b88e 100644 (file)
@@ -287,6 +287,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
       b->func->impl = nir_function_impl_create(func);
       nir_builder_init(&b->nb, func->impl);
       b->nb.cursor = nir_before_cf_list(&b->func->impl->body);
+      b->nb.exact = b->exact;
 
       b->func_param_idx = 0;
 
@@ -1038,6 +1039,7 @@ vtn_function_emit(struct vtn_builder *b, struct vtn_function *func,
    nir_builder_init(&b->nb, func->impl);
    b->func = func;
    b->nb.cursor = nir_after_cf_list(&func->impl->body);
+   b->nb.exact = b->exact;
    b->has_loop_continue = false;
    b->phi_table = _mesa_pointer_hash_table_create(b);
 
index a2b3dee7517cc52f31b86430fbcbd23371691e9c..3a5c5f32224b73649ae52614c365b17b083b68ad 100644 (file)
@@ -604,6 +604,9 @@ struct vtn_builder {
    unsigned func_param_idx;
 
    bool has_loop_continue;
+
+   /* false by default, set to true by the ContractionOff execution mode */
+   bool exact;
 };
 
 nir_ssa_def *