[Mesa-dev] [PATCH 03/28] spirv/nir: keep track of SPV_KHR_shader_float_controls execution modes
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Wed Dec 5 15:55:18 UTC 2018
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/compiler/shader_enums.h | 14 ++++++++++++++
src/compiler/shader_info.h | 3 +++
src/compiler/spirv/spirv_to_nir.c | 26 ++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index f023b48cbb3..15caf753efb 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -750,6 +750,20 @@ enum compare_func
COMPARE_FUNC_ALWAYS,
};
+enum shader_float_controls
+{
+ SHADER_DEFAULT_FLOAT_CONTROL_MODE = 0x0000,
+ SHADER_DENORM_PRESERVE_FP16 = 0x0001,
+ SHADER_DENORM_PRESERVE_FP32 = 0x0002,
+ SHADER_DENORM_PRESERVE_FP64 = 0x0004,
+ SHADER_DENORM_FLUSH_TO_ZERO_FP16 = 0x0008,
+ SHADER_DENORM_FLUSH_TO_ZERO_FP32 = 0x0010,
+ SHADER_DENORM_FLUSH_TO_ZERO_FP64 = 0x0020,
+ SHADER_SIGNED_ZERO_INF_NAN_PRESERVE = 0x0040,
+ SHADER_ROUNDING_MODE_RTE = 0x0080,
+ SHADER_ROUNDING_MODE_RTZ = 0x0100,
+};
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 21c3d371a63..0383058522e 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -133,6 +133,9 @@ typedef struct shader_info {
/** Was this shader linked with any transform feedback varyings? */
bool has_transform_feedback_varyings;
+ /* SPV_KHR_shader_float_controls: execution mode for floating point ops */
+ unsigned shader_float_controls_execution_mode;
+
union {
struct {
/* Which inputs are doubles */
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 100fcd8e298..3f71644ce34 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3758,6 +3758,32 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
vtn_assert(b->shader->info.stage == MESA_SHADER_FRAGMENT);
break;
+ case SpvExecutionModeDenormPreserve:
+ switch (mode->literals[0]) {
+ case 16: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_PRESERVE_FP16; break;
+ case 32: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_PRESERVE_FP32; break;
+ case 64: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_PRESERVE_FP64; break;
+ default: vtn_fail("Floating point type not supported");
+ }
+ break;
+ case SpvExecutionModeDenormFlushToZero:
+ switch (mode->literals[0]) {
+ case 16: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_FLUSH_TO_ZERO_FP16; break;
+ case 32: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_FLUSH_TO_ZERO_FP32; break;
+ case 64: b->shader->info.shader_float_controls_execution_mode |= SHADER_DENORM_FLUSH_TO_ZERO_FP64; break;
+ default: vtn_fail("Floating point type not supported");
+ }
+ break;
+ case SpvExecutionModeSignedZeroInfNanPreserve:
+ b->shader->info.shader_float_controls_execution_mode |= SHADER_SIGNED_ZERO_INF_NAN_PRESERVE;
+ break;
+ case SpvExecutionModeRoundingModeRTE:
+ b->shader->info.shader_float_controls_execution_mode |= SHADER_ROUNDING_MODE_RTE;
+ break;
+ case SpvExecutionModeRoundingModeRTZ:
+ b->shader->info.shader_float_controls_execution_mode |= SHADER_ROUNDING_MODE_RTZ;
+ break;
+
default:
vtn_fail("Unhandled execution mode");
}
--
2.19.1
More information about the mesa-dev
mailing list