Diligent Engine  v.2.4.g
Sampler.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 
32 
33 #include "DeviceObject.h"
34 
36 
37 
38 // {595A59BF-FA81-4855-BC5E-C0E048745A95}
39 static const INTERFACE_ID IID_Sampler =
40  {0x595a59bf, 0xfa81, 0x4855, {0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95}};
41 
42 
43 // clang-format off
44 
46 
59 
63 
67 
73 
77 
81 
85 
90 
92  Uint32 MaxAnisotropy DEFAULT_INITIALIZER(0);
93 
97 
100  Float32 BorderColor[4] DEFAULT_INITIALIZER({});
101 
105  float MinLOD DEFAULT_INITIALIZER(0);
106 
110  float MaxLOD DEFAULT_INITIALIZER(+3.402823466e+38F);
111 
112 
113 #if DILIGENT_CPP_INTERFACE
114  SamplerDesc()noexcept{}
115 
117  FILTER_TYPE _MagFilter,
118  FILTER_TYPE _MipFilter,
122  Float32 _MipLODBias = SamplerDesc{}.MipLODBias,
123  Uint32 _MaxAnisotropy = SamplerDesc{}.MaxAnisotropy,
124  COMPARISON_FUNCTION _ComparisonFunc = SamplerDesc{}.ComparisonFunc,
125  float _MinLOD = SamplerDesc{}.MinLOD,
126  float _MaxLOD = SamplerDesc{}.MaxLOD) :
127  MinFilter {_MinFilter },
128  MagFilter {_MagFilter },
129  MipFilter {_MipFilter },
130  AddressU {_AddressU },
131  AddressV {_AddressV },
132  AddressW {_AddressW },
133  MipLODBias {_MipLODBias },
134  MaxAnisotropy {_MaxAnisotropy },
135  ComparisonFunc {_ComparisonFunc},
136  MinLOD {_MinLOD },
137  MaxLOD {_MaxLOD }
138  {
139  BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0;
140  }
142 
149  bool operator == (const SamplerDesc& RHS)const
150  {
151  // Name is primarily used for debug purposes and does not affect the state.
152  // It is ignored in comparison operation.
153  return // strcmp(Name, RHS.Name) == 0 &&
154  MinFilter == RHS.MinFilter &&
155  MagFilter == RHS.MagFilter &&
156  MipFilter == RHS.MipFilter &&
157  AddressU == RHS.AddressU &&
158  AddressV == RHS.AddressV &&
159  AddressW == RHS.AddressW &&
160  MipLODBias == RHS.MipLODBias &&
161  MaxAnisotropy == RHS.MaxAnisotropy &&
162  ComparisonFunc == RHS.ComparisonFunc &&
163  BorderColor[0] == RHS.BorderColor[0] &&
164  BorderColor[1] == RHS.BorderColor[1] &&
165  BorderColor[2] == RHS.BorderColor[2] &&
166  BorderColor[3] == RHS.BorderColor[3] &&
167  MinLOD == RHS.MinLOD &&
168  MaxLOD == RHS.MaxLOD;
169  }
170 #endif
171 };
172 typedef struct SamplerDesc SamplerDesc;
173 
174 #define DILIGENT_INTERFACE_NAME ISampler
175 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
176 
177 // clang-format off
178 #define ISamplerInclusiveMethods \
179  IDeviceObjectInclusiveMethods \
180  /*ISamplerMethods Sampler*/
181 // clang-format on
182 
183 #if DILIGENT_CPP_INTERFACE
184 
185 // clang-format off
186 
188 
193 {
194 #if DILIGENT_CPP_INTERFACE
195  virtual const SamplerDesc& METHOD(GetDesc)() const override = 0;
197 #endif
198 };
200 
201 #endif
202 
203 
204 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
205 
206 #if DILIGENT_C_INTERFACE
207 
208 typedef struct ISamplerVtbl
209 {
211 } ISamplerVtbl;
212 
213 typedef struct ISampler
214 {
215  struct ISamplerVtbl* pVtbl;
216 } ISampler;
217 
218 # define ISampler_GetDesc(This) (const struct SamplerDesc*)IDeviceObject_GetDesc(This)
219 
220 #endif
221 
222 DILIGENT_END_NAMESPACE // namespace Diligent
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
Diligent::SamplerDesc
Sampler description.
Definition: Sampler.h:58
Diligent::SamplerDesc::MagFilter
FILTER_TYPE MagFilter
Texture magnification filter, see Diligent::FILTER_TYPE for details. Default value: Diligent::FILTER_...
Definition: Sampler.h:66
Diligent::ISampler
Texture sampler interface.
Definition: Sampler.h:192
Diligent::TEXTURE_ADDRESS_MODE
TEXTURE_ADDRESS_MODE
Texture address mode.
Definition: GraphicsTypes.h:889
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Diligent::SamplerDesc::BorderColor
Float32 BorderColor[4]
Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV,...
Definition: Sampler.h:100
Diligent::SamplerDesc::ComparisonFunc
COMPARISON_FUNCTION ComparisonFunc
A function that compares sampled data against existing sampled data when comparsion filter is used....
Definition: Sampler.h:96
Diligent::Float32
float Float32
32-bit float
Definition: BasicTypes.h:43
Diligent::FILTER_TYPE
FILTER_TYPE
Filter type.
Definition: GraphicsTypes.h:864
Diligent::SamplerDesc::SamplerDesc
SamplerDesc(FILTER_TYPE _MinFilter, FILTER_TYPE _MagFilter, FILTER_TYPE _MipFilter, TEXTURE_ADDRESS_MODE _AddressU=SamplerDesc{}.AddressU, TEXTURE_ADDRESS_MODE _AddressV=SamplerDesc{}.AddressV, TEXTURE_ADDRESS_MODE _AddressW=SamplerDesc{}.AddressW, Float32 _MipLODBias=SamplerDesc{}.MipLODBias, Uint32 _MaxAnisotropy=SamplerDesc{}.MaxAnisotropy, COMPARISON_FUNCTION _ComparisonFunc=SamplerDesc{}.ComparisonFunc, float _MinLOD=SamplerDesc{}.MinLOD, float _MaxLOD=SamplerDesc{}.MaxLOD)
Definition: Sampler.h:116
Diligent::operator==
bool operator==(const Plane3D &p1, const Plane3D &p2)
Definition: AdvancedMath.hpp:442
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
Diligent::SamplerDesc::MipLODBias
Float32 MipLODBias
Offset from the calculated mipmap level. For example, if a sampler calculates that a texture should b...
Definition: Sampler.h:89
Diligent::SamplerDesc::MaxAnisotropy
Uint32 MaxAnisotropy
Maximum anisotropy level for the anisotropic filter. Default value: 0.
Definition: Sampler.h:92
Diligent::SamplerDesc::AddressW
TEXTURE_ADDRESS_MODE AddressW
Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details Default value: ...
Definition: Sampler.h:84
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:1196
Diligent::COMPARISON_FUNC_NEVER
@ COMPARISON_FUNC_NEVER
Comparison never passes. Direct3D counterpart: D3D11_COMPARISON_NEVER/D3D12_COMPARISON_FUNC_NEVER....
Definition: GraphicsTypes.h:938
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
DILIGENT_DERIVE
#define DILIGENT_DERIVE(TypeName)
Definition: CommonDefinitions.h:90
Diligent::SamplerDesc::MaxLOD
float MaxLOD
Specifies the maximum value that LOD is clamped to before accessing the texture MIP levels....
Definition: Sampler.h:110
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::SamplerDesc::MinLOD
float MinLOD
Specifies the minimum value that LOD is clamped to before accessing the texture MIP levels....
Definition: Sampler.h:105
Diligent::COMPARISON_FUNCTION
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:931
Diligent::SamplerDesc::AddressV
TEXTURE_ADDRESS_MODE AddressV
Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details Default value: ...
Definition: Sampler.h:80
DeviceObject.h
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
Diligent::SamplerDesc::SamplerDesc
SamplerDesc() noexcept
Definition: Sampler.h:114
Diligent::SamplerDesc::MinFilter
FILTER_TYPE MinFilter
Texture minification filter, see Diligent::FILTER_TYPE for details. Default value: Diligent::FILTER_T...
Definition: Sampler.h:62
ISamplerInclusiveMethods
#define ISamplerInclusiveMethods
Definition: Sampler.h:178
Diligent::SamplerDesc
struct SamplerDesc SamplerDesc
Definition: Sampler.h:172
Diligent::FILTER_TYPE_LINEAR
@ FILTER_TYPE_LINEAR
Linear filtering.
Definition: GraphicsTypes.h:868
Diligent::TEXTURE_ADDRESS_CLAMP
@ TEXTURE_ADDRESS_CLAMP
Texture coordinates outside the range [0.0, 1.0] are set to the texture color at 0....
Definition: GraphicsTypes.h:905
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::SamplerDesc::MipFilter
FILTER_TYPE MipFilter
Mip filter, see Diligent::FILTER_TYPE for details. Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR,...
Definition: Sampler.h:72
Diligent::SamplerDesc::AddressU
TEXTURE_ADDRESS_MODE AddressU
Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details Default value: ...
Definition: Sampler.h:76
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37