• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef VULKAN_GPU_ACCELERATION_STRUCTURE_VK_H
17 #define VULKAN_GPU_ACCELERATION_STRUCTURE_VK_H
18 
19 #include <vulkan/vulkan_core.h>
20 
21 #include <base/containers/unique_ptr.h>
22 #include <render/device/gpu_resource_desc.h>
23 #include <render/namespace.h>
24 #include <render/vulkan/intf_device_vk.h>
25 
26 #include "device/gpu_acceleration_structure.h"
27 
28 RENDER_BEGIN_NAMESPACE()
29 class Device;
30 class GpuBufferVk;
31 
32 struct GpuAccelerationStructurePlatformDataVk final : public GpuAccelerationStructurePlatformData {
33     VkBuffer buffer { VK_NULL_HANDLE };
34     uint32_t byteSize { 0u };
35     uint64_t deviceAddress { 0 };
36 #if (RENDER_VULKAN_RT_ENABLED == 1)
37     VkAccelerationStructureKHR accelerationStructure { VK_NULL_HANDLE };
38 #endif
39 };
40 
41 class GpuAccelerationStructureVk final : public GpuAccelerationStructure {
42 public:
43     GpuAccelerationStructureVk(Device& device, const GpuAccelerationStructureDesc& desc);
44     ~GpuAccelerationStructureVk();
45 
46     const GpuAccelerationStructureDesc& GetDesc() const override;
47     const GpuAccelerationStructurePlatformDataVk& GetPlatformData() const;
48 
49 private:
50     Device& device_;
51 
52     GpuAccelerationStructurePlatformDataVk plat_;
53     GpuAccelerationStructureDesc desc_;
54 
55     BASE_NS::unique_ptr<GpuBufferVk> gpuBuffer_;
56 };
57 RENDER_END_NAMESPACE()
58 
59 #endif // VULKAN_GPU_ACCELERATION_STRUCTURE_VK_H
60