Loading...
Searching...
No Matches
commandBuffer.h
1//
2// Copyright 2016 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_HD_ST_COMMAND_BUFFER_H
8#define PXR_IMAGING_HD_ST_COMMAND_BUFFER_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hd/version.h"
13#include "pxr/imaging/hdSt/drawItemInstance.h"
14
16
17#include <memory>
18#include <vector>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class HdRenderIndex;
23class HdStDrawItem;
25class Hgi;
26class HgiGraphicsCmds;
27
28using HdStRenderPassStateSharedPtr = std::shared_ptr<class HdStRenderPassState>;
29using HdStResourceRegistrySharedPtr =
30 std::shared_ptr<class HdStResourceRegistry>;
31
32using HdDrawItemConstPtrVector = std::vector<class HdDrawItem const*>;
33using HdDrawItemConstPtrVectorSharedPtr
34 = std::shared_ptr<HdDrawItemConstPtrVector>;
35
36using HdSt_DrawBatchSharedPtr = std::shared_ptr<class HdSt_DrawBatch>;
37using HdSt_DrawBatchSharedPtrVector = std::vector<HdSt_DrawBatchSharedPtr>;
38
48public:
49 HDST_API
51 HDST_API
53
55 HDST_API
57 HdStRenderPassStateSharedPtr const &renderPassState,
58 HdRenderIndex *renderIndex);
59
61 HDST_API
63 HdStRenderPassStateSharedPtr const &renderPassState,
64 HdStResourceRegistrySharedPtr const &resourceRegistry);
65
67 HDST_API
68 void SyncDrawItemVisibility(unsigned visChangeCount);
69
73 HDST_API
74 void SetDrawItems(HdDrawItemConstPtrVectorSharedPtr const &drawItems,
75 unsigned currentBatchVersion,
76 Hgi const *hgi);
77
79 HDST_API
80 void RebuildDrawBatchesIfNeeded(unsigned currentBatchVersion,
81 Hgi const *hgi);
82
84 size_t GetTotalSize() const {
85 if (_drawItems) return _drawItems->size();
86 return 0;
87 }
88
90 size_t GetVisibleSize() const { return _visibleSize; }
91
93 size_t GetCulledSize() const {
94 if (_drawItems) {
95 return _drawItems->size() - _visibleSize;
96 }
97 return 0;
98 }
99
100 HDST_API
101 void SetEnableTinyPrimCulling(bool tinyPrimCulling);
102
103private:
104 void _RebuildDrawBatches(Hgi const *hgi);
105
107 void _FrustumCullCPU(GfMatrix4d const &cullMatrix);
108
109 HdDrawItemConstPtrVectorSharedPtr _drawItems;
110 std::vector<HdStDrawItemInstance> _drawItemInstances;
111 HdSt_DrawBatchSharedPtrVector _drawBatches;
112 size_t _visibleSize;
113 unsigned int _visChangeCount;
114 unsigned int _drawBatchesVersion;
115};
116
117
118PXR_NAMESPACE_CLOSE_SCOPE
119
120#endif //PXR_IMAGING_HD_ST_COMMAND_BUFFER_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
A buffer of commands (HdStDrawItem or HdComputeItem objects) to be executed.
Definition: commandBuffer.h:47
size_t GetVisibleSize() const
Returns the number of draw items, excluding culled items.
Definition: commandBuffer.h:90
HDST_API void PrepareDraw(HgiGraphicsCmds *gfxCmds, HdStRenderPassStateSharedPtr const &renderPassState, HdRenderIndex *renderIndex)
Prepare the command buffer for draw.
HDST_API void RebuildDrawBatchesIfNeeded(unsigned currentBatchVersion, Hgi const *hgi)
Rebuild all draw batches if any underlying buffer array is invalidated.
HDST_API void SyncDrawItemVisibility(unsigned visChangeCount)
Sync visibility state from RprimSharedState to DrawItemInstances.
size_t GetCulledSize() const
Returns the number of culled draw items.
Definition: commandBuffer.h:93
size_t GetTotalSize() const
Returns the total number of draw items, including culled items.
Definition: commandBuffer.h:84
HDST_API void SetDrawItems(HdDrawItemConstPtrVectorSharedPtr const &drawItems, unsigned currentBatchVersion, Hgi const *hgi)
Sets the draw items to use for batching.
HDST_API void ExecuteDraw(HgiGraphicsCmds *gfxCmds, HdStRenderPassStateSharedPtr const &renderPassState, HdStResourceRegistrySharedPtr const &resourceRegistry)
Execute the command buffer.
A container to store instance state for a drawitem.
A graphics API independent abstraction of graphics commands.
Definition: graphicsCmds.h:31
Hydra Graphics Interface.
Definition: hgi.h:95