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 // ---------------------------------------------------------------------- //
99 _needsGarbageCollection = true;
100 }
101
102 void ClearGarbageCollectionNeeded() {
103 _needsGarbageCollection = false;
104 }
105
106 bool IsGarbageCollectionNeeded() const {
107 return _needsGarbageCollection;
108 }
109
110private:
111 typedef std::unordered_map<TfToken, std::atomic_int, TfHash> _TagToCountMap;
112
113 void _AdjustTagCount(
114 std::shared_timed_mutex *mutex,
115 _TagToCountMap *tagToCountMap,
116 const TfToken &tag,
117 const int increment);
118
119 bool _HasTag(
120 std::shared_timed_mutex *mutex,
121 const _TagToCountMap *tagToCountMap,
122 const TfToken &tag) const;
123
124 std::atomic_uint _drawBatchesVersion;
125 std::atomic_uint _materialTagsVersion;
126 std::atomic_uint _geomSubsetDrawItemsVersion;
127 bool _needsGarbageCollection; // Doesn't need to be atomic since parallel
128 // sync might only set it (and not clear).
129
130 mutable std::shared_timed_mutex _materialTagToCountMutex;
131 _TagToCountMap _materialTagToCount;
132
133 mutable std::shared_timed_mutex _renderTagToCountMutex;
134 _TagToCountMap _renderTagToCount;
135};
136
137PXR_NAMESPACE_CLOSE_SCOPE
138
139#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 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:98
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