Mesa (master): st/mesa: bail out of try_pbo_upload_common when constant upload fails

Nicolai Hähnle nh at kemper.freedesktop.org
Fri Feb 5 14:24:30 UTC 2016


Module: Mesa
Branch: master
Commit: 7e9670c8bc9422296ce07dce99e1d266063952c3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e9670c8bc9422296ce07dce99e1d266063952c3

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Wed Feb  3 18:02:55 2016 +0100

st/mesa: bail out of try_pbo_upload_common when constant upload fails

Also fixes a resource leak when an upload_mgr is used for constants.

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/state_tracker/st_cb_texture.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 84dfc70..f2b607c 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1434,6 +1434,9 @@ try_pbo_upload_common(struct gl_context *ctx,
          u_upload_data(st->constbuf_uploader, 0, sizeof(constants),
                        st->ctx->Const.UniformBufferOffsetAlignment,
                        &constants, &cb.buffer_offset, &cb.buffer);
+         if (!cb.buffer)
+            goto fail_constant_upload;
+
          u_upload_unmap(st->constbuf_uploader);
       } else {
          cb.buffer = NULL;
@@ -1444,6 +1447,8 @@ try_pbo_upload_common(struct gl_context *ctx,
 
       cso_save_constant_buffer_slot0(st->cso_context, PIPE_SHADER_FRAGMENT);
       cso_set_constant_buffer(st->cso_context, PIPE_SHADER_FRAGMENT, 0, &cb);
+
+      pipe_resource_reference(&cb.buffer, NULL);
    }
 
    /* Framebuffer_state */
@@ -1524,6 +1529,7 @@ try_pbo_upload_common(struct gl_context *ctx,
    cso_restore_fragment_shader(st->cso_context);
    cso_restore_stream_outputs(st->cso_context);
    cso_restore_constant_buffer_slot0(st->cso_context, PIPE_SHADER_FRAGMENT);
+fail_constant_upload:
    cso_restore_vertex_elements(st->cso_context);
    cso_restore_aux_vertex_buffer_slot(st->cso_context);
 fail_vertex_upload:




More information about the mesa-commit mailing list