summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/framebuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/framebuffer.c')
-rw-r--r--src/mesa/main/framebuffer.c75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 3ec8b91eaa2..78a80649a04 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -844,22 +844,49 @@ _mesa_get_color_read_format(struct gl_context *ctx,
}
else {
const mesa_format format = fb->_ColorReadBuffer->Format;
- const GLenum data_type = _mesa_get_format_datatype(format);
- if (format == MESA_FORMAT_B8G8R8A8_UNORM)
+ switch (format) {
+ case MESA_FORMAT_RGBA_UINT8:
+ return GL_RGBA_INTEGER;
+ case MESA_FORMAT_B8G8R8A8_UNORM:
return GL_BGRA;
- else if (format == MESA_FORMAT_B5G6R5_UNORM)
+ case MESA_FORMAT_B5G6R5_UNORM:
+ case MESA_FORMAT_R11G11B10_FLOAT:
return GL_RGB;
- else if (format == MESA_FORMAT_R_UNORM8)
+ case MESA_FORMAT_RG_FLOAT32:
+ case MESA_FORMAT_RG_FLOAT16:
+ case MESA_FORMAT_R8G8_UNORM:
+ case MESA_FORMAT_R8G8_SNORM:
+ return GL_RG;
+ case MESA_FORMAT_RG_SINT32:
+ case MESA_FORMAT_RG_UINT32:
+ case MESA_FORMAT_RG_SINT16:
+ case MESA_FORMAT_RG_UINT16:
+ case MESA_FORMAT_RG_SINT8:
+ case MESA_FORMAT_RG_UINT8:
+ return GL_RG_INTEGER;
+ case MESA_FORMAT_R_FLOAT32:
+ case MESA_FORMAT_R_FLOAT16:
+ case MESA_FORMAT_R_UNORM16:
+ case MESA_FORMAT_R_UNORM8:
+ case MESA_FORMAT_R_SNORM16:
+ case MESA_FORMAT_R_SNORM8:
return GL_RED;
+ case MESA_FORMAT_R_SINT32:
+ case MESA_FORMAT_R_UINT32:
+ case MESA_FORMAT_R_SINT16:
+ case MESA_FORMAT_R_UINT16:
+ case MESA_FORMAT_R_SINT8:
+ case MESA_FORMAT_R_UINT8:
+ return GL_RED_INTEGER;
+ default:
+ break;
+ }
- switch (data_type) {
- case GL_UNSIGNED_INT:
- case GL_INT:
+ if (_mesa_is_format_integer(format))
return GL_RGBA_INTEGER;
- default:
+ else
return GL_RGBA;
- }
}
}
@@ -892,29 +919,13 @@ _mesa_get_color_read_type(struct gl_context *ctx,
return GL_NONE;
}
else {
- const GLenum format = fb->_ColorReadBuffer->Format;
- const GLenum data_type = _mesa_get_format_datatype(format);
-
- if (format == MESA_FORMAT_B5G6R5_UNORM)
- return GL_UNSIGNED_SHORT_5_6_5;
-
- if (format == MESA_FORMAT_B10G10R10A2_UNORM ||
- format == MESA_FORMAT_B10G10R10X2_UNORM ||
- format == MESA_FORMAT_R10G10B10A2_UNORM ||
- format == MESA_FORMAT_R10G10B10X2_UNORM)
- return GL_UNSIGNED_INT_2_10_10_10_REV;
-
- switch (data_type) {
- case GL_SIGNED_NORMALIZED:
- return GL_BYTE;
- case GL_UNSIGNED_INT:
- case GL_INT:
- case GL_FLOAT:
- return data_type;
- case GL_UNSIGNED_NORMALIZED:
- default:
- return GL_UNSIGNED_BYTE;
- }
+ const mesa_format format = fb->_ColorReadBuffer->Format;
+ GLenum data_type;
+ GLuint comps;
+
+ _mesa_uncompressed_format_to_type_and_comps(format, &data_type, &comps);
+
+ return data_type;
}
}