anv: add a protected scratch pool
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Reviewed-by: Ivan Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29778>
This commit is contained in:

committed by
Marge Bot

parent
c0138e99e6
commit
08a4e0a2e3
@@ -1297,9 +1297,13 @@ anv_bo_pool_free(struct anv_bo_pool *pool, struct anv_bo *bo)
|
|||||||
// Scratch pool
|
// Scratch pool
|
||||||
|
|
||||||
void
|
void
|
||||||
anv_scratch_pool_init(struct anv_device *device, struct anv_scratch_pool *pool)
|
anv_scratch_pool_init(struct anv_device *device, struct anv_scratch_pool *pool,
|
||||||
|
bool protected)
|
||||||
{
|
{
|
||||||
memset(pool, 0, sizeof(*pool));
|
memset(pool, 0, sizeof(*pool));
|
||||||
|
pool->alloc_flags = ANV_BO_ALLOC_INTERNAL |
|
||||||
|
(protected ? ANV_BO_ALLOC_PROTECTED : 0) |
|
||||||
|
(device->info->verx10 < 125 ? ANV_BO_ALLOC_32BIT_ADDRESS : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1367,11 +1371,8 @@ anv_scratch_pool_alloc(struct anv_device *device, struct anv_scratch_pool *pool,
|
|||||||
*
|
*
|
||||||
* so nothing will ever touch the top page.
|
* so nothing will ever touch the top page.
|
||||||
*/
|
*/
|
||||||
const enum anv_bo_alloc_flags alloc_flags =
|
|
||||||
ANV_BO_ALLOC_INTERNAL |
|
|
||||||
(devinfo->verx10 < 125 ? ANV_BO_ALLOC_32BIT_ADDRESS : 0);
|
|
||||||
VkResult result = anv_device_alloc_bo(device, "scratch", size,
|
VkResult result = anv_device_alloc_bo(device, "scratch", size,
|
||||||
alloc_flags,
|
pool->alloc_flags,
|
||||||
0 /* explicit_address */,
|
0 /* explicit_address */,
|
||||||
&bo);
|
&bo);
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
@@ -1413,10 +1414,14 @@ anv_scratch_pool_get_surf(struct anv_device *device,
|
|||||||
anv_state_pool_alloc(&device->scratch_surface_state_pool,
|
anv_state_pool_alloc(&device->scratch_surface_state_pool,
|
||||||
device->isl_dev.ss.size, 64);
|
device->isl_dev.ss.size, 64);
|
||||||
|
|
||||||
|
isl_surf_usage_flags_t usage =
|
||||||
|
(pool->alloc_flags & ANV_BO_ALLOC_PROTECTED) ?
|
||||||
|
ISL_SURF_USAGE_PROTECTED_BIT : 0;
|
||||||
|
|
||||||
isl_buffer_fill_state(&device->isl_dev, state.map,
|
isl_buffer_fill_state(&device->isl_dev, state.map,
|
||||||
.address = anv_address_physical(addr),
|
.address = anv_address_physical(addr),
|
||||||
.size_B = bo->size,
|
.size_B = bo->size,
|
||||||
.mocs = anv_mocs(device, bo, 0),
|
.mocs = anv_mocs(device, bo, usage),
|
||||||
.format = ISL_FORMAT_RAW,
|
.format = ISL_FORMAT_RAW,
|
||||||
.swizzle = ISL_SWIZZLE_IDENTITY,
|
.swizzle = ISL_SWIZZLE_IDENTITY,
|
||||||
.stride_B = per_thread_scratch,
|
.stride_B = per_thread_scratch,
|
||||||
|
@@ -3839,7 +3839,8 @@ VkResult anv_CreateDevice(
|
|||||||
isl_null_fill_state(&device->isl_dev, &device->host_null_surface_state,
|
isl_null_fill_state(&device->isl_dev, &device->host_null_surface_state,
|
||||||
.size = isl_extent3d(1, 1, 1) /* This shouldn't matter */);
|
.size = isl_extent3d(1, 1, 1) /* This shouldn't matter */);
|
||||||
|
|
||||||
anv_scratch_pool_init(device, &device->scratch_pool);
|
anv_scratch_pool_init(device, &device->scratch_pool, false);
|
||||||
|
anv_scratch_pool_init(device, &device->protected_scratch_pool, true);
|
||||||
|
|
||||||
/* TODO(RT): Do we want some sort of data structure for this? */
|
/* TODO(RT): Do we want some sort of data structure for this? */
|
||||||
memset(device->rt_scratch_bos, 0, sizeof(device->rt_scratch_bos));
|
memset(device->rt_scratch_bos, 0, sizeof(device->rt_scratch_bos));
|
||||||
@@ -4027,6 +4028,7 @@ VkResult anv_CreateDevice(
|
|||||||
anv_device_release_bo(device, device->btd_fifo_bo);
|
anv_device_release_bo(device, device->btd_fifo_bo);
|
||||||
fail_trivial_batch_bo_and_scratch_pool:
|
fail_trivial_batch_bo_and_scratch_pool:
|
||||||
anv_scratch_pool_finish(device, &device->scratch_pool);
|
anv_scratch_pool_finish(device, &device->scratch_pool);
|
||||||
|
anv_scratch_pool_finish(device, &device->protected_scratch_pool);
|
||||||
fail_trivial_batch:
|
fail_trivial_batch:
|
||||||
anv_device_release_bo(device, device->trivial_batch_bo);
|
anv_device_release_bo(device, device->trivial_batch_bo);
|
||||||
fail_ray_query_bo:
|
fail_ray_query_bo:
|
||||||
@@ -4182,6 +4184,7 @@ void anv_DestroyDevice(
|
|||||||
}
|
}
|
||||||
|
|
||||||
anv_scratch_pool_finish(device, &device->scratch_pool);
|
anv_scratch_pool_finish(device, &device->scratch_pool);
|
||||||
|
anv_scratch_pool_finish(device, &device->protected_scratch_pool);
|
||||||
|
|
||||||
if (device->vk.enabled_extensions.KHR_ray_query) {
|
if (device->vk.enabled_extensions.KHR_ray_query) {
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(device->ray_query_shadow_bos); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(device->ray_query_shadow_bos); i++) {
|
||||||
|
@@ -902,6 +902,7 @@ VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, uint32_t size,
|
|||||||
void anv_bo_pool_free(struct anv_bo_pool *pool, struct anv_bo *bo);
|
void anv_bo_pool_free(struct anv_bo_pool *pool, struct anv_bo *bo);
|
||||||
|
|
||||||
struct anv_scratch_pool {
|
struct anv_scratch_pool {
|
||||||
|
enum anv_bo_alloc_flags alloc_flags;
|
||||||
/* Indexed by Per-Thread Scratch Space number (the hardware value) and stage */
|
/* Indexed by Per-Thread Scratch Space number (the hardware value) and stage */
|
||||||
struct anv_bo *bos[16][MESA_SHADER_STAGES];
|
struct anv_bo *bos[16][MESA_SHADER_STAGES];
|
||||||
uint32_t surfs[16];
|
uint32_t surfs[16];
|
||||||
@@ -909,7 +910,8 @@ struct anv_scratch_pool {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void anv_scratch_pool_init(struct anv_device *device,
|
void anv_scratch_pool_init(struct anv_device *device,
|
||||||
struct anv_scratch_pool *pool);
|
struct anv_scratch_pool *pool,
|
||||||
|
bool protected);
|
||||||
void anv_scratch_pool_finish(struct anv_device *device,
|
void anv_scratch_pool_finish(struct anv_device *device,
|
||||||
struct anv_scratch_pool *pool);
|
struct anv_scratch_pool *pool);
|
||||||
struct anv_bo *anv_scratch_pool_alloc(struct anv_device *device,
|
struct anv_bo *anv_scratch_pool_alloc(struct anv_device *device,
|
||||||
@@ -1903,6 +1905,7 @@ struct anv_device {
|
|||||||
struct anv_queue * queues;
|
struct anv_queue * queues;
|
||||||
|
|
||||||
struct anv_scratch_pool scratch_pool;
|
struct anv_scratch_pool scratch_pool;
|
||||||
|
struct anv_scratch_pool protected_scratch_pool;
|
||||||
struct anv_bo *rt_scratch_bos[16];
|
struct anv_bo *rt_scratch_bos[16];
|
||||||
struct anv_bo *btd_fifo_bo;
|
struct anv_bo *btd_fifo_bo;
|
||||||
struct anv_address rt_uuid_addr;
|
struct anv_address rt_uuid_addr;
|
||||||
|
Reference in New Issue
Block a user