mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
vulkan: Allow reserving scratch memory for encode passes
Reviewed-by: Natalie Vock <natalie.vock@gmx.de> Reviewed-by: Connor Abbott <cwabbott0@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35385>
This commit is contained in:
parent
f336b4d1dd
commit
6cae6e8708
2 changed files with 15 additions and 0 deletions
|
|
@ -224,9 +224,20 @@ get_scratch_layout(struct vk_device *device,
|
|||
else
|
||||
lbvh_node_space = sizeof(struct lbvh_node_info) * internal_count;
|
||||
|
||||
uint32_t encode_scratch_size = 0;
|
||||
if (device->as_build_ops->get_encode_scratch_size) {
|
||||
for (uint32_t i = 0; i < MAX_ENCODE_PASSES; i++) {
|
||||
uint32_t tmp_size = device->as_build_ops->get_encode_scratch_size(device, config.encode_key[i], leaf_count);
|
||||
encode_scratch_size = MAX2(encode_scratch_size, tmp_size);
|
||||
}
|
||||
}
|
||||
|
||||
scratch->header_offset = offset;
|
||||
offset += sizeof(struct vk_ir_header);
|
||||
|
||||
/* The encode passes should not need node sorting state. Reuse the space reserved for node sorting. */
|
||||
uint32_t encode_scratch_end = offset + encode_scratch_size;
|
||||
|
||||
scratch->sort_buffer_offset[0] = offset;
|
||||
offset += requirements.keyvals_size;
|
||||
|
||||
|
|
@ -240,6 +251,9 @@ get_scratch_layout(struct vk_device *device,
|
|||
scratch->lbvh_node_offset = offset;
|
||||
offset += MAX3(requirements.internal_size, ploc_scratch_space, lbvh_node_space);
|
||||
|
||||
/* Make sure encode scratch space does not overlap the BVH. */
|
||||
offset = MAX2(offset, encode_scratch_end);
|
||||
|
||||
scratch->ir_offset = offset;
|
||||
offset += ir_leaf_size * leaf_count;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ struct vk_acceleration_structure_build_ops {
|
|||
VkDeviceSize (*get_as_size)(VkDevice device,
|
||||
const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
|
||||
uint32_t leaf_count);
|
||||
VkDeviceSize (*get_encode_scratch_size)(struct vk_device *device, uint32_t key, uint32_t leaf_count);
|
||||
VkDeviceSize (*get_update_scratch_size)(struct vk_device *device,
|
||||
const VkAccelerationStructureBuildGeometryInfoKHR *build_info,
|
||||
uint32_t leaf_count);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue