HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
computation.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_COMPUTATION_H
8 #define PXR_IMAGING_HD_ST_COMPUTATION_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdSt/api.h"
12 
13 #include <memory>
14 #include <vector>
15 
17 
18 
19 class HdResourceRegistry;
20 
21 using HdBufferArrayRangeSharedPtr = std::shared_ptr<class HdBufferArrayRange>;
22 using HdBufferSpecVector = std::vector<struct HdBufferSpec>;
23 
24 using HdStComputationSharedPtr = std::shared_ptr<class HdStComputation>;
25 using HdStComputationSharedPtrVector = std::vector<HdStComputationSharedPtr>;
26 
27 /// \class HdStComputation
28 ///
29 /// An interface class for GPU computation.
30 ///
31 /// GPU computation fills the result into range, which has to be allocated
32 /// using buffer specs determined by GetBufferSpecs, and registered as a pair
33 /// of computation and range.
34 ///
36 {
37 public:
38  HDST_API
39  virtual ~HdStComputation();
40 
41  /// Execute computation.
42  virtual void Execute(
44  HdResourceRegistry *resourceRegistry) = 0;
45 
46  /// Returns the size of its destination buffer (located by range argument
47  /// of Execute()). This function will be called after all HdBufferSources
48  /// have been resolved and commited, so it can use the result of those
49  /// buffer source results.
50  /// Returning 0 means it doesn't need to resize.
51  virtual int GetNumOutputElements() const = 0;
52 
53  /// Add the buffer spec for this computation into given bufferspec vector.
54  /// Caller has to allocate the destination buffer with respect to the
55  /// BufferSpecs, and passes the range when registering the computation.
56  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const = 0;
57 
58  /// This function is needed as HdStComputation shares a templatized
59  /// interface with HdBufferSource.
60  ///
61  /// It is a check to see if the GetBufferSpecs would produce a valid result.
62  bool IsValid() { return true; }
63 };
64 
65 
67 
68 #endif // PXR_IMAGING_HD_ST_COMPUTATION_H
std::vector< HdStComputationSharedPtr > HdStComputationSharedPtrVector
Definition: computation.h:25
GLenum GLint * range
Definition: glcorearb.h:1925
virtual void Execute(HdBufferArrayRangeSharedPtr const &range, HdResourceRegistry *resourceRegistry)=0
Execute computation.
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
virtual int GetNumOutputElements() const =0
std::shared_ptr< class HdStComputation > HdStComputationSharedPtr
Definition: computation.h:24
std::vector< struct HdBufferSpec > HdBufferSpecVector
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define HDST_API
Definition: api.h:23
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:27
virtual HDST_API ~HdStComputation()