All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extCompGpuComputationResource.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_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
25 #define HDST_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/bufferSource.h"
30 #include "pxr/imaging/hdSt/resourceBinder.h"
31 #include "pxr/imaging/hdSt/computeShader.h"
32 #include "pxr/imaging/hdSt/resourceRegistry.h"
33 
34 #include <vector>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 typedef boost::shared_ptr<class HdStExtCompGpuComputationResource>
39  HdStExtCompGpuComputationResourceSharedPtr;
40 typedef boost::shared_ptr<class HdStGLSLProgram> HdStGLSLProgramSharedPtr;
41 typedef std::vector<HdBufferArrayRangeSharedPtr> HdBufferArrayRangeSharedPtrVector;
42 
60 public:
80  HdBufferSpecVector const &outputBufferSpecs,
81  HdStComputeShaderSharedPtr const &kernel,
82  HdBufferArrayRangeSharedPtrVector const &inputs,
83  HdStResourceRegistrySharedPtr const &registry
84  );
85 
86  virtual ~HdStExtCompGpuComputationResource() = default;
87 
90  HdBufferArrayRangeSharedPtrVector const &GetInputs() const {
91  return _inputs;
92  }
93 
98  HdStGLSLProgramSharedPtr const &GetProgram() const {
99  return _computeProgram;
100  }
101 
105  HdSt_ResourceBinder const &GetResourceBinder() const {
106  return _resourceBinder;
107  }
108 
112  HDST_API
113  bool Resolve();
114 
115 private:
116  HdBufferSpecVector _outputBufferSpecs;
117  HdStComputeShaderSharedPtr _kernel;
118  HdStResourceRegistrySharedPtr _registry;
119 
120  size_t _shaderSourceHash;
121  HdBufferArrayRangeSharedPtrVector _inputs;
122  HdStGLSLProgramSharedPtr _computeProgram;
123  HdSt_ResourceBinder _resourceBinder;
124 
127  const HdStExtCompGpuComputationResource &) = delete;
129  const HdStExtCompGpuComputationResource &) = delete;
130 };
131 
132 PXR_NAMESPACE_CLOSE_SCOPE
133 
134 #endif // HDST_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
135 
HDST_API bool Resolve()
Resolve the resource bindings and program for use by a computation.
HdBufferArrayRangeSharedPtrVector const & GetInputs() const
Gets the HdBufferArrayRange that inputs should be loaded into using the resource binder.
HdStGLSLProgramSharedPtr const & GetProgram() const
Gets the GPU HdStGLSLProgram to run to execute the computation.
A resource that represents the persistent GPU resources of an ExtComputation.
HdSt_ResourceBinder const & GetResourceBinder() const
Gets the resource binder that matches the layout of the compute program.