vsg  1.1.0
VulkanSceneGraph library
AccelerationStructure.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2019 Thomas Hogarth
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 
13 </editor-fold> */
14 
15 #include <vsg/core/Value.h>
16 #include <vsg/maths/mat4.h>
17 #include <vsg/state/BufferInfo.h>
18 #include <vsg/state/Descriptor.h>
19 #include <vsg/vk/DeviceMemory.h>
20 
21 namespace vsg
22 {
23 
25  class VSG_DECLSPEC AccelerationStructure : public Inherit<Object, AccelerationStructure>
26  {
27  public:
28  AccelerationStructure(VkAccelerationStructureTypeKHR type, Device* device);
29 
30  virtual void compile(Context& context);
31 
32  operator VkAccelerationStructureKHR() const { return _accelerationStructure; }
33  operator VkAccelerationStructureBuildGeometryInfoKHR() const { return _accelerationStructureBuildGeometryInfo; }
34 
35  uint64_t handle() const { return _handle; }
36 
37  VkDeviceSize requiredScratchSize() const { return _requiredBuildScratchSize; }
38 
39  protected:
40  virtual ~AccelerationStructure();
41 
42  VkAccelerationStructureKHR _accelerationStructure;
43  VkAccelerationStructureCreateInfoKHR _accelerationStructureInfo;
44  std::vector<uint32_t> _geometryPrimitiveCounts;
45  VkAccelerationStructureBuildGeometryInfoKHR _accelerationStructureBuildGeometryInfo;
46  ref_ptr<Buffer> _buffer;
47  ref_ptr<DeviceMemory> _memory;
48  uint64_t _handle = 0;
49  VkDeviceSize _requiredBuildScratchSize;
50 
51  ref_ptr<Device> _device;
52  };
53  VSG_type_name(vsg::AccelerationStructure);
54 
55  using AccelerationStructures = std::vector<ref_ptr<AccelerationStructure>>;
56 
57 } // namespace vsg
AccelerationStructure is a base class for top/bottom level acceleration structure classes.
Definition: AccelerationStructure.h:26
Definition: Context.h:67
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition: Device.h:37
Definition: Inherit.h:28
Definition: ref_ptr.h:22
Definition: vulkan.h:674