Loading...
Searching...
No Matches
samplerObject.h
1//
2// Copyright 2020 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_ST_SAMPLER_OBJECT_H
8#define PXR_IMAGING_HD_ST_SAMPLER_OBJECT_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/enums.h"
13
14#include "pxr/imaging/hgi/handle.h"
15#include "pxr/imaging/hd/types.h"
16
17#include <memory>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class Hgi;
27class HdSt_SamplerObjectRegistry;
29
30using HdStSamplerObjectSharedPtr =
31 std::shared_ptr<class HdStSamplerObject>;
32
50{
51public:
52 virtual ~HdStSamplerObject() = 0;
53
54protected:
55 explicit HdStSamplerObject(
56 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
57
58 Hgi* _GetHgi() const;
59 HdSt_SamplerObjectRegistry * const _samplerObjectRegistry;
60};
61
67public:
68 HDST_API
70 HdStUvTextureObject const &uvTexture,
71 HdSamplerParameters const &samplerParameters,
72 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
73
74 HDST_API
75 ~HdStUvSamplerObject() override;
76
80 return _sampler;
81 }
82
83private:
84 HgiSamplerHandle _sampler;
85};
86
92public:
94 HdStFieldTextureObject const &uvTexture,
95 HdSamplerParameters const &samplerParameters,
96 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
97
98 ~HdStFieldSamplerObject() override;
99
103 return _sampler;
104 }
105
106private:
107 HgiSamplerHandle _sampler;
108};
109
116public:
118 HdStPtexTextureObject const &ptexTexture,
119 // samplerParameters are ignored by ptex
120 HdSamplerParameters const &samplerParameters,
121 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
122
123 ~HdStPtexSamplerObject() override;
124
128 return _texelsSampler;
129 }
130
134 return _layoutSampler;
135 }
136
137private:
138 HgiSamplerHandle _texelsSampler;
139 HgiSamplerHandle _layoutSampler;
140};
141
148public:
150 HdStUdimTextureObject const &ptexTexture,
151 // samplerParameters are ignored by udim (at least for now)
152 HdSamplerParameters const &samplerParameters,
153 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
154
155 ~HdStUdimSamplerObject() override;
156
160 return _texelsSampler;
161 }
162
166 return _layoutSampler;
167 }
168
169private:
170 HgiSamplerHandle _texelsSampler;
171 HgiSamplerHandle _layoutSampler;
172};
173
182public:
183 HDST_API
185 HdStCubemapTextureObject const &cubemapTexture,
186 HdSamplerParameters const &samplerParameters,
187 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
188
189 HDST_API
190 ~HdStCubemapSamplerObject() override;
191
195 return _sampler;
196 }
197
198private:
199 HgiSamplerHandle _sampler;
200};
201
202template<HdStTextureType textureType>
203struct HdSt_TypedSamplerObjectHelper;
204
210template<HdStTextureType textureType>
212 typename HdSt_TypedSamplerObjectHelper<textureType>::type;
213
214template<>
215struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Uv> {
216 using type = HdStUvSamplerObject;
217};
218
219template<>
220struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Field> {
221 using type = HdStFieldSamplerObject;
222};
223
224template<>
225struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Ptex> {
226 using type = HdStPtexSamplerObject;
227};
228
229template<>
230struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Udim> {
231 using type = HdStUdimSamplerObject;
232};
233
234template<>
235struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Cubemap> {
236 using type = HdStCubemapSamplerObject;
237};
238
239PXR_NAMESPACE_CLOSE_SCOPE
240
241#endif
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:110
A sampler suitable for HdStCubemapTextureObject.
const HgiSamplerHandle & GetSampler() const
The sampler.
A base class for cubemap textures.
A sampler suitable for HdStFieldTextureObject.
Definition: samplerObject.h:91
const HgiSamplerHandle & GetSampler() const
The sampler.
A uvw texture with a bounding box describing how to transform it.
Ptex doesn't bind samplers, so this class is just holding a sampler to resolve handles for bindless t...
const HgiSamplerHandle & GetTexelsSampler() const
The GPU sampler object for the texels texture.
const HgiSamplerHandle & GetLayoutSampler() const
The GPU sampler object for the layout texture.
A base class encapsulating a GPU sampler object.
Definition: samplerObject.h:50
A template alias such that, e.g., HdStUvSamplerObject can be accessed as HdStTypedSamplerObject<HdStT...
A sampler suitable for Udim textures (wraps one GPU sampler for the texels texture).
const HgiSamplerHandle & GetTexelsSampler() const
The GPU sampler object for the texels texture.
const HgiSamplerHandle & GetLayoutSampler() const
The GPU sampler object for the layout texture.
A sampler suitable for HdStUvTextureObject.
Definition: samplerObject.h:66
const HgiSamplerHandle & GetSampler() const
The sampler.
Definition: samplerObject.h:79
A base class for uv textures.
Hydra Graphics Interface.
Definition: hgi.h:95