Skip to content

Commit

Permalink
ARB1: Make TEXM3X3* opcodes able to handle Cubemap or Volume samplers.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 29, 2012
1 parent 4cc91ed commit 86b0819
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions mojoshader.c
Expand Up @@ -5660,10 +5660,14 @@ static void emit_ARB1_TEXM3X3TEX(Context *ctx)
src4, sizeof (src4));
get_ARB1_destarg_varname(ctx, dst, sizeof (dst));

RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, stage);
const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "CUBE" : "3D";

output_line(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
output_line(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
output_line(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
output_line(ctx, "TEX %s, %s, texture[%d], 3D;", dst, dst, stage);
output_line(ctx, "TEX %s, %s, texture[%d], %s;", dst, dst, stage, ttypestr);
emit_ARB1_dest_modifiers(ctx);
} // emit_ARB1_TEXM3X3TEX

Expand Down Expand Up @@ -5700,6 +5704,10 @@ static void emit_ARB1_TEXM3X3SPEC(Context *ctx)
src5, sizeof (src5));
get_ARB1_destarg_varname(ctx, dst, sizeof (dst));

RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, stage);
const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "CUBE" : "3D";

output_line(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
output_line(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
output_line(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
Expand All @@ -5716,7 +5724,7 @@ static void emit_ARB1_TEXM3X3SPEC(Context *ctx)

output_line(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };", tmp, tmp);
output_line(ctx, "MAD %s, %s, %s, -%s;", tmp, tmp, dst, src5);
output_line(ctx, "TEX %s, %s, texture[%d], 3D;", dst, tmp, stage);
output_line(ctx, "TEX %s, %s, texture[%d], %s;", dst, tmp, stage, ttypestr);
emit_ARB1_dest_modifiers(ctx);
} // emit_ARB1_TEXM3X3SPEC

Expand Down Expand Up @@ -5752,6 +5760,10 @@ static void emit_ARB1_TEXM3X3VSPEC(Context *ctx)
src4, sizeof (src4));
get_ARB1_destarg_varname(ctx, dst, sizeof (dst));

RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, stage);
const TextureType ttype = (TextureType) (sreg ? sreg->index : 0);
const char *ttypestr = (ttype == TEXTURE_TYPE_CUBE) ? "CUBE" : "3D";

output_line(ctx, "MOV %s.x, %s.w;", tmp3, src0);
output_line(ctx, "MOV %s.y, %s.w;", tmp3, src2);
output_line(ctx, "MOV %s.z, %s.w;", tmp3, dst);
Expand All @@ -5771,7 +5783,7 @@ static void emit_ARB1_TEXM3X3VSPEC(Context *ctx)

output_line(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };", tmp, tmp);
output_line(ctx, "MAD %s, %s, %s, -%s;", tmp, tmp, dst, tmp3);
output_line(ctx, "TEX %s, %s, texture[%d], 3D;", dst, tmp, stage);
output_line(ctx, "TEX %s, %s, texture[%d], %s;", dst, tmp, stage, ttypestr);
emit_ARB1_dest_modifiers(ctx);
} // emit_ARB1_TEXM3X3VSPEC

Expand Down

0 comments on commit 86b0819

Please sign in to comment.