From 1952322d749bf4fdb1050ca9d306d8b13eb095b7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 18 Apr 2012 00:19:32 -0400 Subject: [PATCH] glsl: Implemented most of the missing srcmods. Reread the GLSL spec, and it turns out that "vec3(x,y,z) - 3.0" is legal syntactic sugar: the compiler knows to subtract 3.0 from each of the three components in that vec3. This made this simpler than having to tapdance to generate correct constant vectors ourselves, and it's easier to read. --- mojoshader.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index eecbacd0..1c82dce0 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -1933,7 +1933,6 @@ static const char *make_GLSL_srcarg_string(Context *ctx, const size_t idx, return buf; } // if -// !!! FIXME: not right. const SourceArgInfo *arg = &ctx->source_args[idx]; const char *premod_str = ""; @@ -1955,27 +1954,26 @@ static const char *make_GLSL_srcarg_string(Context *ctx, const size_t idx, break; case SRCMOD_SIGNNEGATE: - premod_str = "-"; - // fall through. + premod_str = "-(("; + postmod_str = " - 0.5) * 2.0)"; + break; + case SRCMOD_SIGN: - fail(ctx, "SRCMOD_SIGN unsupported"); return buf; // !!! FIXME - postmod_str = "_bx2"; + premod_str = "(("; + postmod_str = " - 0.5) * 2.0)"; break; case SRCMOD_COMPLEMENT: - fail(ctx, "SRCMOD_COMPLEMENT unsupported"); return buf; // !!! FIXME (need to handle vecsize) - premod_str = "(1.0 - ("; - postmod_str = "))"; + premod_str = "(1.0 - "; + postmod_str = ")"; break; case SRCMOD_X2NEGATE: - fail(ctx, "SRCMOD_X2NEGATE unsupported"); return buf; // !!! FIXME (need to handle vecsize) premod_str = "-("; postmod_str = " * 2.0)"; break; case SRCMOD_X2: - fail(ctx, "SRCMOD_X2 unsupported"); return buf; // !!! FIXME (need to handle vecsize) premod_str = "("; postmod_str = " * 2.0)"; break;