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_BLAS_H_ 17 #define SRC_VULKAN_BLAS_H_ 18 19 #include <vector> 20 #include <memory> 21 22 #include "src/acceleration_structure.h" 23 #include "src/vulkan/device.h" 24 #include "src/vulkan/transfer_buffer.h" 25 26 namespace amber { 27 namespace vulkan { 28 29 class BLAS { 30 public: 31 explicit BLAS(Device* device); 32 ~BLAS(); 33 34 Result CreateBLAS(amber::BLAS* blas); 35 Result BuildBLAS(CommandBuffer* command_buffer); GetVkBLAS()36 VkAccelerationStructureKHR GetVkBLAS() { return blas_; } 37 VkDeviceAddress getVkBLASDeviceAddress(); 38 39 private: 40 Device* device_ = nullptr; 41 VkAccelerationStructureKHR blas_ = VK_NULL_HANDLE; 42 bool built_ = false; 43 std::unique_ptr<TransferBuffer> buffer_; 44 std::unique_ptr<TransferBuffer> scratch_buffer_; 45 std::unique_ptr<TransferBuffer> vertex_buffer_; 46 VkAccelerationStructureBuildGeometryInfoKHR 47 accelerationStructureBuildGeometryInfoKHR_; 48 std::vector<VkAccelerationStructureGeometryKHR> 49 accelerationStructureGeometriesKHR_; 50 std::vector<VkAccelerationStructureBuildRangeInfoKHR> 51 accelerationStructureBuildRangeInfoKHR_; 52 std::vector<uint32_t> maxPrimitiveCounts_; 53 }; 54 55 } // namespace vulkan 56 } // namespace amber 57 58 #endif // SRC_VULKAN_BLAS_H_ 59