HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
textureBinder.h
Go to the documentation of this file.
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_TEXTURE_BINDER_H
25 #define PXR_IMAGING_HD_ST_TEXTURE_BINDER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
30 
32 
33 using HdBufferSpecVector = std::vector<struct HdBufferSpec>;
34 
35 /// \class HdSt_TextureBinder
36 ///
37 /// A class helping HdStShaderCode with binding textures.
38 ///
39 /// This class helps binding GL texture names or populating the shader
40 /// bar with texture sampler handles if bindless textures are used. It
41 /// also includes writing texture metadata such as the sampling
42 /// transform to the shader bar.
43 ///
45 public:
46  using NamedTextureHandle =
50 
51  /// Add buffer specs necessary for the textures (e.g., for
52  /// bindless texture sampler handles or sampling transform).
53  ///
54  /// Specify whether to use the texture by binding it or by
55  /// using bindless handles with useBindlessHandles.
56  ///
57  static void
60  bool useBindlessHandles,
61  HdBufferSpecVector * specs);
62 
63  /// Compute buffer sources for shader bar.
64  ///
65  /// This works in conjunction with GetBufferSpecs, but unlike
66  /// GetBufferSpecs is extracting information from the texture
67  /// handles and thus can only be called after the textures have
68  /// been committed in
69  /// HdStShaderCode::AddResourcesFromTextures().
70  ///
71  /// Specify whether to use the texture by binding it or by
72  /// using bindless handles with useBindlessHandles.
73  ///
74  static void
77  bool useBindlessHandles,
79 
80  /// Bind textures.
81  ///
82  /// Specify whether to use the texture by binding it or by
83  /// using bindless handles with useBindlessHandles.
84  ///
85  static void
87  HdSt_ResourceBinder const &binder,
88  bool useBindlessHandles,
90 
91  /// Unbind textures.
92  ///
93  /// Specify whether to use the texture by binding it or by
94  /// using bindless handles with useBindlessHandles.
95  ///
96  static void
98  HdSt_ResourceBinder const &binder,
99  bool useBindlessHandles,
101 };
102 
104 
105 #endif // PXR_IMAGING_HD_ST_TEXTURE_BINDER_H
static void ComputeBufferSources(const NamedTextureHandleVector &textures, bool useBindlessHandles, HdBufferSourceSharedPtrVector *sources)
HdStShaderCode::NamedTextureHandleVector NamedTextureHandleVector
Definition: textureBinder.h:49
static void BindResources(HdSt_ResourceBinder const &binder, bool useBindlessHandles, const NamedTextureHandleVector &textures)
std::vector< HdBufferSourceSharedPtr > HdBufferSourceSharedPtrVector
Definition: bufferSource.h:44
const GLuint * textures
Definition: glcorearb.h:415
GLsizei GLenum * sources
Definition: glcorearb.h:2541
static void UnbindResources(HdSt_ResourceBinder const &binder, bool useBindlessHandles, const NamedTextureHandleVector &textures)
static void GetBufferSpecs(const NamedTextureHandleVector &textures, bool useBindlessHandles, HdBufferSpecVector *specs)
std::vector< struct HdBufferSpec > HdBufferSpecVector
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
std::vector< NamedTextureHandle > NamedTextureHandleVector
Definition: shaderCode.h:154
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91