Loading...
Searching...
No Matches
renderParam.h
1//
2// Copyright 2021 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_PLUGIN_HD_ST_RENDER_PARAM_H
8#define PXR_IMAGING_PLUGIN_HD_ST_RENDER_PARAM_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/renderDelegate.h"
12#include "pxr/imaging/hdSt/api.h"
13
14#include <atomic>
15#include <shared_mutex>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
26class HdStRenderParam final : public HdRenderParam
27{
28public:
30 ~HdStRenderParam() override;
31
32 // ---------------------------------------------------------------------- //
34 // ---------------------------------------------------------------------- //
37 HDST_API
39
40 HDST_API
41 unsigned int GetDrawBatchesVersion() const;
42
45 HDST_API
47
48 HDST_API
49 unsigned int GetMaterialTagsVersion() const;
50
53 HDST_API
55
56 HDST_API
57 unsigned int GetGeomSubsetDrawItemsVersion() const;
58
59 // ---------------------------------------------------------------------- //
61 // ---------------------------------------------------------------------- /
62
68 HDST_API
69 bool HasMaterialTag(const TfToken &materialTag) const;
70
72 HDST_API
73 void IncreaseMaterialTagCount(const TfToken &materialTag);
74
76 HDST_API
77 void DecreaseMaterialTagCount(const TfToken &materialTag);
78
79 // ---------------------------------------------------------------------- //
81 // ---------------------------------------------------------------------- /
82
84 HDST_API
85 bool HasAnyRenderTag(const TfTokenVector &renderTags) const;
86
88 HDST_API
89 void IncreaseRenderTagCount(const TfToken &renderTag);
90
92 HDST_API
93 void DecreaseRenderTagCount(const TfToken &renderTag);
94
95 // ---------------------------------------------------------------------- //
97 // ---------------------------------------------------------------------- //
100 HDST_API
102
103 HDST_API
104 unsigned int GetActiveDrawTargetSetVersion() const;
105
106 // ---------------------------------------------------------------------- //
108 // ---------------------------------------------------------------------- //
110 _needsGarbageCollection = true;
111 }
112
113 void ClearGarbageCollectionNeeded() {
114 _needsGarbageCollection = false;
115 }
116
117 bool IsGarbageCollectionNeeded() const {
118 return _needsGarbageCollection;
119 }
120
121private:
122 typedef std::unordered_map<TfToken, std::atomic_int, TfHash> _TagToCountMap;
123
124 void _AdjustTagCount(
125 std::shared_timed_mutex *mutex,
126 _TagToCountMap *tagToCountMap,
127 const TfToken &tag,
128 const int increment);
129
130 bool _HasTag(
131 std::shared_timed_mutex *mutex,
132 const _TagToCountMap *tagToCountMap,
133 const TfToken &tag) const;
134
135 std::atomic_uint _drawBatchesVersion;
136 std::atomic_uint _materialTagsVersion;
137 std::atomic_uint _geomSubsetDrawItemsVersion;
138 std::atomic_uint _activeDrawTargetSetVersion;
139 bool _needsGarbageCollection; // Doesn't need to be atomic since parallel
140 // sync might only set it (and not clear).
141
142 mutable std::shared_timed_mutex _materialTagToCountMutex;
143 _TagToCountMap _materialTagToCount;
144
145 mutable std::shared_timed_mutex _renderTagToCountMutex;
146 _TagToCountMap _renderTagToCount;
147};
148
149PXR_NAMESPACE_CLOSE_SCOPE
150
151#endif // PXR_IMAGING_PLUGIN_HD_ST_RENDER_PARAM_H
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
The render delegate can create an object of type HdRenderParam, to pass to each prim during Sync().
Definition: renderParam.h:27
HDST_API void DecreaseRenderTagCount(const TfToken &renderTag)
Unregister that there is an rprim with given renderTag.
HDST_API void MarkDrawBatchesDirty()
Draw items cache and batch invalidation.
HDST_API void MarkMaterialTagsDirty()
Marks material tags dirty, meaning that the draw items associated with the collection of a render pas...
HDST_API void DecreaseMaterialTagCount(const TfToken &materialTag)
Unregister that there is an rprim with given materialTag.
HDST_API void MarkActiveDrawTargetSetDirty()
Draw targets.
HDST_API void IncreaseRenderTagCount(const TfToken &renderTag)
Register that there is an rprim with given renderTag.
HDST_API bool HasAnyRenderTag(const TfTokenVector &renderTags) const
Render tag tracking.
HDST_API bool HasMaterialTag(const TfToken &materialTag) const
Material tag tracking.
HDST_API void IncreaseMaterialTagCount(const TfToken &materialTag)
Register that there is an rprim with given materialTag.
void SetGarbageCollectionNeeded()
Garbage collection tracking.
Definition: renderParam.h:109
HDST_API void MarkGeomSubsetDrawItemsDirty()
Marks geom subsets draw items dirty, meaning that the draw items associated with the collection of a ...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440