Loading...
Searching...
No Matches
indirectCommandEncoder.h
1//
2// Copyright 2022 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_INDIRECT_COMMAND_ENCODER_H
25#define PXR_IMAGING_HGI_INDIRECT_COMMAND_ENCODER_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hgi/api.h"
29#include "pxr/imaging/hgi/cmds.h"
30#include "pxr/imaging/hgi/resourceBindings.h"
31#include "pxr/imaging/hgi/graphicsPipeline.h"
32
33#include <memory>
34#include <stdint.h>
35
36PXR_NAMESPACE_OPEN_SCOPE
37
38class Hgi;
39class HgiComputeCmds;
40class HgiGraphicsCmds;
41
42struct HgiIndirectCommands
43{
44 HgiIndirectCommands(uint32_t drawCount,
45 HgiGraphicsPipelineHandle const &graphicsPipeline,
46 HgiResourceBindingsHandle const &resourceBindings)
47 : drawCount(drawCount)
48 , graphicsPipeline(graphicsPipeline)
49 , resourceBindings(resourceBindings)
50 {
51 }
52
53 virtual ~HgiIndirectCommands() = default;
54
55 uint32_t drawCount;
56 HgiGraphicsPipelineHandle graphicsPipeline;
57 HgiResourceBindingsHandle resourceBindings;
58};
59
60using HgiIndirectCommandsUniquePtr = std::unique_ptr<HgiIndirectCommands>;
61
74{
75public:
76 HGI_API
78
82 HGI_API
83 virtual HgiIndirectCommandsUniquePtr EncodeDraw(
84 HgiComputeCmds * computeCmds,
85 HgiGraphicsPipelineHandle const& pipeline,
86 HgiResourceBindingsHandle const& resourceBindings,
87 HgiVertexBufferBindingVector const& vertexBindings,
88 HgiBufferHandle const& drawParameterBuffer,
89 uint32_t drawBufferByteOffset,
90 uint32_t drawCount,
91 uint32_t stride) = 0;
92
96 HGI_API
97 virtual HgiIndirectCommandsUniquePtr EncodeDrawIndexed(
98 HgiComputeCmds * computeCmds,
99 HgiGraphicsPipelineHandle const& pipeline,
100 HgiResourceBindingsHandle const& resourceBindings,
101 HgiVertexBufferBindingVector const& vertexBindings,
102 HgiBufferHandle const& indexBuffer,
103 HgiBufferHandle const& drawParameterBuffer,
104 uint32_t drawBufferByteOffset,
105 uint32_t drawCount,
106 uint32_t stride,
107 uint32_t patchBaseVertexByteOffset) = 0;
108
111 HGI_API
112 virtual void ExecuteDraw(
113 HgiGraphicsCmds * gfxCmds,
114 HgiIndirectCommands const* commands) = 0;
115
116protected:
117 HGI_API
119
120private:
121 HgiIndirectCommandEncoder & operator=(const HgiIndirectCommandEncoder&) = delete;
123};
124
125PXR_NAMESPACE_CLOSE_SCOPE
126
127#endif
Graphics commands are recorded in 'cmds' objects which are later submitted to hgi.
Definition: cmds.h:45
A graphics API independent abstraction of compute commands.
Definition: computeCmds.h:46
A graphics API independent abstraction of graphics commands.
Definition: graphicsCmds.h:48
Hydra Graphics Interface.
Definition: hgi.h:111
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.