Loading...
Searching...
No Matches
samplerObject.h
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_HD_ST_SAMPLER_OBJECT_H
25#define PXR_IMAGING_HD_ST_SAMPLER_OBJECT_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hdSt/api.h"
29
30#include "pxr/imaging/hgi/handle.h"
31#include "pxr/imaging/hd/enums.h"
32#include "pxr/imaging/hd/types.h"
33
34#include <memory>
35
36PXR_NAMESPACE_OPEN_SCOPE
37
38class Hgi;
43class HdSt_SamplerObjectRegistry;
45
46using HdStSamplerObjectSharedPtr =
47 std::shared_ptr<class HdStSamplerObject>;
48
66{
67public:
68 virtual ~HdStSamplerObject() = 0;
69
70protected:
71 explicit HdStSamplerObject(
72 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
73
74 Hgi* _GetHgi() const;
75 HdSt_SamplerObjectRegistry * const _samplerObjectRegistry;
76};
77
83public:
84 HDST_API
86 HdStUvTextureObject const &uvTexture,
87 HdSamplerParameters const &samplerParameters,
88 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
89
90 HDST_API
91 ~HdStUvSamplerObject() override;
92
96 return _sampler;
97 }
98
99private:
100 HgiSamplerHandle _sampler;
101};
102
108public:
110 HdStFieldTextureObject const &uvTexture,
111 HdSamplerParameters const &samplerParameters,
112 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
113
114 ~HdStFieldSamplerObject() override;
115
119 return _sampler;
120 }
121
122private:
123 HgiSamplerHandle _sampler;
124};
125
132public:
134 HdStPtexTextureObject const &ptexTexture,
135 // samplerParameters are ignored by ptex
136 HdSamplerParameters const &samplerParameters,
137 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
138
139 ~HdStPtexSamplerObject() override;
140
144 return _texelsSampler;
145 }
146
150 return _layoutSampler;
151 }
152
153private:
154 HgiSamplerHandle _texelsSampler;
155 HgiSamplerHandle _layoutSampler;
156};
157
164public:
166 HdStUdimTextureObject const &ptexTexture,
167 // samplerParameters are ignored by udim (at least for now)
168 HdSamplerParameters const &samplerParameters,
169 HdSt_SamplerObjectRegistry * samplerObjectRegistry);
170
171 ~HdStUdimSamplerObject() override;
172
176 return _texelsSampler;
177 }
178
182 return _layoutSampler;
183 }
184
185private:
186 HgiSamplerHandle _texelsSampler;
187 HgiSamplerHandle _layoutSampler;
188};
189
190template<HdTextureType textureType>
191struct HdSt_TypedSamplerObjectHelper;
192
198template<HdTextureType textureType>
200 typename HdSt_TypedSamplerObjectHelper<textureType>::type;
201
202template<>
203struct HdSt_TypedSamplerObjectHelper<HdTextureType::Uv> {
204 using type = HdStUvSamplerObject;
205};
206
207template<>
208struct HdSt_TypedSamplerObjectHelper<HdTextureType::Field> {
209 using type = HdStFieldSamplerObject;
210};
211
212template<>
213struct HdSt_TypedSamplerObjectHelper<HdTextureType::Ptex> {
214 using type = HdStPtexSamplerObject;
215};
216
217template<>
218struct HdSt_TypedSamplerObjectHelper<HdTextureType::Udim> {
219 using type = HdStUdimSamplerObject;
220};
221
222PXR_NAMESPACE_CLOSE_SCOPE
223
224#endif
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:127
A sampler suitable for HdStFieldTextureObject.
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:66
A template alias such that, e.g., HdStUvSamplerObject can be accessed as HdStTypedSamplerObject<HdTex...
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:82
const HgiSamplerHandle & GetSampler() const
The sampler.
Definition: samplerObject.h:95
A base class for uv textures.
Hydra Graphics Interface.
Definition: hgi.h:111