[Mesa-dev] [PATCH 12/12] nir/spirv: handle ContractionOff execution mode
Karol Herbst
kherbst at redhat.com
Tue Dec 4 18:26:50 UTC 2018
Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
src/compiler/spirv/spirv_info.h | 1 +
src/compiler/spirv/spirv_info_c.py | 1 +
src/compiler/spirv/spirv_to_nir.c | 9 ++++++++-
src/compiler/spirv/vtn_alu.c | 4 ++--
src/compiler/spirv/vtn_cfg.c | 2 ++
src/compiler/spirv/vtn_private.h | 3 +++
6 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/compiler/spirv/spirv_info.h b/src/compiler/spirv/spirv_info.h
index 121ffd2febb..a03c2ef8eb0 100644
--- a/src/compiler/spirv/spirv_info.h
+++ b/src/compiler/spirv/spirv_info.h
@@ -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 */
diff --git a/src/compiler/spirv/spirv_info_c.py b/src/compiler/spirv/spirv_info_c.py
index ff7942bcd3a..6880d3e329d 100644
--- a/src/compiler/spirv/spirv_info_c.py
+++ b/src/compiler/spirv/spirv_info_c.py
@@ -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),
]
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 1a7d5b3a9bd..488c61cf1c6 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3771,9 +3771,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;
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
index dc6fedc9129..f910630acfb 100644
--- a/src/compiler/spirv/vtn_alu.c
+++ b/src/compiler/spirv/vtn_alu.c
@@ -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;
}
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 5b3cc703f94..bc1a949fdee 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -281,6 +281,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;
@@ -1040,6 +1041,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_hash_table_create(b, _mesa_hash_pointer,
_mesa_key_pointer_equal);
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index e380d8e82ff..930beec30ef 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -607,6 +607,9 @@ struct vtn_builder {
bool has_loop_continue;
+ /* false by default, set to true by the ContractionOff execution mode */
+ bool exact;
+
/* when a physical memory model is choosen */
bool physical_ptrs;
};
--
2.19.2
More information about the mesa-dev
mailing list