All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
computeShader.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_COMPUTE_SHADER_H
25 #define PXR_IMAGING_HD_ST_COMPUTE_SHADER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hdSt/shaderCode.h"
31 #include "pxr/imaging/hd/bufferSource.h"
32 
33 #include "pxr/imaging/garch/gl.h"
34 
35 #include "pxr/usd/sdf/path.h"
36 
37 #include "pxr/base/vt/value.h"
38 #include "pxr/base/tf/token.h"
39 
40 #include <boost/shared_ptr.hpp>
41 
42 #include <vector>
43 
44 PXR_NAMESPACE_OPEN_SCOPE
45 
46 typedef boost::shared_ptr<class HdStComputeShader> HdStComputeShaderSharedPtr;
47 
57 public:
58  HDST_API
60  HDST_API
61  virtual ~HdStComputeShader();
62 
63 
64  // ---------------------------------------------------------------------- //
66  // ---------------------------------------------------------------------- //
67  HDST_API
68  virtual std::string GetSource(TfToken const &shaderStageKey) const;
69  HDST_API
70  virtual HdMaterialParamVector const& GetParams() const;
71  HDST_API
72  virtual HdBufferArrayRangeSharedPtr const& GetShaderData() const;
73  HDST_API
74  virtual TextureDescriptorVector GetTextures() const;
75  HDST_API
76  virtual void BindResources(int program,
77  HdSt_ResourceBinder const &binder,
78  HdRenderPassState const &state) override;
79  HDST_API
80  virtual void UnbindResources(int program,
81  HdSt_ResourceBinder const &binder,
82  HdRenderPassState const &state) override;
83  HDST_API
84  virtual void AddBindings(HdBindingRequestVector *customBindings);
85  HDST_API
86  virtual ID ComputeHash() const;
87 
89  HDST_API
90  void SetComputeSource(const std::string &source);
91 
93  HDST_API
94  virtual void Reload();
95 
96 protected:
97  HDST_API
98  void _SetSource(TfToken const &shaderStageKey, std::string const &source);
99 
100 private:
101  std::string _computeSource;
102 
103  // Shader Parameters
104  HdMaterialParamVector _params;
105  HdBufferSpecVector _paramSpec;
106  HdBufferArrayRangeSharedPtr _paramArray;
107 
108  TextureDescriptorVector _textureDescriptors;
109 
110  // No copying
111  HdStComputeShader(const HdStComputeShader &) = delete;
112  HdStComputeShader &operator =(const HdStComputeShader &) = delete;
113 };
114 
115 
116 PXR_NAMESPACE_CLOSE_SCOPE
117 
118 #endif // PXR_IMAGING_HD_ST_COMPUTE_SHADER_H
A scene-based ComputeShader object.
Definition: computeShader.h:56
HDST_API void SetComputeSource(const std::string &source)
Setter method for prim.
A set of rendering parameters used among render passes.
virtual HDST_API void UnbindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state) override
Unbinds shader-specific resources.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual HDST_API HdBufferArrayRangeSharedPtr const & GetShaderData() const
Returns a buffer which stores parameter fallback values and texture handles.
virtual HDST_API std::string GetSource(TfToken const &shaderStageKey) const
Returns the shader source provided by this shader for shaderStageKey.
virtual HDST_API void BindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state) override
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
Definition: shaderCode.h:61
virtual HDST_API void AddBindings(HdBindingRequestVector *customBindings)
Add custom bindings (used by codegen)
virtual HDST_API HdMaterialParamVector const & GetParams() const
Returns the shader parameters for this shader.
virtual HDST_API void Reload()
If the prim is based on asset, reload that asset.
virtual HDST_API ID ComputeHash() const
Returns the hash value of this shader.