Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
icculus committed Apr 4, 2008
1 parent 70decf6 commit 68f5250
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 15 additions & 6 deletions mojoshader.h
Expand Up @@ -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;


Expand Down Expand Up @@ -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;

Expand Down
6 changes: 2 additions & 4 deletions testparse.c
Expand Up @@ -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

Expand Down

0 comments on commit 68f5250

Please sign in to comment.