From 68f5250aaed233dad42e0021097e54a52b58a8ab Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 4 Apr 2008 11:27:09 -0400 Subject: [PATCH] Simplifed public uniform information. No sense in having a name here, since it's basically meaningless in some profiles, like D3D. Even profiles that actually need a string name to bind data, like GLSL, can reconstruct it easily enough, since there was never a human-readable name to start with. --HG-- branch : trunk --- mojoshader.h | 21 +++++++++++++++------ testparse.c | 6 ++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/mojoshader.h b/mojoshader.h index 6b901f32..eecaabd7 100644 --- a/mojoshader.h +++ b/mojoshader.h @@ -46,18 +46,28 @@ typedef enum MOJOSHADER_TYPE_ANY = 0xFFFFFFFF /* used for bitmasks */ } MOJOSHADER_shaderType; +/* + * Data types for uniforms. See MOJOSHADER_uniform for more information. + */ typedef enum { MOJOSHADER_UNIFORM_FLOAT, MOJOSHADER_UNIFORM_INT, MOJOSHADER_UNIFORM_BOOL -} MOJOSHADER_uniform_type; +} MOJOSHADER_uniformType; +/* + * These are the uniforms to be set for a shader. "Uniforms" are what Direct3D + * calls "Constants" ... IDirect3DDevice::SetVertexShaderConstantF() would + * need this data, for example. These integers are register indexes. So if + * index==6 and type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a + * 4-float vector to be specified for what would be register "c6" in D3D + * assembly language, before drawing with the shader. + */ typedef struct { int index; - const char *name; - MOJOSHADER_uniform_type type; + MOJOSHADER_uniformType type; } MOJOSHADER_uniform; @@ -118,9 +128,8 @@ typedef struct int uniform_count; /* - * (uniform_count) elements of data on how to access uniforms to be - * set by this shader. "Uniforms" are what Direct3D calls "Constants" ... - * IDirect3DDevice::SetVertexShaderConstantF() would need this data. + * (uniform_count) elements of data that specify Uniforms to be set for + * this shader. See discussion on MOJOSHADER_uniform for details. */ MOJOSHADER_uniform *uniforms; diff --git a/testparse.c b/testparse.c index fa912810..007b3ebd 100644 --- a/testparse.c +++ b/testparse.c @@ -60,15 +60,13 @@ static void do_parse(const unsigned char *buf, const int len, const char *prof) printf(" (none.)\n"); else { - static const char *typenames[] = { "float", "int", "bool" }; int i; printf("\n"); for (i = 0; i < pd->uniform_count; i++) { + static const char *typenames[] = { "float", "int", "bool" }; const MOJOSHADER_uniform *u = &pd->uniforms[i]; - const char *name = u->name ? u->name : ""; - const char *typestr = typenames[(int) u->type]; - printf(" * %d: %s %s\n", u->index, typestr, name); + printf(" * %d: %s\n", u->index, typenames[(int) u->type]); } // for } // else