VPP  0.7
A high-level modern C++ API for Vulkan
vppImageView.hpp
1 /*
2  Copyright 2016-2018 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 // -----------------------------------------------------------------------------
28 namespace vpp {
29 // -----------------------------------------------------------------------------
30 
31 enum ESamplingMode
32 {
33  SAMPLER_NORMALIZED,
34  SAMPLER_UNNORMALIZED
35 };
36 
37 // -----------------------------------------------------------------------------
81 template<
82  class ImageT,
83  ESamplingMode SAMPLING = SAMPLER_NORMALIZED,
84  class FormatT = typename ImageT::format_type,
85  unsigned int ASPECTS = FormatT::aspects,
86  ECubeMode CUBE = CUBE_ALLOW >
88 {
89 };
90 
91 // -----------------------------------------------------------------------------
111 template< class AttributesT >
113 {
114 public:
116  typedef typename AttributesT::image_type image_type;
117 
119  typedef typename AttributesT::format_type format_type;
120 
122  typedef AttributesT attributes_type;
123 
125  ImageView();
126 
128  explicit ImageView ( const image_type& hImage );
129 
131  ImageView ( const image_type& hImage, unsigned int layer );
132 
134  ImageView ( const image_type& hImage, unsigned int mipLevel, unsigned int layer );
135 
137  explicit ImageView ( const FrameImageView& hGenericView );
138 
140  ImageView (
141  const image_type& hImage,
142  unsigned int baseMipLevel,
143  unsigned int levelCount,
144  unsigned int baseArrayLayer,
145  unsigned int layerCount,
146  const VkComponentMapping& componentMapping = ComponentMapping()
147  );
148 
150  operator VkImageView() const;
151 
153  const image_type& image() const;
154 
156  const Device& device() const;
157 
159  const VkImageSubresourceRange& subresourceRange() const;
160 
162  FrameImageView frameView() const;
163 };
164 
165 // -----------------------------------------------------------------------------
187 template< class AttributesT >
188 auto bind (
189  const ImageView< AttributesT >& view,
190  VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED );
191 
192 // -----------------------------------------------------------------------------
220 template< class AttributesT, class SamplerT >
221 auto bind (
222  const SamplerT& sampler,
223  const ImageView< AttributesT >& view,
224  VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED );
225 
226 // -----------------------------------------------------------------------------
227 } // namespace vpp
228 // -----------------------------------------------------------------------------
A template encoding image view attributes inside C++ type.
Definition: vppImageView.hpp:87
Represents logical rendering device.
Definition: vppDevice.hpp:49
AttributesT::format_type format_type
Format type (an instance of vpp::format template).
Definition: vppImageView.hpp:119
FrameImageView frameView() const
Converts the typed view to untyped view.
AttributesT attributes_type
Attributes type (taken from the argument).
Definition: vppImageView.hpp:122
Untyped image view class. Useful for constructing FrameBuffer objects.
Definition: vppFrameImageView.hpp:46
The VPP namespace.
Definition: main.hpp:1
const Device & device() const
Retrieves the device.
auto bind(const ImageView< AttributesT > &view, VkImageLayout layout=VK_IMAGE_LAYOUT_UNDEFINED)
Helper function to bind specified image view to a binding point in a pipeline.
const VkImageSubresourceRange & subresourceRange() const
Retrieves the range of image slice (levels and layers).
const image_type & image() const
Retrieves the image.
AttributesT::image_type image_type
Image type.
Definition: vppImageView.hpp:116
ImageView()
Constructs null reference.
Typed image view.
Definition: vppImageView.hpp:112