Skip to content

Commit

Permalink
vulkan/gpu: properly clamp vulkan buffer sizes
Browse files Browse the repository at this point in the history
Avoids triggering assertions added by 3bd1c97.

This is not a very elegant solution, by the way. Actually, it would be
better to query the maximum buffer size specifically for use as UBOs
etc, e.g. by allocating a test buffer and querying the driver for its
allowed memory types, then looking at only those memory types.
  • Loading branch information
haasn committed Oct 21, 2023
1 parent adc9d7f commit b63864e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/vulkan/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,18 @@ pl_gpu pl_gpu_create_vk(struct vk_ctx *vk)
gpu->glsl.max_gather_offset = limits.maxTexelGatherOffset;
}

const size_t max_size = vk_malloc_avail(vk->ma, 0);
gpu->limits = (struct pl_gpu_limits) {
// pl_gpu
.thread_safe = true,
.callbacks = true,
// pl_buf
.max_buf_size = vk_malloc_avail(vk->ma, 0),
.max_ubo_size = limits.maxUniformBufferRange,
.max_ssbo_size = limits.maxStorageBufferRange,
.max_buf_size = max_size,
.max_ubo_size = PL_MIN(limits.maxUniformBufferRange, max_size),
.max_ssbo_size = PL_MIN(limits.maxStorageBufferRange, max_size),
.max_vbo_size = vk_malloc_avail(vk->ma, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT),
.max_mapped_size = vk_malloc_avail(vk->ma, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT),
.max_buffer_texels = limits.maxTexelBufferElements,
.max_buffer_texels = PL_MIN(limits.maxTexelBufferElements, max_size),
.align_host_ptr = host_props.minImportedHostPointerAlignment,
.host_cached = vk_malloc_avail(vk->ma, VK_MEMORY_PROPERTY_HOST_CACHED_BIT),
// pl_tex
Expand Down

0 comments on commit b63864e

Please sign in to comment.