Diligent Engine  v.2.4.g
TextureView.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 // clang-format off
31 
34 
35 #include "../../../Primitives/interface/FlagEnum.h"
36 #include "DeviceObject.h"
37 
39 
40 struct ISampler;
41 
42 // {5B2EA04E-8128-45E4-AA4D-6DC7E70DC424}
43 static const INTERFACE_ID IID_TextureView =
44  {0x5b2ea04e, 0x8128, 0x45e4,{0xaa, 0x4d, 0x6d, 0xc7, 0xe7, 0xd, 0xc4, 0x24}};
45 
46 // clang-format off
47 
50 {
53 
56 
59 
62 };
64 
67 {
70 
75 };
77 
78 
81 
84 
91 
95 
97  Uint32 MostDetailedMip DEFAULT_INITIALIZER(0);
98 
105 
106  union
107  {
110 
113  };
114 
115  union
116  {
119  Uint32 NumArraySlices DEFAULT_INITIALIZER(0);
120 
124  };
125 
129 
132 
133 #if DILIGENT_CPP_INTERFACE
134 
135  TextureViewDesc() noexcept {}
136 
138  RESOURCE_DIMENSION _TextureDim,
140  Uint32 _MostDetailedMip = TextureViewDesc{}.MostDetailedMip,
141  Uint32 _NumMipLevels = TextureViewDesc{}.NumMipLevels,
142  Uint32 _FirstArrayOrDepthSlice = TextureViewDesc{}.FirstArraySlice,
143  Uint32 _NumArrayOrDepthSlices = TextureViewDesc{}.NumArraySlices,
145  TEXTURE_VIEW_FLAGS _Flags = TextureViewDesc{}.Flags) noexcept :
146  ViewType{_ViewType},
147  TextureDim{_TextureDim},
148  Format{_Format},
149  MostDetailedMip{_MostDetailedMip},
150  NumMipLevels{_NumMipLevels},
151  FirstArraySlice{_FirstArrayOrDepthSlice},
152  NumArraySlices{_NumArrayOrDepthSlices},
153  AccessFlags{_AccessFlags},
154  Flags{_Flags}
155  {}
156 
158 
163  bool operator==(const TextureViewDesc& RHS) const
164  {
165  // Name is primarily used for debug purposes and does not affect the view.
166  // It is ignored in comparison operation.
167  return //strcmp(Name, RHS.Name) == 0 &&
168  ViewType == RHS.ViewType &&
169  TextureDim == RHS.TextureDim &&
170  Format == RHS.Format &&
171  MostDetailedMip == RHS.MostDetailedMip &&
172  NumMipLevels == RHS.NumMipLevels &&
174  FirstDepthSlice == RHS.FirstDepthSlice &&
175  NumArraySlices == RHS.NumArraySlices &&
176  NumDepthSlices == RHS.NumDepthSlices &&
177  AccessFlags == RHS.AccessFlags;
178  }
179 #else
180 
181 #endif
182 };
184 
185 // clang-format on
186 
187 #define DILIGENT_INTERFACE_NAME ITextureView
188 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
189 
190 #define ITextureViewInclusiveMethods \
191  IDeviceObjectInclusiveMethods; \
192  ITextureViewMethods TextureView
193 
195 
203 {
204 #if DILIGENT_CPP_INTERFACE
205  virtual const TextureViewDesc& METHOD(GetDesc)() const override = 0;
207 #endif
208 
213  VIRTUAL void METHOD(SetSampler)(THIS_ struct ISampler * pSampler) PURE;
214 
216 
219  VIRTUAL struct ISampler* METHOD(GetSampler)(THIS) PURE;
220 
221 
223 
226  VIRTUAL struct ITexture* METHOD(GetTexture)(THIS) PURE;
227 };
229 
230 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
231 
232 #if DILIGENT_C_INTERFACE
233 
234 # define ITextureView_GetDesc(This) (const struct TextureViewDesc*)IDeviceObject_GetDesc(This)
235 
236 // clang-format off
237 
238 # define ITextureView_SetSampler(This, ...) CALL_IFACE_METHOD(TextureView, SetSampler, This, __VA_ARGS__)
239 # define ITextureView_GetSampler(This) CALL_IFACE_METHOD(TextureView, GetSampler, This)
240 # define ITextureView_GetTexture(This) CALL_IFACE_METHOD(TextureView, GetTexture, This)
241 
242 // clang-format on
243 
244 #endif
245 
Diligent::TextureViewDesc::Format
TEXTURE_FORMAT Format
View format. If default value Diligent::TEX_FORMAT_UNKNOWN is provided, the view format will match th...
Definition: TextureView.h:94
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
Diligent::UAV_ACCESS_FLAG_READ
@ UAV_ACCESS_FLAG_READ
Allow read operations on the UAV.
Definition: TextureView.h:55
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
Diligent::UAV_ACCESS_FLAG
UAV_ACCESS_FLAG
Describes allowed unordered access view mode.
Definition: TextureView.h:49
Diligent::TextureViewDesc::operator==
bool operator==(const TextureViewDesc &RHS) const
Tests if two structures are equivalent.
Definition: TextureView.h:163
Diligent::TEXTURE_VIEW_FLAGS
TEXTURE_VIEW_FLAGS
Texture view flags.
Definition: TextureView.h:66
Diligent::ISampler
Texture sampler interface.
Definition: Sampler.h:192
Diligent::UAV_ACCESS_FLAG_READ_WRITE
@ UAV_ACCESS_FLAG_READ_WRITE
Allow read and write operations on the UAV.
Definition: TextureView.h:61
Diligent::TextureViewDesc::MostDetailedMip
Uint32 MostDetailedMip
Most detailed mip level to use.
Definition: TextureView.h:97
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Diligent::TextureViewDesc::NumMipLevels
Uint32 NumMipLevels
Total number of mip levels for the view of the texture. Render target and depth stencil views can add...
Definition: TextureView.h:104
Diligent::TextureViewDesc::NumArraySlices
Uint32 NumArraySlices
For a texture array, number of array slices to address in the view. Set to 0 to address all array sli...
Definition: TextureView.h:119
Diligent::UAV_ACCESS_FLAG_WRITE
@ UAV_ACCESS_FLAG_WRITE
Allow write operations on the UAV.
Definition: TextureView.h:58
NumMipLevels
int NumMipLevels
Definition: GenerateMipsCS_inc.h:23
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:202
Diligent::TextureViewDesc::AccessFlags
UAV_ACCESS_FLAG AccessFlags
For an unordered access view, allowed access flags. See Diligent::UAV_ACCESS_FLAG for details.
Definition: TextureView.h:128
Diligent::TEXTURE_VIEW_TYPE
TEXTURE_VIEW_TYPE
Texture view type.
Definition: GraphicsTypes.h:274
Diligent::DeviceObjectAttribs
struct DeviceObjectAttribs DeviceObjectAttribs
Definition: GraphicsTypes.h:1212
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
THIS
#define THIS
Definition: DefineInterfaceHelperMacros.h:81
Diligent::TEX_FORMAT_UNKNOWN
@ TEX_FORMAT_UNKNOWN
Unknown format.
Definition: GraphicsTypes.h:331
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::TextureViewDesc::ViewType
TEXTURE_VIEW_TYPE ViewType
Describes the texture view type, see Diligent::TEXTURE_VIEW_TYPE for details.
Definition: TextureView.h:83
Diligent::TextureViewDesc::FirstArraySlice
Uint32 FirstArraySlice
For a texture array, first array slice to address in the view.
Definition: TextureView.h:109
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::TextureViewDesc::Flags
TEXTURE_VIEW_FLAGS Flags
Texture view flags, see Diligent::TEXTURE_VIEW_FLAGS.
Definition: TextureView.h:131
DILIGENT_DERIVE
#define DILIGENT_DERIVE(TypeName)
Definition: CommonDefinitions.h:90
FirstArraySlice
int FirstArraySlice
Definition: GenerateMipsCS_inc.h:24
Diligent::TextureViewDesc
struct TextureViewDesc TextureViewDesc
Definition: TextureView.h:183
Diligent::RESOURCE_DIM_UNDEFINED
@ RESOURCE_DIM_UNDEFINED
Texture type undefined.
Definition: GraphicsTypes.h:258
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::TextureViewDesc::TextureDim
RESOURCE_DIMENSION TextureDim
View interpretation of the original texture. For instance, one slice of a 2D texture array can be vie...
Definition: TextureView.h:90
Diligent::TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION
@ TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION
Allow automatic mipmap generation for this view. This flag is only allowed for TEXTURE_VIEW_SHADER_RE...
Definition: TextureView.h:74
DeviceObject.h
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
Diligent::TEXTURE_VIEW_FLAG_NONE
@ TEXTURE_VIEW_FLAG_NONE
No flags.
Definition: TextureView.h:69
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
Diligent::TextureViewDesc::TextureViewDesc
TextureViewDesc(TEXTURE_VIEW_TYPE _ViewType, RESOURCE_DIMENSION _TextureDim, TEXTURE_FORMAT _Format=TextureViewDesc{}.Format, Uint32 _MostDetailedMip=TextureViewDesc{}.MostDetailedMip, Uint32 _NumMipLevels=TextureViewDesc{}.NumMipLevels, Uint32 _FirstArrayOrDepthSlice=TextureViewDesc{}.FirstArraySlice, Uint32 _NumArrayOrDepthSlices=TextureViewDesc{}.NumArraySlices, UAV_ACCESS_FLAG _AccessFlags=TextureViewDesc{}.AccessFlags, TEXTURE_VIEW_FLAGS _Flags=TextureViewDesc{}.Flags) noexcept
Definition: TextureView.h:137
DILIGENT_TYPED_ENUM
#define DILIGENT_TYPED_ENUM(EnumName, EnumType)
Definition: CommonDefinitions.h:88
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::TextureViewDesc::FirstDepthSlice
Uint32 FirstDepthSlice
For a 3D texture, first depth slice to address the view.
Definition: TextureView.h:112
DEFINE_FLAG_ENUM_OPERATORS
DEFINE_FLAG_ENUM_OPERATORS(FILE_DIALOG_FLAGS)
Diligent::RESOURCE_DIMENSION
RESOURCE_DIMENSION
Describes resource dimension.
Definition: GraphicsTypes.h:256
Diligent::UAV_ACCESS_UNSPECIFIED
@ UAV_ACCESS_UNSPECIFIED
Access mode is unspecified.
Definition: TextureView.h:52
Diligent::TextureViewDesc
Texture view description.
Definition: TextureView.h:80
Diligent::TEXTURE_VIEW_UNDEFINED
@ TEXTURE_VIEW_UNDEFINED
Undefined view type.
Definition: GraphicsTypes.h:277
Diligent::ITexture
Texture inteface.
Definition: Texture.h:273
Diligent::TextureViewDesc::TextureViewDesc
TextureViewDesc() noexcept
Definition: TextureView.h:135
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82
Diligent::TextureViewDesc::NumDepthSlices
Uint32 NumDepthSlices
For a 3D texture, number of depth slices to address in the view Set to 0 to address all depth slices.
Definition: TextureView.h:123