summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-12-01 13:39:59 +0800
committerChia-I Wu <olv@lunarg.com>2010-12-01 16:46:01 +0800
commit2bb788ccc674669bc03ad09e4396f079044112e8 (patch)
treed6037ef8dd3e6c96d8db953624bc0650eea29534 /src/gallium/state_trackers
parentd7aa03b4feb7c30408b2ed3070e0fe33e2fd05ba (diff)
st/vega: Simplify radial gradient.
Eight less instructions with comments.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/vega/asm_fill.h119
1 files changed, 46 insertions, 73 deletions
diff --git a/src/gallium/state_trackers/vega/asm_fill.h b/src/gallium/state_trackers/vega/asm_fill.h
index fcc953ced8..70ff153ca9 100644
--- a/src/gallium/state_trackers/vega/asm_fill.h
+++ b/src/gallium/state_trackers/vega/asm_fill.h
@@ -47,6 +47,24 @@ solid_fill( struct ureg_program *ureg,
ureg_MOV(ureg, *out, constant[2]);
}
+#define PAINT_TRANSFORM \
+ ureg_MOV(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_XY), in[0]); \
+ ureg_MOV(ureg, \
+ ureg_writemask(temp[0], TGSI_WRITEMASK_Z), \
+ ureg_scalar(constant[3], TGSI_SWIZZLE_Y)); \
+ ureg_DP3(ureg, temp[1], constant[4], ureg_src(temp[0])); \
+ ureg_DP3(ureg, temp[2], constant[5], ureg_src(temp[0])); \
+ ureg_DP3(ureg, temp[3], constant[6], ureg_src(temp[0])); \
+ ureg_RCP(ureg, temp[3], ureg_src(temp[3])); \
+ ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3])); \
+ ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3])); \
+ ureg_MOV(ureg, \
+ ureg_writemask(temp[4], TGSI_WRITEMASK_X), \
+ ureg_src(temp[1])); \
+ ureg_MOV(ureg, \
+ ureg_writemask(temp[4], TGSI_WRITEMASK_Y), \
+ ureg_src(temp[2]));
+
static INLINE void
linear_grad( struct ureg_program *ureg,
struct ureg_dst *out,
@@ -55,21 +73,8 @@ linear_grad( struct ureg_program *ureg,
struct ureg_dst *temp,
struct ureg_src *constant)
{
+ PAINT_TRANSFORM
- ureg_MOV(ureg,
- ureg_writemask(temp[0], TGSI_WRITEMASK_XY),
- in[0]);
- ureg_MOV(ureg,
- ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
- ureg_scalar(constant[3], TGSI_SWIZZLE_Y));
- ureg_DP3(ureg, temp[1], constant[4], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[2], constant[5], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[3], constant[6], ureg_src(temp[0]));
- ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
- ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
- ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
- ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_X), ureg_src(temp[1]));
- ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
ureg_MUL(ureg, temp[0],
ureg_scalar(constant[2], TGSI_SWIZZLE_Y),
ureg_scalar(ureg_src(temp[4]), TGSI_SWIZZLE_Y));
@@ -90,52 +95,32 @@ radial_grad( struct ureg_program *ureg,
struct ureg_dst *temp,
struct ureg_src *constant)
{
-
- ureg_MOV(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_XY), in[0]);
- ureg_MOV(ureg,
- ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
- ureg_scalar(constant[3], TGSI_SWIZZLE_Y));
- ureg_DP3(ureg, temp[1], constant[4], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[2], constant[5], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[3], constant[6], ureg_src(temp[0]));
+ PAINT_TRANSFORM
+
+ /*
+ * Calculate (sqrt(B^2 + AC) - B) / A, where
+ *
+ * A is CONST[2].z,
+ * B is DP2((x, y), CONST[2].xy), and
+ * C is DP2((x, y), (x, y)).
+ */
+
+ /* B and C */
+ ureg_DP2(ureg, temp[0], ureg_src(temp[4]), constant[2]);
+ ureg_DP2(ureg, temp[1], ureg_src(temp[4]), ureg_src(temp[4]));
+
+ /* the square root */
+ ureg_MUL(ureg, temp[2], ureg_src(temp[0]), ureg_src(temp[0]));
+ ureg_MAD(ureg, temp[3], ureg_src(temp[1]),
+ ureg_scalar(constant[2], TGSI_SWIZZLE_Z), ureg_src(temp[2]));
+ ureg_RSQ(ureg, temp[3], ureg_src(temp[3]));
ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
- ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
- ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
- ureg_MOV(ureg, ureg_writemask(temp[5], TGSI_WRITEMASK_X), ureg_src(temp[1]));
- ureg_MOV(ureg, ureg_writemask(temp[5], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
- ureg_MUL(ureg, temp[0], ureg_scalar(constant[2], TGSI_SWIZZLE_Y),
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y));
- ureg_MAD(ureg, temp[1],
- ureg_scalar(constant[2], TGSI_SWIZZLE_X),
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X), ureg_src(temp[0]));
- ureg_ADD(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[1]));
- ureg_MUL(ureg, temp[3],
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y),
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_Y));
- ureg_MAD(ureg, temp[4],
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X),
- ureg_scalar(ureg_src(temp[5]), TGSI_SWIZZLE_X),
- ureg_src(temp[3]));
- ureg_MOV(ureg, temp[4], ureg_negate(ureg_src(temp[4])));
- ureg_MUL(ureg, temp[2],
- ureg_scalar(constant[2], TGSI_SWIZZLE_Z),
- ureg_src(temp[4]));
- ureg_MUL(ureg, temp[0],
- ureg_scalar(constant[3], TGSI_SWIZZLE_W),
- ureg_src(temp[2]));
- ureg_MUL(ureg, temp[3], ureg_src(temp[1]), ureg_src(temp[1]));
-
- ureg_SUB(ureg, temp[2], ureg_src(temp[3]), ureg_src(temp[0]));
- ureg_RSQ(ureg, temp[2], ureg_abs(ureg_src(temp[2])));
- ureg_RCP(ureg, temp[2], ureg_src(temp[2]));
- ureg_SUB(ureg, temp[1], ureg_src(temp[2]), ureg_src(temp[1]));
- ureg_ADD(ureg, temp[0],
- ureg_scalar(constant[2], TGSI_SWIZZLE_Z),
- ureg_scalar(constant[2], TGSI_SWIZZLE_Z));
- ureg_RCP(ureg, temp[0], ureg_src(temp[0]));
- ureg_MUL(ureg, temp[2], ureg_src(temp[1]), ureg_src(temp[0]));
- ureg_TEX(ureg, *out, TGSI_TEXTURE_1D, ureg_src(temp[2]), sampler[0]);
+ ureg_SUB(ureg, temp[3], ureg_src(temp[3]), ureg_src(temp[0]));
+ ureg_RCP(ureg, temp[0], ureg_scalar(constant[2], TGSI_SWIZZLE_Z));
+ ureg_MUL(ureg, temp[0], ureg_src(temp[0]), ureg_src(temp[3]));
+
+ ureg_TEX(ureg, *out, TGSI_TEXTURE_1D, ureg_src(temp[0]), sampler[0]);
}
@@ -147,20 +132,8 @@ pattern( struct ureg_program *ureg,
struct ureg_dst *temp,
struct ureg_src *constant)
{
- ureg_MOV(ureg,
- ureg_writemask(temp[0], TGSI_WRITEMASK_XY),
- in[0]);
- ureg_MOV(ureg,
- ureg_writemask(temp[0], TGSI_WRITEMASK_Z),
- ureg_scalar(constant[3], TGSI_SWIZZLE_Y));
- ureg_DP3(ureg, temp[1], constant[4], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[2], constant[5], ureg_src(temp[0]));
- ureg_DP3(ureg, temp[3], constant[6], ureg_src(temp[0]));
- ureg_RCP(ureg, temp[3], ureg_src(temp[3]));
- ureg_MUL(ureg, temp[1], ureg_src(temp[1]), ureg_src(temp[3]));
- ureg_MUL(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[3]));
- ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_X), ureg_src(temp[1]));
- ureg_MOV(ureg, ureg_writemask(temp[4], TGSI_WRITEMASK_Y), ureg_src(temp[2]));
+ PAINT_TRANSFORM
+
ureg_RCP(ureg, temp[0],
ureg_swizzle(constant[3],
TGSI_SWIZZLE_Z,
@@ -446,7 +419,7 @@ static const struct shader_asm_info shaders_paint_asm[] = {
{VEGA_LINEAR_GRADIENT_SHADER, linear_grad,
VG_TRUE, 2, 5, 0, 1, 0, 5},
{VEGA_RADIAL_GRADIENT_SHADER, radial_grad,
- VG_TRUE, 2, 5, 0, 1, 0, 6},
+ VG_TRUE, 2, 5, 0, 1, 0, 5},
{VEGA_PATTERN_SHADER, pattern,
VG_TRUE, 3, 4, 0, 1, 0, 5},
{VEGA_PAINT_DEGENERATE_SHADER, paint_degenerate,