Skip to content

Commit

Permalink
Merge pull request #2605 from mattyjams/pr/fix_compilation_errors_wit…
Browse files Browse the repository at this point in the history
…h_cxx20

Fix compilation issues when building USD using the C++20 standard

(Internal change: 2351146)
  • Loading branch information
pixar-oss committed Dec 10, 2024
2 parents 555ea51 + 7f1de71 commit a40dca2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pxr/imaging/hd/instanceRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class HdInstanceRegistry {
private:
template <typename T>
static bool _IsUnique(std::shared_ptr<T> const &value) {
return value.unique();
return value.use_count() == 1;
}

typename InstanceType::Dictionary _dictionary;
Expand Down
10 changes: 6 additions & 4 deletions pxr/imaging/hdSt/resourceRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,9 @@ HdStResourceRegistry::GarbageCollectDispatchBuffers()
_dispatchBufferRegistry.erase(
std::remove_if(
_dispatchBufferRegistry.begin(), _dispatchBufferRegistry.end(),
std::bind(&HdStDispatchBufferSharedPtr::unique,
std::placeholders::_1)),
[](const HdStDispatchBufferSharedPtr& ptr) {
return ptr.use_count() == 1;
}),
_dispatchBufferRegistry.end());
}

Expand All @@ -564,8 +565,9 @@ HdStResourceRegistry::GarbageCollectBufferResources()
_bufferResourceRegistry.erase(
std::remove_if(
_bufferResourceRegistry.begin(), _bufferResourceRegistry.end(),
std::bind(&HdStBufferResourceSharedPtr::unique,
std::placeholders::_1)),
[](const HdStBufferResourceSharedPtr& ptr) {
return ptr.use_count() == 1;
}),
_bufferResourceRegistry.end());
}

Expand Down
4 changes: 2 additions & 2 deletions pxr/imaging/hdSt/samplerObjectRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ HdSt_SamplerObjectRegistry::GarbageCollect()
size_t last = _samplerObjects.size();

for (size_t i = 0; i < last; i++) {
if (_samplerObjects[i].unique()) {
if (_samplerObjects[i].use_count() == 1) {
while(true) {
last--;
if (i == last) {
break;
}
if (!_samplerObjects[last].unique()) {
if (_samplerObjects[last].use_count() != 1) {
_samplerObjects[i] = _samplerObjects[last];
break;
}
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hio/stb/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -4626,7 +4626,7 @@ static int stbi__check_png_header(stbi__context *s)
return 1;
}

typedef struct
typedef struct stbi__png_type
{
stbi__context *s;
stbi_uc *idata, *expanded, *out;
Expand Down
12 changes: 9 additions & 3 deletions pxr/imaging/hio/stb/stb_image.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- original/stb_image.h 2024-05-21 15:30:18.887733957 -0700
+++ stb_image.h 2024-05-21 15:17:49.371401403 -0700
--- original/stb_image.h 2024-12-09 08:40:54
+++ stb_image.h 2024-12-09 08:41:15
@@ -490,14 +490,14 @@
STBIDEF void stbi_image_free (void *retval_from_stbi_load);

Expand Down Expand Up @@ -28,7 +28,13 @@
static int stbi__png_is16(stbi__context *s);
#endif

@@ -4631,6 +4631,7 @@
@@ -4626,11 +4626,12 @@
return 1;
}

-typedef struct
+typedef struct stbi__png_type
{
stbi__context *s;
stbi_uc *idata, *expanded, *out;
int depth;
Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/pcp/primIndex_Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ PcpPrimIndex_Graph::_InsertChildInStrengthOrder(
void
PcpPrimIndex_Graph::_DetachSharedNodePool()
{
if (!_nodes.unique()) {
if (_nodes.use_count() != 1) {
TRACE_FUNCTION();
TfAutoMallocTag tag("_DetachSharedNodePool");
_nodes = std::make_shared<_NodePool>(*_nodes);
Expand All @@ -623,7 +623,7 @@ PcpPrimIndex_Graph::_DetachSharedNodePool()
void
PcpPrimIndex_Graph::_DetachSharedNodePoolForNewNodes(size_t numAddedNodes)
{
if (!_nodes.unique()) {
if (_nodes.use_count() != 1) {
TRACE_FUNCTION();
TfAutoMallocTag tag("_DetachSharedNodePoolForNewNodes");
// Create a new copy, but with some extra capacity since we are adding
Expand Down

0 comments on commit a40dca2

Please sign in to comment.