graphicsCmds.h
1 //
2 // Copyright 2019 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_GRAPHICS_CMDS_H
25 #define PXR_IMAGING_HGI_GRAPHICS_CMDS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/gf/vec4i.h"
29 #include "pxr/imaging/hgi/api.h"
30 #include "pxr/imaging/hgi/graphicsCmdsDesc.h"
31 #include "pxr/imaging/hgi/graphicsPipeline.h"
32 #include "pxr/imaging/hgi/resourceBindings.h"
33 #include "pxr/imaging/hgi/cmds.h"
34 #include <memory>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 using HgiGraphicsCmdsUniquePtr = std::unique_ptr<class HgiGraphicsCmds>;
39 
40 
47 class HgiGraphicsCmds : public HgiCmds
48 {
49 public:
50  HGI_API
51  ~HgiGraphicsCmds() override;
52 
54  HGI_API
55  virtual void PushDebugGroup(const char* label) = 0;
56 
58  HGI_API
59  virtual void PopDebugGroup() = 0;
60 
62  HGI_API
63  virtual void SetViewport(GfVec4i const& vp) = 0;
64 
67  HGI_API
68  virtual void SetScissor(GfVec4i const& sc) = 0;
69 
74  HGI_API
75  virtual void BindPipeline(HgiGraphicsPipelineHandle pipeline) = 0;
76 
80  HGI_API
81  virtual void BindResources(HgiResourceBindingsHandle resources) = 0;
82 
93  HGI_API
94  virtual void SetConstantValues(
96  HgiShaderStage stages,
97  uint32_t bindIndex,
98  uint32_t byteSize,
99  const void* data) = 0;
100 
102  HGI_API
103  virtual void BindVertexBuffers(
104  HgiVertexBufferBindingVector const &bindings) = 0;
105 
114  HGI_API
115  virtual void Draw(
116  uint32_t vertexCount,
117  uint32_t baseVertex,
118  uint32_t instanceCount,
119  uint32_t baseInstance) = 0;
120 
126  // struct IndirectCommand {
127  // uint32_t vertexCount;
128  // uint32_t instanceCount;
129  // uint32_t baseVertex;
130  // uint32_t baseInstance;
131  // }
135  HGI_API
136  virtual void DrawIndirect(
137  HgiBufferHandle const& drawParameterBuffer,
138  uint32_t drawBufferByteOffset,
139  uint32_t drawCount,
140  uint32_t stride) = 0;
141 
153  HGI_API
154  virtual void DrawIndexed(
155  HgiBufferHandle const& indexBuffer,
156  uint32_t indexCount,
157  uint32_t indexBufferByteOffset,
158  uint32_t baseVertex,
159  uint32_t instanceCount,
160  uint32_t baseInstance) = 0;
161 
168  // struct IndirectCommand {
169  // uint32_t indexCount;
170  // uint32_t instanceCount;
171  // uint32_t baseIndex;
172  // uint32_t baseVertex;
173  // uint32_t baseInstance;
174  // }
175  // struct MetalPatchIndirectCommand {
176  // uint32_t patchCount;
177  // uint32_t instanceCount;
178  // uint32_t patchStart;
179  // uint32_t baseInstance;
180  // }
191  HGI_API
192  virtual void DrawIndexedIndirect(
193  HgiBufferHandle const& indexBuffer,
194  HgiBufferHandle const& drawParameterBuffer,
195  uint32_t drawBufferByteOffset,
196  uint32_t drawCount,
197  uint32_t stride,
198  std::vector<uint32_t> const& drawParameterBufferUInt32,
199  uint32_t patchBaseVertexByteOffset) = 0;
200 
203  HGI_API
204  virtual void InsertMemoryBarrier(HgiMemoryBarrier barrier) = 0;
205 
206 protected:
207  HGI_API
208  HgiGraphicsCmds();
209 
210 private:
211  HgiGraphicsCmds & operator=(const HgiGraphicsCmds&) = delete;
212  HgiGraphicsCmds(const HgiGraphicsCmds&) = delete;
213 };
214 
215 
216 
217 PXR_NAMESPACE_CLOSE_SCOPE
218 
219 #endif
Basic type for a vector of 4 int components.
Definition: vec4i.h:61
virtual HGI_API void DrawIndexedIndirect(HgiBufferHandle const &indexBuffer, HgiBufferHandle const &drawParameterBuffer, uint32_t drawBufferByteOffset, uint32_t drawCount, uint32_t stride, std::vector< uint32_t > const &drawParameterBufferUInt32, uint32_t patchBaseVertexByteOffset)=0
Records a indexed multi-draw command that reads the draw parameters from a provided drawParameterBuff...
virtual HGI_API void Draw(uint32_t vertexCount, uint32_t baseVertex, uint32_t instanceCount, uint32_t baseInstance)=0
Records a draw command that renders one or more instances of primitives using the number of vertices ...
A graphics API independent abstraction of graphics commands.
Definition: graphicsCmds.h:47
virtual HGI_API void InsertMemoryBarrier(HgiMemoryBarrier barrier)=0
Inserts a barrier so that data written to memory by commands before the barrier is available to comma...
virtual HGI_API void BindVertexBuffers(HgiVertexBufferBindingVector const &bindings)=0
Binds the vertex buffer(s) that describe the vertex attributes.
virtual HGI_API void SetConstantValues(HgiGraphicsPipelineHandle pipeline, HgiShaderStage stages, uint32_t bindIndex, uint32_t byteSize, const void *data)=0
Set Push / Function constants.
virtual HGI_API void PushDebugGroup(const char *label)=0
Push a debug marker.
virtual HGI_API void DrawIndexed(HgiBufferHandle const &indexBuffer, uint32_t indexCount, uint32_t indexBufferByteOffset, uint32_t baseVertex, uint32_t instanceCount, uint32_t baseInstance)=0
Records a draw command that renders one or more instances of primitives using an indexBuffer starting...
virtual HGI_API void SetScissor(GfVec4i const &sc)=0
Only pixels that lie within the scissor box are modified by drawing commands.
virtual HGI_API void PopDebugGroup()=0
Pop the last debug marker.
virtual HGI_API void SetViewport(GfVec4i const &vp)=0
Set viewport [left, BOTTOM, width, height] - OpenGL coords.
virtual HGI_API void BindPipeline(HgiGraphicsPipelineHandle pipeline)=0
Bind a pipeline state object.
virtual HGI_API void DrawIndirect(HgiBufferHandle const &drawParameterBuffer, uint32_t drawBufferByteOffset, uint32_t drawCount, uint32_t stride)=0
Records a multi-draw command that reads the draw parameters from a provided drawParameterBuffer.
virtual HGI_API void BindResources(HgiResourceBindingsHandle resources)=0
Bind resources such as textures and uniform buffers.
Graphics commands are recorded in 'cmds' objects which are later submitted to hgi.
Definition: cmds.h:44