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;
22class HdStCubemapTextureObject;
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
71public:
72 HDST_API
74 HdStUvTextureObject const &uvTexture,
75 HdSamplerParameters const &samplerParameters,
76 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
77
78 HDST_API
79 ~HdStUvSamplerObject() override;
80
84 return _sampler;
85 }
86
87private:
88 HgiSamplerHandle _sampler;
89};
90
96public:
98 HdStFieldTextureObject const &uvTexture,
99 HdSamplerParameters const &samplerParameters,
100 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
101
102 ~HdStFieldSamplerObject() override;
103
107 return _sampler;
108 }
109
110private:
111 HgiSamplerHandle _sampler;
112};
113
120public:
122 HdStPtexTextureObject const &ptexTexture,
123 // samplerParameters are ignored by ptex
124 HdSamplerParameters const &samplerParameters,
125 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
126
127 ~HdStPtexSamplerObject() override;
128
132 return _texelsSampler;
133 }
134
138 return _layoutSampler;
139 }
140
141private:
142 HgiSamplerHandle _texelsSampler;
143 HgiSamplerHandle _layoutSampler;
144};
145
152public:
154 HdStUdimTextureObject const &ptexTexture,
155 // samplerParameters are ignored by udim (at least for now)
156 HdSamplerParameters const &samplerParameters,
157 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
158
159 ~HdStUdimSamplerObject() override;
160
164 return _texelsSampler;
165 }
166
170 return _layoutSampler;
171 }
172
173private:
174 HgiSamplerHandle _texelsSampler;
175 HgiSamplerHandle _layoutSampler;
176};
177
178template<HdStTextureType textureType>
179struct HdSt_TypedSamplerObjectHelper;
180
186template<HdStTextureType textureType>
188 typename HdSt_TypedSamplerObjectHelper<textureType>::type;
189
190template<>
191struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Uv> {
192 using type = HdStUvSamplerObject;
193};
194
195template<>
196struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Field> {
197 using type = HdStFieldSamplerObject;
198};
199
200template<>
201struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Ptex> {
202 using type = HdStPtexSamplerObject;
203};
204
205template<>
206struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Udim> {
207 using type = HdStUdimSamplerObject;
208};
209
210template<>
211struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Cubemap> {
212 using type = HdStUvSamplerObject;
213};
214
215PXR_NAMESPACE_CLOSE_SCOPE
216
217#endif
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:110
A sampler suitable for HdStFieldTextureObject.
Definition: samplerObject.h:95
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:70
const HgiSamplerHandle & GetSampler() const
The sampler.
Definition: samplerObject.h:83
A base class for uv textures (including cubemaps).
Hydra Graphics Interface.
Definition: hgi.h:95