Skip to content

Commit

Permalink
Flag more registers as scalar. Fixes use of dcl_fog, oPts and oFog re…
Browse files Browse the repository at this point in the history
…gisters.
  • Loading branch information
icculus committed Apr 13, 2012
1 parent b4e8c75 commit 234406f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions mojoshader.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions mojoshader_internal.h
Expand Up @@ -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:
Expand Down

0 comments on commit 234406f

Please sign in to comment.