summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-03-15 15:00:02 +0100
committerMarek Olšák <[email protected]>2011-03-29 12:50:22 +0200
commitb518f4d0ea72dc3872f351250034aa9155756dd3 (patch)
tree3a80fca50114cbc60036a54195c3e17128708eb7 /src/mesa
parent2af1da15468d06d3ce9d89bcc706276ecc66f761 (diff)
st/mesa: choose an appropriate texture format for DrawPixels
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index dc53e276cb3..1707f827cc8 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -296,7 +296,7 @@ base_format(GLenum format)
* of the given format and type.
*/
static GLenum
-internal_format(GLenum format, GLenum type)
+internal_format(struct gl_context *ctx, GLenum format, GLenum type)
{
switch (format) {
case GL_DEPTH_COMPONENT:
@@ -326,7 +326,53 @@ internal_format(GLenum format, GLenum type)
}
}
else {
- return GL_RGBA;
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ default:
+ return GL_RGBA8;
+
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return GL_RGBA4;
+
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return GL_RGB5_A1;
+
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return GL_RGB10_A2;
+
+ case GL_UNSIGNED_SHORT:
+ case GL_UNSIGNED_INT:
+ return GL_RGBA16;
+
+ case GL_BYTE:
+ return
+ ctx->Extensions.EXT_texture_snorm ? GL_RGBA8_SNORM : GL_RGBA8;
+
+ case GL_SHORT:
+ case GL_INT:
+ return
+ ctx->Extensions.EXT_texture_snorm ? GL_RGBA16_SNORM : GL_RGBA16;
+
+ case GL_HALF_FLOAT_ARB:
+ return
+ ctx->Extensions.ARB_texture_float ? GL_RGBA16F :
+ ctx->Extensions.EXT_texture_snorm ? GL_RGBA16_SNORM : GL_RGBA16;
+
+ case GL_FLOAT:
+ case GL_DOUBLE:
+ return
+ ctx->Extensions.ARB_texture_float ? GL_RGBA32F :
+ ctx->Extensions.EXT_texture_snorm ? GL_RGBA16_SNORM : GL_RGBA16;
+ }
}
}
}
@@ -369,7 +415,7 @@ make_texture(struct st_context *st,
GLenum baseFormat, intFormat;
baseFormat = base_format(format);
- intFormat = internal_format(format, type);
+ intFormat = internal_format(ctx, format, type);
mformat = st_ChooseTextureFormat_renderable(ctx, intFormat,
format, type, GL_FALSE);