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 7edf1e64b3
commit 6c777ed76b
Notes: blender-bot 2023-02-14 03:21:27 +01:00
Referenced by issue #83625, Naming Vertex Color attribute as "snout, Snout" causes shader error.
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 3 additions and 4 deletions

View File

@ -264,13 +264,12 @@ int GPU_vertformat_attr_id_get(const GPUVertFormat *format, const char *name)
/* Encode 8 original bytes into 11 safe bytes. */
static void safe_bytes(char out[11], const char data[8])
{
char safe_chars[63] = "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;
}
}