diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml
index d6f4a43..da85cc1 100644
--- a/.github/workflows/swift.yml
+++ b/.github/workflows/swift.yml
@@ -21,5 +21,11 @@ jobs:
with:
checkout-scheme: release/6.2
- name: Build
- run: swift build
+ run: swift build --traits CompatibilityModeAttributeGraphV6
+ working-directory: ./Compute
+ - name: Test
+ run: |
+ swift test --traits CompatibilityModeAttributeGraphV6 --filter UtilitiesTests
+ swift test --traits CompatibilityModeAttributeGraphV6 --filter ComputeLayoutDescriptorTests
+ swift test --traits CompatibilityModeAttributeGraphV6 --filter ComputeTests
working-directory: ./Compute
diff --git a/Package.resolved b/Package.resolved
index cdce0b4..e7df565 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -1,13 +1,13 @@
{
- "originHash" : "4cf189cb4efdb66c68fe77b7823a66ab1b93e0017d80eccbae8ac327811f76ec",
+ "originHash" : "0db1a6cf7f89646c902e1f765ceeda44383c8f1ec559ce4abfbe1fb3bc963fad",
"pins" : [
{
"identity" : "darwinprivateframeworks",
"kind" : "remoteSourceControl",
- "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks",
+ "location" : "https://github.com/jcmosc/DarwinPrivateFrameworks",
"state" : {
- "revision" : "5eb0f26ea5a5bbd5068f6b3daf3a97dd3682b234",
- "version" : "0.0.4"
+ "branch" : "main",
+ "revision" : "add872df66b139bbb26b44f1dc272199b9f7da6a"
}
},
{
diff --git a/Package.swift b/Package.swift
index a66f1a3..eb7bce4 100644
--- a/Package.swift
+++ b/Package.swift
@@ -27,8 +27,8 @@ if let useLocalDepsEnv = Context.environment["COMPUTE_USE_LOCAL_DEPS"], !useLoca
dependencies +=
[
.package(
- url: "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks",
- from: "0.0.4"
+ url: "https://github.com/jcmosc/DarwinPrivateFrameworks",
+ branch: "main"
)
]
}
@@ -73,6 +73,9 @@ let package = Package(
products: [
.library(name: "Compute", targets: ["Compute"])
],
+ traits: [
+ .trait(name: "CompatibilityModeAttributeGraphV6")
+ ],
dependencies: dependencies,
targets: [
.target(
diff --git a/Sources/Compute/Attribute/AnyAttribute.swift b/Sources/Compute/Attribute/AnyAttribute.swift
index f552712..1c9e32f 100644
--- a/Sources/Compute/Attribute/AnyAttribute.swift
+++ b/Sources/Compute/Attribute/AnyAttribute.swift
@@ -10,7 +10,7 @@ extension Graph {
_ attribute: AnyAttribute,
type: Metadata,
invalidating: Bool,
- modify: (UnsafeMutableRawPointer) -> Void
+ modify: @escaping (UnsafeMutableRawPointer) -> Void
)
}
@@ -35,8 +35,10 @@ extension AnyAttribute {
}
public func mutateBody
(as type: Body.Type, invalidating: Bool, _ mutator: (inout Body) -> Void) {
- Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
- mutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
+ withoutActuallyEscaping(mutator) { escapingMutator in
+ Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
+ escapingMutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
+ }
}
}
diff --git a/Sources/Compute/Attribute/Attribute.swift b/Sources/Compute/Attribute/Attribute.swift
index 10b5895..443ea44 100644
--- a/Sources/Compute/Attribute/Attribute.swift
+++ b/Sources/Compute/Attribute/Attribute.swift
@@ -45,9 +45,15 @@ public struct Attribute {
let typeID = graphContext.internAttributeType(
type: Metadata(Body.self)
) {
+ let bodyType: _AttributeBody.Type
+ #if CompatibilityModeAttributeGraphV6
+ bodyType = Body.self
+ #else
+ bodyType = flags.contains(.external) ? _External.self : Body.self
+ #endif
let attributeType =
_AttributeType(
- selfType: flags.contains(.external) ? _External.self : Body.self,
+ selfType: bodyType,
valueType: Value.self,
flags: flags,
update: update()
diff --git a/Sources/ComputeCxx/Graph/Graph.cpp b/Sources/ComputeCxx/Graph/Graph.cpp
index c629df8..a562962 100644
--- a/Sources/ComputeCxx/Graph/Graph.cpp
+++ b/Sources/ComputeCxx/Graph/Graph.cpp
@@ -801,7 +801,7 @@ void Graph::indirect_attribute_set(data::ptr indirect_node, Attrib
}
uint64_t source_subgraph_id = source && !source.is_nil() ? source.subgraph()->subgraph_id() : 0;
- indirect_node->modify(WeakAttributeID(source, source_subgraph_id), resolved_source.offset());
+ indirect_node->modify(WeakAttributeID(source, uint32_t(source_subgraph_id)), resolved_source.offset());
indirect_node->set_traverses_contexts(AttributeID(indirect_node).subgraph()->context_id() !=
source.subgraph()->context_id());
diff --git a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift
index c75f50f..db8ec0c 100644
--- a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift
+++ b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift
@@ -34,17 +34,28 @@ struct AttributeTests {
)
let attributeType = attribute.identifier.info.type.pointee
- #expect(attributeType.self_id == Metadata(_External.self))
+ #if CompatibilityModeAttributeGraphV6
+ #expect(attributeType.self_id == Metadata(External.self))
+ #else
+ #expect(attributeType.self_id == Metadata(_External.self))
+ #endif
#expect(attributeType.value_id == Metadata(Int.self))
#expect(attributeType.flags == [.external, .comparisonModeEquatableAlways])
#expect(attributeType.internal_offset == 28)
#expect(attributeType.value_layout == expectedlayout)
- let attributeBody = unsafeBitCast(
- _External.self as any _AttributeBody.Type,
- to: (type: Metadata, witnessTable: UnsafeRawPointer).self
- )
+ #if CompatibilityModeAttributeGraphV6
+ let attributeBody = unsafeBitCast(
+ External.self as any _AttributeBody.Type,
+ to: (type: Metadata, witnessTable: UnsafeRawPointer).self
+ )
+ #else
+ let attributeBody = unsafeBitCast(
+ _External.self as any _AttributeBody.Type,
+ to: (type: Metadata, witnessTable: UnsafeRawPointer).self
+ )
+ #endif
#expect(attributeType.body_conformance.type_id == attributeBody.type)
#expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable)
}
@@ -69,17 +80,28 @@ struct AttributeTests {
)
let attributeType = attribute.identifier.info.type.pointee
- #expect(attributeType.self_id == Metadata(_External.self))
+ #if CompatibilityModeAttributeGraphV6
+ #expect(attributeType.self_id == Metadata(External.self))
+ #else
+ #expect(attributeType.self_id == Metadata(_External.self))
+ #endif
#expect(attributeType.value_id == Metadata(Int.self))
#expect(attributeType.flags == [.external, .comparisonModeEquatableAlways])
#expect(attributeType.internal_offset == 28)
#expect(attributeType.value_layout == expectedlayout)
- let attributeBody = unsafeBitCast(
- _External.self as any _AttributeBody.Type,
- to: (type: Metadata, witnessTable: UnsafeRawPointer).self
- )
+ #if CompatibilityModeAttributeGraphV6
+ let attributeBody = unsafeBitCast(
+ External.self as any _AttributeBody.Type,
+ to: (type: Metadata, witnessTable: UnsafeRawPointer).self
+ )
+ #else
+ let attributeBody = unsafeBitCast(
+ _External.self as any _AttributeBody.Type,
+ to: (type: Metadata, witnessTable: UnsafeRawPointer).self
+ )
+ #endif
#expect(attributeType.body_conformance.type_id == attributeBody.type)
#expect(attributeType.body_conformance.witness_table == attributeBody.witnessTable)
}
diff --git a/Tests/ComputeTests/Shared/Graph/GraphTests.swift b/Tests/ComputeTests/Shared/Graph/GraphTests.swift
index 0a39792..c27f60d 100644
--- a/Tests/ComputeTests/Shared/Graph/GraphTests.swift
+++ b/Tests/ComputeTests/Shared/Graph/GraphTests.swift
@@ -301,7 +301,7 @@ struct GraphTests {
@Test
func initialDescription() async throws {
- await try #require(processExitsWith: .success) {
+ try await #require(processExitsWith: .success) {
let description =
try #require(
Graph.description(nil, options: [DescriptionOption.format: "graph/dict"] as NSDictionary)
@@ -336,7 +336,7 @@ struct GraphTests {
// which we can't predict deterministically.
@Test
func graphDescription() async throws {
- await try #require(processExitsWith: .success) {
+ try await #require(processExitsWith: .success) {
let graph = Graph()
let subgraph = Subgraph(graph: graph)