diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/vega/asm_fill.h | 74 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shader.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shaders_cache.c | 22 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shaders_cache.h | 14 |
4 files changed, 58 insertions, 58 deletions
diff --git a/src/gallium/state_trackers/vega/asm_fill.h b/src/gallium/state_trackers/vega/asm_fill.h index 19a2d93fe5..22ad6ac39a 100644 --- a/src/gallium/state_trackers/vega/asm_fill.h +++ b/src/gallium/state_trackers/vega/asm_fill.h @@ -174,38 +174,6 @@ paint_degenerate( struct ureg_program *ureg, } static INLINE void -color_transform( struct ureg_program *ureg, - struct ureg_dst *out, - struct ureg_src *in, - struct ureg_src *sampler, - struct ureg_dst *temp, - struct ureg_src *constant) -{ - ureg_MAD(ureg, temp[1], ureg_src(temp[0]), constant[0], constant[1]); - /* clamp to [0.0f, 1.0f] */ - ureg_CLAMP(ureg, temp[1], - ureg_src(temp[1]), - ureg_scalar(constant[3], TGSI_SWIZZLE_X), - ureg_scalar(constant[3], TGSI_SWIZZLE_Y)); - ureg_MOV(ureg, *out, ureg_src(temp[1])); -} - -static INLINE void -mask( struct ureg_program *ureg, - struct ureg_dst *out, - struct ureg_src *in, - struct ureg_src *sampler, - struct ureg_dst *temp, - struct ureg_src *constant) -{ - ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[1]); - ureg_MUL(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_W), - ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W), - ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W)); - ureg_MOV(ureg, *out, ureg_src(temp[0])); -} - -static INLINE void image_normal( struct ureg_program *ureg, struct ureg_dst *out, struct ureg_src *in, @@ -242,6 +210,23 @@ image_stencil( struct ureg_program *ureg, ureg_MUL(ureg, *out, ureg_src(temp[0]), ureg_src(temp[1])); } +static INLINE void +color_transform( struct ureg_program *ureg, + struct ureg_dst *out, + struct ureg_src *in, + struct ureg_src *sampler, + struct ureg_dst *temp, + struct ureg_src *constant) +{ + ureg_MAD(ureg, temp[1], ureg_src(temp[0]), constant[0], constant[1]); + /* clamp to [0.0f, 1.0f] */ + ureg_CLAMP(ureg, temp[1], + ureg_src(temp[1]), + ureg_scalar(constant[3], TGSI_SWIZZLE_X), + ureg_scalar(constant[3], TGSI_SWIZZLE_Y)); + ureg_MOV(ureg, *out, ureg_src(temp[1])); +} + /** * Emit instructions for the specified blend mode. Colors should be * premultiplied. Two temporary registers are required. @@ -396,6 +381,21 @@ blend_lighten( struct ureg_program *ureg, } static INLINE void +mask( struct ureg_program *ureg, + struct ureg_dst *out, + struct ureg_src *in, + struct ureg_src *sampler, + struct ureg_dst *temp, + struct ureg_src *constant) +{ + ureg_TEX(ureg, temp[1], TGSI_TEXTURE_2D, in[0], sampler[1]); + ureg_MUL(ureg, ureg_writemask(temp[0], TGSI_WRITEMASK_W), + ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W), + ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W)); + ureg_MOV(ureg, *out, ureg_src(temp[0])); +} + +static INLINE void premultiply( struct ureg_program *ureg, struct ureg_dst *out, struct ureg_src *in, @@ -500,11 +500,6 @@ static const struct shader_asm_info shaders_color_transform_asm[] = { VG_FALSE, 0, 4, 0, 0, 0, 2} }; -static const struct shader_asm_info shaders_mask_asm[] = { - {VEGA_MASK_SHADER, mask, - VG_TRUE, 0, 0, 1, 1, 0, 2} -}; - /* extra blend modes */ static const struct shader_asm_info shaders_blend_asm[] = { {VEGA_BLEND_MULTIPLY_SHADER, blend_multiply, @@ -517,6 +512,11 @@ static const struct shader_asm_info shaders_blend_asm[] = { VG_TRUE, 3, 1, 2, 1, 0, 4}, }; +static const struct shader_asm_info shaders_mask_asm[] = { + {VEGA_MASK_SHADER, mask, + VG_TRUE, 0, 0, 1, 1, 0, 2} +}; + /* premultiply */ static const struct shader_asm_info shaders_premultiply_asm[] = { {VEGA_PREMULTIPLY_SHADER, premultiply, diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c index db410e3dad..20ced813b4 100644 --- a/src/gallium/state_trackers/vega/shader.c +++ b/src/gallium/state_trackers/vega/shader.c @@ -255,9 +255,6 @@ static void setup_shader_program(struct shader *shader) if (shader->color_transform) shader_id |= VEGA_COLOR_TRANSFORM_SHADER; - if (shader->masking) - shader_id |= VEGA_MASK_SHADER; - switch(blend_mode) { case VG_BLEND_MULTIPLY: shader_id |= VEGA_BLEND_MULTIPLY_SHADER; @@ -276,6 +273,9 @@ static void setup_shader_program(struct shader *shader) break; } + if (shader->masking) + shader_id |= VEGA_MASK_SHADER; + if (black_white) shader_id |= VEGA_BW_SHADER; diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c index d1ebe7e677..76bac5139f 100644 --- a/src/gallium/state_trackers/vega/shaders_cache.c +++ b/src/gallium/state_trackers/vega/shaders_cache.c @@ -53,8 +53,8 @@ * 1) Paint generation (color/gradient/pattern) * 2) Image composition (normal/multiply/stencil) * 3) Color transform - * 4) Mask - * 5) Extended blend (multiply/screen/darken/lighten) + * 4) Extended blend (multiply/screen/darken/lighten) + * 5) Mask * 6) Premultiply/Unpremultiply * 7) Color transform (to black and white) */ @@ -301,10 +301,13 @@ create_shader(struct pipe_context *pipe, } /* fourth stage */ - sh = SHADERS_GET_MASK_SHADER(id); + sh = SHADERS_GET_BLEND_SHADER(id); switch (sh) { - case VEGA_MASK_SHADER: - shaders[idx] = &shaders_mask_asm[(sh >> SHADERS_MASK_SHIFT) - 1]; + case VEGA_BLEND_MULTIPLY_SHADER: + case VEGA_BLEND_SCREEN_SHADER: + case VEGA_BLEND_DARKEN_SHADER: + case VEGA_BLEND_LIGHTEN_SHADER: + shaders[idx] = &shaders_blend_asm[(sh >> SHADERS_BLEND_SHIFT) - 1]; assert(shaders[idx]->id == sh); idx++; break; @@ -313,13 +316,10 @@ create_shader(struct pipe_context *pipe, } /* fifth stage */ - sh = SHADERS_GET_BLEND_SHADER(id); + sh = SHADERS_GET_MASK_SHADER(id); switch (sh) { - case VEGA_BLEND_MULTIPLY_SHADER: - case VEGA_BLEND_SCREEN_SHADER: - case VEGA_BLEND_DARKEN_SHADER: - case VEGA_BLEND_LIGHTEN_SHADER: - shaders[idx] = &shaders_blend_asm[(sh >> SHADERS_BLEND_SHIFT) - 1]; + case VEGA_MASK_SHADER: + shaders[idx] = &shaders_mask_asm[(sh >> SHADERS_MASK_SHIFT) - 1]; assert(shaders[idx]->id == sh); idx++; break; diff --git a/src/gallium/state_trackers/vega/shaders_cache.h b/src/gallium/state_trackers/vega/shaders_cache.h index b626045f9a..008e4f5b94 100644 --- a/src/gallium/state_trackers/vega/shaders_cache.h +++ b/src/gallium/state_trackers/vega/shaders_cache.h @@ -36,17 +36,17 @@ struct shaders_cache; #define _SHADERS_PAINT_BITS 3 #define _SHADERS_IMAGE_BITS 2 #define _SHADERS_COLOR_TRANSFORM_BITS 1 -#define _SHADERS_MASK_BITS 1 #define _SHADERS_BLEND_BITS 3 +#define _SHADERS_MASK_BITS 1 #define _SHADERS_PREMULTIPLY_BITS 2 #define _SHADERS_BW_BITS 1 #define SHADERS_PAINT_SHIFT (0) #define SHADERS_IMAGE_SHIFT (SHADERS_PAINT_SHIFT + _SHADERS_PAINT_BITS) #define SHADERS_COLOR_TRANSFORM_SHIFT (SHADERS_IMAGE_SHIFT + _SHADERS_IMAGE_BITS) -#define SHADERS_MASK_SHIFT (SHADERS_COLOR_TRANSFORM_SHIFT + _SHADERS_COLOR_TRANSFORM_BITS) -#define SHADERS_BLEND_SHIFT (SHADERS_MASK_SHIFT + _SHADERS_MASK_BITS) -#define SHADERS_PREMULTIPLY_SHIFT (SHADERS_BLEND_SHIFT + _SHADERS_BLEND_BITS) +#define SHADERS_BLEND_SHIFT (SHADERS_COLOR_TRANSFORM_SHIFT + _SHADERS_COLOR_TRANSFORM_BITS) +#define SHADERS_MASK_SHIFT (SHADERS_BLEND_SHIFT + _SHADERS_BLEND_BITS) +#define SHADERS_PREMULTIPLY_SHIFT (SHADERS_MASK_SHIFT + _SHADERS_MASK_BITS) #define SHADERS_BW_SHIFT (SHADERS_PREMULTIPLY_SHIFT + _SHADERS_PREMULTIPLY_BITS) #define _SHADERS_GET_STAGE(stage, id) \ @@ -55,8 +55,8 @@ struct shaders_cache; #define SHADERS_GET_PAINT_SHADER(id) _SHADERS_GET_STAGE(PAINT, id) #define SHADERS_GET_IMAGE_SHADER(id) _SHADERS_GET_STAGE(IMAGE, id) #define SHADERS_GET_COLOR_TRANSFORM_SHADER(id) _SHADERS_GET_STAGE(COLOR_TRANSFORM, id) -#define SHADERS_GET_MASK_SHADER(id) _SHADERS_GET_STAGE(MASK, id) #define SHADERS_GET_BLEND_SHADER(id) _SHADERS_GET_STAGE(BLEND, id) +#define SHADERS_GET_MASK_SHADER(id) _SHADERS_GET_STAGE(MASK, id) #define SHADERS_GET_PREMULTIPLY_SHADER(id) _SHADERS_GET_STAGE(PREMULTIPLY, id) #define SHADERS_GET_BW_SHADER(id) _SHADERS_GET_STAGE(BW, id) @@ -73,13 +73,13 @@ enum VegaShaderType { VEGA_COLOR_TRANSFORM_SHADER = 1 << SHADERS_COLOR_TRANSFORM_SHIFT, - VEGA_MASK_SHADER = 1 << SHADERS_MASK_SHIFT, - VEGA_BLEND_MULTIPLY_SHADER = 1 << SHADERS_BLEND_SHIFT, VEGA_BLEND_SCREEN_SHADER = 2 << SHADERS_BLEND_SHIFT, VEGA_BLEND_DARKEN_SHADER = 3 << SHADERS_BLEND_SHIFT, VEGA_BLEND_LIGHTEN_SHADER = 4 << SHADERS_BLEND_SHIFT, + VEGA_MASK_SHADER = 1 << SHADERS_MASK_SHIFT, + VEGA_PREMULTIPLY_SHADER = 1 << SHADERS_PREMULTIPLY_SHIFT, VEGA_UNPREMULTIPLY_SHADER = 2 << SHADERS_PREMULTIPLY_SHIFT, |