summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorMichel Dänzer <daenzer@vmware.com>2009-12-05 17:42:50 +0100
committerMichel Dänzer <michel@daenzer.net>2009-12-05 17:59:49 +0100
commit01537a84dfe65cd1512d6fbf71e975fad5639432 (patch)
tree1ec93043c054eab94234e18fb390485d7cab9e98 /src/mesa
parentd13c603e37bf7fb4c84b215775eb547761c1e2ec (diff)
st/mesa: Prefer alpha-less formats for RGB textures.
This can e.g. increase the chance of being able to accelerate glCopyTex(Sub)Image from an alpha-less renderbuffer.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_format.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 02f80057c2..93125afe9e 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -389,6 +389,33 @@ default_rgba_format(struct pipe_screen *screen,
}
/**
+ * Find an RGB format supported by the context/winsys.
+ */
+static enum pipe_format
+default_rgb_format(struct pipe_screen *screen,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
+{
+ static const enum pipe_format colorFormats[] = {
+ PIPE_FORMAT_X8R8G8B8_UNORM,
+ PIPE_FORMAT_B8G8R8X8_UNORM,
+ PIPE_FORMAT_R8G8B8X8_UNORM,
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_B8G8R8A8_UNORM,
+ PIPE_FORMAT_R8G8B8A8_UNORM,
+ PIPE_FORMAT_R5G6B5_UNORM
+ };
+ uint i;
+ for (i = 0; i < Elements(colorFormats); i++) {
+ if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
+ return colorFormats[i];
+ }
+ }
+ return PIPE_FORMAT_NONE;
+}
+
+/**
* Find an sRGBA format supported by the context/winsys.
*/
static enum pipe_format
@@ -472,13 +499,14 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case 4:
case GL_RGBA:
case GL_COMPRESSED_RGBA:
- case 3:
- case GL_RGB:
- case GL_COMPRESSED_RGB:
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
return default_rgba_format( screen, target, tex_usage, geom_flags );
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ return default_rgb_format( screen, target, tex_usage, geom_flags );
case GL_RGBA16:
if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
@@ -500,7 +528,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return default_rgba_format( screen, target, tex_usage, geom_flags );
+ return default_rgb_format( screen, target, tex_usage, geom_flags );
case GL_RGB5:
case GL_RGB4: