From 72d872ad824110402a4455cb2b3aadb5c5160f89 Mon Sep 17 00:00:00 2001 From: Pi Tabred Date: Sat, 14 Dec 2013 10:32:00 -0700 Subject: [PATCH] mesa: get_texbuffer_format(): differentiate between core and compat context alpha, lumincance and intensity formats are illegal in a core context. Add a check to return MESA_FORMAT_NONE if one of those is requested within a core context. Reviewed-by: Brian Paul --- src/mesa/main/teximage.c | 167 ++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 80 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index f92dc1a6932..6bcabd3275a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3880,87 +3880,94 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, static gl_format get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) { + if (ctx->API != API_OPENGL_CORE) { + switch (internalFormat) { + case GL_ALPHA8: + return MESA_FORMAT_A8; + case GL_ALPHA16: + return MESA_FORMAT_A16; + case GL_ALPHA16F_ARB: + return MESA_FORMAT_ALPHA_FLOAT16; + case GL_ALPHA32F_ARB: + return MESA_FORMAT_ALPHA_FLOAT32; + case GL_ALPHA8I_EXT: + return MESA_FORMAT_ALPHA_INT8; + case GL_ALPHA16I_EXT: + return MESA_FORMAT_ALPHA_INT16; + case GL_ALPHA32I_EXT: + return MESA_FORMAT_ALPHA_INT32; + case GL_ALPHA8UI_EXT: + return MESA_FORMAT_ALPHA_UINT8; + case GL_ALPHA16UI_EXT: + return MESA_FORMAT_ALPHA_UINT16; + case GL_ALPHA32UI_EXT: + return MESA_FORMAT_ALPHA_UINT32; + case GL_LUMINANCE8: + return MESA_FORMAT_L8; + case GL_LUMINANCE16: + return MESA_FORMAT_L16; + case GL_LUMINANCE16F_ARB: + return MESA_FORMAT_LUMINANCE_FLOAT16; + case GL_LUMINANCE32F_ARB: + return MESA_FORMAT_LUMINANCE_FLOAT32; + case GL_LUMINANCE8I_EXT: + return MESA_FORMAT_LUMINANCE_INT8; + case GL_LUMINANCE16I_EXT: + return MESA_FORMAT_LUMINANCE_INT16; + case GL_LUMINANCE32I_EXT: + return MESA_FORMAT_LUMINANCE_INT32; + case GL_LUMINANCE8UI_EXT: + return MESA_FORMAT_LUMINANCE_UINT8; + case GL_LUMINANCE16UI_EXT: + return MESA_FORMAT_LUMINANCE_UINT16; + case GL_LUMINANCE32UI_EXT: + return MESA_FORMAT_LUMINANCE_UINT32; + case GL_LUMINANCE8_ALPHA8: + return MESA_FORMAT_AL88; + case GL_LUMINANCE16_ALPHA16: + return MESA_FORMAT_AL1616; + case GL_LUMINANCE_ALPHA16F_ARB: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; + case GL_LUMINANCE_ALPHA32F_ARB: + return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; + case GL_LUMINANCE_ALPHA8I_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT8; + case GL_LUMINANCE_ALPHA16I_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT8; + case GL_LUMINANCE_ALPHA32I_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT16; + case GL_LUMINANCE_ALPHA8UI_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT8; + case GL_LUMINANCE_ALPHA16UI_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT16; + case GL_LUMINANCE_ALPHA32UI_EXT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT32; + case GL_INTENSITY8: + return MESA_FORMAT_I8; + case GL_INTENSITY16: + return MESA_FORMAT_I16; + case GL_INTENSITY16F_ARB: + return MESA_FORMAT_INTENSITY_FLOAT16; + case GL_INTENSITY32F_ARB: + return MESA_FORMAT_INTENSITY_FLOAT32; + case GL_INTENSITY8I_EXT: + return MESA_FORMAT_INTENSITY_INT8; + case GL_INTENSITY16I_EXT: + return MESA_FORMAT_INTENSITY_INT16; + case GL_INTENSITY32I_EXT: + return MESA_FORMAT_INTENSITY_INT32; + case GL_INTENSITY8UI_EXT: + return MESA_FORMAT_INTENSITY_UINT8; + case GL_INTENSITY16UI_EXT: + return MESA_FORMAT_INTENSITY_UINT16; + case GL_INTENSITY32UI_EXT: + return MESA_FORMAT_INTENSITY_UINT32; + default: + break; + } + } + switch (internalFormat) { - case GL_ALPHA8: - return MESA_FORMAT_A8; - case GL_ALPHA16: - return MESA_FORMAT_A16; - case GL_ALPHA16F_ARB: - return MESA_FORMAT_ALPHA_FLOAT16; - case GL_ALPHA32F_ARB: - return MESA_FORMAT_ALPHA_FLOAT32; - case GL_ALPHA8I_EXT: - return MESA_FORMAT_ALPHA_INT8; - case GL_ALPHA16I_EXT: - return MESA_FORMAT_ALPHA_INT16; - case GL_ALPHA32I_EXT: - return MESA_FORMAT_ALPHA_INT32; - case GL_ALPHA8UI_EXT: - return MESA_FORMAT_ALPHA_UINT8; - case GL_ALPHA16UI_EXT: - return MESA_FORMAT_ALPHA_UINT16; - case GL_ALPHA32UI_EXT: - return MESA_FORMAT_ALPHA_UINT32; - case GL_LUMINANCE8: - return MESA_FORMAT_L8; - case GL_LUMINANCE16: - return MESA_FORMAT_L16; - case GL_LUMINANCE16F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT16; - case GL_LUMINANCE32F_ARB: - return MESA_FORMAT_LUMINANCE_FLOAT32; - case GL_LUMINANCE8I_EXT: - return MESA_FORMAT_LUMINANCE_INT8; - case GL_LUMINANCE16I_EXT: - return MESA_FORMAT_LUMINANCE_INT16; - case GL_LUMINANCE32I_EXT: - return MESA_FORMAT_LUMINANCE_INT32; - case GL_LUMINANCE8UI_EXT: - return MESA_FORMAT_LUMINANCE_UINT8; - case GL_LUMINANCE16UI_EXT: - return MESA_FORMAT_LUMINANCE_UINT16; - case GL_LUMINANCE32UI_EXT: - return MESA_FORMAT_LUMINANCE_UINT32; - case GL_LUMINANCE8_ALPHA8: - return MESA_FORMAT_AL88; - case GL_LUMINANCE16_ALPHA16: - return MESA_FORMAT_AL1616; - case GL_LUMINANCE_ALPHA16F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16; - case GL_LUMINANCE_ALPHA32F_ARB: - return MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32; - case GL_LUMINANCE_ALPHA8I_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_INT8; - case GL_LUMINANCE_ALPHA16I_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_INT8; - case GL_LUMINANCE_ALPHA32I_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_INT16; - case GL_LUMINANCE_ALPHA8UI_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_UINT8; - case GL_LUMINANCE_ALPHA16UI_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_UINT16; - case GL_LUMINANCE_ALPHA32UI_EXT: - return MESA_FORMAT_LUMINANCE_ALPHA_UINT32; - case GL_INTENSITY8: - return MESA_FORMAT_I8; - case GL_INTENSITY16: - return MESA_FORMAT_I16; - case GL_INTENSITY16F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT16; - case GL_INTENSITY32F_ARB: - return MESA_FORMAT_INTENSITY_FLOAT32; - case GL_INTENSITY8I_EXT: - return MESA_FORMAT_INTENSITY_INT8; - case GL_INTENSITY16I_EXT: - return MESA_FORMAT_INTENSITY_INT16; - case GL_INTENSITY32I_EXT: - return MESA_FORMAT_INTENSITY_INT32; - case GL_INTENSITY8UI_EXT: - return MESA_FORMAT_INTENSITY_UINT8; - case GL_INTENSITY16UI_EXT: - return MESA_FORMAT_INTENSITY_UINT16; - case GL_INTENSITY32UI_EXT: - return MESA_FORMAT_INTENSITY_UINT32; case GL_RGBA8: return MESA_FORMAT_RGBA8888_REV; case GL_RGBA16: -- 2.30.2