zink. Changed sampler default name.
authorDuncan Hopkins <duncan@thefoundry.co.uk>
Wed, 25 Sep 2019 10:52:37 +0000 (11:52 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 14 May 2020 12:24:28 +0000 (12:24 +0000)
Changed the sampler variable name from 'sampler' to 'sampler_<num>' to stop symbol classes in the Metal MSL shaders, as 'sampler' is a keyword.
Improves human readability when debugging issues.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4211>

src/mesa/program/prog_to_nir.c

index 31ad0cb58c5608c3c726e99bc5b8b4b53581e3e2..14dc89183a092d72e04a05a7cac22a67699c27d0 100644 (file)
@@ -541,7 +541,9 @@ ptn_tex(struct ptn_compile *c, nir_alu_dest dest, nir_ssa_def **src,
    if (!var) {
       const struct glsl_type *type =
          glsl_sampler_type(instr->sampler_dim, false, false, GLSL_TYPE_FLOAT);
-      var = nir_variable_create(b->shader, nir_var_uniform, type, "sampler");
+      char samplerName[20];
+      snprintf(samplerName, sizeof(samplerName), "sampler_%d", prog_inst->TexSrcUnit);
+      var = nir_variable_create(b->shader, nir_var_uniform, type, samplerName);
       var->data.binding = prog_inst->TexSrcUnit;
       var->data.explicit_binding = true;
       c->sampler_vars[prog_inst->TexSrcUnit] = var;