summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Oliveira <igor.oliveira@openbossa.org>2010-02-12 10:11:38 -0400
committerIgor Trindade Oliveira <igor@Cygnus.(none)>2010-02-12 10:11:38 -0400
commitce25c0d9e942da51c4fa69497fc4e8068a889448 (patch)
tree0612564e0000994ea7e8dc2733bcd9e984700f99
parent86439e03741c35d65fd17afb113ec2beac671293 (diff)
vega: add support to VG_BLEND_EXCLUSION_KHR advanced blend mode.
It is used by SVG1.2 and it is defined as: Produces an effect similar to that of 'difference', but appears as lower contrast. Painting with white inverts the destination color. Painting with black produces no change
-rw-r--r--src/gallium/state_trackers/vega/api_params.c2
-rw-r--r--src/gallium/state_trackers/vega/asm_fill.h34
-rw-r--r--src/gallium/state_trackers/vega/shader.c6
-rw-r--r--src/gallium/state_trackers/vega/shaders_cache.c16
-rw-r--r--src/gallium/state_trackers/vega/shaders_cache.h7
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c1
6 files changed, 55 insertions, 11 deletions
diff --git a/src/gallium/state_trackers/vega/api_params.c b/src/gallium/state_trackers/vega/api_params.c
index e33ec0bc50..9dbfd2c347 100644
--- a/src/gallium/state_trackers/vega/api_params.c
+++ b/src/gallium/state_trackers/vega/api_params.c
@@ -161,7 +161,7 @@ void vgSeti (VGParamType type, VGint value)
break;
case VG_BLEND_MODE:
if (value < VG_BLEND_SRC ||
- value > VG_BLEND_INVERT_KHR)
+ value > VG_BLEND_EXCLUSION_KHR)
error = VG_ILLEGAL_ARGUMENT_ERROR;
else {
ctx->state.dirty |= BLEND_DIRTY;
diff --git a/src/gallium/state_trackers/vega/asm_fill.h b/src/gallium/state_trackers/vega/asm_fill.h
index 1b57fefe41..ec9720004b 100644
--- a/src/gallium/state_trackers/vega/asm_fill.h
+++ b/src/gallium/state_trackers/vega/asm_fill.h
@@ -843,6 +843,38 @@ blend_invert_khr( struct ureg_program *ureg,
}
static INLINE void
+blend_exclusion_khr( 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[2]);
+ EXTENDED_BLENDER_OVER_FUNC
+ ureg_MUL(ureg, temp[2], ureg_src(temp[0]),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_MUL(ureg, temp[4], ureg_src(temp[1]),
+ ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W));
+ ureg_ADD(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[4]));
+ ureg_MUL(ureg, temp[4], ureg_src(temp[0]), ureg_src(temp[1]));
+ ureg_ADD(ureg, temp[4], ureg_src(temp[4]), ureg_src(temp[4]));
+ ureg_SUB(ureg, temp[2], ureg_src(temp[2]), ureg_src(temp[4]));
+ ureg_ADD(ureg, ureg_writemask(temp[1], TGSI_WRITEMASK_XYZ),
+ ureg_src(temp[2]), ureg_src(temp[3]));
+
+ ureg_MUL(ureg, temp[2], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_ADD(ureg, temp[3], ureg_scalar(ureg_src(temp[0]), TGSI_SWIZZLE_W),
+ ureg_scalar(ureg_src(temp[1]), TGSI_SWIZZLE_W));
+ ureg_SUB(ureg, ureg_writemask(temp[1], TGSI_WRITEMASK_W),
+ ureg_src(temp[3]), ureg_src(temp[2]));
+
+
+ ureg_MOV(ureg, *out, ureg_src(temp[1]));
+}
+
+static INLINE void
premultiply( struct ureg_program *ureg,
struct ureg_dst *out,
struct ureg_src *in,
@@ -967,6 +999,8 @@ static const struct shader_asm_info shaders_asm[] = {
VG_TRUE, 1, 1, 2, 1, 0, 6},
{VEGA_BLEND_INVERT_KHR_SHADER, blend_invert_khr,
VG_TRUE, 1, 1, 2, 1, 0, 6},
+ {VEGA_BLEND_EXCLUSION_KHR_SHADER, blend_exclusion_khr,
+ VG_TRUE, 1, 1, 2, 1, 0, 6},
/* premultiply */
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 0a710c1948..b2ad72ab5d 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -135,7 +135,8 @@ static VGint blend_bind_samplers(struct vg_context *ctx,
bmode == VG_BLEND_COLORBURN_KHR ||
bmode == VG_BLEND_DIFFERENCE_KHR ||
bmode == VG_BLEND_SUBTRACT_KHR ||
- bmode == VG_BLEND_INVERT_KHR) {
+ bmode == VG_BLEND_INVERT_KHR ||
+ bmode == VG_BLEND_EXCLUSION_KHR) {
struct st_framebuffer *stfb = ctx->draw_buffer;
vg_prepare_blend_surface(ctx);
@@ -297,6 +298,9 @@ static void setup_shader_program(struct shader *shader)
case VG_BLEND_INVERT_KHR:
shader_id |= VEGA_BLEND_INVERT_KHR_SHADER;
break;
+ case VG_BLEND_EXCLUSION_KHR:
+ shader_id |= VEGA_BLEND_EXCLUSION_KHR_SHADER;
+ break;
default:
/* handled by pipe_blend_state */
diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c
index ba85c4e680..5e476d672f 100644
--- a/src/gallium/state_trackers/vega/shaders_cache.c
+++ b/src/gallium/state_trackers/vega/shaders_cache.c
@@ -369,25 +369,29 @@ create_shader(struct pipe_context *pipe,
debug_assert(shaders_asm[20].id == VEGA_BLEND_INVERT_KHR_SHADER);
shaders[idx] = &shaders_asm[20];
++idx;
+ } else if ((id & VEGA_BLEND_EXCLUSION_KHR_SHADER)){
+ debug_assert(shaders_asm[21].id == VEGA_BLEND_EXCLUSION_KHR_SHADER);
+ shaders[idx] = &shaders_asm[21];
+ ++idx;
}
/* fifth stage */
if ((id & VEGA_PREMULTIPLY_SHADER)) {
- debug_assert(shaders_asm[21].id == VEGA_PREMULTIPLY_SHADER);
- shaders[idx] = &shaders_asm[21];
+ debug_assert(shaders_asm[22].id == VEGA_PREMULTIPLY_SHADER);
+ shaders[idx] = &shaders_asm[22];
++idx;
} else if ((id & VEGA_UNPREMULTIPLY_SHADER)) {
- debug_assert(shaders_asm[22].id == VEGA_UNPREMULTIPLY_SHADER);
- shaders[idx] = &shaders_asm[22];
+ debug_assert(shaders_asm[23].id == VEGA_UNPREMULTIPLY_SHADER);
+ shaders[idx] = &shaders_asm[23];
++idx;
}
/* sixth stage */
if ((id & VEGA_BW_SHADER)) {
- debug_assert(shaders_asm[23].id == VEGA_BW_SHADER);
- shaders[idx] = &shaders_asm[23];
+ debug_assert(shaders_asm[24].id == VEGA_BW_SHADER);
+ shaders[idx] = &shaders_asm[24];
++idx;
}
diff --git a/src/gallium/state_trackers/vega/shaders_cache.h b/src/gallium/state_trackers/vega/shaders_cache.h
index 93f5909f26..1d0cc0b57c 100644
--- a/src/gallium/state_trackers/vega/shaders_cache.h
+++ b/src/gallium/state_trackers/vega/shaders_cache.h
@@ -57,11 +57,12 @@ enum VegaShaderType {
VEGA_BLEND_DIFFERENCE_KHR_SHADER = 1 << 18,
VEGA_BLEND_SUBTRACT_KHR_SHADER = 1 << 19,
VEGA_BLEND_INVERT_KHR_SHADER = 1 << 20,
+ VEGA_BLEND_EXCLUSION_KHR_SHADER = 1 << 21,
- VEGA_PREMULTIPLY_SHADER = 1 << 21,
- VEGA_UNPREMULTIPLY_SHADER = 1 << 22,
+ VEGA_PREMULTIPLY_SHADER = 1 << 22,
+ VEGA_UNPREMULTIPLY_SHADER = 1 << 23,
- VEGA_BW_SHADER = 1 << 23
+ VEGA_BW_SHADER = 1 << 24
};
struct vg_shader {
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 5ba02a2ee6..94670f3684 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -348,6 +348,7 @@ void vg_validate_state(struct vg_context *ctx)
case VG_BLEND_DIFFERENCE_KHR:
case VG_BLEND_SUBTRACT_KHR:
case VG_BLEND_INVERT_KHR:
+ case VG_BLEND_EXCLUSION_KHR:
blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;