aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texparam.c')
-rw-r--r--mesalib/src/mesa/main/texparam.c137
1 files changed, 64 insertions, 73 deletions
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 4909b76cb..6e14face4 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -33,6 +33,7 @@
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/context.h"
+#include "main/enums.h"
#include "main/formats.h"
#include "main/macros.h"
#include "main/mfeatures.h"
@@ -116,12 +117,14 @@ get_texobj(struct gl_context *ctx, GLenum target, GLboolean get)
}
break;
case GL_TEXTURE_1D_ARRAY_EXT:
- if (ctx->Extensions.MESA_texture_array) {
+ if (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array) {
return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX];
}
break;
case GL_TEXTURE_2D_ARRAY_EXT:
- if (ctx->Extensions.MESA_texture_array) {
+ if (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array) {
return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX];
}
break;
@@ -231,8 +234,7 @@ set_tex_parameteri(struct gl_context *ctx,
}
/* fall-through */
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)",
- params[0] );
+ goto invalid_param;
}
return GL_FALSE;
@@ -246,8 +248,7 @@ set_tex_parameteri(struct gl_context *ctx,
texObj->MagFilter = params[0];
return GL_TRUE;
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(param=0x%x)",
- params[0]);
+ goto invalid_param;
}
return GL_FALSE;
@@ -315,21 +316,18 @@ set_tex_parameteri(struct gl_context *ctx,
return GL_FALSE;
case GL_TEXTURE_COMPARE_MODE_ARB:
- if (ctx->Extensions.ARB_shadow &&
- (params[0] == GL_NONE ||
- params[0] == GL_COMPARE_R_TO_TEXTURE_ARB)) {
- if (texObj->CompareMode != params[0]) {
+ if (ctx->Extensions.ARB_shadow) {
+ if (texObj->CompareMode == params[0])
+ return GL_FALSE;
+ if (params[0] == GL_NONE ||
+ params[0] == GL_COMPARE_R_TO_TEXTURE_ARB) {
flush(ctx);
texObj->CompareMode = params[0];
return GL_TRUE;
}
- return GL_FALSE;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexParameter(GL_TEXTURE_COMPARE_MODE_ARB)");
+ goto invalid_param;
}
- return GL_FALSE;
+ goto invalid_pname;
case GL_TEXTURE_COMPARE_FUNC_ARB:
if (ctx->Extensions.ARB_shadow) {
@@ -354,32 +352,26 @@ set_tex_parameteri(struct gl_context *ctx,
}
/* fall-through */
default:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexParameter(GL_TEXTURE_COMPARE_FUNC_ARB)");
+ goto invalid_param;
}
}
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
- }
- return GL_FALSE;
+ goto invalid_pname;
case GL_DEPTH_TEXTURE_MODE_ARB:
- if (ctx->Extensions.ARB_depth_texture &&
- (params[0] == GL_LUMINANCE ||
- params[0] == GL_INTENSITY ||
- params[0] == GL_ALPHA ||
- (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED))) {
- if (texObj->DepthMode != params[0]) {
+ if (ctx->Extensions.ARB_depth_texture) {
+ if (texObj->DepthMode == params[0])
+ return GL_FALSE;
+ if (params[0] == GL_LUMINANCE ||
+ params[0] == GL_INTENSITY ||
+ params[0] == GL_ALPHA ||
+ (ctx->Extensions.ARB_texture_rg && params[0] == GL_RED)) {
flush(ctx);
texObj->DepthMode = params[0];
return GL_TRUE;
}
+ goto invalid_param;
}
- else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glTexParameter(GL_DEPTH_TEXTURE_MODE_ARB)");
- }
- return GL_FALSE;
+ goto invalid_pname;
#if FEATURE_OES_draw_texture
case GL_TEXTURE_CROP_RECT_OES:
@@ -410,8 +402,7 @@ set_tex_parameteri(struct gl_context *ctx,
return GL_TRUE;
}
}
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
- return GL_FALSE;
+ goto invalid_pname;
case GL_TEXTURE_SWIZZLE_RGBA_EXT:
if (ctx->Extensions.EXT_texture_swizzle) {
@@ -431,8 +422,8 @@ set_tex_parameteri(struct gl_context *ctx,
}
return GL_TRUE;
}
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
- return GL_FALSE;
+ goto invalid_pname;
+
case GL_TEXTURE_SRGB_DECODE_EXT:
if (ctx->Extensions.EXT_texture_sRGB_decode) {
GLenum decode = params[0];
@@ -445,11 +436,20 @@ set_tex_parameteri(struct gl_context *ctx,
return GL_TRUE;
}
}
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
- return GL_FALSE;
+ goto invalid_pname;
+
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
+ goto invalid_pname;
}
+
+invalid_pname:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=%s)",
+ _mesa_lookup_enum_by_nr(pname));
+ return GL_FALSE;
+
+invalid_param:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param=%s)",
+ _mesa_lookup_enum_by_nr(params[0]));
return GL_FALSE;
}
@@ -834,7 +834,6 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
const struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
const struct gl_texture_image *img = NULL;
- GLboolean isProxy;
GLint maxLevels;
gl_format texFormat;
GET_CURRENT_CONTEXT(ctx);
@@ -862,7 +861,6 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
}
texObj = _mesa_select_tex_object(ctx, texUnit, target);
- _mesa_lock_texture(ctx, texObj);
img = _mesa_select_tex_image(ctx, texObj, target, level);
if (!img || !img->TexFormat) {
@@ -871,13 +869,11 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
*params = 1;
else
*params = 0;
- goto out;
+ return;
}
texFormat = img->TexFormat;
- isProxy = _mesa_is_proxy_texture(target);
-
switch (pname) {
case GL_TEXTURE_WIDTH:
*params = img->Width;
@@ -889,9 +885,9 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
*params = img->Depth;
break;
case GL_TEXTURE_INTERNAL_FORMAT:
- if (_mesa_is_format_compressed(img->TexFormat)) {
+ if (_mesa_is_format_compressed(texFormat)) {
/* need to return the actual compressed format */
- *params = _mesa_compressed_format_to_glenum(ctx, img->TexFormat);
+ *params = _mesa_compressed_format_to_glenum(ctx, texFormat);
}
else {
/* return the user's requested internal format */
@@ -962,8 +958,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
if (ctx->Extensions.ARB_depth_texture)
*params = _mesa_get_format_bits(texFormat, pname);
else
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
break;
case GL_TEXTURE_STENCIL_SIZE_EXT:
if (ctx->Extensions.EXT_packed_depth_stencil ||
@@ -971,8 +966,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
*params = _mesa_get_format_bits(texFormat, pname);
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_SHARED_SIZE:
@@ -983,14 +977,14 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
*params = 0;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
- if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) {
+ if (_mesa_is_format_compressed(texFormat) &&
+ !_mesa_is_proxy_texture(target)) {
*params = _mesa_format_image_size(texFormat, img->Width,
img->Height, img->Depth);
}
@@ -1000,7 +994,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
}
break;
case GL_TEXTURE_COMPRESSED:
- *params = (GLint) _mesa_is_format_compressed(img->TexFormat);
+ *params = (GLint) _mesa_is_format_compressed(texFormat);
break;
/* GL_ARB_texture_float */
@@ -1010,8 +1004,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_GREEN_TYPE_ARB:
@@ -1020,8 +1013,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_BLUE_TYPE_ARB:
@@ -1030,8 +1022,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_ALPHA_TYPE_ARB:
@@ -1040,8 +1031,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_LUMINANCE_TYPE_ARB:
@@ -1050,8 +1040,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_INTENSITY_TYPE_ARB:
@@ -1060,8 +1049,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
case GL_TEXTURE_DEPTH_TYPE_ARB:
@@ -1070,18 +1058,21 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
_mesa_get_format_datatype(texFormat) : GL_NONE;
}
else {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
break;
default:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetTexLevelParameter[if]v(pname)");
+ goto invalid_pname;
}
- out:
- _mesa_unlock_texture(ctx, texObj);
+ /* no error if we get here */
+ return;
+
+invalid_pname:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname=%s)",
+ _mesa_lookup_enum_by_nr(pname));
}