+ struct gl_texture_object *tex)
+{
+ if (*ptr != tex)
+ _mesa_reference_texobj_(ptr, tex);
+}
+
+/**
+ * Lock a texture for updating. See also _mesa_lock_context_textures().
+ */
+static inline void
+_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
+{
+ mtx_lock(&ctx->Shared->TexMutex);
+ ctx->Shared->TextureStateStamp++;
+ (void) texObj;
+}
+
+static inline void
+_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
+{
+ (void) texObj;
+ mtx_unlock(&ctx->Shared->TexMutex);
+}
+
+
+/** Is the texture "complete" with respect to the given sampler state? */
+static inline GLboolean
+_mesa_is_texture_complete(const struct gl_texture_object *texObj,
+ const struct gl_sampler_object *sampler)
+{
+ /*
+ * According to ARB_stencil_texturing, NEAREST_MIPMAP_NEAREST would
+ * be forbidden, however it is allowed per GL 4.5 rules, allow it
+ * even without GL 4.5 since it was a spec mistake.
+ */
+ if ((texObj->_IsIntegerFormat ||
+ (texObj->StencilSampling &&
+ texObj->Image[0][texObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL)) &&
+ (sampler->MagFilter != GL_NEAREST ||
+ (sampler->MinFilter != GL_NEAREST &&
+ sampler->MinFilter != GL_NEAREST_MIPMAP_NEAREST))) {
+ /* If the format is integer, only nearest filtering is allowed */
+ return GL_FALSE;
+ }
+
+ if (_mesa_is_mipmap_filter(sampler))
+ return texObj->_MipmapComplete;
+ else
+ return texObj->_BaseComplete;
+}
+