}
+/**
+ * Get the texture object for given target and texunit
+ * Proxy targets are accepted only allowProxyTarget is true.
+ * Return NULL if any error (and record the error).
+ */
+struct gl_texture_object *
+_mesa_get_texobj_by_target_and_texunit(struct gl_context *ctx, GLenum target,
+ GLuint texunit, bool allowProxyTarget,
+ const char* caller)
+{
+ struct gl_texture_unit *texUnit;
+ int targetIndex;
+
+ if (_mesa_is_proxy_texture(target) && allowProxyTarget) {
+ return _mesa_get_current_tex_object(ctx, target);
+ }
+
+ if (texunit >= ctx->Const.MaxCombinedTextureImageUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(texunit=%d)", caller, texunit);
+ return NULL;
+ }
+
+ texUnit = _mesa_get_tex_unit(ctx, texunit);
+
+ targetIndex = _mesa_tex_target_to_index(ctx, target);
+ if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", caller);
+ return NULL;
+ }
+ assert(targetIndex < NUM_TEXTURE_TARGETS);
+
+ return texUnit->CurrentTex[targetIndex];
+}
+
+
/**
* Allocate and initialize a new texture object. But don't put it into the
* texture object hash table.
}
-/**
- * Get current texture object for given target.
- * Return NULL if any error (and record the error).
- * Note that this is different from _mesa_get_current_tex_object() in that
- * proxy targets are not accepted.
- * Only the glGetTexLevelParameter() functions accept proxy targets.
- */
-static struct gl_texture_object *
-get_texobj_by_target(struct gl_context *ctx, GLenum target, GLboolean get)
-{
- struct gl_texture_unit *texUnit;
- int targetIndex;
-
- if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "gl%sTexParameter(current unit)", get ? "Get" : "");
- return NULL;
- }
-
- texUnit = _mesa_get_current_tex_unit(ctx);
-
- targetIndex = _mesa_tex_target_to_index(ctx, target);
- if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "gl%sTexParameter(target)", get ? "Get" : "");
- return NULL;
- }
- assert(targetIndex < NUM_TEXTURE_TARGETS);
-
- return texUnit->CurrentTex[targetIndex];
-}
-
-
static bool
is_texparameteri_target_valid(GLenum target)
{
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameterf");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameterfv");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameteri");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameteriv");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameterIiv");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_FALSE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glTexParameterIuiv");
if (!texObj)
return;
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- obj = get_texobj_by_target(ctx, target, GL_TRUE);
+ obj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glGetTexParameterfv");
if (!obj)
return;
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
- obj = get_texobj_by_target(ctx, target, GL_TRUE);
+ obj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glGetTexParameteriv");
if (!obj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_TRUE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glGetTexParameterIiv");
if (!texObj)
return;
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
- texObj = get_texobj_by_target(ctx, target, GL_TRUE);
+ texObj = _mesa_get_texobj_by_target_and_texunit(ctx, target,
+ ctx->Texture.CurrentUnit,
+ false,
+ "glGetTexParameterIuiv");
if (!texObj)
return;