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 HDST_COMPUTEHADER_H
25 #define HDST_COMPUTEHADER_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(HdSt_ResourceBinder const &binder, int program);
77  HDST_API
78  virtual void UnbindResources(HdSt_ResourceBinder const &binder, int program);
79  HDST_API
80  virtual void AddBindings(HdBindingRequestVector *customBindings);
81  HDST_API
82  virtual ID ComputeHash() const;
83 
85  HDST_API
86  void SetComputeSource(const std::string &source);
87 
89  HDST_API
90  virtual void Reload();
91 
92 protected:
93  HDST_API
94  void _SetSource(TfToken const &shaderStageKey, std::string const &source);
95 
96 private:
97  std::string _computeSource;
98 
99  // Shader Parameters
100  HdMaterialParamVector _params;
101  HdBufferSpecVector _paramSpec;
102  HdBufferArrayRangeSharedPtr _paramArray;
103 
104  TextureDescriptorVector _textureDescriptors;
105 
106  // No copying
107  HdStComputeShader(const HdStComputeShader &) = delete;
108  HdStComputeShader &operator =(const HdStComputeShader &) = delete;
109 };
110 
111 
112 PXR_NAMESPACE_CLOSE_SCOPE
113 
114 #endif // HDST_SURFACESHADER_H
A scene-based ComputeShader object.
Definition: computeShader.h:56
HDST_API void SetComputeSource(const std::string &source)
Setter method for prim.
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.
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
Definition: shaderCode.h:59
virtual HDST_API void UnbindResources(HdSt_ResourceBinder const &binder, int program)
Unbinds shader-specific resources.
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.
virtual HDST_API void BindResources(HdSt_ResourceBinder const &binder, int program)
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...