aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texobj.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/texobj.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/texobj.c')
-rw-r--r--src/mesa/main/texobj.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 5d49ce7924c..5c57266d361 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -219,6 +219,42 @@ _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target)
/**
+ * 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.
*