2011/5/5 Christian König <deathsim...@vodafone.de>:
> Am Donnerstag, den 05.05.2011, 12:11 +0100 schrieb Andy Furniss:
>> Andy Furniss wrote:
>> > There has been a regression though -
>> >
>> > [g3dvl] remove resource_format workaround
>> >
>> > causes quite bad artifacts on newmobcal.
>>
>> I can get rid of the new artifacts for xvmc with the patch below.
>>
>> ffmpeg12vdpau shows the same "new" artifacts, but is not fixed by this.
> The problem is more complicated than this, using a signed buffer format
> is just a workaround, the real solution is to implement blender clamping
> in r600g. You could try this (temporary) patch until I figured out how
> to do this correctly on all supported hardware:

Something like the attached patch should work.

Alex


>
> --- a/src/gallium/drivers/r600/r600_state.c
> +++ b/src/gallium/drivers/r600/r600_state.c
> @@ -786,10 +786,10 @@ static void r600_cb(struct r600_pipe_context *rctx, 
> struct r600_pipe_state *rsta
>           if BLEND_FLOAT32 is set of > 11 bits in a UNORM or SNORM */
>        if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS && 
> desc->channel[i].size < 12) {
>                //TODO: Seems to work on RV710, but i have no idea what to do 
> between R600-RV710
> -               if (rctx->family < CHIP_RV710) {
> -                       color_info |= S_0280A0_BLEND_CLAMP(1);
> -                       color_info_mask |= S_0280A0_BLEND_CLAMP(1);
> -               }
> +               //if (rctx->family < CHIP_RV710) {
> +               //      color_info |= S_0280A0_BLEND_CLAMP(1);
> +               //      color_info_mask |= S_0280A0_BLEND_CLAMP(1);
> +               //}
>                color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM);
>        }
>
> I'm currently focusing more on the variable length decoding part of the
> vdpau mpeg2, by the way: How is well does this work on your hardware?
>
> Regards,
> Christian.
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
From cf459847da193c103bc34fea6a789373dee63568 Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexdeuc...@gmail.com>
Date: Thu, 5 May 2011 17:47:44 -0400
Subject: [PATCH] r600g: fix up the rules for enabling SOURCE_FORMAT(EXPORT_NORM)

Setting SOURCE_FORMAT to EXPORT_NORM is an optimization.
Leaving SOURCE_FORMAT at 0 will work in all cases, but is less
efficient.  The conditions for the setting the EXPORT_NORM
optimization are as follows:

R600/RV6xx:
BLEND_CLAMP is enabled
BLEND_FLOAT32 is disabled
11-bit or smaller UNORM/SNORM/SRGB

R7xx/evergreen:
11-bit or smaller UNORM/SNORM/SRGB
16-bit or smaller FLOAT

Signed-off-by: Alex Deucher <alexdeuc...@gmail.com>
---
 src/gallium/drivers/r600/evergreen_state.c |   15 ++++++++---
 src/gallium/drivers/r600/r600_state.c      |   35 ++++++++++++++++++++++++----
 2 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index e325361..7a4d625 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -707,11 +707,18 @@ static void evergreen_cb(struct r600_pipe_context *rctx, struct r600_pipe_state
 		S_028C70_ENDIAN(endian);
 
 
-	/* we can only set the export size if any thing is snorm/unorm component is > 11 bits,
-	   if we aren't a float, sint or uint */
+	/* EXPORT_NORM is an optimzation that can be enabled for better
+	 * performance in certain cases.
+	 * EXPORT_NORM can be enabled if:
+	 * - 11-bit or smaller UNORM/SNORM/SRGB
+	 * - 16-bit or smaller FLOAT
+	 */
 	if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS &&
-	    desc->channel[i].size < 12 && desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT &&
-	    ntype != V_028C70_NUMBER_UINT && ntype != V_028C70_NUMBER_SINT)
+	    ((desc->channel[i].size < 12 &&
+	      desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT &&
+	      ntype != V_028C70_NUMBER_UINT && ntype != V_028C70_NUMBER_SINT) ||
+	     (desc->channel[i].size < 17 &&
+	      desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)))
 		color_info |= S_028C70_SOURCE_FORMAT(V_028C70_EXPORT_4C_16BPC);
 
 	if (rtex->array_mode[level] > V_028C70_ARRAY_LINEAR_ALIGNED) {
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 1c27f88..fbf2c84 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -767,11 +767,36 @@ static void r600_cb(struct r600_pipe_context *rctx, struct r600_pipe_state *rsta
 		S_0280A0_NUMBER_TYPE(ntype) |
 		S_0280A0_ENDIAN(endian);
 
-	/* on R600 this can't be set if BLEND_CLAMP isn't set,
-	   if BLEND_FLOAT32 is set of > 11 bits in a UNORM or SNORM */
-	if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS &&
-	    desc->channel[i].size < 12)
-		color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM);
+	/* EXPORT_NORM is an optimzation that can be enabled for better
+	 * performance in certain cases
+	 */
+	if (rctx->family < CHIP_RV770) {
+		/* EXPORT_NORM can be enabled if:
+		 * - 11-bit or smaller UNORM/SNORM/SRGB
+		 * - BLEND_CLAMP is enabled
+		 * - BLEND_FLOAT32 is disabled
+		 */
+		if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS &&
+		    (desc->channel[i].size < 12 &&
+		     desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT &&
+		     ntype != V_0280A0_NUMBER_UINT &&
+		     ntype != V_0280A0_NUMBER_SINT) &&
+		    G_0280A0_BLEND_CLAMP(color_info) &&
+		    !G_0280A0_BLEND_FLOAT32(color_info))
+			color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM);
+	} else {
+		/* EXPORT_NORM can be enabled if:
+		 * - 11-bit or smaller UNORM/SNORM/SRGB
+		 * - 16-bit or smaller FLOAT
+		 */
+		if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS &&
+		    ((desc->channel[i].size < 12 &&
+		      desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT &&
+		      ntype != V_0280A0_NUMBER_UINT && ntype != V_0280A0_NUMBER_SINT) ||
+		    (desc->channel[i].size < 17 &&
+		     desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)))
+			color_info |= S_0280A0_SOURCE_FORMAT(V_0280A0_EXPORT_NORM);
+	}
 
 	r600_pipe_state_add_reg(rstate,
 				R_028040_CB_COLOR0_BASE + cb * 4,
-- 
1.7.1.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to