Fix T83625: Shading attribute names cause compilation error.

Some GPU platforms don't support having more than one underscore in
sequence in an attribute name. This change will remove the underscore
as a possible character when encoding to save names.
This commit is contained in:
Jeroen Bakker 2020-12-18 09:56:28 +01:00
parent 96336007e9
commit 2db277092d
Notes: blender-bot 2023-02-14 07:31:32 +01:00
Referenced by issue #83625, Naming Vertex Color attribute as "snout, Snout" causes shader error.
1 changed files with 3 additions and 4 deletions

View File

@ -262,13 +262,12 @@ void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr_id, const char *
/* Encode 8 original bytes into 11 safe bytes. */
static void safe_bytes(char out[11], const char data[8])
{
char safe_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
char safe_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
uint64_t in = *(uint64_t *)data;
for (int i = 0; i < 11; i++) {
/* Encoding in base63 */
out[i] = safe_chars[in % 63lu];
in /= 63lu;
out[i] = safe_chars[in % 62lu];
in /= 62lu;
}
}