Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngine/interface/Sampler.h Source File

Diligent Engine API Reference

Sampler.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include <cfloat>
30 #include "DeviceObject.h"
31
32 namespace Diligent
33 {
34
35 // {595A59BF-FA81-4855-BC5E-C0E048745A95}
36 static constexpr INTERFACE_ID IID_Sampler =
37 { 0x595a59bf, 0xfa81, 0x4855, { 0xbc, 0x5e, 0xc0, 0xe0, 0x48, 0x74, 0x5a, 0x95 } };
38
40
52 struct SamplerDesc : DeviceObjectAttribs
53 {
55 FILTER_TYPE MinFilter;
56
58 FILTER_TYPE MagFilter;
59
63 FILTER_TYPE MipFilter;
64
66 TEXTURE_ADDRESS_MODE AddressU;
67
69 TEXTURE_ADDRESS_MODE AddressV;
70
72 TEXTURE_ADDRESS_MODE AddressW;
73
77 Float32 MipLODBias;
78
80 Uint32 MaxAnisotropy;
81
84 COMPARISON_FUNCTION ComparisonFunc;
85
87 Float32 BorderColor[4];
88
91 float MinLOD;
92
95 float MaxLOD;
96
98
113 SamplerDesc(FILTER_TYPE _MinFilter = FILTER_TYPE_LINEAR,
114 FILTER_TYPE _MagFilter = FILTER_TYPE_LINEAR,
115 FILTER_TYPE _MipFilter = FILTER_TYPE_LINEAR,
116 TEXTURE_ADDRESS_MODE _AddressU = TEXTURE_ADDRESS_CLAMP,
117 TEXTURE_ADDRESS_MODE _AddressV = TEXTURE_ADDRESS_CLAMP,
118 TEXTURE_ADDRESS_MODE _AddressW = TEXTURE_ADDRESS_CLAMP,
119 Float32 _MipLODBias = 0,
120 Uint32 _MaxAnisotropy = 0,
121 COMPARISON_FUNCTION _ComparisonFunc = COMPARISON_FUNC_NEVER,
122 float _MinLOD = 0,
123 float _MaxLOD = +FLT_MAX) :
124 MinFilter(_MinFilter),
125 MagFilter(_MagFilter),
126 MipFilter(_MipFilter),
127 AddressU(_AddressU),
128 AddressV(_AddressV),
129 AddressW(_AddressW),
130 MipLODBias(_MipLODBias),
131 MaxAnisotropy(_MaxAnisotropy),
132 ComparisonFunc(_ComparisonFunc),
133 MinLOD(_MinLOD),
134 MaxLOD(_MaxLOD)
135 {
136 BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0;
137 }
138
139 SamplerDesc(const SamplerDesc&) = default;
140 SamplerDesc(SamplerDesc&&) = default;
141 SamplerDesc& operator = (const SamplerDesc&) = default;
142 SamplerDesc& operator = (SamplerDesc&&) = default;
143
145
152 bool operator ==(const SamplerDesc& RHS)const
153 {
154 // Name is primarily used for debug purposes and does not affect the state.
155 // It is ignored in comparison operation.
156 return // strcmp(Name, RHS.Name) == 0 &&
157 MinFilter == RHS.MinFilter &&
158 MagFilter == RHS.MagFilter &&
159 MipFilter == RHS.MipFilter &&
160 AddressU == RHS.AddressU &&
161 AddressV == RHS.AddressV &&
162 AddressW == RHS.AddressW &&
163 MipLODBias == RHS.MipLODBias &&
164 MaxAnisotropy == RHS.MaxAnisotropy &&
165 ComparisonFunc == RHS.ComparisonFunc &&
166 BorderColor[0] == RHS.BorderColor[0] &&
167 BorderColor[1] == RHS.BorderColor[1] &&
168 BorderColor[2] == RHS.BorderColor[2] &&
169 BorderColor[3] == RHS.BorderColor[3] &&
170 MinLOD == RHS.MinLOD &&
171 MaxLOD == RHS.MaxLOD;
172 }
173 };
174
176
180 class ISampler : public IDeviceObject
181 {
182 public:
184 virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ) = 0;
185
187 virtual const SamplerDesc& GetDesc()const = 0;
188 };
189
190 }
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:40
Diligent::SamplerDesc::MaxLOD
float MaxLOD
Specifies the maximum value that LOD is clamped to before accessing the texture MIP levels...
Definition: Sampler.h:95
Diligent::TEXTURE_ADDRESS_CLAMP
Texture coordinates outside the range [0.0, 1.0] are set to the texture color at 0.0 or 1.0, respectively. Direct3D Counterpart: D3D11_TEXTURE_ADDRESS_CLAMP/D3D12_TEXTURE_ADDRESS_MODE_CLAMP. OpenGL counterpart: GL_CLAMP_TO_EDGE.
Definition: GraphicsTypes.h:821
Diligent::COMPARISON_FUNC_NEVER
Comparison never passes. Direct3D counterpart: D3D11_COMPARISON_NEVER/D3D12_COMPARISON_FUNC_NEVER. OpenGL counterpart: GL_NEVER.
Definition: GraphicsTypes.h:854
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::SamplerDesc::AddressV
TEXTURE_ADDRESS_MODE AddressV
Texture address mode for V coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details.
Definition: Sampler.h:69
Diligent::TEXTURE_ADDRESS_MODE
TEXTURE_ADDRESS_MODE
Texture address mode.
Definition: GraphicsTypes.h:805
Diligent::ISampler::GetDesc
virtual const SamplerDesc & GetDesc() const =0
Returns the sampler description used to create the object.
Diligent::ISampler::QueryInterface
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface)=0
Queries the specific interface, see IObject::QueryInterface() for details.
Diligent::SamplerDesc::AddressU
TEXTURE_ADDRESS_MODE AddressU
Texture address mode for U coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details.
Definition: Sampler.h:66
Diligent::SamplerDesc::AddressW
TEXTURE_ADDRESS_MODE AddressW
Texture address mode for W coordinate, see Diligent::TEXTURE_ADDRESS_MODE for details.
Definition: Sampler.h:72
Diligent::SamplerDesc
Sampler description.
Definition: Sampler.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:77
Diligent::SamplerDesc::ComparisonFunc
COMPARISON_FUNCTION ComparisonFunc
A function that compares sampled data against existing sampled data when comparsion filter is used...
Definition: Sampler.h:84
Diligent::SamplerDesc::MinLOD
float MinLOD
Specifies the minimum value that LOD is clamped to before accessing the texture MIP levels...
Definition: Sampler.h:91
Diligent::SamplerDesc::SamplerDesc
SamplerDesc(FILTER_TYPE _MinFilter=FILTER_TYPE_LINEAR, FILTER_TYPE _MagFilter=FILTER_TYPE_LINEAR, FILTER_TYPE _MipFilter=FILTER_TYPE_LINEAR, TEXTURE_ADDRESS_MODE _AddressU=TEXTURE_ADDRESS_CLAMP, TEXTURE_ADDRESS_MODE _AddressV=TEXTURE_ADDRESS_CLAMP, TEXTURE_ADDRESS_MODE _AddressW=TEXTURE_ADDRESS_CLAMP, Float32 _MipLODBias=0, Uint32 _MaxAnisotropy=0, COMPARISON_FUNCTION _ComparisonFunc=COMPARISON_FUNC_NEVER, float _MinLOD=0, float _MaxLOD=+FLT_MAX)
Initializes the structure members.
Definition: Sampler.h:113
Diligent::DeviceObjectAttribs
Describes common device object attributes.
Definition: GraphicsTypes.h:900
Diligent::FILTER_TYPE
FILTER_TYPE
Filter type.
Definition: GraphicsTypes.h:780
Diligent::SamplerDesc::MipFilter
FILTER_TYPE MipFilter
Mip filter, see Diligent::FILTER_TYPE for details. Only FILTER_TYPE_POINT, FILTER_TYPE_LINEAR, FILTER_TYPE_ANISOTROPIC, and FILTER_TYPE_COMPARISON_ANISOTROPIC are allowed.
Definition: Sampler.h:63
Diligent::SamplerDesc::BorderColor
Float32 BorderColor[4]
Border color to use if TEXTURE_ADDRESS_BORDER is specified for AddressU, AddressV, or AddressW.
Definition: Sampler.h:87
Diligent::SamplerDesc::MaxAnisotropy
Uint32 MaxAnisotropy
Maximum anisotropy level for the anisotropic filter.
Definition: Sampler.h:80
Diligent::ISampler
Texture sampler interface.
Definition: Sampler.h:180
Diligent::SamplerDesc::MinFilter
FILTER_TYPE MinFilter
Texture minification filter, see Diligent::FILTER_TYPE for details.
Definition: Sampler.h:55
Diligent::COMPARISON_FUNCTION
COMPARISON_FUNCTION
Comparison function.
Definition: GraphicsTypes.h:847
Diligent::SamplerDesc::MagFilter
FILTER_TYPE MagFilter
Texture magnification filter, see Diligent::FILTER_TYPE for details.
Definition: Sampler.h:58
Diligent::SamplerDesc::operator==
bool operator==(const SamplerDesc &RHS) const
Tests if two structures are equivalent.
Definition: Sampler.h:152
Diligent::FILTER_TYPE_LINEAR
Linear filtering.
Definition: GraphicsTypes.h:784