Loading...
Searching...
No Matches
indirectCommandEncoder.h
1//
2// Copyright 2022 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_INDIRECT_COMMAND_ENCODER_H
8#define PXR_IMAGING_HGI_INDIRECT_COMMAND_ENCODER_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hgi/api.h"
12#include "pxr/imaging/hgi/cmds.h"
13#include "pxr/imaging/hgi/resourceBindings.h"
14#include "pxr/imaging/hgi/graphicsPipeline.h"
15
16#include <memory>
17#include <stdint.h>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class Hgi;
22class HgiComputeCmds;
23class HgiGraphicsCmds;
24
25struct HgiIndirectCommands
26{
27 HgiIndirectCommands(uint32_t drawCount,
28 HgiGraphicsPipelineHandle const &graphicsPipeline,
29 HgiResourceBindingsHandle const &resourceBindings)
30 : drawCount(drawCount)
31 , graphicsPipeline(graphicsPipeline)
32 , resourceBindings(resourceBindings)
33 {
34 }
35
36 virtual ~HgiIndirectCommands() = default;
37
38 uint32_t drawCount;
39 HgiGraphicsPipelineHandle graphicsPipeline;
40 HgiResourceBindingsHandle resourceBindings;
41};
42
43using HgiIndirectCommandsUniquePtr = std::unique_ptr<HgiIndirectCommands>;
44
57{
58public:
59 HGI_API
61
65 HGI_API
66 virtual HgiIndirectCommandsUniquePtr EncodeDraw(
67 HgiComputeCmds * computeCmds,
68 HgiGraphicsPipelineHandle const& pipeline,
69 HgiResourceBindingsHandle const& resourceBindings,
70 HgiVertexBufferBindingVector const& vertexBindings,
71 HgiBufferHandle const& drawParameterBuffer,
72 uint32_t drawBufferByteOffset,
73 uint32_t drawCount,
74 uint32_t stride) = 0;
75
79 HGI_API
80 virtual HgiIndirectCommandsUniquePtr EncodeDrawIndexed(
81 HgiComputeCmds * computeCmds,
82 HgiGraphicsPipelineHandle const& pipeline,
83 HgiResourceBindingsHandle const& resourceBindings,
84 HgiVertexBufferBindingVector const& vertexBindings,
85 HgiBufferHandle const& indexBuffer,
86 HgiBufferHandle const& drawParameterBuffer,
87 uint32_t drawBufferByteOffset,
88 uint32_t drawCount,
89 uint32_t stride,
90 uint32_t patchBaseVertexByteOffset) = 0;
91
94 HGI_API
95 virtual void ExecuteDraw(
96 HgiGraphicsCmds * gfxCmds,
97 HgiIndirectCommands const* commands) = 0;
98
99protected:
100 HGI_API
102
103private:
104 HgiIndirectCommandEncoder & operator=(const HgiIndirectCommandEncoder&) = delete;
106};
107
108PXR_NAMESPACE_CLOSE_SCOPE
109
110#endif
Graphics commands are recorded in 'cmds' objects which are later submitted to hgi.
Definition: cmds.h:29
A graphics API independent abstraction of compute commands.
Definition: computeCmds.h:29
A graphics API independent abstraction of graphics commands.
Definition: graphicsCmds.h:31
Hydra Graphics Interface.
Definition: hgi.h:95
The indirect command encoder is used to record the drawing primitives for a batch and capture the res...
virtual HGI_API void ExecuteDraw(HgiGraphicsCmds *gfxCmds, HgiIndirectCommands const *commands)=0
Excutes an indirect command batch from the HgiIndirectCommands structure.
virtual HGI_API HgiIndirectCommandsUniquePtr EncodeDrawIndexed(HgiComputeCmds *computeCmds, HgiGraphicsPipelineHandle const &pipeline, HgiResourceBindingsHandle const &resourceBindings, HgiVertexBufferBindingVector const &vertexBindings, HgiBufferHandle const &indexBuffer, HgiBufferHandle const &drawParameterBuffer, uint32_t drawBufferByteOffset, uint32_t drawCount, uint32_t stride, uint32_t patchBaseVertexByteOffset)=0
Encodes a batch of indexed draw commands from the drawParameterBuffer.
virtual HGI_API HgiIndirectCommandsUniquePtr EncodeDraw(HgiComputeCmds *computeCmds, HgiGraphicsPipelineHandle const &pipeline, HgiResourceBindingsHandle const &resourceBindings, HgiVertexBufferBindingVector const &vertexBindings, HgiBufferHandle const &drawParameterBuffer, uint32_t drawBufferByteOffset, uint32_t drawCount, uint32_t stride)=0
Encodes a batch of draw commands from the drawParameterBuffer.