diff options
-rw-r--r-- | src/mesa/shader/slang/slang_label.c | 21 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_label.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c index 4d35d2e72a..e6a03f9e4f 100644 --- a/src/mesa/shader/slang/slang_label.c +++ b/src/mesa/shader/slang/slang_label.c @@ -21,6 +21,27 @@ _slang_label_new(const char *name) return l; } +/** + * As above, but suffix the name with a unique number. + */ +slang_label * +_slang_label_new_unique(const char *name) +{ + static int id = 1; + slang_label *l = (slang_label *) _mesa_calloc(sizeof(slang_label)); + if (l) { + l->Name = (char *) _mesa_malloc(_mesa_strlen(name) + 10); + if (!l->Name) { + _mesa_free(l); + return NULL; + } + _mesa_sprintf(l->Name, "%s_%d", name, id); + id++; + l->Location = -1; + } + return l; +} + void _slang_label_delete(slang_label *l) { diff --git a/src/mesa/shader/slang/slang_label.h b/src/mesa/shader/slang/slang_label.h index 661624f173..0f1a45b30f 100644 --- a/src/mesa/shader/slang/slang_label.h +++ b/src/mesa/shader/slang/slang_label.h @@ -25,6 +25,9 @@ typedef struct slang_label_ slang_label; extern slang_label * _slang_label_new(const char *name); +extern slang_label * +_slang_label_new_unique(const char *name); + extern void _slang_label_delete(slang_label *l); |