-
Bring your game to Mac, Part 2: Compile your shaders
Discover how the Metal shader converter streamlines the process of bringing your HLSL shaders to Metal as we continue our three-part series on bringing your game to Mac. Find out how to build a fast, end-to-end shader pipeline from DXIL that supports all shader stages and allows you to leverage the advanced features of Apple GPUs. We'll also show you how to reduce app launch time and stutters by generating GPU binaries with the offline compiler.
To get the most out of this session, we recommend first watching “Bring your game to Mac, Part 1: Make a game plan." And once you're ready to level up, check out “Bring your game to Mac, Part 3: Render with Metal" from WWDC23.Capítulos
- 0:00 - Intro
- 0:49 - New Metal compiler tools
- 1:54 - Convert your shaders
- 12:27 - Finalize GPU binaries
- 18:20 - Wrap-Up
Recursos
- Get started with Metal shader converter
- Download the Metal shader converter (Mac and Windows)
- Download the game porting toolkit
- Metal
Vídeos relacionados
WWDC23
Tech Talks
WWDC22
WWDC21
WWDC20
-
Buscar neste vídeo...
-
-
14:28 - Json Metal Script
{“libraries": { "paths": [ {"path": “ba.metallib”, "label": "myMetalLib"} ] }, "pipelines": { "render_pipelines": [{ "vertex_function": "alias:myMetalLib#v", "fragment_function": "alias:myMetalLib#f", "raster_sample_count": 2, "color_attachments": [{ "pixel_format": "BGRA8Unorm" }], "depth_attachment_pixel_format": "Depth32Float" }] } } -
16:30 - Testing Binary Archive hit
// Create Pipeline Descriptor MTLComputePipelineDescriptor *computeDesc = [MTLComputePipelineDescriptor new]; computeDesc.binaryArchives = @[existingBinaryArchive]; computeDesc.computeFunction = computeFn; id<MTLComputePipelineState> computePS = [device newComputePipelineStateWithDescriptor:computeDesc options:MTLPipelineOptionFailonBinaryArchiveMiss error:&err]; if(computePS == nil) { // Binary archive is missing compiled shader. } -
17:03 - Loading appropriate Binary Archive
// Load OS-specific binary archives MTLComputePipelineDescriptor *computeDesc = [MTLComputePipelineDescriptor new]; if (@available(macOS 14, *)) { computeDesc.binaryArchives = @[binaryArchive_macOS14]; } else { computeDesc.binaryArchives = @[binaryArchive_macOS13_3]; } computeDesc.computeFunction = computeFn; id<MTLComputePipelineState> computePS = [device newComputePipelineStateWithDescriptor:computeDesc options:nil error:&err];
-