vsg: include/vsg/state/BufferView.h Source File

vsg 1.1.9 VulkanSceneGraph library |

Loading...
Searching...
No Matches
BufferView.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission 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
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE 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/state/Buffer.h>
16#include <vsg/vk/vk_buffer.h>
17
18namespace vsg
19{
20 // forward declare
21 class Context;
22
24 class VSG_DECLSPEC BufferView : public Inherit<Object, BufferView>
25 {
26 public:
27 BufferView();
28 BufferView(ref_ptr<Buffer> buffer, VkFormat format, VkDeviceSize offset, VkDeviceSize range);
29
31 VkBufferView vk(uint32_t deviceID) const { return _vulkanData[deviceID].bufferView; }
32
33 // VkBufferViewCreateInfo settings
34 ref_ptr<Buffer> buffer;
35 VkFormat format = VK_FORMAT_UNDEFINED;
36 VkDeviceSize offset = 0;
37 VkDeviceSize range = 0;
38
39 int compare(const Object& rhs_object) const override;
40
41 virtual void compile(Device* device);
42 virtual void compile(Context& context);
43
44 protected:
45 virtual ~BufferView();
46
47 struct VulkanData
48 {
49 VkBufferView bufferView = VK_NULL_HANDLE;
50 ref_ptr<Device> device;
51
52 ~VulkanData() { release(); }
53 void release();
54 };
55
56 vk_buffer<VulkanData> _vulkanData;
57 };
58 VSG_type_name(vsg::BufferView);
59
60 using BufferViewList = std::vector<ref_ptr<BufferView>>;
61
62} // namespace vsg
vsg::BufferView
BufferView encapsulates VkBufferView and the VkBufferViewCreateInfo settings used to set it up.
Definition BufferView.h:25
vsg::BufferView::compare
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
vsg::BufferView::vk
VkBufferView vk(uint32_t deviceID) const
Vulkan VkBufferView handle.
Definition BufferView.h:31
vsg::Context
Definition Context.h:67
vsg::Device
Device encapsulates VkDevice, a logical handle to the PhysicalDevice with capabilities specified duri...
Definition Device.h:39
vsg::Object
Definition Object.h:60
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::BufferView::VulkanData
Definition BufferView.h:48
vsg::vk_buffer
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:28