HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sampler.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HGI_SAMPLER_H
25 #define PXR_IMAGING_HGI_SAMPLER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
29 #include "pxr/imaging/hgi/enums.h"
30 #include "pxr/imaging/hgi/handle.h"
31 #include "pxr/imaging/hgi/types.h"
32 
33 #include <string>
34 #include <vector>
35 
37 
38 
39 /// \struct HgiSamplerDesc
40 ///
41 /// Describes the properties needed to create a GPU sampler.
42 ///
43 /// <ul>
44 /// <li>debugName:
45 /// This label can be applied as debug label for GPU debugging.</li>
46 /// <li>magFilter:
47 /// The (magnification) filter used to combine pixels when the sample area is
48 /// smaller than a pixel.</li>
49 /// <li>minFilter:
50 /// The (minification) filter used to combine pixels when the sample area is
51 /// larger than a pixel.</li>
52 /// <li> mipFilter:
53 /// The filter used for combining pixels between two mipmap levels.</li>
54 /// <li>addressMode***:
55 /// Wrapping modes.</li>
56 /// <li>borderColor:
57 /// The border color for clamped texture values.</li>
58 /// <li>enableCompare:
59 /// Enables sampler comparison against a reference value during lookups.</li>
60 /// <li>compareFunction:
61 /// The comparison function to apply if sampler compare is enabled.</li>
62 /// </ul>
63 ///
65 {
74  , enableCompare(false)
76  {}
77 
88 };
89 
90 HGI_API
91 bool operator==(
92  const HgiSamplerDesc& lhs,
93  const HgiSamplerDesc& rhs);
94 
95 HGI_API
96 bool operator!=(
97  const HgiSamplerDesc& lhs,
98  const HgiSamplerDesc& rhs);
99 
100 
101 ///
102 /// \class HgiSampler
103 ///
104 /// Represents a graphics platform independent GPU sampler resource that
105 /// perform texture sampling operations.
106 /// Samplers should be created via Hgi::CreateSampler.
107 ///
109 {
110 public:
111  HGI_API
112  virtual ~HgiSampler();
113 
114  /// The descriptor describes the object.
115  HGI_API
116  HgiSamplerDesc const& GetDescriptor() const;
117 
118  /// This function returns the handle to the Hgi backend's gpu resource, cast
119  /// to a uint64_t. Clients should avoid using this function and instead
120  /// use Hgi base classes so that client code works with any Hgi platform.
121  /// For transitioning code to Hgi, it can however we useful to directly
122  /// access a platform's internal resource handles.
123  /// There is no safety provided in using this. If you by accident pass a
124  /// HgiMetal resource into an OpenGL call, bad things may happen.
125  /// In OpenGL this returns the GLuint resource name.
126  /// In Metal this returns the id<MTLSamplerState> as uint64_t.
127  /// In Vulkan this returns the VkSampler as uint64_t.
128  HGI_API
129  virtual uint64_t GetRawResource() const = 0;
130 
131 protected:
132  HGI_API
133  HgiSampler(HgiSamplerDesc const& desc);
134 
136 
137 private:
138  HgiSampler() = delete;
139  HgiSampler & operator=(const HgiSampler&) = delete;
140  HgiSampler(const HgiSampler&) = delete;
141 };
142 
144 using HgiSamplerHandleVector = std::vector<HgiSamplerHandle>;
145 
146 
148 
149 #endif
HgiSamplerAddressMode
Definition: enums.h:173
HgiCompareFunction
Definition: enums.h:541
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HgiCompareFunction compareFunction
Definition: sampler.h:87
HgiMipFilter
Definition: enums.h:216
HgiMipFilter mipFilter
Definition: sampler.h:81
HgiSamplerAddressMode addressModeU
Definition: sampler.h:82
HgiSamplerFilter minFilter
Definition: sampler.h:80
HgiSamplerFilter magFilter
Definition: sampler.h:79
virtual HGI_API ~HgiSampler()
virtual HGI_API uint64_t GetRawResource() const =0
HgiBorderColor
Definition: enums.h:235
std::string debugName
Definition: sampler.h:78
HGI_API HgiSamplerDesc const & GetDescriptor() const
The descriptor describes the object.
HgiBorderColor borderColor
Definition: sampler.h:85
HgiSamplerDesc()
Definition: sampler.h:66
HgiSamplerAddressMode addressModeV
Definition: sampler.h:83
bool enableCompare
Definition: sampler.h:86
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::vector< HgiSamplerHandle > HgiSamplerHandleVector
Definition: sampler.h:144
HgiSamplerDesc _descriptor
Definition: sampler.h:135
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HgiSamplerFilter
Definition: enums.h:195
HgiSamplerAddressMode addressModeW
Definition: sampler.h:84