summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2009-10-23 09:35:36 -0400
committerZack Rusin <[email protected]>2009-10-23 19:39:16 -0400
commitb17c885a8aa88ef06f384330d59aeb23b73350bb (patch)
tree7e7087ffc6b8290d6f35b81c534ee0640c7d75dd /src/gallium
parent49d402e275cdaf46de8db5a475dfe00509141195 (diff)
st/xorg: fix text with component alpha rendering
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_composite.c50
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.c11
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa_tgsi.h7
3 files changed, 45 insertions, 23 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
index 7366fa7b852..1bc3350e8b6 100644
--- a/src/gallium/state_trackers/xorg/xorg_composite.c
+++ b/src/gallium/state_trackers/xorg/xorg_composite.c
@@ -109,6 +109,7 @@ blend_for_op(struct xorg_composite_blend *blend,
blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR;
}
}
+
return supported;
}
@@ -257,8 +258,15 @@ bind_shaders(struct exa_context *exa, int op,
if (pMaskPicture) {
vs_traits |= VS_MASK;
fs_traits |= FS_MASK;
- if (pMaskPicture->componentAlpha)
- fs_traits |= FS_COMPONENT_ALPHA;
+ if (pMaskPicture->componentAlpha) {
+ struct xorg_composite_blend blend;
+ blend_for_op(&blend, op,
+ pSrcPicture, pMaskPicture, NULL);
+ if (blend.alpha_src) {
+ fs_traits |= FS_CA_SRCALPHA;
+ } else
+ fs_traits |= FS_CA_FULL;
+ }
}
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits);
@@ -289,21 +297,27 @@ bind_samplers(struct exa_context *exa, int op,
exa->pipe->flush(exa->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
if (pSrcPicture && pSrc) {
- unsigned src_wrap = render_repeat_to_gallium(
- pSrcPicture->repeatType);
- int filter;
-
- render_filter_to_gallium(pSrcPicture->filter, &filter);
-
- src_sampler.wrap_s = src_wrap;
- src_sampler.wrap_t = src_wrap;
- src_sampler.min_img_filter = filter;
- src_sampler.mag_img_filter = filter;
- src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
- src_sampler.normalized_coords = 1;
- samplers[0] = &src_sampler;
- exa->bound_textures[0] = pSrc->tex;
- ++exa->num_bound_samplers;
+ if (exa->has_solid_color) {
+ debug_assert(!"solid color with textures");
+ samplers[0] = NULL;
+ exa->bound_textures[0] = NULL;
+ } else {
+ unsigned src_wrap = render_repeat_to_gallium(
+ pSrcPicture->repeatType);
+ int filter;
+
+ render_filter_to_gallium(pSrcPicture->filter, &filter);
+
+ src_sampler.wrap_s = src_wrap;
+ src_sampler.wrap_t = src_wrap;
+ src_sampler.min_img_filter = filter;
+ src_sampler.mag_img_filter = filter;
+ src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
+ src_sampler.normalized_coords = 1;
+ samplers[0] = &src_sampler;
+ exa->bound_textures[0] = pSrc->tex;
+ exa->num_bound_samplers = 1;
+ }
}
if (pMaskPicture && pMask) {
@@ -321,7 +335,7 @@ bind_samplers(struct exa_context *exa, int op,
mask_sampler.normalized_coords = 1;
samplers[1] = &mask_sampler;
exa->bound_textures[1] = pMask->tex;
- ++exa->num_bound_samplers;
+ exa->num_bound_samplers = 2;
}
cso_set_samplers(exa->renderer->cso, exa->num_bound_samplers,
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index abb00824eb9..3c90dab3c5d 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -55,10 +55,13 @@ src_in_mask(struct ureg_program *ureg,
struct ureg_dst dst,
struct ureg_src src,
struct ureg_src mask,
- boolean component_alpha)
+ int component_alpha)
{
- if (component_alpha) {
+ if (component_alpha == FS_CA_FULL) {
ureg_MUL(ureg, dst, src, mask);
+ } else if (component_alpha == FS_CA_SRCALPHA) {
+ ureg_MUL(ureg, dst,
+ ureg_scalar(src, TGSI_SWIZZLE_W), mask);
}
else {
ureg_MUL(ureg, dst, src,
@@ -289,7 +292,7 @@ create_fs(struct pipe_context *pipe,
boolean is_solid = fs_traits & FS_SOLID_FILL;
boolean is_lingrad = fs_traits & FS_LINGRAD_FILL;
boolean is_radgrad = fs_traits & FS_RADGRAD_FILL;
- boolean is_comp_alpha = fs_traits & FS_COMPONENT_ALPHA;
+ unsigned comp_alpha = fs_traits & FS_COMPONENT_ALPHA;
ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
if (ureg == NULL)
@@ -386,7 +389,7 @@ create_fs(struct pipe_context *pipe,
ureg_TEX(ureg, mask,
TGSI_TEXTURE_2D, mask_pos, mask_sampler);
/* src IN mask */
- src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), is_comp_alpha);
+ src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), comp_alpha);
ureg_release_temporary(ureg, mask);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
index c290d44e8fc..0ea44fa137e 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h
@@ -24,7 +24,12 @@ enum xorg_fs_traits {
FS_FILL = (FS_SOLID_FILL |
FS_LINGRAD_FILL |
FS_RADGRAD_FILL),
- FS_COMPONENT_ALPHA = 1 << 5
+ /* src.rgba * mask.rgba */
+ FS_CA_FULL = 1 << 5,
+ /* src.aaaa * mask.rgba */
+ FS_CA_SRCALPHA = 1 << 6,
+ FS_COMPONENT_ALPHA = (FS_CA_FULL |
+ FS_CA_SRCALPHA)
};
struct xorg_shader {