1 // Copyright 2024 The Amber Authors. 2 // Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #ifndef SRC_VULKAN_TLAS_H_ 17 #define SRC_VULKAN_TLAS_H_ 18 19 #include <memory> 20 21 #include "src/acceleration_structure.h" 22 #include "src/vulkan/device.h" 23 #include "src/vulkan/transfer_buffer.h" 24 25 namespace amber { 26 namespace vulkan { 27 28 class TLAS { 29 public: 30 explicit TLAS(Device* device); 31 ~TLAS(); 32 33 Result CreateTLAS(amber::TLAS* tlas, BlasesMap* blases); 34 Result BuildTLAS(VkCommandBuffer cmdBuffer); GetVkTLAS()35 VkAccelerationStructureKHR GetVkTLAS() { return tlas_; } 36 37 private: 38 Device* device_ = nullptr; 39 VkAccelerationStructureKHR tlas_ = VK_NULL_HANDLE; 40 bool built_ = false; 41 std::unique_ptr<TransferBuffer> buffer_; 42 std::unique_ptr<TransferBuffer> scratch_buffer_; 43 std::unique_ptr<TransferBuffer> instance_buffer_; 44 uint32_t instances_count_ = 0; 45 VkAccelerationStructureGeometryKHR accelerationStructureGeometryKHR_; 46 VkAccelerationStructureBuildGeometryInfoKHR 47 accelerationStructureBuildGeometryInfoKHR_; 48 }; 49 50 } // namespace vulkan 51 } // namespace amber 52 53 #endif // SRC_VULKAN_TLAS_H_ 54