cultmath: generator maps integer vector and matrix return types to HLSL

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-16 20:01:10 +02:00
commit 89bf977dcf
2 changed files with 8 additions and 1 deletions

View file

@ -67,6 +67,13 @@ def write(kind, glsl, value):
return {'f': 'asuint(%s)', 'i': 'asuint(%s)', 'u': '%s'}[kind] % value
def hlsl_type(t):
m = GLSL_VEC.match(t)
if m:
return {'': 'float', 'i': 'int', 'u': 'uint'}[m.group(1)] + m.group(2)
return 'float3x3' if t == 'mat3' else t
def body(sig, n, win, wout, defs, glsl):
m = re.fullmatch(r'(\w+)\s+(\w+)\((.*)\)', sig)
ret, name, params = m.group(1), m.group(2), [p.strip() for p in m.group(3).split(',') if p.strip()]

View file

@ -10,7 +10,7 @@
static void *slurp(const char *p, size_t *n) {
FILE *f = fopen(p, "rb"); if (!f) { perror(p); exit(2); }
fseek(f, 0, SEEK_END); *n = ftell(f); fseek(f, 0, SEEK_SET);
void *b = malloc(*n ? *n : 4); fread(b, 1, *n, f); fclose(f); return b;
void *b = malloc(*n ? *n : 4); if (fread(b, 1, *n, f) != *n) exit(2); fclose(f); return b;
}
int main(int argc, char **argv) {