summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2016-05-22 16:09:53 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2016-05-23 20:00:39 -0400
commit2e8e1e89090ddfc95ae3b732b7b810d68c3217e5 (patch)
tree2f4e9d097c88f4e834b0985ca1d03514bba2bb77 /src/mesa/main/teximage.c
parent1e99a46b446522dbb12634139c2f2060d5dabf94 (diff)
downloadexternal_mesa3d-2e8e1e89090ddfc95ae3b732b7b810d68c3217e5.zip
external_mesa3d-2e8e1e89090ddfc95ae3b732b7b810d68c3217e5.tar.gz
external_mesa3d-2e8e1e89090ddfc95ae3b732b7b810d68c3217e5.tar.bz2
main: check driver float texture support before upgrading to 16F/32F
When passing in GL_RGBA or other base formats, we will try to upgrade the format to whatever the passed in type was. However not all drivers (notably nv30) support 32F textures, and so this would lead to crashes down the line. Only upgrade when the relevant extensions are available. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7cf15f5..9da3be6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -72,40 +72,45 @@
* For example, given base format GL_RGBA, type GL_Float return GL_RGBA32F_ARB.
*/
static GLenum
-adjust_for_oes_float_texture(GLenum format, GLenum type)
+adjust_for_oes_float_texture(const struct gl_context *ctx,
+ GLenum format, GLenum type)
{
switch (type) {
case GL_FLOAT:
- switch (format) {
- case GL_RGBA:
- return GL_RGBA32F;
- case GL_RGB:
- return GL_RGB32F;
- case GL_ALPHA:
- return GL_ALPHA32F_ARB;
- case GL_LUMINANCE:
- return GL_LUMINANCE32F_ARB;
- case GL_LUMINANCE_ALPHA:
- return GL_LUMINANCE_ALPHA32F_ARB;
- default:
- break;
+ if (ctx->Extensions.OES_texture_float) {
+ switch (format) {
+ case GL_RGBA:
+ return GL_RGBA32F;
+ case GL_RGB:
+ return GL_RGB32F;
+ case GL_ALPHA:
+ return GL_ALPHA32F_ARB;
+ case GL_LUMINANCE:
+ return GL_LUMINANCE32F_ARB;
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA32F_ARB;
+ default:
+ break;
+ }
}
break;
case GL_HALF_FLOAT_OES:
- switch (format) {
- case GL_RGBA:
- return GL_RGBA16F;
- case GL_RGB:
- return GL_RGB16F;
- case GL_ALPHA:
- return GL_ALPHA16F_ARB;
- case GL_LUMINANCE:
- return GL_LUMINANCE16F_ARB;
- case GL_LUMINANCE_ALPHA:
- return GL_LUMINANCE_ALPHA16F_ARB;
- default:
- break;
+ if (ctx->Extensions.OES_texture_half_float) {
+ switch (format) {
+ case GL_RGBA:
+ return GL_RGBA16F;
+ case GL_RGB:
+ return GL_RGB16F;
+ case GL_ALPHA:
+ return GL_ALPHA16F_ARB;
+ case GL_LUMINANCE:
+ return GL_LUMINANCE16F_ARB;
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA16F_ARB;
+ default:
+ break;
+ }
}
break;
@@ -2904,7 +2909,7 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims,
texObj->_IsHalfFloat = GL_TRUE;
}
- internalFormat = adjust_for_oes_float_texture(format, type);
+ internalFormat = adjust_for_oes_float_texture(ctx, format, type);
}
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,