On Sun, Apr 4, 2010 at 6:31 PM, Dave Airlie <airl...@gmail.com> wrote:
> Hey,
>
> So I was trying to fix tfp test on r300g, and ran into an issue with
> dri st I think.
>
> So the way TFP works we get dri2_set_tex_buffer, which then validates the
> attachment, but ignores the format passed in. So r300g picks up the kernel
> buffer from the handle and sets up the texture + texture state without
> the format
> information.
>
> Once we've validated, we call ctx->st->teximage and can give it a different
> format however at no point does r300g get any place to change the texture 
> format
> and update its internal state.
>
> I'm not sure if either r300g should delay setting up its internal
> state for emission
> until later or whether we need to enhance the st interface.
>
> The main issue with we get a TFP with a B8G8R8X8 but the visual is B8G8R8A8
> which triggers this.
The attached patch fixes tfp test for me (with i915g).  Could you see if r300g
passes the test with the patch?

The teximage callback has an internal_format parameter that specifies how the
pipe texture should be treated.  It can differ from the format of the texture.
It seems to suffice for TFP.  I was lazy enough not to use it :(

-- 
o...@lunarg.com
From 2a1c9adc331523be84db243fffabb9dc9d0843eb Mon Sep 17 00:00:00 2001
From: Chia-I Wu <o...@lunarg.com>
Date: Mon, 5 Apr 2010 10:06:52 +0800
Subject: [PATCH] st/dri: Fix setTexBuffer2 with __DRI_TEXTURE_FORMAT_RGB.

When the format is __DRI_TEXTURE_FORMAT_RGB, the texture should be
treated as if there is no alpha channel.
---
 src/gallium/state_trackers/dri/drm/dri2.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/gallium/state_trackers/dri/drm/dri2.c 
b/src/gallium/state_trackers/dri/drm/dri2.c
index c632f0f..09e5e04 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -84,9 +84,25 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
    pt = drawable->textures[ST_ATTACHMENT_FRONT_LEFT];
 
    if (pt) {
+      enum pipe_format internal_format = pt->format;
+
+      if (format == __DRI_TEXTURE_FORMAT_RGB)  {
+         /* only need to cover the formats recognized by dri_fill_st_visual */
+         switch (internal_format) {
+         case PIPE_FORMAT_B8G8R8A8_UNORM:
+            internal_format = PIPE_FORMAT_B8G8R8X8_UNORM;
+            break;
+         case PIPE_FORMAT_A8R8G8B8_UNORM:
+            internal_format = PIPE_FORMAT_X8R8G8B8_UNORM;
+            break;
+         default:
+            break;
+         }
+      }
+
       ctx->st->teximage(ctx->st,
             (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT,
-            0, drawable->stvis.color_format, pt, FALSE);
+            0, internal_format, pt, FALSE);
    }
 }
 
-- 
1.7.0

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to