mesa: add check for NV_texture_barrier in _mesa_TextureBarrierNV()
authorBrian Paul <brianp@vmware.com>
Thu, 16 Apr 2015 21:27:41 +0000 (15:27 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 22 Apr 2015 14:58:05 +0000 (08:58 -0600)
If an app called glTextureBarrierNV() without checking if the
extension was available, we'd crash with some gallium drivers
in st_TextureBarrier() because the pipe_context::texture_barrier()
pointer was NULL.

Generate GL_INVALID_OPERATION instead.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/texturebarrier.c

index 08ff561504cc4c14fe03c8af1b1794302a564e07..d879eed57f27c933b166f886b9453007b0edf288 100644 (file)
@@ -49,5 +49,11 @@ _mesa_TextureBarrierNV(void)
 {
    GET_CURRENT_CONTEXT(ctx);
 
+   if (!ctx->Extensions.NV_texture_barrier) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glTextureBarrier(not supported)");
+      return;
+   }
+
    ctx->Driver.TextureBarrier(ctx);
 }