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 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 PXR_IMAGING_HGI_COMPUTE_CMDS_H
25 #define PXR_IMAGING_HGI_COMPUTE_CMDS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
31 #include "pxr/imaging/hgi/cmds.h"
32 #include <memory>
33 
35 
36 using HgiComputeCmdsUniquePtr = std::unique_ptr<class HgiComputeCmds>;
37 
38 
39 /// \class HgiComputeCmds
40 ///
41 /// A graphics API independent abstraction of compute commands.
42 /// HgiComputeCmds is a lightweight object that cannot be re-used after it has
43 /// been submitted. A new cmds object should be acquired for each frame.
44 ///
45 class HgiComputeCmds : public HgiCmds
46 {
47 public:
48  HGI_API
49  ~HgiComputeCmds() override;
50 
51  /// Push a debug marker.
52  HGI_API
53  virtual void PushDebugGroup(const char* label) = 0;
54 
55  /// Pop the last debug marker.
56  HGI_API
57  virtual void PopDebugGroup() = 0;
58 
59  /// Bind a pipeline state object. Usually you call this right after calling
60  /// CreateGraphicsCmds to set the graphics pipeline state.
61  /// The resource bindings used when creating the pipeline must be compatible
62  /// with the resources bound via BindResources().
63  HGI_API
64  virtual void BindPipeline(HgiComputePipelineHandle pipeline) = 0;
65 
66  /// Bind resources such as textures and uniform buffers.
67  /// Usually you call this right after BindPipeline() and the resources bound
68  /// must be compatible with the bound pipeline.
69  HGI_API
70  virtual void BindResources(HgiResourceBindingsHandle resources) = 0;
71 
72  /// Set Push / Function constants.
73  /// `pipeline` is the compute pipeline that you are binding before the
74  /// draw call. It contains the program used for the uniform buffer
75  /// constant values for.
76  /// `bindIndex` is the binding point index in the pipeline's shader
77  /// to bind the data to.
78  /// `byteSize` is the size of the data you are updating.
79  /// `data` is the data you are copying into the push constants block.
80  HGI_API
81  virtual void SetConstantValues(
82  HgiComputePipelineHandle pipeline,
83  uint32_t bindIndex,
84  uint32_t byteSize,
85  const void* data) = 0;
86 
87  /// Execute a compute shader with provided thread group count in each
88  /// dimension.
89  HGI_API
90  virtual void Dispatch(int dimX, int dimY) = 0;
91 
92  /// Inserts a barrier so that data written to memory by commands before
93  /// the barrier is available to commands after the barrier.
94  HGI_API
95  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
96 
97  /// Returns the dispatch method for this encoder.
98  HGI_API
99  virtual HgiComputeDispatch GetDispatchMethod() const = 0;
100 
101 protected:
102  HGI_API
103  HgiComputeCmds();
104 
105 private:
106  HgiComputeCmds & operator=(const HgiComputeCmds&) = delete;
107  HgiComputeCmds(const HgiComputeCmds&) = delete;
108 };
109 
110 
111 
113 
114 #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:825
virtual HGI_API void BindPipeline(HgiComputePipelineHandle pipeline)=0
HgiBits HgiMemoryBarrier
Definition: enums.h:685
virtual HGI_API HgiComputeDispatch GetDispatchMethod() const =0
Returns the dispatch method for this encoder.
std::unique_ptr< class HgiComputeCmds > HgiComputeCmdsUniquePtr
Definition: computeCmds.h:36
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: cmds.h:44
Definition: format.h:895
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