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;
26class HdSt_SamplerObjectRegistry;
28
29using HdStSamplerObjectSharedPtr =
30 std::shared_ptr<class HdStSamplerObject>;
31
49{
50public:
51 virtual ~HdStSamplerObject() = 0;
52
53protected:
54 explicit HdStSamplerObject(
55 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
56
57 Hgi* _GetHgi() const;
58 HdSt_SamplerObjectRegistry * const _samplerObjectRegistry;
59};
60
66public:
67 HDST_API
69 HdStUvTextureObject const &uvTexture,
70 HdSamplerParameters const &samplerParameters,
71 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
72
73 HDST_API
74 ~HdStUvSamplerObject() override;
75
79 return _sampler;
80 }
81
82private:
83 HgiSamplerHandle _sampler;
84};
85
91public:
93 HdStFieldTextureObject const &uvTexture,
94 HdSamplerParameters const &samplerParameters,
95 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
96
97 ~HdStFieldSamplerObject() override;
98
102 return _sampler;
103 }
104
105private:
106 HgiSamplerHandle _sampler;
107};
108
115public:
117 HdStPtexTextureObject const &ptexTexture,
118 // samplerParameters are ignored by ptex
119 HdSamplerParameters const &samplerParameters,
120 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
121
122 ~HdStPtexSamplerObject() override;
123
127 return _texelsSampler;
128 }
129
133 return _layoutSampler;
134 }
135
136private:
137 HgiSamplerHandle _texelsSampler;
138 HgiSamplerHandle _layoutSampler;
139};
140
147public:
149 HdStUdimTextureObject const &ptexTexture,
150 // samplerParameters are ignored by udim (at least for now)
151 HdSamplerParameters const &samplerParameters,
152 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
153
154 ~HdStUdimSamplerObject() override;
155
159 return _texelsSampler;
160 }
161
165 return _layoutSampler;
166 }
167
168private:
169 HgiSamplerHandle _texelsSampler;
170 HgiSamplerHandle _layoutSampler;
171};
172
173template<HdStTextureType textureType>
174struct HdSt_TypedSamplerObjectHelper;
175
181template<HdStTextureType textureType>
183 typename HdSt_TypedSamplerObjectHelper<textureType>::type;
184
185template<>
186struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Uv> {
187 using type = HdStUvSamplerObject;
188};
189
190template<>
191struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Field> {
192 using type = HdStFieldSamplerObject;
193};
194
195template<>
196struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Ptex> {
197 using type = HdStPtexSamplerObject;
198};
199
200template<>
201struct HdSt_TypedSamplerObjectHelper<HdStTextureType::Udim> {
202 using type = HdStUdimSamplerObject;
203};
204
205PXR_NAMESPACE_CLOSE_SCOPE
206
207#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:90
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:49
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:65
const HgiSamplerHandle & GetSampler() const
The sampler.
Definition: samplerObject.h:78
A base class for uv textures.
Hydra Graphics Interface.
Definition: hgi.h:94