v3dv: drop assert for map of a mapped buffer

This triggers when dumping CLIF because the dump process involves
internally mapping all the BOs. We could unmap them there after we
are done, but there is really no reason why we need to assert on this,
so let's just keep things simple and unmap. If the user is really
double mapping, that should be caught by the validation layers.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga
2020-03-11 12:56:34 +01:00
committed by Marge Bot
parent 75b1dea4e2
commit f986a60451
+17 -8
View File
@@ -1250,18 +1250,34 @@ device_free(struct v3dv_device *device, struct v3dv_device_memory *mem)
v3dv_bo_free(device, mem->bo);
}
static void
device_unmap(struct v3dv_device *device, struct v3dv_device_memory *mem)
{
assert(mem && mem->bo->map && mem->bo->map_size > 0);
v3dv_bo_unmap(device, mem->bo);
}
static VkResult
device_map(struct v3dv_device *device,
struct v3dv_device_memory *mem,
uint32_t size)
{
assert(mem && mem->bo);
/* From the spec:
*
* "After a successful call to vkMapMemory the memory object memory is
* considered to be currently host mapped. It is an application error to
* call vkMapMemory on a memory object that is already host mapped."
*
* We are not concerned with this ourselves (validation layers should
* catch these errors and warn users), however, the driver may internally
* map things (for example for debug CLIF dumps) so by the time the user
* call here the buffer might already been mapped internally, so let's just
* make sure we unmap if needed.
*/
assert(mem && mem->bo->map == NULL);
if (mem->bo->map)
device_unmap(device, mem);
bool ok = v3dv_bo_map(device, mem->bo, size);
if (!ok)
@@ -1270,13 +1286,6 @@ device_map(struct v3dv_device *device,
return VK_SUCCESS;
}
static void
device_unmap(struct v3dv_device *device, struct v3dv_device_memory *mem)
{
assert(mem && mem->bo->map && mem->bo->map_size > 0);
v3dv_bo_unmap(device, mem->bo);
}
static VkResult
device_import_bo(struct v3dv_device *device,
const VkAllocationCallbacks *pAllocator,