Diligent Engine  v.2.4.g
BufferView.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 "DeviceObject.h"
36 
38 
39 // {E2E83490-E9D2-495B-9A83-ABB413A38B07}
40 static const struct INTERFACE_ID IID_BufferView =
41  {0xe2e83490, 0xe9d2, 0x495b, {0x9a, 0x83, 0xab, 0xb4, 0x13, 0xa3, 0x8b, 0x7}};
42 
45 {
48 
52 
58  Bool IsNormalized DEFAULT_INITIALIZER(False);
59 
60 
61 #if DILIGENT_CPP_INTERFACE
62  // We have to explicitly define constructors because otherwise Apple's clang fails to compile the following legitimate code:
63  // BufferFormat{VT_FLOAT32, 4}
64 
65  BufferFormat()noexcept{}
66 
68  Uint8 _NumComponents,
69  Bool _IsNormalized = BufferFormat{}.IsNormalized)noexcept :
70  ValueType {_ValueType },
71  NumComponents {_NumComponents},
72  IsNormalized {_IsNormalized }
73  {}
74 
75 
77  bool operator == (const BufferFormat& RHS)const
78  {
79  return ValueType == RHS.ValueType &&
81  IsNormalized == RHS.IsNormalized;
82  }
83 #endif
84 };
85 typedef struct BufferFormat BufferFormat;
86 
89 
92 
96  struct BufferFormat Format;
97 
101 
104 
105 
106 #if DILIGENT_CPP_INTERFACE
107  BufferViewDesc()noexcept{}
108 
109  explicit
111  BufferFormat _Format = BufferViewDesc{}.Format,
112  Uint32 _ByteOffset = BufferViewDesc{}.ByteOffset,
113  Uint32 _ByteWidth = BufferViewDesc{}.ByteWidth)noexcept :
114  ViewType {_ViewType },
115  Format {_Format },
116  ByteOffset {_ByteOffset},
117  ByteWidth {_ByteWidth }
118  {}
119 
121 
128  bool operator==(const BufferViewDesc& RHS) const
129  {
130  // Name is primarily used for debug purposes and does not affect the view.
131  // It is ignored in comparison operation.
132  return //strcmp(Name, RHS.Name) == 0 &&
133  ViewType == RHS.ViewType &&
134  ByteOffset== RHS.ByteOffset &&
135  ByteWidth == RHS.ByteWidth &&
136  Format == RHS.Format;
137  }
138 #endif
139 };
141 
142 #define DILIGENT_INTERFACE_NAME IBufferView
143 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
144 
145 #define IBufferViewInclusiveMethods \
146  IDeviceObjectInclusiveMethods; \
147  IBufferViewMethods BufferView
148 
150 
156 {
157 #if DILIGENT_CPP_INTERFACE
158  virtual const BufferViewDesc& METHOD(GetDesc)() const override = 0;
160 #endif
161 
163 
166  VIRTUAL struct IBuffer* METHOD(GetBuffer)(THIS) CONST PURE;
167 };
169 
170 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
171 
172 #if DILIGENT_C_INTERFACE
173 
174 // clang-format off
175 
176 # define IBufferView_GetDesc(This) (const struct BufferViewDesc*)IDeviceObject_GetDesc(This)
177 
178 # define IBufferView_GetBuffer(This) CALL_IFACE_METHOD(BufferView, GetBuffer, This)
179 
180 // clang-format on
181 
182 #endif
183 
184 DILIGENT_END_NAMESPACE // namespace Diligent
Diligent::BufferViewDesc
Buffer view description.
Definition: BufferView.h:88
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
Diligent::BufferFormat::NumComponents
Uint8 NumComponents
Number of components. Allowed values: 1, 2, 3, 4. For a formatted buffer, this value cannot be 0.
Definition: BufferView.h:51
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Diligent::BufferViewDesc::Format
struct BufferFormat Format
Format of the view. This member is only used for formatted and raw buffers. To create raw view of a r...
Definition: BufferView.h:96
Diligent::operator==
bool operator==(const Plane3D &p1, const Plane3D &p2)
Definition: AdvancedMath.hpp:442
Diligent::BufferFormat::ValueType
VALUE_TYPE ValueType
Type of components. For a formatted buffer views, this value cannot be VT_UNDEFINED.
Definition: BufferView.h:47
Diligent::VT_UNDEFINED
@ VT_UNDEFINED
Undefined type.
Definition: GraphicsTypes.h:51
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::IBuffer
Buffer interface.
Definition: Buffer.h:187
Diligent::BufferViewDesc::BufferViewDesc
BufferViewDesc() noexcept
Definition: BufferView.h:107
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:1196
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::VALUE_TYPE
VALUE_TYPE
Value type.
Definition: GraphicsTypes.h:49
CONST
#define CONST
Definition: DefineInterfaceHelperMacros.h:84
NumComponents
D3D10_SB_OPERAND_NUM_COMPONENTS NumComponents
Definition: DXBCUtils.cpp:519
DILIGENT_DERIVE
#define DILIGENT_DERIVE(TypeName)
Definition: CommonDefinitions.h:90
Diligent::BufferViewDesc::ByteWidth
Uint32 ByteWidth
Size in bytes of the referenced buffer region.
Definition: BufferView.h:103
Diligent::BufferFormat::BufferFormat
BufferFormat() noexcept
Definition: BufferView.h:65
Diligent::BufferViewDesc::ByteOffset
Uint32 ByteOffset
Offset in bytes from the beginnig of the buffer to the start of the buffer region referenced by the v...
Definition: BufferView.h:100
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::Bool
bool Bool
Boolean.
Definition: BasicTypes.h:59
Diligent::BufferViewDesc::operator==
bool operator==(const BufferViewDesc &RHS) const
Comparison operator tests if two structures are equivalent.
Definition: BufferView.h:128
Diligent::BufferFormat::BufferFormat
BufferFormat(VALUE_TYPE _ValueType, Uint8 _NumComponents, Bool _IsNormalized=BufferFormat{}.IsNormalized) noexcept
Definition: BufferView.h:67
Diligent::BufferViewDesc::BufferViewDesc
BufferViewDesc(BUFFER_VIEW_TYPE _ViewType, BufferFormat _Format=BufferViewDesc{}.Format, Uint32 _ByteOffset=BufferViewDesc{}.ByteOffset, Uint32 _ByteWidth=BufferViewDesc{}.ByteWidth) noexcept
Definition: BufferView.h:110
DeviceObject.h
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
Diligent::BufferViewDesc
struct BufferViewDesc BufferViewDesc
Definition: BufferView.h:140
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
Diligent::BUFFER_VIEW_UNDEFINED
@ BUFFER_VIEW_UNDEFINED
Undefined view type.
Definition: GraphicsTypes.h:306
Diligent::BufferViewDesc::ViewType
BUFFER_VIEW_TYPE ViewType
View type. See Diligent::BUFFER_VIEW_TYPE for details.
Definition: BufferView.h:91
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::BufferFormat
Buffer format description.
Definition: BufferView.h:44
Diligent::IBufferView
Buffer view interface.
Definition: BufferView.h:155
Diligent::BufferFormat::IsNormalized
Bool IsNormalized
For signed and unsigned integer value types (VT_INT8, VT_INT16, VT_INT32, VT_UINT8,...
Definition: BufferView.h:58
Diligent::BUFFER_VIEW_TYPE
BUFFER_VIEW_TYPE
Buffer view type.
Definition: GraphicsTypes.h:303
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37