summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texparam.c
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <[email protected]>2019-04-30 13:37:12 +0200
committerMarek Olšák <[email protected]>2019-08-06 17:03:06 -0400
commit0e595326c4d728f17abc7c72f9a263965ff65da9 (patch)
tree4ef8581dd85d9010d7acb9993965f9531f21ceee /src/mesa/main/texparam.c
parent58030d2b3ded667585f4f5e7bc459008f7ba7e8f (diff)
mesa: add new helper _mesa_get_texobj_by_target_and_texunit
Based on the 'static get_texobj_by_target' function from texparam.c, but extended to also take the texunit as a parameter. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/main/texparam.c')
-rw-r--r--src/mesa/main/texparam.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index f3a01ae65e5..78888b660fa 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -114,39 +114,6 @@ validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap)
}
-/**
- * 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)
{
@@ -1096,7 +1063,10 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
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;
@@ -1109,7 +1079,10 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
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;
@@ -1122,7 +1095,10 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
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;
@@ -1135,7 +1111,10 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
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;
@@ -1153,7 +1132,10 @@ _mesa_TexParameterIiv(GLenum target, GLenum pname, const GLint *params)
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;
@@ -1171,7 +1153,10 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
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;
@@ -2445,7 +2430,10 @@ _mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
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;
@@ -2458,7 +2446,10 @@ _mesa_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
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;
@@ -2472,7 +2463,10 @@ _mesa_GetTexParameterIiv(GLenum target, GLenum pname, GLint *params)
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;
@@ -2487,7 +2481,10 @@ _mesa_GetTexParameterIuiv(GLenum target, GLenum pname, GLuint *params)
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;