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 scope.
35  HGI_API
36  virtual void PushDebugGroup(const char* label,
37  const GfVec4f& color = s_computeDebugColor) = 0;
38 
39  /// Pop the last debug scope.
40  HGI_API
41  virtual void PopDebugGroup() = 0;
42 
43  /// Insert a debug marker
44  HGI_API
45  virtual void InsertDebugMarker(
46  const char* label,
47  const GfVec4f& color = s_markerDebugColor) = 0;
48 
49  /// Bind a pipeline state object. Usually you call this right after calling
50  /// CreateGraphicsCmds to set the graphics pipeline state.
51  /// The resource bindings used when creating the pipeline must be compatible
52  /// with the resources bound via BindResources().
53  HGI_API
54  virtual void BindPipeline(HgiComputePipelineHandle pipeline) = 0;
55 
56  /// Bind resources such as textures and uniform buffers.
57  /// Usually you call this right after BindPipeline() and the resources bound
58  /// must be compatible with the bound pipeline.
59  HGI_API
60  virtual void BindResources(HgiResourceBindingsHandle resources) = 0;
61 
62  /// Set Push / Function constants.
63  /// `pipeline` is the compute pipeline that you are binding before the
64  /// draw call. It contains the program used for the uniform buffer
65  /// constant values for.
66  /// `bindIndex` is the binding point index in the pipeline's shader
67  /// to bind the data to.
68  /// `byteSize` is the size of the data you are updating.
69  /// `data` is the data you are copying into the push constants block.
70  HGI_API
71  virtual void SetConstantValues(
72  HgiComputePipelineHandle pipeline,
73  uint32_t bindIndex,
74  uint32_t byteSize,
75  const void* data) = 0;
76 
77  /// Execute a compute shader with provided thread group count in each
78  /// dimension.
79  HGI_API
80  virtual void Dispatch(int dimX, int dimY) = 0;
81 
82  /// Inserts a barrier so that data written to memory by commands before
83  /// the barrier is available to commands after the barrier.
84  HGI_API
85  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
86 
87  /// Returns the dispatch method for this encoder.
88  HGI_API
89  virtual HgiComputeDispatch GetDispatchMethod() const = 0;
90 
91 protected:
92  HGI_API
94 
95 private:
96  HgiComputeCmds & operator=(const HgiComputeCmds&) = delete;
97  HgiComputeCmds(const HgiComputeCmds&) = delete;
98 };
99 
100 
101 
103 
104 #endif
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
virtual HGI_API void InsertDebugMarker(const char *label, const GfVec4f &color=s_markerDebugColor)=0
Insert a debug marker.
HGI_API ~HgiComputeCmds() override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
HGI_API HgiComputeCmds()
virtual HGI_API void Dispatch(int dimX, int dimY)=0
virtual HGI_API void PushDebugGroup(const char *label, const GfVec4f &color=s_computeDebugColor)=0
Push a debug scope.
virtual HGI_API void PopDebugGroup()=0
Pop the last debug scope.
virtual HGI_API void BindResources(HgiResourceBindingsHandle resources)=0
HgiComputeDispatch
Definition: enums.h:822
virtual HGI_API void BindPipeline(HgiComputePipelineHandle pipeline)=0
HgiBits HgiMemoryBarrier
Definition: enums.h:679
virtual HGI_API HgiComputeDispatch GetDispatchMethod() const =0
Returns the dispatch method for this encoder.
static constexpr GfVec4f s_markerDebugColor
Definition: cmds.h:61
std::unique_ptr< class HgiComputeCmds > HgiComputeCmdsUniquePtr
Definition: computeCmds.h:19
Definition: vec4f.h:45
#define HGI_API
Definition: api.h:23
GLuint color
Definition: glcorearb.h:1261
static constexpr GfVec4f s_computeDebugColor
Definition: cmds.h:55
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: cmds.h:28
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