From fa633adb7f61c857bb751c2d2a5d57b18a5cc54f Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Fri, 3 Feb 2017 12:52:10 -0500 Subject: [PATCH] Minor fixes from FNA branch --- mojoshader.c | 12 ++++++++++-- mojoshader_effects.c | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 36294923..baa8cdd8 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -9036,8 +9036,9 @@ static int parse_source_token(Context *ctx, SourceArgInfo *info) case SRCMOD_NOT: // !!! FIXME: I _think_ this is right... if (shader_version_atleast(ctx, 2, 0)) { - if (info->regtype != REG_TYPE_PREDICATE) - fail(ctx, "NOT only allowed on predicate register."); + if (info->regtype != REG_TYPE_PREDICATE + && info->regtype != REG_TYPE_CONSTBOOL) + fail(ctx, "NOT only allowed on bool registers."); } // if break; @@ -10722,6 +10723,13 @@ static void parse_preshader(Context *ctx, const uint32 *tokens, uint32 tokcount) if ( (!is_comment_token(ctx, *tokens, &subtokcount)) || (subtokcount > tokcount) ) { + // !!! FIXME: Standalone preshaders have this EOS-looking token, + // !!! FIXME: sometimes followed by tokens that don't appear to + // !!! FIXME: have anything to do with the rest of the blob. + // !!! FIXME: So for now, treat this as a special "EOS" comment. + if (SWAP32(*tokens) == 0xFFFF) + break; + fail(ctx, "Bogus preshader data."); return; } // if diff --git a/mojoshader_effects.c b/mojoshader_effects.c index 3eb16d9f..d971c84e 100644 --- a/mojoshader_effects.c +++ b/mojoshader_effects.c @@ -745,7 +745,6 @@ static void readlargeobjects(const uint32 numlargeobjects, */ object->shader.is_preshader = 1; const uint32 start = *((uint32 *) *ptr) + 4; - const uint32 end = 16; // FIXME: Why? -flibit const char *array = readstring(*ptr, 0, m, d); object->shader.param_count = 1; object->shader.params = (uint32 *) m(sizeof (uint32), d); @@ -753,7 +752,7 @@ static void readlargeobjects(const uint32 numlargeobjects, effect->param_count, array); f((void *) array, d); - object->shader.preshader = MOJOSHADER_parsePreshader(*ptr + start, length - end, + object->shader.preshader = MOJOSHADER_parsePreshader(*ptr + start, length, m, f, d); // !!! FIXME: check for errors. object->shader.preshader_param_count = object->shader.preshader->symbol_count;