mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
anv: Use vk_get_bvh_build_pipeline_spv helper
Took inspiration from RADV driver changes. This allow us to get rid of our local helper get_pipeline_spv(). Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36245>
This commit is contained in:
parent
20b2944274
commit
349de5b0be
2 changed files with 70 additions and 187 deletions
|
|
@ -2066,6 +2066,12 @@ enum anv_internal_kernel_name {
|
||||||
*/
|
*/
|
||||||
#define ANV_RT_UUID_MACRO "ANV_RT_BVH_0001"
|
#define ANV_RT_UUID_MACRO "ANV_RT_BVH_0001"
|
||||||
|
|
||||||
|
enum anv_object_key_bvh_type {
|
||||||
|
ANV_OBJECT_KEY_BVH_ENCODE = VK_META_OBJECT_KEY_DRIVER_OFFSET,
|
||||||
|
ANV_OBJECT_KEY_BVH_HEADER,
|
||||||
|
ANV_OBJECT_KEY_BVH_COPY,
|
||||||
|
};
|
||||||
|
|
||||||
enum bvh_dump_type {
|
enum bvh_dump_type {
|
||||||
BVH_ANV,
|
BVH_ANV,
|
||||||
BVH_IR_HDR,
|
BVH_IR_HDR,
|
||||||
|
|
|
||||||
|
|
@ -248,64 +248,6 @@ static const uint32_t copy_spv[] = {
|
||||||
#include COPY_SPV_PATH
|
#include COPY_SPV_PATH
|
||||||
};
|
};
|
||||||
|
|
||||||
static VkResult
|
|
||||||
get_pipeline_spv(struct anv_device *device,
|
|
||||||
const char *name, const uint32_t *spv, uint32_t spv_size,
|
|
||||||
unsigned push_constant_size, VkPipeline *pipeline,
|
|
||||||
VkPipelineLayout *layout)
|
|
||||||
{
|
|
||||||
|
|
||||||
size_t key_size = strlen(name);
|
|
||||||
|
|
||||||
const VkPushConstantRange pc_range = {
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = push_constant_size,
|
|
||||||
};
|
|
||||||
|
|
||||||
VkResult result = vk_meta_get_pipeline_layout(&device->vk,
|
|
||||||
&device->meta_device, NULL,
|
|
||||||
&pc_range, name, key_size,
|
|
||||||
layout);
|
|
||||||
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
VkPipeline pipeline_from_cache =
|
|
||||||
vk_meta_lookup_pipeline(&device->meta_device, name, key_size);
|
|
||||||
if (pipeline_from_cache != VK_NULL_HANDLE) {
|
|
||||||
*pipeline = pipeline_from_cache;
|
|
||||||
return VK_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkShaderModuleCreateInfo module_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
|
||||||
.pNext = NULL,
|
|
||||||
.flags = 0,
|
|
||||||
.codeSize = spv_size,
|
|
||||||
.pCode = spv,
|
|
||||||
};
|
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo shader_stage = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
|
||||||
.pNext = &module_info,
|
|
||||||
.flags = 0,
|
|
||||||
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.pName = "main",
|
|
||||||
.pSpecializationInfo = NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
VkComputePipelineCreateInfo pipeline_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
|
||||||
.flags = 0,
|
|
||||||
.stage = shader_stage,
|
|
||||||
.layout = *layout,
|
|
||||||
};
|
|
||||||
|
|
||||||
return vk_meta_create_compute_pipeline(&device->vk, &device->meta_device,
|
|
||||||
&pipeline_info, name, key_size, pipeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_bvh_layout(VkGeometryTypeKHR geometry_type, uint32_t leaf_count,
|
get_bvh_layout(VkGeometryTypeKHR geometry_type, uint32_t leaf_count,
|
||||||
struct bvh_layout *layout)
|
struct bvh_layout *layout)
|
||||||
|
|
@ -360,24 +302,60 @@ anv_get_build_config(VkDevice device, struct vk_acceleration_structure_build_sta
|
||||||
state->config.encode_key[1] = (state->build_info->flags & VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR) ? 1 : 0;
|
state->config.encode_key[1] = (state->build_info->flags & VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VkResult
|
static void
|
||||||
anv_encode_bind_pipeline(VkCommandBuffer commandBuffer, const struct vk_acceleration_structure_build_state *state)
|
anv_bvh_build_bind_pipeline(VkCommandBuffer commandBuffer,
|
||||||
|
enum anv_object_key_bvh_type type,
|
||||||
|
const uint32_t *spirv, uint32_t spirv_size,
|
||||||
|
uint32_t push_constant_size, uint32_t flags)
|
||||||
{
|
{
|
||||||
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||||
struct anv_device *device = cmd_buffer->device;
|
struct anv_device *device = cmd_buffer->device;
|
||||||
|
|
||||||
VkPipeline pipeline;
|
VkPipeline pipeline;
|
||||||
|
VkResult result = vk_get_bvh_build_pipeline_spv(&device->vk,
|
||||||
|
&device->meta_device,
|
||||||
|
(enum anv_object_key_bvh_type)type,
|
||||||
|
spirv, spirv_size, push_constant_size,
|
||||||
|
&device->accel_struct_build.build_args,
|
||||||
|
flags, &pipeline);
|
||||||
|
if (result != VK_SUCCESS) {
|
||||||
|
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
device->vk.dispatch_table.CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
|
pipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
anv_bvh_build_set_args(VkCommandBuffer commandBuffer, const void *args,
|
||||||
|
uint32_t size)
|
||||||
|
{
|
||||||
|
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||||
|
struct anv_device *device = cmd_buffer->device;
|
||||||
VkPipelineLayout layout;
|
VkPipelineLayout layout;
|
||||||
VkResult result = get_pipeline_spv(device, "encode", encode_spv,
|
vk_get_bvh_build_pipeline_layout(&device->vk, &device->meta_device, size,
|
||||||
sizeof(encode_spv),
|
&layout);
|
||||||
sizeof(struct encode_args), &pipeline,
|
|
||||||
&layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
anv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
VkPushConstantsInfoKHR push_info = {
|
||||||
pipeline);
|
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
||||||
|
.layout = layout,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.offset = 0,
|
||||||
|
.size = size,
|
||||||
|
.pValues = args,
|
||||||
|
};
|
||||||
|
|
||||||
|
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VkResult
|
||||||
|
anv_encode_bind_pipeline(VkCommandBuffer commandBuffer, const struct vk_acceleration_structure_build_state *state)
|
||||||
|
{
|
||||||
|
anv_bvh_build_bind_pipeline(commandBuffer,
|
||||||
|
ANV_OBJECT_KEY_BVH_ENCODE,
|
||||||
|
encode_spv, sizeof(encode_spv),
|
||||||
|
sizeof(struct encode_args), 0);
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,18 +367,12 @@ anv_encode_as(VkCommandBuffer commandBuffer, const struct vk_acceleration_struct
|
||||||
|
|
||||||
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||||
VK_FROM_HANDLE(vk_acceleration_structure, dst, state->build_info->dstAccelerationStructure);
|
VK_FROM_HANDLE(vk_acceleration_structure, dst, state->build_info->dstAccelerationStructure);
|
||||||
struct anv_device *device = cmd_buffer->device;
|
|
||||||
|
|
||||||
uint64_t intermediate_header_addr = state->build_info->scratchData.deviceAddress + state->scratch.header_offset;
|
uint64_t intermediate_header_addr = state->build_info->scratchData.deviceAddress + state->scratch.header_offset;
|
||||||
uint64_t intermediate_bvh_addr = state->build_info->scratchData.deviceAddress + state->scratch.ir_offset;
|
uint64_t intermediate_bvh_addr = state->build_info->scratchData.deviceAddress + state->scratch.ir_offset;
|
||||||
|
|
||||||
VkGeometryTypeKHR geometry_type = vk_get_as_geometry_type(state->build_info);
|
VkGeometryTypeKHR geometry_type = vk_get_as_geometry_type(state->build_info);
|
||||||
|
|
||||||
VkPipeline pipeline;
|
|
||||||
VkPipelineLayout layout;
|
|
||||||
get_pipeline_spv(device, "encode", encode_spv, sizeof(encode_spv),
|
|
||||||
sizeof(struct encode_args), &pipeline, &layout);
|
|
||||||
|
|
||||||
STATIC_ASSERT(sizeof(struct anv_accel_struct_header) == ANV_RT_BVH_HEADER_SIZE);
|
STATIC_ASSERT(sizeof(struct anv_accel_struct_header) == ANV_RT_BVH_HEADER_SIZE);
|
||||||
STATIC_ASSERT(sizeof(struct anv_instance_leaf) == ANV_RT_INSTANCE_LEAF_SIZE);
|
STATIC_ASSERT(sizeof(struct anv_instance_leaf) == ANV_RT_INSTANCE_LEAF_SIZE);
|
||||||
STATIC_ASSERT(sizeof(struct anv_quad_leaf_node) == ANV_RT_QUAD_LEAF_SIZE);
|
STATIC_ASSERT(sizeof(struct anv_quad_leaf_node) == ANV_RT_QUAD_LEAF_SIZE);
|
||||||
|
|
@ -419,17 +391,7 @@ anv_encode_as(VkCommandBuffer commandBuffer, const struct vk_acceleration_struct
|
||||||
.leaf_node_count = state->leaf_node_count,
|
.leaf_node_count = state->leaf_node_count,
|
||||||
.geometry_type = geometry_type,
|
.geometry_type = geometry_type,
|
||||||
};
|
};
|
||||||
|
anv_bvh_build_set_args(commandBuffer, &args, sizeof(args));
|
||||||
VkPushConstantsInfoKHR push_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
|
||||||
.layout = layout,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = sizeof(args),
|
|
||||||
.pValues = &args,
|
|
||||||
};
|
|
||||||
|
|
||||||
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
|
||||||
|
|
||||||
struct anv_address indirect_addr =
|
struct anv_address indirect_addr =
|
||||||
anv_address_from_u64(intermediate_header_addr +
|
anv_address_from_u64(intermediate_header_addr +
|
||||||
|
|
@ -441,20 +403,11 @@ anv_encode_as(VkCommandBuffer commandBuffer, const struct vk_acceleration_struct
|
||||||
static VkResult
|
static VkResult
|
||||||
anv_init_header_bind_pipeline(VkCommandBuffer commandBuffer, const struct vk_acceleration_structure_build_state *state)
|
anv_init_header_bind_pipeline(VkCommandBuffer commandBuffer, const struct vk_acceleration_structure_build_state *state)
|
||||||
{
|
{
|
||||||
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
|
||||||
|
|
||||||
if (state->config.encode_key[1] == 1) {
|
if (state->config.encode_key[1] == 1) {
|
||||||
VkPipeline pipeline;
|
anv_bvh_build_bind_pipeline(commandBuffer,
|
||||||
VkPipelineLayout layout;
|
ANV_OBJECT_KEY_BVH_HEADER,
|
||||||
VkResult result = get_pipeline_spv(cmd_buffer->device, "header",
|
header_spv, sizeof(header_spv),
|
||||||
header_spv, sizeof(header_spv),
|
sizeof(struct header_args), 0);
|
||||||
sizeof(struct header_args), &pipeline,
|
|
||||||
&layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
anv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
|
||||||
pipeline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
@ -465,7 +418,6 @@ anv_init_header(VkCommandBuffer commandBuffer, const struct vk_acceleration_stru
|
||||||
{
|
{
|
||||||
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
VK_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
|
||||||
VK_FROM_HANDLE(vk_acceleration_structure, dst, state->build_info->dstAccelerationStructure);
|
VK_FROM_HANDLE(vk_acceleration_structure, dst, state->build_info->dstAccelerationStructure);
|
||||||
struct anv_device *device = cmd_buffer->device;
|
|
||||||
|
|
||||||
uint64_t intermediate_header_addr = state->build_info->scratchData.deviceAddress + state->scratch.header_offset;
|
uint64_t intermediate_header_addr = state->build_info->scratchData.deviceAddress + state->scratch.header_offset;
|
||||||
uint64_t intermediate_bvh_addr = state->build_info->scratchData.deviceAddress + state->scratch.ir_offset;
|
uint64_t intermediate_bvh_addr = state->build_info->scratchData.deviceAddress + state->scratch.ir_offset;
|
||||||
|
|
@ -496,11 +448,6 @@ anv_init_header(VkCommandBuffer commandBuffer, const struct vk_acceleration_stru
|
||||||
*/
|
*/
|
||||||
base = offsetof(struct anv_accel_struct_header, instance_count);
|
base = offsetof(struct anv_accel_struct_header, instance_count);
|
||||||
|
|
||||||
VkPipeline pipeline;
|
|
||||||
VkPipelineLayout layout;
|
|
||||||
get_pipeline_spv(device, "header", header_spv, sizeof(header_spv),
|
|
||||||
sizeof(struct header_args), &pipeline, &layout);
|
|
||||||
|
|
||||||
struct header_args args = {
|
struct header_args args = {
|
||||||
.src = intermediate_header_addr,
|
.src = intermediate_header_addr,
|
||||||
.dst = vk_acceleration_structure_get_va(dst),
|
.dst = vk_acceleration_structure_get_va(dst),
|
||||||
|
|
@ -508,16 +455,7 @@ anv_init_header(VkCommandBuffer commandBuffer, const struct vk_acceleration_stru
|
||||||
.instance_count = instance_count,
|
.instance_count = instance_count,
|
||||||
};
|
};
|
||||||
|
|
||||||
VkPushConstantsInfoKHR push_info = {
|
anv_bvh_build_set_args(commandBuffer, &args, sizeof(args));
|
||||||
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
|
||||||
.layout = layout,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = sizeof(args),
|
|
||||||
.pValues = &args,
|
|
||||||
};
|
|
||||||
|
|
||||||
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
|
||||||
vk_common_CmdDispatch(commandBuffer, 1, 1, 1);
|
vk_common_CmdDispatch(commandBuffer, 1, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
vk_barrier_compute_w_to_host_r(commandBuffer);
|
vk_barrier_compute_w_to_host_r(commandBuffer);
|
||||||
|
|
@ -716,41 +654,21 @@ genX(CmdCopyAccelerationStructureKHR)(
|
||||||
|
|
||||||
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
||||||
|
|
||||||
VkPipeline pipeline;
|
|
||||||
VkPipelineLayout layout;
|
|
||||||
VkResult result = get_pipeline_spv(cmd_buffer->device, "copy", copy_spv,
|
|
||||||
sizeof(copy_spv), sizeof(struct copy_args),
|
|
||||||
&pipeline, &layout);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct anv_cmd_saved_state saved;
|
struct anv_cmd_saved_state saved;
|
||||||
anv_cmd_buffer_save_state(cmd_buffer,
|
anv_cmd_buffer_save_state(cmd_buffer,
|
||||||
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
||||||
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
||||||
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
||||||
|
|
||||||
anv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
anv_bvh_build_bind_pipeline(commandBuffer, ANV_OBJECT_KEY_BVH_COPY,
|
||||||
pipeline);
|
copy_spv, sizeof(copy_spv),
|
||||||
|
sizeof(struct copy_args), 0);
|
||||||
struct copy_args consts = {
|
struct copy_args consts = {
|
||||||
.src_addr = vk_acceleration_structure_get_va(src),
|
.src_addr = vk_acceleration_structure_get_va(src),
|
||||||
.dst_addr = vk_acceleration_structure_get_va(dst),
|
.dst_addr = vk_acceleration_structure_get_va(dst),
|
||||||
.mode = ANV_COPY_MODE_COPY,
|
.mode = ANV_COPY_MODE_COPY,
|
||||||
};
|
};
|
||||||
|
anv_bvh_build_set_args(commandBuffer, &consts, sizeof(consts));
|
||||||
VkPushConstantsInfoKHR push_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
|
||||||
.layout = layout,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = sizeof(consts),
|
|
||||||
.pValues = &consts,
|
|
||||||
};
|
|
||||||
|
|
||||||
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
|
||||||
|
|
||||||
/* L1/L2 caches flushes should have been dealt with by pipeline barriers.
|
/* L1/L2 caches flushes should have been dealt with by pipeline barriers.
|
||||||
* Unfortunately some platforms require L3 flush because CS (reading the
|
* Unfortunately some platforms require L3 flush because CS (reading the
|
||||||
|
|
@ -782,26 +700,15 @@ genX(CmdCopyAccelerationStructureToMemoryKHR)(
|
||||||
|
|
||||||
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
||||||
|
|
||||||
VkPipeline pipeline;
|
|
||||||
VkPipelineLayout layout;
|
|
||||||
VkResult result = get_pipeline_spv(device, "copy", copy_spv,
|
|
||||||
sizeof(copy_spv),
|
|
||||||
sizeof(struct copy_args), &pipeline,
|
|
||||||
&layout);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct anv_cmd_saved_state saved;
|
struct anv_cmd_saved_state saved;
|
||||||
anv_cmd_buffer_save_state(cmd_buffer,
|
anv_cmd_buffer_save_state(cmd_buffer,
|
||||||
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
||||||
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
||||||
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
||||||
|
|
||||||
anv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
anv_bvh_build_bind_pipeline(commandBuffer, ANV_OBJECT_KEY_BVH_COPY,
|
||||||
pipeline);
|
copy_spv, sizeof(copy_spv),
|
||||||
|
sizeof(struct copy_args), 0);
|
||||||
struct copy_args consts = {
|
struct copy_args consts = {
|
||||||
.src_addr = vk_acceleration_structure_get_va(src),
|
.src_addr = vk_acceleration_structure_get_va(src),
|
||||||
.dst_addr = pInfo->dst.deviceAddress,
|
.dst_addr = pInfo->dst.deviceAddress,
|
||||||
|
|
@ -810,17 +717,7 @@ genX(CmdCopyAccelerationStructureToMemoryKHR)(
|
||||||
|
|
||||||
memcpy(consts.driver_uuid, device->physical->driver_uuid, VK_UUID_SIZE);
|
memcpy(consts.driver_uuid, device->physical->driver_uuid, VK_UUID_SIZE);
|
||||||
memcpy(consts.accel_struct_compat, device->physical->rt_uuid, VK_UUID_SIZE);
|
memcpy(consts.accel_struct_compat, device->physical->rt_uuid, VK_UUID_SIZE);
|
||||||
|
anv_bvh_build_set_args(commandBuffer, &consts, sizeof(consts));
|
||||||
VkPushConstantsInfoKHR push_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
|
||||||
.layout = layout,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = sizeof(consts),
|
|
||||||
.pValues = &consts,
|
|
||||||
};
|
|
||||||
|
|
||||||
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
|
||||||
|
|
||||||
/* L1/L2 caches flushes should have been dealt with by pipeline barriers.
|
/* L1/L2 caches flushes should have been dealt with by pipeline barriers.
|
||||||
* Unfortunately some platforms require L3 flush because CS (reading the
|
* Unfortunately some platforms require L3 flush because CS (reading the
|
||||||
|
|
@ -852,42 +749,22 @@ genX(CmdCopyMemoryToAccelerationStructureKHR)(
|
||||||
|
|
||||||
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
trace_intel_begin_as_copy(&cmd_buffer->trace);
|
||||||
|
|
||||||
VkPipeline pipeline;
|
|
||||||
VkPipelineLayout layout;
|
|
||||||
VkResult result = get_pipeline_spv(cmd_buffer->device, "copy", copy_spv,
|
|
||||||
sizeof(copy_spv),
|
|
||||||
sizeof(struct copy_args), &pipeline,
|
|
||||||
&layout);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct anv_cmd_saved_state saved;
|
struct anv_cmd_saved_state saved;
|
||||||
anv_cmd_buffer_save_state(cmd_buffer,
|
anv_cmd_buffer_save_state(cmd_buffer,
|
||||||
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
ANV_CMD_SAVED_STATE_COMPUTE_PIPELINE |
|
||||||
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
ANV_CMD_SAVED_STATE_DESCRIPTOR_SET_ALL |
|
||||||
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
ANV_CMD_SAVED_STATE_PUSH_CONSTANTS, &saved);
|
||||||
|
|
||||||
anv_CmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
|
anv_bvh_build_bind_pipeline(commandBuffer, ANV_OBJECT_KEY_BVH_COPY,
|
||||||
pipeline);
|
copy_spv, sizeof(copy_spv),
|
||||||
|
sizeof(struct copy_args), 0);
|
||||||
|
|
||||||
const struct copy_args consts = {
|
const struct copy_args consts = {
|
||||||
.src_addr = pInfo->src.deviceAddress,
|
.src_addr = pInfo->src.deviceAddress,
|
||||||
.dst_addr = vk_acceleration_structure_get_va(dst),
|
.dst_addr = vk_acceleration_structure_get_va(dst),
|
||||||
.mode = ANV_COPY_MODE_DESERIALIZE,
|
.mode = ANV_COPY_MODE_DESERIALIZE,
|
||||||
};
|
};
|
||||||
|
anv_bvh_build_set_args(commandBuffer, &consts, sizeof(consts));
|
||||||
VkPushConstantsInfoKHR push_info = {
|
|
||||||
.sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR,
|
|
||||||
.layout = layout,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.offset = 0,
|
|
||||||
.size = sizeof(consts),
|
|
||||||
.pValues = &consts,
|
|
||||||
};
|
|
||||||
|
|
||||||
anv_CmdPushConstants2KHR(commandBuffer, &push_info);
|
|
||||||
|
|
||||||
vk_common_CmdDispatch(commandBuffer, 512, 1, 1);
|
vk_common_CmdDispatch(commandBuffer, 512, 1, 1);
|
||||||
anv_cmd_buffer_restore_state(cmd_buffer, &saved);
|
anv_cmd_buffer_restore_state(cmd_buffer, &saved);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue