All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mixinShader.h
1 //
2 // Copyright 2017 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_MIXIN_SHADER_H
25 #define PXR_IMAGING_HD_ST_MIXIN_SHADER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hdSt/shaderCode.h"
30 
31 PXR_NAMESPACE_OPEN_SCOPE
32 
40 class HdStMixinShader final : public HdStShaderCode {
41 public:
42 
43  HDST_API
44  HdStMixinShader(
45  std::string mixinSource,
46  HdStShaderCodeSharedPtr baseShader);
47 
48  HDST_API
49  virtual ~HdStMixinShader();
50 
52  virtual HdStShaderCode::ID ComputeHash() const override;
53 
56  virtual std::string GetSource(TfToken const &shaderStageKey) const override;
57 
58  virtual HdMaterialParamVector const& GetParams() const override;
59 
60  virtual bool IsEnabledPrimvarFiltering() const override;
61 
62  virtual TfTokenVector const& GetPrimvarNames() const override;
63 
64  virtual HdStShaderCode::TextureDescriptorVector GetTextures() const override;
65 
68  virtual HdBufferArrayRangeSharedPtr const& GetShaderData() const override;
69 
71  HDST_API
72  virtual void BindResources(int program,
73  HdSt_ResourceBinder const &binder,
74  HdRenderPassState const &state) override;
75 
77  HDST_API
78  virtual void UnbindResources(int program,
79  HdSt_ResourceBinder const &binder,
80  HdRenderPassState const &state) override;
81 
83  virtual void AddBindings(HdBindingRequestVector* customBindings) override;
84 
86  HDST_API
87  virtual TfToken GetMaterialTag() const override;
88 
89 private:
90  std::string _mixinSource;
91  HdStShaderCodeSharedPtr _baseShader;
92 
93  HdStMixinShader() = delete;
94  HdStMixinShader(const HdStMixinShader &) = delete;
95  HdStMixinShader &operator =(const HdStMixinShader &) = delete;
96 };
97 
98 
99 PXR_NAMESPACE_CLOSE_SCOPE
100 
101 #endif // PXR_IMAGING_HD_ST_MIXIN_SHADER_H
102 
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.