zink: clamp UBO sizes instead of asserting
this is a nice idea, but there are apps/games that do not respect hardware capabilities and yolo-bind fixed size buffers fixes Ballionaire (2667120) launch on non-desktop drivers cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33819>
This commit is contained in:
committed by
Marge Bot
parent
df1ff3c711
commit
b04eaa8589
@@ -678,9 +678,14 @@ update_descriptor_state_ubo_db(struct zink_context *ctx, gl_shader_stage shader,
|
||||
ctx->di.descriptor_res[ZINK_DESCRIPTOR_TYPE_UBO][shader][slot] = res;
|
||||
if (res) {
|
||||
ctx->di.db.ubos[shader][slot].address = res->obj->bda + ctx->ubos[shader][slot].buffer_offset;
|
||||
ctx->di.db.ubos[shader][slot].range = ctx->ubos[shader][slot].buffer_size;
|
||||
assert(ctx->di.db.ubos[shader][slot].range == VK_WHOLE_SIZE ||
|
||||
ctx->di.db.ubos[shader][slot].range <= screen->info.props.limits.maxUniformBufferRange);
|
||||
ctx->di.db.ubos[shader][slot].range = MIN2(ctx->ubos[shader][slot].buffer_size, screen->info.props.limits.maxUniformBufferRange);
|
||||
#ifndef NDEBUG
|
||||
static bool warned = false;
|
||||
if (!warned && ctx->ubos[shader][slot].buffer_size > screen->info.props.limits.maxUniformBufferRange) {
|
||||
mesa_loge("ZINK: app is binding too-big UBO! Clamping!");
|
||||
warned = true;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ctx->di.db.ubos[shader][slot].address = 0;
|
||||
ctx->di.db.ubos[shader][slot].range = VK_WHOLE_SIZE;
|
||||
@@ -696,10 +701,15 @@ update_descriptor_state_ubo_lazy(struct zink_context *ctx, gl_shader_stage shade
|
||||
ctx->di.descriptor_res[ZINK_DESCRIPTOR_TYPE_UBO][shader][slot] = res;
|
||||
if (res) {
|
||||
ctx->di.t.ubos[shader][slot].buffer = res->obj->buffer;
|
||||
ctx->di.t.ubos[shader][slot].range = ctx->ubos[shader][slot].buffer_size;
|
||||
assert(ctx->di.t.ubos[shader][slot].range <= screen->info.props.limits.maxUniformBufferRange);
|
||||
}
|
||||
else {
|
||||
ctx->di.t.ubos[shader][slot].range = MIN2(ctx->ubos[shader][slot].buffer_size, screen->info.props.limits.maxUniformBufferRange);
|
||||
#ifndef NDEBUG
|
||||
static bool warned = false;
|
||||
if (!warned && ctx->ubos[shader][slot].buffer_size > screen->info.props.limits.maxUniformBufferRange) {
|
||||
mesa_loge("ZINK: app is binding too-big UBO! Clamping!");
|
||||
warned = true;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
bool have_null_descriptors = screen->info.rb2_feats.nullDescriptor;
|
||||
VkBuffer null_buffer = zink_resource(ctx->dummy_vertex_buffer)->obj->buffer;
|
||||
ctx->di.t.ubos[shader][slot].buffer = have_null_descriptors ? VK_NULL_HANDLE : null_buffer;
|
||||
|
||||
Reference in New Issue
Block a user