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

vsg 1.1.13 VulkanSceneGraph library

Loading...
Searching...
No Matches
ImageView.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/Image.h>
16
17namespace vsg
18{
19 class Context;
20
21 extern VSG_DECLSPEC VkImageAspectFlags computeAspectFlagsForFormat(VkFormat format);
22
24 class VSG_DECLSPEC ImageView : public Inherit<Object, ImageView>
25 {
26 public:
27 explicit ImageView(ref_ptr<Image> in_image = {});
28 ImageView(ref_ptr<Image> in_image, VkImageAspectFlags aspectFlags);
29
31 VkImageViewCreateFlags flags = 0;
32 ref_ptr<Image> image;
33 VkImageViewType viewType = VK_IMAGE_VIEW_TYPE_2D;
34 VkFormat format = VK_FORMAT_UNDEFINED;
35 VkComponentMapping components = {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY};
36 VkImageSubresourceRange subresourceRange;
37
39 VkImageView vk(uint32_t deviceID) const { return _vulkanData[deviceID].imageView; }
40
41 int compare(const Object& rhs_object) const override;
42
43 virtual void compile(Device* device);
44 virtual void compile(Context& context);
45
46 protected:
47 virtual ~ImageView();
48
49 struct VulkanData
50 {
51 VkImageView imageView = VK_NULL_HANDLE;
52 ref_ptr<Device> device;
53
54 ~VulkanData() { release(); }
55 void release();
56 };
57
58 vk_buffer<VulkanData> _vulkanData;
59 };
60 VSG_type_name(vsg::ImageView);
61
62 using ImageViews = std::vector<ref_ptr<ImageView>>;
63
65 extern VSG_DECLSPEC ref_ptr<ImageView> createImageView(Context& context, ref_ptr<Image> image, VkImageAspectFlags aspectFlags);
66
68 extern VSG_DECLSPEC ref_ptr<ImageView> createImageView(Device* device, ref_ptr<Image> image, VkImageAspectFlags aspectFlags);
69
70} // namespace vsg
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::ImageView
ImageView class encapsulates VkImageView and VkImageViewCreateInfo settings used to set it up.
Definition ImageView.h:25
vsg::ImageView::vk
VkImageView vk(uint32_t deviceID) const
Vulkan VkImageView handle.
Definition ImageView.h:39
vsg::ImageView::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::ImageView::flags
VkImageViewCreateFlags flags
VkImageViewCreateInfo settings.
Definition ImageView.h:31
vsg::Object
Definition Object.h:60
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::ImageView::VulkanData
Definition ImageView.h:50
vsg::vk_buffer
vk_buffer that manages a single logical device supported.
Definition vk_buffer.h:29