Loading...
Searching...
No Matches
commandBuffer.h
1//
2// Copyright 2016 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_HD_ST_COMMAND_BUFFER_H
25#define PXR_IMAGING_HD_ST_COMMAND_BUFFER_H
26
27#include "pxr/pxr.h"
28#include "pxr/imaging/hdSt/api.h"
29#include "pxr/imaging/hd/version.h"
30#include "pxr/imaging/hdSt/drawItemInstance.h"
31
33
34#include <memory>
35#include <vector>
36
37PXR_NAMESPACE_OPEN_SCOPE
38
39class HdRenderIndex;
40class HdStDrawItem;
42class Hgi;
43class HgiGraphicsCmds;
44
45using HdStRenderPassStateSharedPtr = std::shared_ptr<class HdStRenderPassState>;
46using HdStResourceRegistrySharedPtr =
47 std::shared_ptr<class HdStResourceRegistry>;
48
49using HdDrawItemConstPtrVector = std::vector<class HdDrawItem const*>;
50using HdDrawItemConstPtrVectorSharedPtr
51 = std::shared_ptr<HdDrawItemConstPtrVector>;
52
53using HdSt_DrawBatchSharedPtr = std::shared_ptr<class HdSt_DrawBatch>;
54using HdSt_DrawBatchSharedPtrVector = std::vector<HdSt_DrawBatchSharedPtr>;
55
65public:
66 HDST_API
68 HDST_API
70
72 HDST_API
74 HdStRenderPassStateSharedPtr const &renderPassState,
75 HdRenderIndex *renderIndex);
76
78 HDST_API
80 HdStRenderPassStateSharedPtr const &renderPassState,
81 HdStResourceRegistrySharedPtr const &resourceRegistry);
82
84 HDST_API
85 void SyncDrawItemVisibility(unsigned visChangeCount);
86
90 HDST_API
91 void SetDrawItems(HdDrawItemConstPtrVectorSharedPtr const &drawItems,
92 unsigned currentBatchVersion,
93 Hgi const *hgi);
94
96 HDST_API
97 void RebuildDrawBatchesIfNeeded(unsigned currentBatchVersion,
98 Hgi const *hgi);
99
101 size_t GetTotalSize() const {
102 if (_drawItems) return _drawItems->size();
103 return 0;
104 }
105
107 size_t GetVisibleSize() const { return _visibleSize; }
108
110 size_t GetCulledSize() const {
111 if (_drawItems) {
112 return _drawItems->size() - _visibleSize;
113 }
114 return 0;
115 }
116
117 HDST_API
118 void SetEnableTinyPrimCulling(bool tinyPrimCulling);
119
120private:
121 void _RebuildDrawBatches(Hgi const *hgi);
122
124 void _FrustumCullCPU(GfMatrix4d const &cullMatrix);
125
126 HdDrawItemConstPtrVectorSharedPtr _drawItems;
127 std::vector<HdStDrawItemInstance> _drawItemInstances;
128 HdSt_DrawBatchSharedPtrVector _drawBatches;
129 size_t _visibleSize;
130 unsigned int _visChangeCount;
131 unsigned int _drawBatchesVersion;
132};
133
134
135PXR_NAMESPACE_CLOSE_SCOPE
136
137#endif //PXR_IMAGING_HD_ST_COMMAND_BUFFER_H
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
A buffer of commands (HdStDrawItem or HdComputeItem objects) to be executed.
Definition: commandBuffer.h:64
size_t GetVisibleSize() const
Returns the number of draw items, excluding culled items.
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.
size_t GetTotalSize() const
Returns the total number of draw items, including culled items.
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:48
Hydra Graphics Interface.
Definition: hgi.h:111