summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/vega/shader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/vega/shader.c')
-rw-r--r--src/gallium/state_trackers/vega/shader.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index 8577d21efe4..92d3f5549e9 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -128,16 +128,30 @@ static VGint setup_constant_buffer(struct shader *shader)
return param_bytes;
}
+static VGboolean blend_use_shader(struct vg_context *ctx)
+{
+ VGboolean advanced_blending;
+
+ switch (ctx->state.vg.blend_mode) {
+ case VG_BLEND_MULTIPLY:
+ case VG_BLEND_SCREEN:
+ case VG_BLEND_DARKEN:
+ case VG_BLEND_LIGHTEN:
+ advanced_blending = VG_TRUE;
+ break;
+ default:
+ advanced_blending = VG_FALSE;
+ break;
+ }
+
+ return advanced_blending;
+}
+
static VGint blend_bind_samplers(struct vg_context *ctx,
struct pipe_sampler_state **samplers,
struct pipe_sampler_view **sampler_views)
{
- VGBlendMode bmode = ctx->state.vg.blend_mode;
-
- if (bmode == VG_BLEND_MULTIPLY ||
- bmode == VG_BLEND_SCREEN ||
- bmode == VG_BLEND_DARKEN ||
- bmode == VG_BLEND_LIGHTEN) {
+ if (blend_use_shader(ctx)) {
samplers[2] = &ctx->blend_sampler;
sampler_views[2] = vg_prepare_blend_surface(ctx);
@@ -209,7 +223,6 @@ static void setup_shader_program(struct shader *shader)
VGint shader_id = 0;
VGBlendMode blend_mode = ctx->state.vg.blend_mode;
VGboolean black_white = is_format_bw(shader);
- VGboolean advanced_blend;
/* 1st stage: fill */
if (!shader->drawing_image ||
@@ -256,26 +269,28 @@ static void setup_shader_program(struct shader *shader)
if (shader->color_transform)
shader_id |= VEGA_COLOR_TRANSFORM_SHADER;
- switch(blend_mode) {
- case VG_BLEND_MULTIPLY:
- case VG_BLEND_SCREEN:
- case VG_BLEND_DARKEN:
- case VG_BLEND_LIGHTEN:
- advanced_blend = VG_TRUE;
- break;
- default:
- /* handled by pipe_blend_state */
- advanced_blend = VG_FALSE;
- break;
- }
-
- if (advanced_blend) {
+ if (blend_use_shader(ctx)) {
if (shader->drawing_image && shader->image_mode == VG_DRAW_IMAGE_STENCIL)
shader_id |= VEGA_ALPHA_PER_CHANNEL_SHADER;
else
shader_id |= VEGA_ALPHA_NORMAL_SHADER;
switch(blend_mode) {
+ case VG_BLEND_SRC:
+ shader_id |= VEGA_BLEND_SRC_SHADER;
+ break;
+ case VG_BLEND_SRC_OVER:
+ shader_id |= VEGA_BLEND_SRC_OVER_SHADER;
+ break;
+ case VG_BLEND_DST_OVER:
+ shader_id |= VEGA_BLEND_DST_OVER_SHADER;
+ break;
+ case VG_BLEND_SRC_IN:
+ shader_id |= VEGA_BLEND_SRC_IN_SHADER;
+ break;
+ case VG_BLEND_DST_IN:
+ shader_id |= VEGA_BLEND_DST_IN_SHADER;
+ break;
case VG_BLEND_MULTIPLY:
shader_id |= VEGA_BLEND_MULTIPLY_SHADER;
break;
@@ -288,6 +303,9 @@ static void setup_shader_program(struct shader *shader)
case VG_BLEND_LIGHTEN:
shader_id |= VEGA_BLEND_LIGHTEN_SHADER;
break;
+ case VG_BLEND_ADDITIVE:
+ shader_id |= VEGA_BLEND_ADDITIVE_SHADER;
+ break;
default:
assert(0);
break;