Skip to content

Commit

Permalink
Finally, sprinkle swift interop atop USD v24.08.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed Aug 7, 2024
1 parent b181e82 commit e0e4fb5
Show file tree
Hide file tree
Showing 43 changed files with 16,921 additions and 15,514 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-usd"
version = "23.11.43"
version = "24.8.0"
edition = "2021"
publish = []

Expand Down
2 changes: 1 addition & 1 deletion DeclarativePixarUSD.usda
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#usda 1.0
(
doc = "SwiftUSD v23.11.43 | Declarative API"
doc = "SwiftUSD v24.08.0 | Declarative API"
)

def "DeclarativeScene"
Expand Down
2 changes: 1 addition & 1 deletion HelloPixarUSD.usda
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#usda 1.0
(
doc = "SwiftUSD v23.11.43"
doc = "SwiftUSD v24.08.0"
)

def Xform "Geometry"
Expand Down
68 changes: 42 additions & 26 deletions Python/PyUsd/wrapStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,22 @@ void wrapUsdStage()

.def("CreateNew",
(UsdStageRefPtr(*)(const string &, UsdStage::InitialLoadSet)) & UsdStage::CreateNew,
(arg("identifier"), arg("load") = UsdStage::LoadAll),
(arg("identifier"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateNew",
(UsdStageRefPtr(*)(const string &, const SdfLayerHandle &, UsdStage::InitialLoadSet)) &
UsdStage::CreateNew,
(arg("identifier"), arg("sessionLayer"), arg("load") = UsdStage::LoadAll),
(arg("identifier"),
arg("sessionLayer"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateNew",
(UsdStageRefPtr(*)(
const string &, const ArResolverContext &, UsdStage::InitialLoadSet)) &
UsdStage::CreateNew,
(arg("identifier"), arg("pathResolverContext"), arg("load") = UsdStage::LoadAll),
(arg("identifier"),
arg("pathResolverContext"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateNew",
(UsdStageRefPtr(*)(const string &,
Expand All @@ -217,29 +221,33 @@ void wrapUsdStage()
(arg("identifier"),
arg("sessionLayer"),
arg("pathResolverContext"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.staticmethod("CreateNew")

.def("CreateInMemory",
(UsdStageRefPtr(*)(UsdStage::InitialLoadSet)) & UsdStage::CreateInMemory,
(arg("load") = UsdStage::LoadAll),
(arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateInMemory",
(UsdStageRefPtr(*)(const string &, UsdStage::InitialLoadSet)) &
UsdStage::CreateInMemory,
(arg("identifier"), arg("load") = UsdStage::LoadAll),
(arg("identifier"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateInMemory",
(UsdStageRefPtr(*)(
const string &, const ArResolverContext &, UsdStage::InitialLoadSet)) &
UsdStage::CreateInMemory,
(arg("identifier"), arg("pathResolverContext"), arg("load") = UsdStage::LoadAll),
(arg("identifier"),
arg("pathResolverContext"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateInMemory",
(UsdStageRefPtr(*)(const string &, const SdfLayerHandle &, UsdStage::InitialLoadSet)) &
UsdStage::CreateInMemory,
(arg("identifier"), arg("sessionLayer"), arg("load") = UsdStage::LoadAll),
(arg("identifier"),
arg("sessionLayer"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("CreateInMemory",
(UsdStageRefPtr(*)(const string &,
Expand All @@ -250,36 +258,41 @@ void wrapUsdStage()
(arg("identifier"),
arg("sessionLayer"),
arg("pathResolverContext"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.staticmethod("CreateInMemory")

.def("Open",
(UsdStageRefPtr(*)(const string &, UsdStage::InitialLoadSet)) & UsdStage::Open,
(arg("filePath"), arg("load") = UsdStage::LoadAll),
(arg("filePath"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("Open",
(UsdStageRefPtr(*)(
const string &, const ArResolverContext &, UsdStage::InitialLoadSet)) &
UsdStage::Open,
(arg("filePath"), arg("pathResolverContext"), arg("load") = UsdStage::LoadAll),
(arg("filePath"),
arg("pathResolverContext"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())

.def("Open",
(UsdStageRefPtr(*)(const SdfLayerHandle &, UsdStage::InitialLoadSet)) & UsdStage::Open,
(arg("rootLayer"), arg("load") = UsdStage::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("Open",
(UsdStageRefPtr(*)(
const SdfLayerHandle &, const SdfLayerHandle &, UsdStage::InitialLoadSet)) &
UsdStage::Open,
(arg("rootLayer"), arg("sessionLayer"), arg("load") = UsdStage::LoadAll),
(arg("rootLayer"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def(
"Open",
(UsdStageRefPtr(*)(
const SdfLayerHandle &, const SdfLayerHandle &, UsdStage::InitialLoadSet)) &
UsdStage::Open,
(arg("rootLayer"), arg("sessionLayer"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("Open",
(UsdStageRefPtr(*)(
const SdfLayerHandle &, const ArResolverContext &, UsdStage::InitialLoadSet)) &
UsdStage::Open,
(arg("rootLayer"), arg("pathResolverContext"), arg("load") = UsdStage::LoadAll),
(arg("rootLayer"),
arg("pathResolverContext"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("Open",
(UsdStageRefPtr(*)(const SdfLayerHandle &,
Expand All @@ -290,15 +303,15 @@ void wrapUsdStage()
(arg("rootLayer"),
arg("sessionLayer"),
arg("pathResolverContext"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.staticmethod("Open")

.def("OpenMasked",
(UsdStageRefPtr(*)(
const string &, const UsdStagePopulationMask &, UsdStage::InitialLoadSet)) &
UsdStage::OpenMasked,
(arg("filePath"), arg("mask"), arg("load") = UsdStage::LoadAll),
(arg("filePath"), arg("mask"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("OpenMasked",
(UsdStageRefPtr(*)(const string &,
Expand All @@ -309,21 +322,24 @@ void wrapUsdStage()
(arg("filePath"),
arg("pathResolverContext"),
arg("mask"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("OpenMasked",
(UsdStageRefPtr(*)(
const SdfLayerHandle &, const UsdStagePopulationMask &, UsdStage::InitialLoadSet)) &
UsdStage::OpenMasked,
(arg("rootLayer"), arg("mask"), arg("load") = UsdStage::LoadAll),
(arg("rootLayer"), arg("mask"), arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("OpenMasked",
(UsdStageRefPtr(*)(const SdfLayerHandle &,
const SdfLayerHandle &,
const UsdStagePopulationMask &,
UsdStage::InitialLoadSet)) &
UsdStage::OpenMasked,
(arg("rootLayer"), arg("sessionLayer"), arg("mask"), arg("load") = UsdStage::LoadAll),
(arg("rootLayer"),
arg("sessionLayer"),
arg("mask"),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("OpenMasked",
(UsdStageRefPtr(*)(const SdfLayerHandle &,
Expand All @@ -334,7 +350,7 @@ void wrapUsdStage()
(arg("rootLayer"),
arg("pathResolverContext"),
arg("mask"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.def("OpenMasked",
(UsdStageRefPtr(*)(const SdfLayerHandle &,
Expand All @@ -347,7 +363,7 @@ void wrapUsdStage()
arg("sessionLayer"),
arg("pathResolverContext"),
arg("mask"),
arg("load") = UsdStage::LoadAll),
arg("load") = UsdStage::InitialLoadSet::LoadAll),
return_value_policy<TfPyRefPtrFactory<>>())
.staticmethod("OpenMasked")

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ For more details, please visit the web site [here](http://openusd.org).
##### To use Pixar's USD in swift, add SwiftUSD as a package dependency in your project's Package.swift file.
```swift
dependencies: [
.package(url: "https://github.com/wabiverse/SwiftUSD.git", from: "23.11.43"),
.package(url: "https://github.com/wabiverse/SwiftUSD.git", from: "24.8.0"),
]
```

Expand Down Expand Up @@ -109,7 +109,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/wabiverse/SwiftUSD.git", from: "23.11.43")
.package(url: "https://github.com/wabiverse/SwiftUSD.git", from: "24.8.0")
],
targets: [
/* 📕 For library products... */
Expand Down
4 changes: 3 additions & 1 deletion Sources/Ar/include/Ar/defaultResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Ar/resolver.h"
#include "pxr/pxrns.h"

#include <Arch/swiftInterop.h>

#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -123,7 +125,7 @@ class ArDefaultResolver : public ArResolver {
const ArDefaultResolverContext *_GetCurrentContextPtr() const;

ArResolverContext _defaultContext;
};
} SWIFT_IMMORTAL_REFERENCE;

PXR_NAMESPACE_CLOSE_SCOPE

Expand Down
4 changes: 3 additions & 1 deletion Sources/Ar/include/Ar/resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "Ar/timestamp.h"
#include "pxr/pxrns.h"

#include <Arch/swiftInterop.h>

#include <memory>
#include <string>
#include <vector>
Expand Down Expand Up @@ -791,7 +793,7 @@ class ArResolver {
// been bound via BindContext in their implementations.
AR_API
const ArResolverContext *_GetInternallyManagedCurrentContext() const;
};
} SWIFT_CONFORMS_TO_PROTOCOL(ArPrototypes.ArResolvable) SWIFT_IMMORTAL_REFERENCE;

/// Returns the configured asset resolver.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bin/usdcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static int UsdCat(const Args &args)
}
}
else if (args.flattenLayerStack) {
stage = UsdStage::Open(input, UsdStage::LoadNone);
stage = UsdStage::Open(input, UsdStage::InitialLoadSet::LoadNone);
if (stage) {
layer = UsdUtilsFlattenLayerStack(stage);
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Bin/usdtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ void PrintTree(const Args &args, const ArResolvedPath &resolved)
UsdStageRefPtr stage;
if (!mask.IsEmpty()) {
if (args.unloaded) {
stage = UsdStage::OpenMasked(resolved, mask, UsdStage::LoadNone);
stage = UsdStage::OpenMasked(resolved, mask, UsdStage::InitialLoadSet::LoadNone);
}
else {
stage = UsdStage::OpenMasked(resolved, mask);
}
}
else {
if (args.unloaded) {
stage = UsdStage::Open(resolved, UsdStage::LoadNone);
stage = UsdStage::Open(resolved, UsdStage::InitialLoadSet::LoadNone);
}
else {
stage = UsdStage::Open(resolved);
Expand All @@ -330,7 +330,7 @@ void PrintTree(const Args &args, const ArResolvedPath &resolved)
PrintTree(args, stage);
}
else if (args.flattenLayerStack) {
UsdStageRefPtr stage = UsdStage::Open(resolved, UsdStage::LoadNone);
UsdStageRefPtr stage = UsdStage::Open(resolved, UsdStage::InitialLoadSet::LoadNone);
if (!m.IsClean() || !stage) {
return;
}
Expand Down
8 changes: 5 additions & 3 deletions Sources/Hd/include/Hd/sceneIndexObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HdSceneIndexObserver : public TfWeakBase {
struct RemovedPrimEntry {
SdfPath primPath;

RemovedPrimEntry(const SdfPath &primPath) : primPath(primPath) {}
RemovedPrimEntry(const SdfPath &primPath = SdfPath()) : primPath(primPath) {}
};

using RemovedPrimEntries = TfSmallVector<RemovedPrimEntry, 16>;
Expand All @@ -72,7 +72,8 @@ class HdSceneIndexObserver : public TfWeakBase {
SdfPath primPath;
HdDataSourceLocatorSet dirtyLocators;

DirtiedPrimEntry(const SdfPath &primPath, const HdDataSourceLocatorSet &dirtyLocators)
DirtiedPrimEntry(const SdfPath &primPath = SdfPath(),
const HdDataSourceLocatorSet &dirtyLocators = HdDataSourceLocatorSet())
: primPath(primPath), dirtyLocators(dirtyLocators)
{
}
Expand All @@ -87,7 +88,8 @@ class HdSceneIndexObserver : public TfWeakBase {
struct RenamedPrimEntry {
SdfPath oldPrimPath;
SdfPath newPrimPath;
RenamedPrimEntry(const SdfPath &oldPrimPath, const SdfPath &newPrimPath)
RenamedPrimEntry(const SdfPath &oldPrimPath = SdfPath(),
const SdfPath &newPrimPath = SdfPath())
: oldPrimPath(oldPrimPath), newPrimPath(newPrimPath)
{
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/Hgi/include/Hgi/hgiImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "Tf/type.h"
#include "pxr/pxrns.h"

#include "Arch/swiftInterop.h"

#include "Hgi/api.h"
#include "Hgi/blitCmds.h"
#include "Hgi/buffer.h"
Expand Down Expand Up @@ -328,7 +330,7 @@ class Hgi {
Hgi(const Hgi &) = delete;

std::atomic<uint64_t> _uniqueIdCounter;
};
} SWIFT_IMMORTAL_REFERENCE;

///
/// Hgi factory for plugin system
Expand Down
7 changes: 6 additions & 1 deletion Sources/HgiMetal/hgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ MTL::CommandBuffer *HgiMetal::GetSecondaryCommandBuffer()
return commandBuffer;
}

void HgiMetal::SetHasWork()
{
_workToFlush = true;
}

int HgiMetal::GetAPIVersion() const
{
return GetCapabilities()->GetAPIVersion();
Expand Down Expand Up @@ -463,7 +468,7 @@ bool HgiMetal::_SubmitCmds(HgiCmds *cmds, HgiSubmitWaitType wait)
TRACE_FUNCTION();

if (cmds) {
_workToFlush = Hgi::_SubmitCmds(cmds, wait);
Hgi::_SubmitCmds(cmds, wait);
if (cmds == _currentCmds) {
_currentCmds = nullptr;
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/HgiMetal/include/HgiMetal/hgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef PXR_IMAGING_HGI_METAL_HGIMETAL_H
#define PXR_IMAGING_HGI_METAL_HGIMETAL_H

#include "Arch/swiftInterop.h"

#include "Hgi/hgiImpl.h"
#include "Hgi/tokens.h"
#include "HgiMetal/api.h"
Expand Down Expand Up @@ -219,7 +221,7 @@ class HgiMetal final : public Hgi {
bool _workToFlush;

NS::AutoreleasePool* _pool;
};
} SWIFT_IMMORTAL_REFERENCE;

PXR_NAMESPACE_CLOSE_SCOPE

Expand Down
Loading

0 comments on commit e0e4fb5

Please sign in to comment.