New: [r600g] glCopyTexImage2D selects a texture format that involves fallback to software
https://bugs.freedesktop.org/show_bug.cgi?id=41263
Summary: [r600g] glCopyTexImage2D selects a texture format that
involves fallback to software
Product: DRI
Version: XOrg CVS
Platform: x86 (IA32)
OS/Version: Linux (All)
Status: NEW
Severity: normal
Priority: medium
Component: DRM/Radeon
AssignedTo: [email protected]
ReportedBy: [email protected]
In my compositor, on AMD G-T56N (Fusion, Evergreen) I create a texture using GLX_EXT_texture_from_pixmap, where the source application is using Xv textured video on evergreen to write to its backing pixmap (found with XCompositeNamePixmap).
To have a stable copy of this output for compositing from, I immediately copy the texture to a separate texture whose backing store is owned by the compositor, using code like the following:
glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, source_texture, 0 );
glBindTexture( GL_TEXTURE_2D, dest_texture ); glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0 ); glBindFramebuffer( GL_FRAMEBUFFER, 0 );
Where framebuffer is an FBO that I've created earlier with glGenFramebuffers( 1, &framebuffer ), source_texture is the texture bound to the video pixmap, and dest_texture is my private texture for the compositor to use.
The glCopyTexImage2D call is incredibly slow - it's falling back to a CPU-side copy. Tracing in with GDB shows me that, in st_copy_texsubimage (st_cb_texture.c:1463), src_format is PIPE_FORMAT_B8G8R8A8_UNORM and dest_format is PIPE_FORMAT_R8G8B8A8_UNORM (st_cb_texture.c:1523).
As a result, Gallium can neither do a straight copy of the data, nor can it find a suitable format_writemask to do the swizzle, so it falls back to software.
Either Gallium and r600g needs to learn how to do swizzled copies to make this work, or whichever parts of the chain (highest level in Mesa is copyteximage() at teximage.c:2744) choose the swizzled format need to learn to Not Do That.
Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
[Bug 41263] [r600g] glCopyTexImage2D selects a texture format that involves fallback to software
https://bugs.freedesktop.org/show_bug.cgi?id=41263
--- Comment #1 from Simon Farnsworth <[email protected]> 2011-09-27 08:31:26 PDT --- Forgot to mention - I'm looking at Mesa git, as of:
commit 4c84fbea9d496567d706468113d63cd8f0faeb7f
Author: Brian Paul <[email protected]> Date: Mon Sep 26 20:44:09 2011 -0600
mesa: fix indentation in mipmap.c (3 spaces)
I can update or apply test patches as required.
Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
[Bug 41263] [r600g] glCopyTexImage2D selects a texture format that involves fallback to software
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=41263
--- Comment #2 from Simon Farnsworth <[email protected]> 2011-09-28 10:07:53 PDT --- I think it may be core Mesa at fault.
main/teximage.c:2779
gl_format texFormat = _mesa_choose_texture_format(ctx, texObj,
target, level, internalFormat, GL_NONE, GL_NONE);
is called when internalFormat is GL_RGB. Gallium, not unreasonably, treats this as "choose a nice fast GL_RGB style format", and chooses a reversed format to that of the source. The result is a slow software copy, not a fast hardware copy.
So, two possibilities present themselves to me:
1) Gallium should learn to do swizzled hardware blits with a textured quad.
2) Core Mesa should give Gallium more information about the source, so that it can choose a matching format if possible.
Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
[Bug 41263] [r600g] glCopyTexImage2D selects a texture format that involves fallback to software
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=41263
--- Comment #3 from Simon Farnsworth <[email protected]> 2011-09-28 10:28:33 PDT --- And I have confirmation that it's about choice of texture formats: the
following patch "fixes" the bug for me (no doubt by adding hundreds more for other people).
(quoted diff) +0 -0
b/src/mesa/state_tracker/st_format.c
index 6eb8a50..a310762 100644
src/mesa/state_tracker/st_format.c +1 -1
@@ -616,10 +616,10 @@ struct format_mapping 0#define DEFAULT_RGB_FORMATS \ + PIPE_FORMAT_B8G8R8A8_UNORM, \ PIPE_FORMAT_B8G8R8X8_UNORM, \ PIPE_FORMAT_X8R8G8B8_UNORM, \ PIPE_FORMAT_X8B8G8R8_UNORM, \ - PIPE_FORMAT_B8G8R8A8_UNORM, \ PIPE_FORMAT_A8R8G8B8_UNORM, \ PIPE_FORMAT_A8B8G8R8_UNORM, \ PIPE_FORMAT_B5G6R5_UNORM, \
Signature · 3 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.
[Bug 41263] [r600g] glCopyTexImage2D selects a texture format that involves fallback to software
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=41263
Marek Olšák <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Product|DRI |Mesa
Version|XOrg CVS |git
Component|DRM/Radeon |Mesa core
AssignedTo|[email protected] |[email protected].
|.org |org--- Comment #4 from Marek Olšák <[email protected]> 2011-09-28 16:24:23 PDT --- st/mesa can do swizzled copies just fine. Something else is failing in st_cb_texture.c. See line 1476 in that file. Both those ifs fail. Can you take a look and see why?
Signature · 7 lines
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel