panvk: do not handle illegal null

The Vulkan spec says that VkBindBufferMemoryInfo::memory must be a valid
VkDeviceMemory handle, see

https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkBindBufferMemoryInfo-memory-parameter

So let's assert instead here.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27910>
This commit is contained in:
Erik Faye-Lund 2024-03-01 11:17:07 +01:00 committed by Marge Bot
parent 5a7e58a430
commit 3711964f33

View file

@ -1459,43 +1459,29 @@ panvk_BindBufferMemory2(VkDevice device, uint32_t bindInfoCount,
VK_FROM_HANDLE(panvk_buffer, buffer, pBindInfos[i].buffer);
struct pan_kmod_bo *old_bo = buffer->bo;
if (mem) {
buffer->bo = pan_kmod_bo_get(mem->bo);
buffer->dev_addr = mem->addr.dev + pBindInfos[i].memoryOffset;
assert(mem != NULL);
/* FIXME: Only host map for index buffers so we can do the min/max
* index retrieval on the CPU. This is all broken anyway and the
* min/max search should be done with a compute shader that also
* patches the job descriptor accordingly (basically an indirect draw).
*
* Make sure this goes away as soon as we fixed indirect draws.
*/
if (buffer->vk.usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT) {
VkDeviceSize offset = pBindInfos[i].memoryOffset;
VkDeviceSize pgsize = getpagesize();
off_t map_start = offset & ~(pgsize - 1);
off_t map_end = offset + buffer->vk.size;
void *map_addr =
pan_kmod_bo_mmap(mem->bo, map_start, map_end - map_start,
PROT_WRITE, MAP_SHARED, NULL);
buffer->bo = pan_kmod_bo_get(mem->bo);
buffer->dev_addr = mem->addr.dev + pBindInfos[i].memoryOffset;
assert(map_addr != MAP_FAILED);
buffer->host_ptr = map_addr + (offset & pgsize);
}
} else {
buffer->bo = NULL;
buffer->dev_addr = 0;
buffer->host_ptr = NULL;
if (buffer->host_ptr) {
VkDeviceSize pgsize = getpagesize();
uintptr_t map_start = (uintptr_t)buffer->host_ptr & ~(pgsize - 1);
uintptr_t map_end = (uintptr_t)buffer->host_ptr + buffer->vk.size;
ASSERTED int ret =
os_munmap((void *)map_start, map_end - map_start);
/* FIXME: Only host map for index buffers so we can do the min/max
* index retrieval on the CPU. This is all broken anyway and the
* min/max search should be done with a compute shader that also
* patches the job descriptor accordingly (basically an indirect draw).
*
* Make sure this goes away as soon as we fixed indirect draws.
*/
if (buffer->vk.usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT) {
VkDeviceSize offset = pBindInfos[i].memoryOffset;
VkDeviceSize pgsize = getpagesize();
off_t map_start = offset & ~(pgsize - 1);
off_t map_end = offset + buffer->vk.size;
void *map_addr =
pan_kmod_bo_mmap(mem->bo, map_start, map_end - map_start,
PROT_WRITE, MAP_SHARED, NULL);
assert(!ret);
buffer->host_ptr = NULL;
}
assert(map_addr != MAP_FAILED);
buffer->host_ptr = map_addr + (offset & pgsize);
}
pan_kmod_bo_put(old_bo);