View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Load resources faster with Metal 3

    Discover how you can use fast resource streaming in Metal 3 to quickly load assets. We'll show you how to use an asynchronous set-it-and-forget-it workflow in your app to take advantage of the speed of SSD storage and the throughput of Apple silicon's unified memory architecture. We'll also explore how you can create separate queues that run parallel to — and synchronize with — your GPU render and compute work. Finally, we'll share how to designate assets like audio with high-priority queues to help you load data with lower latency.

    Ressources

    • Resource loading
    • Metal
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC22

    • Discover Metal 3
  • Rechercher dans cette vidéo…
    • 5:19 - Create a handle to an existing file

      // Create an Metal File IO Handle
      
      // Create handle to an existing file
      var fileIOHandle: MTLIOFileHandle!
      do {
          try fileHandle = device.makeIOHandle(url: filePath)
      } catch {
          print(error)
      }
    • 6:49 - Create a Metal IO command queue

      // Create a Metal IO command queue
      
      let commandQueueDescriptor = MTLIOCommandQueueDescriptor()
      
      commandQueueDescriptor.type = MTLIOCommandQueueType.concurrent // or serial
      
      var ioCommandQueue: MTLIOCommandQueue!
      do {
          try ioCommandQueue = device.makeIOCommandQueue(descriptor: commandQueueDescriptor)
      } catch {
          print(error)
      }
    • 7:17 - Create and submit a Metal IO command buffer

      // Create Metal IO Command Buffer
      
      let ioCommandBuffer = ioCommandQueue.makeCommandBuffer()
      
      // Encode load commands
      // Encode load texture and load buffer commands
      ioCommandBuffer.load(texture, slice: 0, level: 0, size: size, 
                           sourceBytesPerRow:bytesPerRow, sourceBytesPerImage: bytesPerImage,  
                           destinationOrigin: destOrigin,
                           sourceHandle: fileHandle, sourceHandleOffset: 0)
      ioCommandBuffer.load(buffer, offset: 0, size: size,
                           sourceHandle: fileHandle, sourceHandleOffset: 0)
      
      
      // Commit command buffer for execution
      ioCommandBuffer.commit()
    • 8:51 - Synchronize loading and rendering with Metal shared events

      var sharedEvent: MTLSharedEvent!
      sharedEvent = device.makeSharedEvent()
      
      // Create Metal IO command buffer
      let ioCommandBuffer = ioCommandQueue.makeCommandBuffer()
      
      ioCommandBuffer.waitForEvent(sharedEvent, value: waitVal)
      
      // Encode load commands
      
      ioCommandBuffer.signalEvent(sharedEvent, value: signalVal)
      ioCommandBuffer.commit()
      
      // Graphics work waits for the IO command buffer to signal
    • 10:29 - TryCancel Metal IO command buffer

      // Player in the center region
      // Encode loads for the North-West region
      ioCommandBufferNW.commit()
      // Encode loads for the West region
      ioCommandBufferW.commit()
      // Encode loads for the South-West region
      ioCommandBufferSW.commit()
      
      // Player in the western region and heading south
      // tryCancel NW command buffer
      ioCommandBufferNW.tryCancel()
      
      // ..
      // ..
      func regionNWCancelled() -> Bool {
          return ioCommandBufferNW.status == MTLIOStatus.cancelled
      }
    • 12:28 - Create a High Priority Metal IO command queue

      // Create a Metal IO command queue
      
      let commandQueueDescriptor = MTLIOCommandQueueDescriptor()
      commandQueueDescriptor.type = MTLIOCommandQueueType.concurrent // or serial
      
      // Set Metal IO command queue Priority
      commandQueueDescriptor.priority = MTLIOPriority.high // or normal or low
      
      var ioCommandQueue: MTLIOCommandQueue!
      do {
          try ioCommandQueue = device.makeIOCommandQueue(descriptor: commandQueueDescriptor)
      } catch {
          print(error)
      }
    • 14:04 - Create a compressed file

      // Create a compressed file
      
      // Create compression context
      let chunkSize = 64 * 1024
      let compressionMethod = MTLIOCompressionMethod.zlib
      let compressionContext = MTLIOCreateCompressionContext(compressedFilePath, compressionMethod, chunkSize)
      
      // Append uncompressed file data to the compression context
      // Get uncompressed file data 
      MTLIOCompressionContextAppendData(compressionContext, filedata.bytes, filedata.length)
      
      
      // Write the compressed file
      MTLIOFlushAndDestroyCompressionContext(compressionContext)
    • 15:05 - Create a handle to a compressed file

      // Create an Metal File IO Handle
      
      // Create handle to a compressed file
      var compressedFileIOHandle : MTLIOFileHandle!
      do {
          try compressedFileHandle = device.makeIOHandle(url: compressedFilePath, compressionMethod: MTLIOCompressionMethod.zlib)
      } catch {
          print(error)
      }

Developer Footer

  • Vidéos
  • WWDC22
  • Load resources faster with Metal 3
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines