From 72a38b37920ef7bb37aec3aa842f655c042967f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 4 Jan 2024 02:22:05 -0500 Subject: [PATCH] st/mesa: remove !obj checking in _mesa_get_bufferobj_reference when it's useless There is at least one case in a future commit where the compiler can't do this automatically. Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-By: Mike Blumenkrantz Part-of: --- src/mesa/main/bufferobj.h | 6 ++---- src/mesa/state_tracker/st_atom_constbuf.c | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index d3729c68d39..0b4c8f80a85 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -36,12 +36,10 @@ * Internal functions */ -static inline struct pipe_resource * +static ALWAYS_INLINE struct pipe_resource * _mesa_get_bufferobj_reference(struct gl_context *ctx, struct gl_buffer_object *obj) { - if (unlikely(!obj)) - return NULL; - + assert(obj); struct pipe_resource *buffer = obj->buffer; /* Only one context is using the fast path. All other contexts must use diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 50937acbeba..bd4903a5160 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -282,7 +282,12 @@ st_bind_ubos(struct st_context *st, struct gl_program *prog, binding = &st->ctx->UniformBufferBindings[prog->sh.UniformBlocks[i]->Binding]; - cb.buffer = _mesa_get_bufferobj_reference(st->ctx, binding->BufferObject); + if (binding->BufferObject) { + cb.buffer = _mesa_get_bufferobj_reference(st->ctx, + binding->BufferObject); + } else { + cb.buffer = NULL; + } if (cb.buffer) { cb.buffer_offset = binding->Offset;