[Mesa-dev] [PATCH] softpipe: don't clamp or do logical operations on floating-point buffers.
Corbin Simpson
mostawesomedude at gmail.com
Sun Nov 6 06:08:33 PST 2011
It's entirely possible that I'm still asleep, but what problem does this
solve? Are ROPs not defined for FP operands?
Sending from a mobile, pardon my terseness. ~ C.
On Nov 6, 2011 4:31 AM, "Morgan Armand" <morgan.devel at gmail.com> wrote:
> ---
> src/gallium/drivers/softpipe/sp_quad_blend.c | 78
> ++++++++++++++++++-------
> 1 files changed, 56 insertions(+), 22 deletions(-)
>
> diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c
> b/src/gallium/drivers/softpipe/sp_quad_blend.c
> index 598df26..4813ada 100644
> --- a/src/gallium/drivers/softpipe/sp_quad_blend.c
> +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
> @@ -702,19 +702,19 @@ blend_quad(struct quad_stage *qs,
> */
> switch (softpipe->blend->rt[blend_index].rgb_func) {
> case PIPE_BLEND_ADD:
> - VEC4_ADD_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
> - VEC4_ADD_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
> - VEC4_ADD_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
> + VEC4_ADD(quadColor[0], source[0], blend_dest[0]); /* R */
> + VEC4_ADD(quadColor[1], source[1], blend_dest[1]); /* G */
> + VEC4_ADD(quadColor[2], source[2], blend_dest[2]); /* B */
> break;
> case PIPE_BLEND_SUBTRACT:
> - VEC4_SUB_SAT(quadColor[0], source[0], blend_dest[0]); /* R */
> - VEC4_SUB_SAT(quadColor[1], source[1], blend_dest[1]); /* G */
> - VEC4_SUB_SAT(quadColor[2], source[2], blend_dest[2]); /* B */
> + VEC4_SUB(quadColor[0], source[0], blend_dest[0]); /* R */
> + VEC4_SUB(quadColor[1], source[1], blend_dest[1]); /* G */
> + VEC4_SUB(quadColor[2], source[2], blend_dest[2]); /* B */
> break;
> case PIPE_BLEND_REVERSE_SUBTRACT:
> - VEC4_SUB_SAT(quadColor[0], blend_dest[0], source[0]); /* R */
> - VEC4_SUB_SAT(quadColor[1], blend_dest[1], source[1]); /* G */
> - VEC4_SUB_SAT(quadColor[2], blend_dest[2], source[2]); /* B */
> + VEC4_SUB(quadColor[0], blend_dest[0], source[0]); /* R */
> + VEC4_SUB(quadColor[1], blend_dest[1], source[1]); /* G */
> + VEC4_SUB(quadColor[2], blend_dest[2], source[2]); /* B */
> break;
> case PIPE_BLEND_MIN:
> VEC4_MIN(quadColor[0], source[0], blend_dest[0]); /* R */
> @@ -735,13 +735,13 @@ blend_quad(struct quad_stage *qs,
> */
> switch (softpipe->blend->rt[blend_index].alpha_func) {
> case PIPE_BLEND_ADD:
> - VEC4_ADD_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
> + VEC4_ADD(quadColor[3], source[3], blend_dest[3]); /* A */
> break;
> case PIPE_BLEND_SUBTRACT:
> - VEC4_SUB_SAT(quadColor[3], source[3], blend_dest[3]); /* A */
> + VEC4_SUB(quadColor[3], source[3], blend_dest[3]); /* A */
> break;
> case PIPE_BLEND_REVERSE_SUBTRACT:
> - VEC4_SUB_SAT(quadColor[3], blend_dest[3], source[3]); /* A */
> + VEC4_SUB(quadColor[3], blend_dest[3], source[3]); /* A */
> break;
> case PIPE_BLEND_MIN:
> VEC4_MIN(quadColor[3], source[3], blend_dest[3]); /* A */
> @@ -856,6 +856,10 @@ blend_fallback(struct quad_stage *qs,
>
> for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++)
> {
> + const enum pipe_format format =
> + softpipe->framebuffer.cbufs[cbuf]->format;
> + const struct util_format_description *desc =
> + util_format_description(format);
> /* which blend/mask state index to use: */
> const uint blend_buf = blend->independent_blend_enable ? cbuf : 0;
> float dest[4][QUAD_SIZE];
> @@ -909,10 +913,19 @@ blend_fallback(struct quad_stage *qs,
>
>
> if (blend->logicop_enable) {
> - logicop_quad( qs, quadColor, dest );
> + if (desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT) {
> + logicop_quad( qs, quadColor, dest );
> + }
> }
> else if (blend->rt[blend_buf].blend_enable) {
> blend_quad(qs, quadColor, dest, blend_color, blend_buf);
> +
> + /* If fixed-point dest color buffer, need to clamp the
> outgoing
> + * fragment colors now.
> + */
> + if (clamp) {
> + clamp_colors(quadColor);
> + }
> }
>
> rebase_colors(bqs->base_format[cbuf], quadColor);
> @@ -969,6 +982,13 @@ blend_single_add_src_alpha_inv_src_alpha(struct
> quad_stage *qs,
> }
> }
>
> + /* If fixed-point dest color buffer, need to clamp the incoming
> + * fragment colors now.
> + */
> + if (bqs->clamp[0]) {
> + clamp_colors(quadColor);
> + }
> +
> VEC4_MUL(source[0], quadColor[0], alpha); /* R */
> VEC4_MUL(source[1], quadColor[1], alpha); /* G */
> VEC4_MUL(source[2], quadColor[2], alpha); /* B */
> @@ -978,12 +998,19 @@ blend_single_add_src_alpha_inv_src_alpha(struct
> quad_stage *qs,
> VEC4_MUL(dest[0], dest[0], one_minus_alpha); /* R */
> VEC4_MUL(dest[1], dest[1], one_minus_alpha); /* G */
> VEC4_MUL(dest[2], dest[2], one_minus_alpha); /* B */
> - VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* B */
> + VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* A */
>
> - VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */
> - VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */
> - VEC4_ADD_SAT(quadColor[2], source[2], dest[2]); /* B */
> - VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */
> + VEC4_ADD(quadColor[0], source[0], dest[0]); /* R */
> + VEC4_ADD(quadColor[1], source[1], dest[1]); /* G */
> + VEC4_ADD(quadColor[2], source[2], dest[2]); /* B */
> + VEC4_ADD(quadColor[3], source[3], dest[3]); /* A */
> +
> + /* If fixed-point dest color buffer, need to clamp the outgoing
> + * fragment colors now.
> + */
> + if (bqs->clamp[0]) {
> + clamp_colors(quadColor);
> + }
>
> rebase_colors(bqs->base_format[0], quadColor);
>
> @@ -1035,10 +1062,17 @@ blend_single_add_one_one(struct quad_stage *qs,
> clamp_colors(quadColor);
> }
>
> - VEC4_ADD_SAT(quadColor[0], quadColor[0], dest[0]); /* R */
> - VEC4_ADD_SAT(quadColor[1], quadColor[1], dest[1]); /* G */
> - VEC4_ADD_SAT(quadColor[2], quadColor[2], dest[2]); /* B */
> - VEC4_ADD_SAT(quadColor[3], quadColor[3], dest[3]); /* A */
> + VEC4_ADD(quadColor[0], quadColor[0], dest[0]); /* R */
> + VEC4_ADD(quadColor[1], quadColor[1], dest[1]); /* G */
> + VEC4_ADD(quadColor[2], quadColor[2], dest[2]); /* B */
> + VEC4_ADD(quadColor[3], quadColor[3], dest[3]); /* A */
> +
> + /* If fixed-point dest color buffer, need to clamp the outgoing
> + * fragment colors now.
> + */
> + if (bqs->clamp[0]) {
> + clamp_colors(quadColor);
> + }
>
> rebase_colors(bqs->base_format[0], quadColor);
>
> --
> 1.7.7.1.msysgit.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111106/7dd16179/attachment.html>
More information about the mesa-dev
mailing list