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 /// </ul>
57 ///
59 {
67  {}
68 
76 };
77 
78 HGI_API
79 bool operator==(
80  const HgiSamplerDesc& lhs,
81  const HgiSamplerDesc& rhs);
82 
83 HGI_API
84 bool operator!=(
85  const HgiSamplerDesc& lhs,
86  const HgiSamplerDesc& rhs);
87 
88 
89 ///
90 /// \class HgiSampler
91 ///
92 /// Represents a graphics platform independent GPU sampler resource that
93 /// perform texture sampling operations.
94 /// Samplers should be created via Hgi::CreateSampler.
95 ///
97 {
98 public:
99  HGI_API
100  virtual ~HgiSampler();
101 
102  /// The descriptor describes the object.
103  HGI_API
104  HgiSamplerDesc const& GetDescriptor() const;
105 
106  /// This function returns the handle to the Hgi backend's gpu resource, cast
107  /// to a uint64_t. Clients should avoid using this function and instead
108  /// use Hgi base classes so that client code works with any Hgi platform.
109  /// For transitioning code to Hgi, it can however we useful to directly
110  /// access a platform's internal resource handles.
111  /// There is no safety provided in using this. If you by accident pass a
112  /// HgiMetal resource into an OpenGL call, bad things may happen.
113  /// In OpenGL this returns the GLuint resource name.
114  /// In Metal this returns the id<MTLSamplerState> as uint64_t.
115  /// In Vulkan this returns the VkSampler as uint64_t.
116  HGI_API
117  virtual uint64_t GetRawResource() const = 0;
118 
119 protected:
120  HGI_API
121  HgiSampler(HgiSamplerDesc const& desc);
122 
124 
125 private:
126  HgiSampler() = delete;
127  HgiSampler & operator=(const HgiSampler&) = delete;
128  HgiSampler(const HgiSampler&) = delete;
129 };
130 
132 using HgiSamplerHandleVector = std::vector<HgiSamplerHandle>;
133 
134 
136 
137 #endif
HgiSamplerAddressMode
Definition: enums.h:121
HgiMipFilter
Definition: enums.h:164
HgiMipFilter mipFilter
Definition: sampler.h:72
HgiSamplerAddressMode addressModeU
Definition: sampler.h:73
HgiSamplerFilter minFilter
Definition: sampler.h:71
HgiSamplerFilter magFilter
Definition: sampler.h:70
virtual HGI_API ~HgiSampler()
virtual HGI_API uint64_t GetRawResource() const =0
std::string debugName
Definition: sampler.h:69
HGI_API HgiSamplerDesc const & GetDescriptor() const
The descriptor describes the object.
HgiSamplerDesc()
Definition: sampler.h:60
HgiSamplerAddressMode addressModeV
Definition: sampler.h:74
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:570
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::vector< HgiSamplerHandle > HgiSamplerHandleVector
Definition: sampler.h:132
HgiSamplerDesc _descriptor
Definition: sampler.h:123
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556
HgiSamplerFilter
Definition: enums.h:143
HgiSamplerAddressMode addressModeW
Definition: sampler.h:75