HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
computeCmds.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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_HGI_COMPUTE_CMDS_H
8 #define PXR_IMAGING_HGI_COMPUTE_CMDS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hgi/api.h"
14 #include "pxr/imaging/hgi/cmds.h"
15 #include <memory>
16 
18 
19 using HgiComputeCmdsUniquePtr = std::unique_ptr<class HgiComputeCmds>;
20 
21 
22 /// \class HgiComputeCmds
23 ///
24 /// A graphics API independent abstraction of compute commands.
25 /// HgiComputeCmds is a lightweight object that cannot be re-used after it has
26 /// been submitted. A new cmds object should be acquired for each frame.
27 ///
28 class HgiComputeCmds : public HgiCmds
29 {
30 public:
31  HGI_API
32  ~HgiComputeCmds() override;
33 
34  /// Push a debug marker.
35  HGI_API
36  virtual void PushDebugGroup(const char* label) = 0;
37 
38  /// Pop the last debug marker.
39  HGI_API
40  virtual void PopDebugGroup() = 0;
41 
42  /// Bind a pipeline state object. Usually you call this right after calling
43  /// CreateGraphicsCmds to set the graphics pipeline state.
44  /// The resource bindings used when creating the pipeline must be compatible
45  /// with the resources bound via BindResources().
46  HGI_API
47  virtual void BindPipeline(HgiComputePipelineHandle pipeline) = 0;
48 
49  /// Bind resources such as textures and uniform buffers.
50  /// Usually you call this right after BindPipeline() and the resources bound
51  /// must be compatible with the bound pipeline.
52  HGI_API
53  virtual void BindResources(HgiResourceBindingsHandle resources) = 0;
54 
55  /// Set Push / Function constants.
56  /// `pipeline` is the compute pipeline that you are binding before the
57  /// draw call. It contains the program used for the uniform buffer
58  /// constant values for.
59  /// `bindIndex` is the binding point index in the pipeline's shader
60  /// to bind the data to.
61  /// `byteSize` is the size of the data you are updating.
62  /// `data` is the data you are copying into the push constants block.
63  HGI_API
64  virtual void SetConstantValues(
65  HgiComputePipelineHandle pipeline,
66  uint32_t bindIndex,
67  uint32_t byteSize,
68  const void* data) = 0;
69 
70  /// Execute a compute shader with provided thread group count in each
71  /// dimension.
72  HGI_API
73  virtual void Dispatch(int dimX, int dimY) = 0;
74 
75  /// Inserts a barrier so that data written to memory by commands before
76  /// the barrier is available to commands after the barrier.
77  HGI_API
78  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
79 
80  /// Returns the dispatch method for this encoder.
81  HGI_API
82  virtual HgiComputeDispatch GetDispatchMethod() const = 0;
83 
84 protected:
85  HGI_API
87 
88 private:
89  HgiComputeCmds & operator=(const HgiComputeCmds&) = delete;
90  HgiComputeCmds(const HgiComputeCmds&) = delete;
91 };
92 
93 
94 
96 
97 #endif
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
HGI_API ~HgiComputeCmds() override
virtual HGI_API void PushDebugGroup(const char *label)=0
Push a debug marker.
HGI_API HgiComputeCmds()
virtual HGI_API void Dispatch(int dimX, int dimY)=0
virtual HGI_API void PopDebugGroup()=0
Pop the last debug marker.
virtual HGI_API void BindResources(HgiResourceBindingsHandle resources)=0
HgiComputeDispatch
Definition: enums.h:812
virtual HGI_API void BindPipeline(HgiComputePipelineHandle pipeline)=0
HgiBits HgiMemoryBarrier
Definition: enums.h:672
virtual HGI_API HgiComputeDispatch GetDispatchMethod() const =0
Returns the dispatch method for this encoder.
std::unique_ptr< class HgiComputeCmds > HgiComputeCmdsUniquePtr
Definition: computeCmds.h:19
#define HGI_API
Definition: api.h:23
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: cmds.h:27
Definition: format.h:1821
virtual HGI_API void SetConstantValues(HgiComputePipelineHandle pipeline, uint32_t bindIndex, uint32_t byteSize, const void *data)=0
virtual HGI_API void InsertMemoryBarrier(HgiMemoryBarrier barrier)=0