mesa: update GL_CLAMP emulation when binding/unbinding textures
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 11 Jul 2022 12:44:00 +0000 (08:44 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 15 Jul 2022 18:58:15 +0000 (18:58 +0000)
binding/unbinding a texture affects the previously specified parameters,
so ensure the driver flag for clamp emulation is also set to perform
updates as needed

Fixes: e8f71f6ac48 ("mesa/st: add PIPE_CAP_GL_CLAMP")

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17459>

src/mesa/main/texobj.c

index 8e8cbb9..7637acd 100644 (file)
@@ -1619,6 +1619,14 @@ bind_texture_object(struct gl_context *ctx, unsigned unit,
     */
    FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT, GL_TEXTURE_BIT);
 
+   /* if the previously bound texture uses GL_CLAMP, flag the driver here
+    * to ensure any emulation is disabled
+    */
+   if (texUnit->CurrentTex[targetIndex] &&
+       texUnit->CurrentTex[targetIndex]->Sampler.glclamp_mask !=
+       texObj->Sampler.glclamp_mask)
+      ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
+
    /* If the refcount on the previously bound texture is decremented to
     * zero, it'll be deleted here.
     */