From da33ef9818fe3b7b241d5a1cfcdf98e75da1e2fd Mon Sep 17 00:00:00 2001 From: icculus Date: Thu, 27 Mar 2008 04:03:06 -0400 Subject: [PATCH] [svn] First shot at DEF* opcodes for GLSL. --HG-- branch : trunk --- mojoshader.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 05df341e..8c5c0010 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -1457,12 +1457,23 @@ static void emit_GLSL_MOVA(Context *ctx) static void emit_GLSL_DEFB(Context *ctx) { - fail(ctx, "unimplemented."); // !!! FIXME + // !!! 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); + output_line(ctx, "const bool %s = %s;", + dst0, ctx->dwords[0] ? "true" : "false"); } // emit_GLSL_DEFB static void emit_GLSL_DEFI(Context *ctx) { - fail(ctx, "unimplemented."); // !!! FIXME + // !!! 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; + output_line(ctx, "const ivec4 %s(%d, %d, %d, %d);", + dst0, (int) x[0], (int) x[1], (int) x[2], (int) x[3]); } // emit_GLSL_DEFI static void emit_GLSL_TEXCOORD(Context *ctx) @@ -1548,7 +1559,13 @@ static void emit_GLSL_CND(Context *ctx) static void emit_GLSL_DEF(Context *ctx) { - fail(ctx, "unimplemented."); // !!! FIXME + // !!! 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? + output_line(ctx, "const vec4 %s(%f, %f, %f, %f);", + dst0, val[0], val[1], val[2], val[3]); } // emit_GLSL_DEF static void emit_GLSL_TEXREG2RGB(Context *ctx)