From e0ab1ed14eda3efb17b83fc8e4f8c9723a3f9ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 6 Feb 2024 12:33:02 +0100 Subject: [PATCH] spirv: make gl_HelperInvocation volatile if demote is being used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Non-volatile gl_HelperInvocation after demote is undefined. In order to avoid application bugs, make it volatile if we use demote. Reviewed-by: Marek Olšák Reviewed-by: Alyssa Rosenzweig Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/spirv/vtn_variables.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 19bbcaaa51d..22e6425207f 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1600,6 +1600,15 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, case SpvDecorationCounterBuffer: /* Counter buffer decorations can safely be ignored by the driver. */ return; + case SpvDecorationBuiltIn: + /* Non-volatile gl_HelperInvocation after demote is undefined. + * In order to avoid application bugs, make it volatile if we use demote. + */ + if (dec->operands[0] == SpvBuiltInHelperInvocation && + (b->enabled_capabilities.DemoteToHelperInvocation || + b->convert_discard_to_demote)) + vtn_var->access |= ACCESS_VOLATILE; + break; default: break; }