All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
textureHandle.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 HD_ST_TEXTURE_HANDLE_H
25 #define HD_ST_TEXTURE_HANDLE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
30 #include "pxr/imaging/hd/enums.h"
31 #include "pxr/imaging/hd/types.h"
32 
33 #include <memory>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 using HdStShaderCodePtr =
38  std::weak_ptr<class HdStShaderCode>;
39 using HdStTextureObjectSharedPtr =
40  std::shared_ptr<class HdStTextureObject>;
41 using HdStSamplerObjectSharedPtr =
42  std::shared_ptr<class HdStSamplerObject>;
43 
44 using HdStTextureHandleSharedPtr =
45  std::shared_ptr<class HdStTextureHandle>;
46 
47 class HdSt_TextureHandleRegistry;
48 
61 {
62 public:
64  HDST_API
66  HdStTextureObjectSharedPtr const &textureObject,
67  const HdSamplerParameters &samplerParams,
68  size_t memoryRequest,
69  bool createBindlessHandle,
70  HdStShaderCodePtr const & shaderCode,
71  HdSt_TextureHandleRegistry *textureHandleRegistry);
72 
73  HDST_API
74  ~HdStTextureHandle();
75 
79  HdStTextureObjectSharedPtr const &GetTextureObject() const {
80  return _textureObject;
81  }
82 
86  HdStSamplerObjectSharedPtr const &GetSamplerObject() const {
87  return _samplerObject;
88  }
89 
93  return _samplerParams;
94  }
95 
98  size_t GetMemoryRequest() const {
99  return _memoryRequest;
100  }
101 
104  HdStShaderCodePtr const &GetShaderCode() const {
105  return _shaderCode;
106  }
107 
113  HDST_API
115 
116 private:
117  HdStTextureObjectSharedPtr _textureObject;
118  HdStSamplerObjectSharedPtr _samplerObject;
119  HdSamplerParameters _samplerParams;
120  size_t _memoryRequest;
121  bool _createBindlessHandle;
122  HdStShaderCodePtr _shaderCode;
123  HdSt_TextureHandleRegistry *_textureHandleRegistry;
124 };
125 
126 PXR_NAMESPACE_CLOSE_SCOPE
127 
128 #endif
HDST_API void ReallocateSamplerIfNecessary()
Allocate sampler for this handle (not thread-safe).
HdStShaderCodePtr const & GetShaderCode() const
Get the shader code associated with this handle.
HdSamplerParameters const & GetSamplerParameters() const
Get sampler parameters.
Definition: textureHandle.h:92
HdStTextureObjectSharedPtr const & GetTextureObject() const
Get texture object.
Definition: textureHandle.h:79
size_t GetMemoryRequest() const
Get how much memory this handle requested for the texture.
Definition: textureHandle.h:98
HdStSamplerObjectSharedPtr const & GetSamplerObject() const
Get sampler object.
Definition: textureHandle.h:86
Collection of standard parameters such as wrap modes to sample a texture.
Definition: types.h:109
HDST_API HdStTextureHandle(HdStTextureObjectSharedPtr const &textureObject, const HdSamplerParameters &samplerParams, size_t memoryRequest, bool createBindlessHandle, HdStShaderCodePtr const &shaderCode, HdSt_TextureHandleRegistry *textureHandleRegistry)
See HdStResourceRegistry::AllocateTextureHandle for details.
Represents a texture and sampler that will be allocated and loaded from a texture file during commit...
Definition: textureHandle.h:60