st/mesa: fix crash when a shader uses a TBO and it's not bound
authorMarek Olšák <marek.olsak@amd.com>
Thu, 6 Feb 2014 01:16:50 +0000 (02:16 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 6 Feb 2014 16:29:59 +0000 (17:29 +0100)
This binds a NULL sampler view in that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74251

Cc: "10.1" "10.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_texture.c

index 81a5d9b4dfbb1f2e0f28df69a146c1c815b5a3e8..824a13e205d31e2eaec25983835b92a65c37ec45 100644 (file)
@@ -1483,6 +1483,12 @@ st_finalize_texture(struct gl_context *ctx,
    if (tObj->Target == GL_TEXTURE_BUFFER) {
       struct st_buffer_object *st_obj = st_buffer_object(tObj->BufferObject);
 
+      if (!st_obj) {
+         pipe_resource_reference(&stObj->pt, NULL);
+         pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+         return GL_TRUE;
+      }
+
       if (st_obj->buffer != stObj->pt) {
          pipe_resource_reference(&stObj->pt, st_obj->buffer);
          pipe_sampler_view_release(st->pipe, &stObj->sampler_view);