mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
tu: Make tu_image point to tu_device_memory instead of tu_bo
Up until now tu_device_memory (turnip's VkDeviceMemory) was a thin wrapper around tu_bo (the GEM BO), so when binding an image to a VkDeviceMemory we could just store the BO. But now we have to skip allocating the BO unless we need to for lazily-allocated memory, and the tracking for that needs to happen at the API level instead of the kernel/GEM level, so store the tu_device_memory instead. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37151>
This commit is contained in:
parent
88d001383a
commit
3b990ba210
7 changed files with 26 additions and 26 deletions
|
|
@ -2566,9 +2566,9 @@ tu_copy_memory_to_image(struct tu_device *device,
|
|||
&device->physical_device->ubwc_config);
|
||||
}
|
||||
|
||||
if (dst_image->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, dst_image->bo,
|
||||
dst_image->bo_offset + image_offset,
|
||||
if (dst_image->mem->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, dst_image->mem->bo,
|
||||
dst_image->mem_offset + image_offset,
|
||||
dst_layer_size, TU_MEM_SYNC_CACHE_TO_GPU);
|
||||
}
|
||||
}
|
||||
|
|
@ -2751,9 +2751,9 @@ tu_copy_image_to_memory(struct tu_device *device,
|
|||
char *dst = (char *) info->pHostPointer;
|
||||
for (unsigned layer = 0; layer < layers; layer++,
|
||||
src += src_layer_stride, dst += dst_layer_stride) {
|
||||
if (src_image->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, src_image->bo,
|
||||
src_image->bo_offset + image_offset,
|
||||
if (src_image->mem->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, src_image->mem->bo,
|
||||
src_image->mem_offset + image_offset,
|
||||
src_layer_size, TU_MEM_SYNC_CACHE_FROM_GPU);
|
||||
}
|
||||
|
||||
|
|
@ -3134,9 +3134,9 @@ tu_copy_image_to_image_cpu(struct tu_device *device,
|
|||
char *dst = (char *) dst_image->map + dst_image_offset;
|
||||
for (unsigned layer = 0; layer < layers_to_copy; layer++,
|
||||
src += src_layer_stride, dst += dst_layer_stride) {
|
||||
if (src_image->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, src_image->bo,
|
||||
src_image->bo_offset + src_image_offset,
|
||||
if (src_image->mem->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, src_image->mem->bo,
|
||||
src_image->mem_offset + src_image_offset,
|
||||
src_layer_size, TU_MEM_SYNC_CACHE_FROM_GPU);
|
||||
}
|
||||
|
||||
|
|
@ -3214,9 +3214,9 @@ tu_copy_image_to_image_cpu(struct tu_device *device,
|
|||
}
|
||||
}
|
||||
|
||||
if (dst_image->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, dst_image->bo,
|
||||
dst_image->bo_offset + dst_image_offset,
|
||||
if (dst_image->mem->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(device, dst_image->mem->bo,
|
||||
dst_image->mem_offset + dst_image_offset,
|
||||
dst_layer_size, TU_MEM_SYNC_CACHE_TO_GPU);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2480,8 +2480,8 @@ tu_trace_end_render_pass(struct tu_cmd_buffer *cmd, bool gmem)
|
|||
struct u_trace_address addr = {};
|
||||
if (cmd->state.lrz.image_view) {
|
||||
struct tu_image *image = cmd->state.lrz.image_view->image;
|
||||
addr.bo = image->bo;
|
||||
addr.offset = (image->iova - image->bo->iova) +
|
||||
addr.bo = image->mem->bo;
|
||||
addr.offset = (image->iova - image->mem->bo->iova) +
|
||||
image->lrz_layout.lrz_fc_offset +
|
||||
offsetof(fd_lrzfc_layout<CHIP>, dir_track);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1003,8 +1003,8 @@ tu_image_bind(struct tu_device *device,
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
image->bo = mem->bo;
|
||||
image->bo_offset = offset;
|
||||
image->mem = mem;
|
||||
image->mem_offset = offset;
|
||||
image->iova = mem->bo->iova + offset;
|
||||
|
||||
if (image->vk.usage & (VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT |
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ struct tu_image
|
|||
uint64_t iova;
|
||||
union {
|
||||
struct {
|
||||
struct tu_bo *bo;
|
||||
uint64_t bo_offset;
|
||||
struct tu_device_memory *mem;
|
||||
uint64_t mem_offset;
|
||||
};
|
||||
struct tu_sparse_vma vma;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -630,10 +630,10 @@ tu_disable_lrz_cpu(struct tu_device *device, struct tu_image *image)
|
|||
|
||||
*lrz_dir_tracking = FD_LRZ_GPU_DIR_DISABLED;
|
||||
|
||||
if (image->bo->cached_non_coherent) {
|
||||
if (image->mem->bo->cached_non_coherent) {
|
||||
tu_bo_sync_cache(
|
||||
device, image->bo,
|
||||
image->bo_offset + image->lrz_layout.lrz_offset + lrz_dir_offset, 1,
|
||||
device, image->mem->bo,
|
||||
image->mem_offset + image->lrz_layout.lrz_offset + lrz_dir_offset, 1,
|
||||
TU_MEM_SYNC_CACHE_TO_GPU);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -618,13 +618,13 @@ log_mem(struct tu_device *dev, struct tu_buffer *buffer, struct tu_image *image,
|
|||
if (buffer) {
|
||||
event->set_source(perfetto::protos::pbzero::perfetto_pbzero_enum_VulkanMemoryEvent::SOURCE_BUFFER);
|
||||
event->set_memory_size(buffer->vk.size);
|
||||
if (buffer->bo)
|
||||
if (buffer->vk.device_address)
|
||||
event->set_memory_address(buffer->vk.device_address);
|
||||
} else {
|
||||
assert(image);
|
||||
event->set_source(perfetto::protos::pbzero::perfetto_pbzero_enum_VulkanMemoryEvent::SOURCE_IMAGE);
|
||||
event->set_memory_size(image->layout[0].size);
|
||||
if (image->bo)
|
||||
if (image->iova)
|
||||
event->set_memory_address(image->iova);
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +666,7 @@ tu_perfetto_log_bind_image(struct tu_device *dev, struct tu_image *image)
|
|||
void
|
||||
tu_perfetto_log_destroy_image(struct tu_device *dev, struct tu_image *image)
|
||||
{
|
||||
log_mem(dev, NULL, image, image->bo ?
|
||||
log_mem(dev, NULL, image, image->mem ?
|
||||
perfetto::protos::pbzero::perfetto_pbzero_enum_VulkanMemoryEvent::OP_DESTROY_BOUND :
|
||||
perfetto::protos::pbzero::perfetto_pbzero_enum_VulkanMemoryEvent::OP_DESTROY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -339,8 +339,8 @@ tu_rmv_log_image_bind(struct tu_device *device, struct tu_image *image)
|
|||
{
|
||||
simple_mtx_lock(&device->vk.memory_trace_data.token_mtx);
|
||||
|
||||
uint64_t address = image->bo ? image->iova : 0;
|
||||
uint64_t size = image->bo ? image->total_size : 0;
|
||||
uint64_t address = image->iova;
|
||||
uint64_t size = image->iova ? image->total_size : 0;
|
||||
tu_rmv_emit_resource_bind_locked(device,
|
||||
tu_rmv_get_resource_id_locked(device, image),
|
||||
address, size);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue