@@ -154,14 +154,32 @@ class.MTLInstanceAccelerationStructureDescriptor.methods."setInstanceDescriptorB
154154class.MTLInstanceAccelerationStructureDescriptor.methods."setInstancedAccelerationStructures:".unsafe = false
155155class.MTLAccelerationStructureGeometryDescriptor.methods."setPrimitiveDataBuffer:".unsafe = false
156156class.MTLAccelerationStructureTriangleGeometryDescriptor.methods."setVertexBuffer:".unsafe = false
157- protocol.MTLRenderCommandEncoder.methods."useResource:usage:".unsafe = false
158- protocol.MTLRenderCommandEncoder.methods."useResource:usage:stages:".unsafe = false
159- protocol.MTLComputeCommandEncoder.methods."useResource:usage:".unsafe = false
160- protocol.MTLBlitCommandEncoder.methods."synchronizeResource:".unsafe = false
161157protocol.MTLBlitCommandEncoder.methods."generateMipmapsForTexture:".unsafe = false
162158protocol.MTLBlitCommandEncoder.methods."optimizeContentsForGPUAccess:".unsafe = false
163159protocol.MTLAccelerationStructureCommandEncoder.methods."copyAndCompactAccelerationStructure:toAccelerationStructure:".unsafe = false
164160
161+ # SAFETY: Synchronizing a resource is safe, as it:
162+ # - Doesn't need to the resource to be bound.
163+ # - Doesn't access the contents of the resource.
164+ # - Doesn't need the resource to be retained by the user, since it already is
165+ # guaranteed to be since they've used the resource elsewhere.
166+ # TODO(breaking): Is that claim true?
167+ protocol.MTLBlitCommandEncoder.methods."synchronizeResource:".unsafe = false
168+
169+ # SAFETY: We consider resource's bound-ness as safe, the safety is moved to
170+ # command encoding methods such as `setTexture:atIndex:` instead.
171+ #
172+ # Calling this with a resource is safe, since it:
173+ # - Doesn't access the contents of the resource.
174+ # - Doesn't need the resource to be retained by the user, since it already is
175+ # guaranteed to be since they've used the resource elsewhere.
176+ #
177+ # TODO(breaking): Are those claims true?
178+ protocol.MTLAccelerationStructureCommandEncoder.methods."useResource:usage:".unsafe = false
179+ protocol.MTLComputeCommandEncoder.methods."useResource:usage:".unsafe = false
180+ protocol.MTLRenderCommandEncoder.methods."useResource:usage:".unsafe = false
181+ protocol.MTLRenderCommandEncoder.methods."useResource:usage:stages:".unsafe = false
182+
165183# SAFETY: Resource options are safe to specify:
166184# - Hazard tracking and storage modes change the required synchronization, but
167185# we handle that above. Also, we wouldn't really be able to prevent
@@ -182,8 +200,12 @@ protocol.MTLHeap.methods."setPurgeableState:".unsafe = false
182200# after this is called.
183201protocol.MTLResource.methods.makeAliasable.unsafe = true
184202
185- # SAFETY: Modifying residency is safe, it's effectively the same as
186- # controlling what's in the L1/L2/L3 cache on the CPU.
203+ # Modifying residency has similar safety as modifying a resource's bound-ness,
204+ # it does mostly the same thing.
205+ # protocol.MTLResidencySet.methods."addAllocation:".unsafe = false
206+
207+ # Taking a residency set in or out of residency is only a performance knob,
208+ # it's similar to controlling what's in the L1/L2/L3 cache on the CPU.
187209# protocol.MTLResidencySet.methods.requestResidency.unsafe = false
188210# protocol.MTLResidencySet.methods.endResidency.unsafe = false
189211
0 commit comments