anv: Store host-located copy of NULL surface state for faster memcpy

Real null_surface_state is located in the GPU memory, so copying from
there will be slow for dGPUs.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10594
Signed-off-by: Sviatoslav Peleshko <sviatoslav.peleshko@globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27577>
This commit is contained in:
Sviatoslav Peleshko 2024-02-12 12:39:41 +02:00 committed by Marge Bot
parent 48a0a3112f
commit 28ad2f488a
3 changed files with 13 additions and 4 deletions

View file

@ -2088,7 +2088,7 @@ anv_descriptor_set_write_image_view(struct anv_device *device,
p, desc->layout),
ANV_SURFACE_STATE_SIZE);
} else {
memcpy(plane_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
memcpy(plane_map, &device->host_null_surface_state, ANV_SURFACE_STATE_SIZE);
}
}
}
@ -2107,7 +2107,7 @@ anv_descriptor_set_write_image_view(struct anv_device *device,
p, desc->layout),
ANV_SURFACE_STATE_SIZE);
} else {
memcpy(plane_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
memcpy(plane_map, &device->host_null_surface_state, ANV_SURFACE_STATE_SIZE);
}
if (sampler) {
@ -2166,7 +2166,7 @@ anv_descriptor_set_write_buffer_view(struct anv_device *device,
if (buffer_view == NULL) {
if (data & ANV_DESCRIPTOR_SURFACE)
memcpy(desc_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
memcpy(desc_map, &device->host_null_surface_state, ANV_SURFACE_STATE_SIZE);
else
memset(desc_map, 0, bind_layout->descriptor_surface_stride);
return;
@ -2252,7 +2252,7 @@ anv_descriptor_set_write_buffer(struct anv_device *device,
if (buffer == NULL) {
if (data & ANV_DESCRIPTOR_SURFACE)
memcpy(desc_map, device->null_surface_state.map, ANV_SURFACE_STATE_SIZE);
memcpy(desc_map, &device->host_null_surface_state, ANV_SURFACE_STATE_SIZE);
else
memset(desc_map, 0, bind_layout->descriptor_surface_stride);
return;

View file

@ -3542,6 +3542,9 @@ VkResult anv_CreateDevice(
.size = isl_extent3d(1, 1, 1) /* This shouldn't matter */);
}
isl_null_fill_state(&device->isl_dev, &device->host_null_surface_state,
.size = isl_extent3d(1, 1, 1) /* This shouldn't matter */);
anv_scratch_pool_init(device, &device->scratch_pool);
/* TODO(RT): Do we want some sort of data structure for this? */

View file

@ -1714,6 +1714,12 @@ struct anv_device {
struct anv_bo * trivial_batch_bo;
struct anv_state null_surface_state;
/**
* NULL surface state copy stored in host memory for use as a fast
* memcpy() source.
*/
char host_null_surface_state[ANV_SURFACE_STATE_SIZE];
struct vk_pipeline_cache * default_pipeline_cache;
struct vk_pipeline_cache * internal_cache;
struct blorp_context blorp;