Skip to content

Commit

Permalink
GLSL profile now emits correct array deference on instructions.
Browse files Browse the repository at this point in the history
Need to coerce the uniforms into real arrays, still, though.  :/

--HG--
branch : trunk
  • Loading branch information
icculus committed May 2, 2008
1 parent c7e2e1a commit fb2fda6
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions mojoshader.c
Expand Up @@ -1826,6 +1826,30 @@ static char *make_GLSL_srcarg_string(Context *ctx, const int idx,
return "";
} // if

const char *rel_lbracket = "";
const char *rel_rbracket = "";
char rel_swizzle[4] = { '\0' };
char rel_regnum_str[16] = { '\0' };
const char *rel_regtype_str = "";
if (arg->relative)
{
rel_swizzle[0] = '.';
rel_swizzle[1] = swizzle_channels[arg->relative_component];
rel_swizzle[2] = '\0';
rel_lbracket = "[";
rel_rbracket = "]";
rel_regtype_str = get_GLSL_register_string(ctx, arg->relative_regtype,
arg->relative_regnum,
rel_regnum_str,
sizeof (rel_regnum_str));

if (regtype_str == NULL)
{
fail(ctx, "Unknown relative source register type.");
return "";
} // if
} // if

char swiz_str[6];
int i = 0;
// 0xE4 == 11100100 ... 3 2 1 0. No swizzle.
Expand All @@ -1842,8 +1866,10 @@ static char *make_GLSL_srcarg_string(Context *ctx, const int idx,

const char *shader_type_str = get_shader_type_string(ctx);
char *retval = get_scratch_buffer(ctx);
snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s_%s%s%s%s", premod_str,
shader_type_str, regtype_str, regnum_str, swiz_str, postmod_str);
snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s_%s%s%s%s%s%s%s%s%s",
premod_str, shader_type_str, regtype_str, regnum_str,
rel_lbracket, rel_regtype_str, rel_regnum_str, rel_swizzle,
rel_rbracket, swiz_str, postmod_str);
// !!! FIXME: make sure the scratch buffer was large enough.
return retval;
} // make_GLSL_srcarg_string
Expand Down

0 comments on commit fb2fda6

Please sign in to comment.