From 234406f21282f35c8f7f45bc08a8eb1c5aa172d4 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 12 Apr 2012 23:13:16 -0400 Subject: [PATCH] Flag more registers as scalar. Fixes use of dcl_fog, oPts and oFog registers. --- mojoshader.c | 13 +++++++++++-- mojoshader_internal.h | 11 +++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 6ad2fcb2..11b1376a 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -144,6 +144,7 @@ typedef struct Context int determined_constants_arrays; int predicated; int uses_pointsize; + int uses_fog; int glsl_generated_lit_opcode; int glsl_generated_texldd_setup; int arb1_wrote_position; @@ -592,6 +593,8 @@ static void add_attribute_register(Context *ctx, const RegisterType rtype, if ((rtype == REG_TYPE_OUTPUT) && (usage == MOJOSHADER_USAGE_POINTSIZE)) ctx->uses_pointsize = 1; // note that we have to check this later. + else if ((rtype == REG_TYPE_OUTPUT) && (usage == MOJOSHADER_USAGE_FOG)) + ctx->uses_fog = 1; // note that we have to check this later. } // add_attribute_register static inline void add_sampler(Context *ctx, const RegisterType rtype, @@ -678,11 +681,17 @@ static inline void adjust_token_position(Context *ctx, const int incr) static int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type, const RegisterType rtype, const int rnum) { - if ((rtype == REG_TYPE_OUTPUT) && (ctx->uses_pointsize)) + const int uses_psize = ctx->uses_pointsize; + const int uses_fog = ctx->uses_fog; + if ( (rtype == REG_TYPE_OUTPUT) && ((uses_psize) || (uses_fog)) ) { const RegisterList *reg = reglist_find(&ctx->attributes, rtype, rnum); if (reg != NULL) - return (reg->usage == MOJOSHADER_USAGE_POINTSIZE); + { + const MOJOSHADER_usage usage = reg->usage; + return ( (uses_psize && (usage == MOJOSHADER_USAGE_POINTSIZE)) || + (uses_fog && (usage == MOJOSHADER_USAGE_FOG)) ); + } // if } // if return scalar_register(shader_type, rtype, rnum); diff --git a/mojoshader_internal.h b/mojoshader_internal.h index dee625dc..78a23977 100644 --- a/mojoshader_internal.h +++ b/mojoshader_internal.h @@ -399,13 +399,20 @@ typedef struct RegisterType regtype; } DestArgInfo; -// NOTE: This will NOT know a dcl_psize output register should be scalar! -// This function doesn't have access to that information. +// NOTE: This will NOT know a dcl_psize or dcl_fog output register should be +// scalar! This function doesn't have access to that information. static inline int scalar_register(const MOJOSHADER_shaderType shader_type, const RegisterType regtype, const int regnum) { switch (regtype) { + case REG_TYPE_RASTOUT: + if (((const RastOutType) regnum) == RASTOUT_TYPE_FOG) + return 1; + else if (((const RastOutType) regnum) == RASTOUT_TYPE_POINT_SIZE) + return 1; + return 0; + case REG_TYPE_DEPTHOUT: case REG_TYPE_CONSTBOOL: case REG_TYPE_LOOP: