MCPcopy Create free account
hub / github.com/Ipotrick/Daxa / create_acceleration_structure_helper

Function create_acceleration_structure_helper

src/impl_device.cpp:467–586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467auto create_acceleration_structure_helper(
468 daxa_Device self,
469 auto & table,
470 VkAccelerationStructureTypeKHR vk_as_type,
471 auto const & info,
472 daxa_BufferId const * buffer,
473 u64 const * offset,
474 auto * out_id,
475 bool owns_buffer_external = false) -> daxa_Result
476{
477 daxa_Result result = DAXA_RESULT_SUCCESS;
478 // --- Begin Parameter Validation ---
479
480 if ((self->properties.implicit_features & DAXA_IMPLICIT_FEATURE_FLAG_BASIC_RAY_TRACING) == 0)
481 {
482 result = DAXA_RESULT_INVALID_WITHOUT_ENABLING_RAY_TRACING;
483 }
484 _DAXA_RETURN_IF_ERROR(result, result);
485
486 // --- End Parameter Validation ---
487
488 auto slot_opt = table.try_create_slot();
489 if (!slot_opt.has_value())
490 {
491 result = DAXA_RESULT_EXCEEDED_MAX_ACCELERATION_STRUCTURES;
492 }
493 _DAXA_RETURN_IF_ERROR(result, result);
494
495 auto [id, ret, hot_data] = slot_opt.value();
496 defer
497 {
498 if (result != DAXA_RESULT_SUCCESS)
499 {
500 table.unsafe_destroy_zombie_slot(id);
501 if (!ret.buffer_id.is_empty())
502 {
503 [[maybe_unused]] auto const _ignore = daxa_dvc_destroy_buffer(self, ret.buffer_id);
504 }
505 }
506 };
507
508 ret.info = info;
509
510 if (buffer)
511 {
512 ret.buffer_id = std::bit_cast<daxa::BufferId>(*buffer);
513 ret.offset = *offset;
514 ret.owns_buffer = owns_buffer_external;
515 }
516 else
517 {
518 daxa::SmallString buffer_name{std::string_view{ret.info.name.data, ret.info.name.size}};
519 if (ret.info.name.size < DAXA_SMALL_STRING_CAPACITY)
520 buffer_name.push_back(' ');
521 if (ret.info.name.size < DAXA_SMALL_STRING_CAPACITY)
522 buffer_name.push_back('b');
523 if (ret.info.name.size < DAXA_SMALL_STRING_CAPACITY)
524 buffer_name.push_back('u');

Calls 9

daxa_dvc_create_bufferFunction · 0.85
try_create_slotMethod · 0.80
has_valueMethod · 0.80
is_emptyMethod · 0.80
hot_slotMethod · 0.80
valueMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected