HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
textureResourceHandle.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_TEXTURE_RESOURCE_HANDLE_H
25 #define PXR_IMAGING_HD_ST_TEXTURE_RESOURCE_HANDLE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 
31 
32 #include <memory>
33 
35 
36 class HdRenderIndex;
37 class SdfPath;
38 
40  std::shared_ptr<class HdStTextureResourceHandle>;
41 
42 using HdStTextureResourceSharedPtr = std::shared_ptr<class HdStTextureResource>;
43 
44 /// HdStTextureResourceHandle is an indirect handle to a GL texture resource
45 ///
46 /// This class provides a way for an HdStTextureResource to be registered
47 /// for a specific scene path. This allows clients (e.g. shader code) to
48 /// access the most recently registered texture resource without having
49 /// to directly observe changes to upstream material, texture, or drawtarget
50 /// texture resource changes.
51 ///
52 /// The underlying HdStTextureResource instances are typically created
53 /// outside of HdSt. They are obtained from the scene delegate and are
54 /// registered with the resource registry via an HdTextureResource::ID
55 /// which is also provided by the scene delegate.
56 ///
57 /// Clients which use HdStTexture resources (e.g. shader code) get the
58 /// underlying GL texture object and GL sampler object IDs from the
59 /// texture resource.
60 ///
61 /// So:
62 /// HdStShaderCode has an array of texture descriptors holding
63 /// HdStTextureResourceHandles. HdStShaderCode binds GL texture
64 /// and sampler objects for the current set of underlying
65 /// HdStTextureResource instances.
66 ///
67 /// HdStTexture Bprim and HdStDrawTarget Sprim and HdStMaterial Sprim
68 /// register HdStTextureResource instances with their scene delegate
69 /// provided HdTextureResource::ID and also register their current
70 /// HdStTextureResource instances with scene path locations using
71 /// HdStTextureResourceHandles.
72 ///
73 /// HdStMaterial Sprim can assign HdStTextureResourceHandles to
74 /// HdStShaderCode to satisfy input texture scene path connections
75 /// and allow HdStShaderCode to resolve GL texture and sampler objects
76 /// during resource bind/unbind.
77 ///
78 /// We then need to propagate dirtiness from HdTexture to HdMaterial
79 /// only when an incompatible change is made to the texture resource
80 /// binding, avoiding an expensive invalidation, e.g. for animated
81 /// texture sources.
82 ///
83 /// This class provides static helper methods to compute registry keys and
84 /// to identify incompatible texture resource changes.
85 ///
87 public:
88  HDST_API
90  HdStTextureResourceSharedPtr const & textureResource = nullptr);
91 
92  HDST_API
94 
95  HDST_API
97 
98  HDST_API
99  void SetTextureResource(
100  HdStTextureResourceSharedPtr const & textureResource);
101 
102  HDST_API
104  HdRenderIndex const * renderIndex,
105  SdfPath const &textureHandleId);
106 
107  HDST_API
108  static bool IsIncompatibleTextureResource(
111 
112 private:
113  HdStTextureResourceSharedPtr _textureResource;
114 
115  HdStTextureResourceHandle(const HdStTextureResourceHandle &)
116  = delete;
117  HdStTextureResourceHandle &operator =(const HdStTextureResourceHandle &)
118  = delete;
119 };
120 
121 
123 
124 #endif //PXR_IMAGING_HD_ST_TEXTURE_RESOURCE_HANDLE_H
HDST_API HdStTextureResourceSharedPtr const & GetTextureResource() const
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
HDST_API void SetTextureResource(HdStTextureResourceSharedPtr const &textureResource)
std::shared_ptr< class HdStTextureResourceHandle > HdStTextureResourceHandleSharedPtr
Definition: material.h:44
std::shared_ptr< class HdStTextureResource > HdStTextureResourceSharedPtr
Definition: material.h:42
static HDST_API bool IsIncompatibleTextureResource(HdStTextureResourceSharedPtr const &a, HdStTextureResourceSharedPtr const &b)
Definition: path.h:288
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
virtual HDST_API ~HdStTextureResourceHandle()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define HDST_API
Definition: api.h:40
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDST_API HdStTextureResourceHandle(HdStTextureResourceSharedPtr const &textureResource=nullptr)
static HDST_API HdTextureResource::ID GetHandleKey(HdRenderIndex const *renderIndex, SdfPath const &textureHandleId)