Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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