All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderCode.h
1 //
2 // Copyright 2016 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_SHADER_CODE_H
25 #define PXR_IMAGING_HD_ST_SHADER_CODE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 
31 #include "pxr/imaging/hd/materialParam.h"
32 #include "pxr/imaging/hdSt/resourceBinder.h" // XXX: including a private class
33 #include "pxr/base/tf/token.h"
34 
35 #include <boost/shared_ptr.hpp>
36 
37 #include <string>
38 #include <vector>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
42 
43 typedef std::vector<class HdBindingRequest> HdBindingRequestVector;
44 
45 typedef boost::shared_ptr<class HdStShaderCode> HdStShaderCodeSharedPtr;
46 typedef std::vector<HdStShaderCodeSharedPtr> HdStShaderCodeSharedPtrVector;
47 
48 typedef boost::shared_ptr<class HdStTextureResourceHandle>
49  HdStTextureResourceHandleSharedPtr;
50 
51 class HdRenderPassState;
52 
53 
62 public:
63  typedef size_t ID;
64 
65  HDST_API
67  HDST_API
68  virtual ~HdStShaderCode();
69 
71  virtual ID ComputeHash() const = 0;
72 
74  HDST_API
75  static ID ComputeHash(HdStShaderCodeSharedPtrVector const &shaders);
76 
79  virtual std::string GetSource(TfToken const &shaderStageKey) const = 0;
80 
81  // XXX: Should be pure-virtual
83  HDST_API
84  virtual HdMaterialParamVector const& GetParams() const;
85 
87  HDST_API
88  virtual bool IsEnabledPrimvarFiltering() const;
89 
91  HDST_API
92  virtual TfTokenVector const& GetPrimvarNames() const;
93 
94  struct TextureDescriptor {
95  TfToken name;
96  HdStTextureResourceHandleSharedPtr handle;
97  enum { TEXTURE_2D, TEXTURE_3D, TEXTURE_UDIM_ARRAY, TEXTURE_UDIM_LAYOUT,
98  TEXTURE_PTEX_TEXEL, TEXTURE_PTEX_LAYOUT };
99  int type;
100  };
101  typedef std::vector<TextureDescriptor> TextureDescriptorVector;
102 
103  // XXX: DOC
104  HDST_API
105  virtual TextureDescriptorVector GetTextures() const;
106 
107  // XXX: Should be pure-virtual
110  HDST_API
111  virtual HdBufferArrayRangeSharedPtr const& GetShaderData() const;
112 
116  virtual void BindResources(int program,
117  HdSt_ResourceBinder const &binder,
118  HdRenderPassState const &state) = 0;
119 
121  virtual void UnbindResources(int program,
122  HdSt_ResourceBinder const &binder,
123  HdRenderPassState const &state) = 0;
124 
126  virtual void AddBindings(HdBindingRequestVector* customBindings) = 0;
127 
133  HDST_API
134  virtual TfToken GetMaterialTag() const;
135 
136 private:
137 
138  // No copying
139  HdStShaderCode(const HdStShaderCode &) = delete;
140  HdStShaderCode &operator =(const HdStShaderCode &) = delete;
141 };
142 
143 
144 PXR_NAMESPACE_CLOSE_SCOPE
145 
146 #endif //HDST_SHADER_H
virtual void BindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
virtual void UnbindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
Unbinds shader-specific resources.
virtual HDST_API TfToken GetMaterialTag() const
Material tags can be set in the meta-data of a glslfx file to control what rprim collection that prim...
virtual HDST_API HdBufferArrayRangeSharedPtr const & GetShaderData() const
Returns a buffer which stores parameter fallback values and texture handles.
virtual std::string GetSource(TfToken const &shaderStageKey) const =0
Returns the shader source provided by this shader for shaderStageKey.
virtual void AddBindings(HdBindingRequestVector *customBindings)=0
Add custom bindings (used by codegen)
A set of rendering parameters used among render passes.
virtual HDST_API bool IsEnabledPrimvarFiltering() const
Returns whether primvar filtering is enabled for this shader.
virtual HDST_API TfTokenVector const & GetPrimvarNames() const
Returns the names of primvar that are used by this shader.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual HDST_API HdMaterialParamVector const & GetParams() const
Returns the shader parameters for this shader.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:433
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
Definition: shaderCode.h:61
virtual ID ComputeHash() const =0
Returns the hash value of this shader.