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; }