Loading...
Searching...
No Matches
graphicsCmds.h
1//
2// Copyright 2019 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_GL_GRAPHICS_CMDS_H
8#define PXR_IMAGING_HGI_GL_GRAPHICS_CMDS_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/gf/vec4i.h"
12#include "pxr/imaging/hgi/graphicsCmds.h"
13#include "pxr/imaging/hgiGL/api.h"
14#include "pxr/imaging/hgiGL/hgi.h"
15#include <cstdint>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
20class HgiGLDevice;
21
27{
28public:
29 HGIGL_API
30 ~HgiGLGraphicsCmds() override;
31
37 HGIGL_API
38 void InsertFunctionOp(std::function<void(void)> const& fn);
39
40 HGIGL_API
41 void PushDebugGroup(const char* label) override;
42
43 HGIGL_API
44 void PopDebugGroup() override;
45
46 HGIGL_API
47 void SetViewport(GfVec4i const& vp) override;
48
49 HGIGL_API
50 void SetScissor(GfVec4i const& sc) override;
51
52 HGIGL_API
53 void BindPipeline(HgiGraphicsPipelineHandle pipeline) override;
54
55 HGIGL_API
56 void BindResources(HgiResourceBindingsHandle resources) override;
57
58 HGIGL_API
61 HgiShaderStage stages,
62 uint32_t bindIndex,
63 uint32_t byteSize,
64 const void* data) override;
65
66 HGIGL_API
68 HgiVertexBufferBindingVector const &bindings) override;
69
70 HGIGL_API
71 void Draw(
72 uint32_t vertexCount,
73 uint32_t baseVertex,
74 uint32_t instanceCount,
75 uint32_t baseInstance) override;
76
77 HGIGL_API
79 HgiBufferHandle const& drawParameterBuffer,
80 uint32_t drawBufferByteOffset,
81 uint32_t drawCount,
82 uint32_t stride) override;
83
84 HGIGL_API
86 HgiBufferHandle const& indexBuffer,
87 uint32_t indexCount,
88 uint32_t indexBufferByteOffset,
89 uint32_t baseVertex,
90 uint32_t instanceCount,
91 uint32_t baseInstance) override;
92
93 HGIGL_API
95 HgiBufferHandle const& indexBuffer,
96 HgiBufferHandle const& drawParameterBuffer,
97 uint32_t drawBufferByteOffset,
98 uint32_t drawCount,
99 uint32_t stride,
100 std::vector<uint32_t> const& drawParameterBufferUInt32,
101 uint32_t patchBaseVertexByteOffset) override;
102
103 HGIGL_API
104 void InsertMemoryBarrier(HgiMemoryBarrier barrier) override;
105
106protected:
107 friend class HgiGL;
108
109 HGIGL_API
111 HgiGLDevice* device,
112 HgiGraphicsCmdsDesc const& desc);
113
114 HGIGL_API
115 bool _Submit(Hgi* hgi, HgiSubmitWaitType wait) override;
116
117private:
118 HgiGLGraphicsCmds() = delete;
119 HgiGLGraphicsCmds & operator=(const HgiGLGraphicsCmds&) = delete;
120 HgiGLGraphicsCmds(const HgiGLGraphicsCmds&) = delete;
121
123 void _AddResolveToOps(HgiGLDevice* device);
124
125 bool _recording;
126 HgiGraphicsCmdsDesc _descriptor;
127 HgiPrimitiveType _primitiveType;
128 int _primitiveIndexSize;
129 HgiGLOpsVector _ops;
130 int _pushStack;
131 int32_t _restoreReadFramebuffer;
132 int32_t _restoreDrawFramebuffer;
133
134 // Cmds is used only one frame so storing multi-frame state on will not
135 // survive.
136};
137
138PXR_NAMESPACE_CLOSE_SCOPE
139
140#endif
Basic type for a vector of 4 int components.
Definition: vec4i.h:44
OpenGL implementation of GPU device.
Definition: device.h:29
OpenGL implementation of HgiGraphicsCmds.
Definition: graphicsCmds.h:27
HGIGL_API void SetScissor(GfVec4i const &sc) override
Only pixels that lie within the scissor box are modified by drawing commands.
HGIGL_API void InsertMemoryBarrier(HgiMemoryBarrier barrier) override
Inserts a barrier so that data written to memory by commands before the barrier is available to comma...
HGIGL_API void BindVertexBuffers(HgiVertexBufferBindingVector const &bindings) override
Binds the vertex buffer(s) that describe the vertex attributes.
HGIGL_API void BindResources(HgiResourceBindingsHandle resources) override
Bind resources such as textures and uniform buffers.
HGIGL_API void SetConstantValues(HgiGraphicsPipelineHandle pipeline, HgiShaderStage stages, uint32_t bindIndex, uint32_t byteSize, const void *data) override
Set Push / Function constants.
HGIGL_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) override
Records a indexed multi-draw command that reads the draw parameters from a provided drawParameterBuff...
HGIGL_API void SetViewport(GfVec4i const &vp) override
Set viewport [left, BOTTOM, width, height] - OpenGL coords.
HGIGL_API void InsertFunctionOp(std::function< void(void)> const &fn)
XXX This function is exposed temporarily for Hgi transition.
HGIGL_API void PopDebugGroup() override
Pop the last debug marker.
HGIGL_API void DrawIndexed(HgiBufferHandle const &indexBuffer, uint32_t indexCount, uint32_t indexBufferByteOffset, uint32_t baseVertex, uint32_t instanceCount, uint32_t baseInstance) override
Records a draw command that renders one or more instances of primitives using an indexBuffer starting...
HGIGL_API void BindPipeline(HgiGraphicsPipelineHandle pipeline) override
Bind a pipeline state object.
HGIGL_API void Draw(uint32_t vertexCount, uint32_t baseVertex, uint32_t instanceCount, uint32_t baseInstance) override
Records a draw command that renders one or more instances of primitives using the number of vertices ...
HGIGL_API void DrawIndirect(HgiBufferHandle const &drawParameterBuffer, uint32_t drawBufferByteOffset, uint32_t drawCount, uint32_t stride) override
Records a multi-draw command that reads the draw parameters from a provided drawParameterBuffer.
HGIGL_API void PushDebugGroup(const char *label) override
Push a debug marker.
OpenGL implementation of the Hydra Graphics Interface.
Definition: hgi.h:55
A graphics API independent abstraction of graphics commands.
Definition: graphicsCmds.h:31
Hydra Graphics Interface.
Definition: hgi.h:95
Describes the properties to begin a HgiGraphicsCmds.