Skip to content

Commit

Permalink
[svn] Output fixes in GLSL profile, thanks to new splitting up of the…
Browse files Browse the repository at this point in the history
… output list.

--HG--
branch : trunk
  • Loading branch information
icculus committed Mar 28, 2008
1 parent 626043e commit 0331ce9
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions mojoshader.c
Expand Up @@ -1195,6 +1195,8 @@ static void emit_GLSL_start(Context *ctx)
{
const uint major = (uint) ctx->major_ver;
const uint minor = (uint) ctx->minor_ver;

ctx->output = &ctx->globals;
if (ctx->shader_type == MOJOSHADER_TYPE_PIXEL)
output_line(ctx, "// Pixel shader, version %u.%u", major, minor);
else if (ctx->shader_type == MOJOSHADER_TYPE_VERTEX)
Expand All @@ -1205,13 +1207,15 @@ static void emit_GLSL_start(Context *ctx)
(uint) ctx->shader_type);
} // else

ctx->output = &ctx->mainline;
output_line(ctx, "void main() {");
ctx->indent++;
} // emit_GLSL_start

static void emit_GLSL_end(Context *ctx)
{
ctx->indent--;
assert(ctx->output == &ctx->mainline);
output_line(ctx, "}");
} // emit_GLSL_end

Expand Down Expand Up @@ -1512,23 +1516,25 @@ static void emit_GLSL_MOVA(Context *ctx)

static void emit_GLSL_DEFB(Context *ctx)
{
// !!! FIXME: this should really insert at the start of the output,
// !!! FIXME: in case an instruction shows up before a DEF* token
// !!! FIXME: (which may be legal in the spec).
const char *dst0 = make_GLSL_destarg_string(ctx, 0);

OutputList *orig_target = ctx->output;
ctx->output = &ctx->globals;
output_line(ctx, "const bool %s = %s;",
dst0, ctx->dwords[0] ? "true" : "false");
ctx->output = orig_target;
} // emit_GLSL_DEFB

static void emit_GLSL_DEFI(Context *ctx)
{
// !!! FIXME: this should really insert at the start of the output,
// !!! FIXME: in case an instruction shows up before a DEF* token
// !!! FIXME: (which may be legal in the spec).
const char *dst0 = make_GLSL_destarg_string(ctx, 0);
const int32 *x = (const int32 *) ctx->dwords;

OutputList *orig_target = ctx->output;
ctx->output = &ctx->globals;
output_line(ctx, "const ivec4 %s(%d, %d, %d, %d);",
dst0, (int) x[0], (int) x[1], (int) x[2], (int) x[3]);
ctx->output = orig_target;
} // emit_GLSL_DEFI

static void emit_GLSL_TEXCOORD(Context *ctx)
Expand Down Expand Up @@ -1624,9 +1630,6 @@ static void emit_GLSL_CND(Context *ctx)

static void emit_GLSL_DEF(Context *ctx)
{
// !!! FIXME: this should really insert at the start of the output,
// !!! FIXME: in case an instruction shows up before a DEF* token
// !!! FIXME: (which may be legal in the spec).
const char *dst0 = make_GLSL_destarg_string(ctx, 0);
const float *val = (const float *) ctx->dwords; // !!! FIXME: could be int?
char val0[32];
Expand All @@ -1637,8 +1640,12 @@ static void emit_GLSL_DEF(Context *ctx)
floatstr(ctx, val1, sizeof (val1), val[1]);
floatstr(ctx, val2, sizeof (val2), val[2]);
floatstr(ctx, val3, sizeof (val3), val[3]);

OutputList *orig_target = ctx->output;
ctx->output = &ctx->globals;
output_line(ctx, "const vec4 %s(%s, %s, %s, %s);",
dst0, val0, val1, val2, val3);
ctx->output = orig_target;
} // emit_GLSL_DEF

static void emit_GLSL_TEXREG2RGB(Context *ctx)
Expand Down

0 comments on commit 0331ce9

Please sign in to comment.