Working With Metal Advanced
|
|
- Shon Kelly Harris
- 6 years ago
- Views:
Transcription
1 Graphics and Games #WWDC14 Working With Metal Advanced Session 605 Gokhan Avkarogullari GPU Software Aaftab Munshi GPU Software Serhat Tekin GPU Software 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
2 Agenda Introduction to Metal Fundamentals of Metal Building a Metal application Metal shading language Advanced Metal Deep dive into creating a graphics application with Metal Data-Parallel Computing with Metal Developer Tools Review
3 Creating Multi-Pass Graphics Applications with Metal
4 Graphics Application with Multiple Passes Multiple framebuffer configurations Render to off-screen and on-screen textures Meshes that are used with multiple shaders Multiple encoders
5 Deferred Lighting with Shadow Maps Shadow Map Depth-only render from the perspective of the directional light Deferred Lighting Multiple render targets Framebuffer fetch for in-place light accumulation Stencil buffer for light culling
6 Deferred Lighting with Shadow Maps Shadow Map Depth-only render from the perspective of the directional light Deferred Lighting Multiple render targets Framebuffer fetch for in-place light accumulation Stencil buffer for light culling Don t worry about the algorithm Focus on the details of how the API is used
7 Deferred Lighting with Shadow Maps Pipeline State Shaders Blend, etc. Depth State Buffers Textures Pipeline State Shaders Blend, etc. Depth State Buffers Textures Render Command Encoder for Shadow Pass Render Command Encoder for Deferred Lighting Pass Command Buffer #1 Command Queue
8 Demo Deferred Lighting
9 Render Setup Actions to take once at application start time Actions that are taken as needed Level load time Texture streaming Mesh streaming Actions to take every frame Actions to take every render-to-texture pass
10 Render Setup Do once Create device Create command queue
11 Render Setup Do as needed Create framebuffer textures Create render pass descriptors Create buffers for meshes Create render pipeline objects Create textures Create state objects Create uniform buffers
12 Render Setup Do every frame Create command buffer Update frame-based uniform buffers Submit command buffer
13 Render Setup Do every render to texture pass Create command encoder Draw many times Update uniform buffers Set states Make draw calls
14 Render Setup Do as needed Create framebuffer textures Create render pass descriptors Create buffers for meshes Create render pipeline objects Create textures Create state objects Create uniform buffers
15 Render Setup A word on descriptors Descriptors are like blueprints Once the object is created the connection to the descriptor is gone Changing descriptors will not change the object Same descriptor can be reused to create another object Descriptor can be modified and then reused to create a new object
16 Render Setup Creating render pass descriptors MTLRenderPassDescriptor Color Color Color Color Depth Stencil
17 Render Setup Creating render pass descriptors MTLRenderPassDescriptor Color Color Color Color Depth Stencil
18 Render Setup Creating render pass descriptors MTLRenderPassAttachmentDescriptor MTLRenderPassDescriptor MTLTexture MTLResolveTexture loadaction storeaction - Color Color Depth Color Color Stencil
19 Render Setup Creating render pass descriptors MTLRenderPassAttachmentDescriptor MTLRenderPassDescriptor Texture MTLTexture MTLResolveTexture loadaction Color Color Color Color storeaction - Depth Stencil
20 Render Setup Render pass descriptor for shadowmap pass shadowrenderpassdescriptor Depth
21 Render Setup Render pass descriptor for shadowmap pass // Create texture id<mtltexture> shadow_texture; MTLTextureDescriptor *shadowtexturedesc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatDepth32Float width: 1024 height: 1024 mipmapped: NO]; shadow_texture = [device newtexturewithdescriptor: shadowtexturedesc];
22 Render Setup Render pass descriptor for shadowmap pass // Create texture id<mtltexture> shadow_texture; MTLTextureDescriptor *shadowtexturedesc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatDepth32Float width: 1024 height: 1024 mipmapped: NO]; shadow_texture = [device newtexturewithdescriptor: shadowtexturedesc];
23 Render Setup Render pass descriptor for shadowmap pass // Create texture id<mtltexture> shadow_texture; MTLTextureDescriptor *shadowtexturedesc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatDepth32Float width: 1024 height: 1024 mipmapped: NO]; shadow_texture = [device newtexturewithdescriptor: shadowtexturedesc];
24 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor];
25 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor]; // Set the texture on the render pass descriptor shadowmappassdesc.depthattachment.texture = shadow_texture;
26 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor]; // Set the texture on the render pass descriptor shadowmappassdesc.depthattachment.texture = shadow_texture;
27 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor]; // Set the texture on the render pass descriptor shadowmappassdesc.depthattachment.texture = shadow_texture; // Set other properties on the render pass descriptor shadowmappassdesc.depthattachment.clearvalue = MTLClearValueMakeDepth(1.0); shadowmappassdesc.depthattachment.loadaction = MTLLoadActionClear; shadowmappassdesc.depthattachment.setstoreaction = MTLStoreActionStore;
28 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor]; // Set the texture on the render pass descriptor shadowmappassdesc.depthattachment.texture = shadow_texture; // Set other properties on the render pass descriptor shadowmappassdesc.depthattachment.clearvalue = MTLClearValueMakeDepth(1.0); shadowmappassdesc.depthattachment.loadaction = MTLLoadActionClear; shadowmappassdesc.depthattachment.setstoreaction = MTLStoreActionStore;
29 Render Setup Render pass descriptor for shadowmap pass // Create render pass descriptor MTLRenderPassDescriptor *shadowmappassdesc = [MTLRenderPassDescriptor renderpassdescriptor]; // Set the texture on the render pass descriptor shadowmappassdesc.depthattachment.texture = shadow_texture; // Set other properties on the render pass descriptor shadowmappassdesc.depthattachment.clearvalue = MTLClearValueMakeDepth(1.0); shadowmappassdesc.depthattachment.loadaction = MTLLoadActionClear; shadowmappassdesc.depthattachment.setstoreaction = MTLStoreActionStore;
30 Render Setup Render pass descriptor for the Deferred Lighting pass deferredpassdesc Color Color Color Color Depth Stencil
31 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO];
32 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO]; // Create textures based on the descriptors gbuffer_texture1 = [device newtexturewithdescriptor: attachmentx_tex_desc];
33 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO]; // Create textures based on the descriptors gbuffer_texture1 = [device newtexturewithdescriptor: attachmentx_tex_desc];
34 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO]; // Create textures based on the descriptors gbuffer_texture1 = [device newtexturewithdescriptor: attachmentx_tex_desc]; // Modify descriptor and create new texture [attachmentx_texture_desc setpixelformat: ]; gbuffer_texture2 = [device newtexturewithdescriptor: attachmentx_tex_desc];
35 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO]; // Create textures based on the descriptors gbuffer_texture1 = [device newtexturewithdescriptor: attachmentx_tex_desc]; // Modify descriptor and create new texture [attachmentx_texture_desc setpixelformat: ]; gbuffer_texture2 = [device newtexturewithdescriptor: attachmentx_tex_desc];
36 Render Setup Render pass descriptor for the Deferred Lighting pass // Create descriptor MTLTextureDescriptor *attachmentx_texture_desc = [MTLTextureDescriptor texture2ddescriptorwithpixelformat: MTLPixelFormatBGRA8Unorm width: desc.width height: desc.height mipmapped: NO]; // Create textures based on the descriptors gbuffer_texture1 = [device newtexturewithdescriptor: attachmentx_tex_desc]; // Modify descriptor and create new texture [attachmentx_texture_desc setpixelformat: ]; gbuffer_texture2 = [device newtexturewithdescriptor: attachmentx_tex_desc];
37 Render Setup Render pass descriptor for the Deferred Lighting pass // Create render pass descriptor MTLRenderPassDescriptor *deferredpassdesc = [MTLRenderPassDescriptor renderpassdescriptor];
38 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; //will come from drawable
39 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; //will come from drawable
40 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore;
41 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore;
42 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1;
43 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1;
44 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1;
45 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1; deferredpassdesc.colorattachments[1].clearvalue = clearcolor1; deferredpassdesc.colorattachments[1].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[1].storeaction = MTLStoreActionDontCare;
46 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1; deferredpassdesc.colorattachments[1].clearvalue = clearcolor1; deferredpassdesc.colorattachments[1].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[1].storeaction = MTLStoreActionDontCare;
47 Render Setup Render pass descriptor for the Deferred Lighting pass // Describe color attachment 0 deferredpassdesc.colorattachments[0].texture = nil; deferredpassdesc.colorattachments[0].clearvalue = clearcolor1; deferredpassdesc.colorattachments[0].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[0].storeaction = MTLStoreActionStore; // Describe color attachment 1 deferredpassdesc.colorattachments[1].texture = gbuffer_texture1; deferredpassdesc.colorattachments[1].clearvalue = clearcolor1; deferredpassdesc.colorattachments[1].loadaction = MTLLoadActionClear; deferredpassdesc.colorattachments[1].storeaction = MTLStoreActionDontCare;
48 Render Setup Do as needed Create framebuffer textures Create render pass descriptors Create textures Create buffers for meshes Create state objects Create pipeline objects Create uniform buffers
49 Creating Textures // Copy texture data to bitmapdata unsigned Npixels = tex_info.width * tex_info.height; id<mtltexture> texture = [device newtexturewithdescriptor: ];
50 Creating Textures // Copy texture data to bitmapdata unsigned Npixels = tex_info.width * tex_info.height; id<mtltexture> texture = [device newtexturewithdescriptor: ]; [texture replaceregion: bitmapdata
51 Creating Textures // Copy texture data to bitmapdata unsigned Npixels = tex_info.width * tex_info.height; id<mtltexture> texture = [device newtexturewithdescriptor: ]; [texture replaceregion: bitmapdata
52 Creating Buffers for Meshes float4 temple[100]; spritebuffer = [device newbufferwithbytes: &temple length: sizeof(temple) options: 0];
53 Creating Buffers for Meshes float4 temple[100]; spritebuffer = [device newbufferwithbytes: &temple length: sizeof(temple) options: 0];
54 Creating State Objects MTLDepthStencilDescriptor *desc = [[MTLDepthStencilDescriptor alloc] init]; desc.depthcomparefunction = MTLCompareFunctionLessEqual; desc.depthwriteenabled = YES; MTLStencilDescriptor *stencilstatedesc = [[MTLStencilDescriptor alloc] init]; stencilstate.stencilcomparefunction = MTLCompareFunctionAlways; stencilstate.stencilfailureoperation = MTLStencilOperationKeep; desc.frontfacestencildescriptor = stencilstatedesc; desc.backfacestencildescriptor = stencilstatedesc; id <MTLDepthStencilState> shadowdepthstencilstate = [device newdepthstencilstatewithdescriptor: desc];
55 Creating State Objects MTLDepthStencilDescriptor *desc = [[MTLDepthStencilDescriptor alloc] init]; desc.depthcomparefunction = MTLCompareFunctionLessEqual; desc.depthwriteenabled = YES; MTLStencilDescriptor *stencilstatedesc = [[MTLStencilDescriptor alloc] init]; stencilstate.stencilcomparefunction = MTLCompareFunctionAlways; stencilstate.stencilfailureoperation = MTLStencilOperationKeep; desc.frontfacestencildescriptor = stencilstatedesc; desc.backfacestencildescriptor = stencilstatedesc; id <MTLDepthStencilState> shadowdepthstencilstate = [device newdepthstencilstatewithdescriptor: desc];
56 GPU Render Pipeline Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Framebuffer
57 Render Pipeline State Object Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Framebuffer
58 Render Pipeline State Object Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Shaders Framebuffer
59 Render Pipeline State Object Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Framebuffer Framebuffer configuration Number of render targets, pixel format, sample count
60 Render Pipeline State Object Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Framebuffer Depth and stencil state
61 Render Pipeline State Object Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Buffers Textures Samplers Fragment Shader Framebuffer
62 Render Pipeline State Object Not Included Buffers Vertex Fetch Buffers Textures Samplers Inputs Vertex Shader Primitive Setup Rasterizer Buffers Buffers Textures Samplers Fragment Shader Framebuffer
63 Render Pipeline State Object Not Included Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Rasterizer Outputs Buffers Textures Samplers Fragment Shader Framebuffer
64 Render Pipeline State Object Not Included Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Rasterizer Buffers Primitive setup Cull mode, facing orientation depth clipping, polygon mode Buffers Textures Samplers Fragment Shader Framebuffer
65 Render Pipeline State Object Not Included Buffers Vertex Fetch Buffers Textures Samplers Vertex Shader Primitive Setup Buffers Buffers Textures Samplers Rasterizer Fragment Shader Viewport and scissor Depth bias/slope/clamp Occlusion queries Framebuffer
66 Creating Render Pipeline State Object Every draw call requires a render pipeline state object to be set Same mesh usually has multiple pipeline state objects The temple object in our demo is rendered twice - The shadow pass Depth only render with simple vertex shader - The deferred pass Rendered to generate g-buffer attributes - Each one requires a different render pipeline state object to be created
67 Creating Render Pipeline State Object shadowmap pass // Create the descriptor MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new];
68 Creating Render Pipeline State Object shadowmap pass // Create the descriptor MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; // Get the shaders from the library id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"];
69 Creating Render Pipeline State Object shadowmap pass // Create the descriptor MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; // Get the shaders from the library id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"];
70 Creating Render Pipeline State Object shadowmap pass // Create the descriptor MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; // Get the shaders from the library id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"]; // Set the states desc.label Render"; desc.vertexfunction = zonlyvert; desc.stencilwriteenabled = false; desc.depthwriteenabled = true; desc.fragmentfunction = nil; //depth write only desc.depthattachmentpixelformat = pixelformat;
71 Creating Render Pipeline State Object shadowmap pass // Create the descriptor MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; // Get the shaders from the library id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"]; // Set the states desc.label Render"; desc.vertexfunction = zonlyvert; desc.stencilwriteenabled = false; desc.depthwriteenabled = true; desc.fragmentfunction = nil; //depth write only desc.depthattachmentpixelformat = pixelformat;
72 Creating Render Pipeline State Object shadowmap pass MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"]; desc.label Render"; desc.vertexfunction = zonlyvert; desc.stencilwriteenabled = false; desc.depthwriteenabled = true; desc.fragmentfunction = nil; //depth write only desc.depthattachmentpixelformat = pixelformat; // Create the render pipeline state object id<mtlrenderpipelinestate> pipeline = [device newrenderpipelinestatewithdescriptor: desc error: &err];
73 Creating Render Pipeline State Object shadowmap pass MTLRenderPipelineDescriptor *desc = [MTLRenderPipelineDescriptor new]; id <MTLFunction> zonlyvert = [zonlylibrary newfunctionwithname:@"zonly"]; desc.label Render"; desc.vertexfunction = zonlyvert; desc.stencilwriteenabled = false; desc.depthwriteenabled = true; desc.fragmentfunction = nil; //depth write only desc.depthattachmentpixelformat = pixelformat; // Create the render pipeline state object id<mtlrenderpipelinestate> pipeline = [device newrenderpipelinestatewithdescriptor: desc error: &err];
74 Creating Render Pipeline State Object Deferred Lighting pass desc.vertexfunction = gbuffervert; desc.fragmentfunction = gbufferfrag; desc.colorattachments[0].pixelformat = gbuffer_texture0.pixelformat; desc.colorattachments[1].pixelformat = gbuffer_texture1.pixelformat; desc.depthattachmentpixelformat = depth_texture.pixelformat; desc.stencilattachmentpixelformat = stencil_texture.pixelformat;
75 Creating Render Pipeline State Object Deferred Lighting pass desc.vertexfunction = gbuffervert; desc.fragmentfunction = gbufferfrag; desc.colorattachments[0].pixelformat = gbuffer_texture0.pixelformat; desc.colorattachments[1].pixelformat = gbuffer_texture1.pixelformat; desc.depthattachmentpixelformat = depth_texture.pixelformat; desc.stencilattachmentpixelformat = stencil_texture.pixelformat;
76 Creating Render Pipeline State Object Deferred Lighting pass desc.vertexfunction = gbuffervert; desc.fragmentfunction = gbufferfrag; desc.colorattachments[0].pixelformat = gbuffer_texture0.pixelformat; desc.colorattachments[1].pixelformat = gbuffer_texture1.pixelformat; desc.depthattachmentpixelformat = depth_texture.pixelformat; desc.stencilattachmentpixelformat = stencil_texture.pixelformat;
77 Render Setup Do every frame Create command buffer Update frame-based uniform buffers Submit command buffer
78 Render Setup Create and submit command buffer // BeginFrame commandbuffer = [commandqueue commandbuffer]; // EndFrame [commandbuffer addpresent: drawable]; [commandbuffer commit]; commandbuffer = nil;
79 Render Setup Create and submit command buffer // BeginFrame commandbuffer = [commandqueue commandbuffer]; // EndFrame [commandbuffer addpresent: drawable]; [commandbuffer commit]; commandbuffer = nil;
80 Render Setup Create and submit command buffer // BeginFrame commandbuffer = [commandqueue commandbuffer]; // EndFrame [commandbuffer addpresent: drawable]; [commandbuffer commit]; commandbuffer = nil;
81 Render Setup Do every render to texture pass Create command encoder Draw many times Update uniform buffers Set states Make draw calls
82 Render Setup shadowmap pass render encoding // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: shadowmappassdesc];
83 Render Setup shadowmap pass render encoding // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: shadowmappassdesc]; // Set states and draw [encoder setrenderpipelinestate: shadow_render_pipeline]; [encoder setdepthstencilstate: shadowdepthstencilstate]; [encoder setvertexbuffer: structurevertexbuffer offset:0 atindex: 0]; [encoder drawindexedprimitives:
84 Render Setup shadowmap pass render encoding // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: shadowmappassdesc]; // Set states and draw [encoder setrenderpipelinestate: shadow_render_pipeline]; [encoder setdepthstencilstate: shadowdepthstencilstate]; [encoder setvertexbuffer: structurevertexbuffer offset:0 atindex: 0]; [encoder drawindexedprimitives:
85 Render Setup shadowmap pass render encoding // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: shadowmappassdesc]; // Set states and draw [encoder setrenderpipelinestate: shadow_render_pipeline]; [encoder setdepthstencilstate: shadowdepthstencilstate]; [encoder setvertexbuffer: structurevertexbuffer offset:0 atindex: 0]; [encoder drawindexedprimitives: // end encoding [encoder endencoding];
86 Render Setup shadowmap pass render encoding // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: shadowmappassdesc]; // Set states and draw [encoder setrenderpipelinestate: shadow_render_pipeline]; [encoder setdepthstencilstate: shadowdepthstencilstate]; [encoder setvertexbuffer: structurevertexbuffer offset:0 atindex: 0]; [encoder drawindexedprimitives: // end encoding [encoder endencoding];
87 Render Setup Deferred Lighting pass render encoding deferredpassdesc.colorattachments[0].texture = texture_from_drawable;
88 Render Setup Deferred Lighting pass render encoding deferredpassdesc.colorattachments[0].texture = texture_from_drawable; // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: deferredpassdesc];
89 Render Setup Deferred Lighting pass render encoding deferredpassdesc.colorattachments[0].texture = texture_from_drawable; // Create encoder id<mtlrendercommandencoder> encoder = [commandbuffer rendercommandencoderwithdescriptor: deferredpassdesc]; // End encoding [encoder endencoding];
90 Agenda Introduction to Metal Fundamentals of Metal Building a Metal application Metal shading language Advanced Metal Deep dive into creating a graphics application with Metal Data-Parallel Computing with Metal Developer Tools Review
91 Data-Parallel Computing with Metal Aaftab Munshi GPU Software
92 Data-Parallel Computing with Metal What you ll learn
93 Data-Parallel Computing with Metal What you ll learn What is data-parallel computing?
94 Data-Parallel Computing with Metal What you ll learn What is data-parallel computing? Data-parallel computing in Metal
95 Data-Parallel Computing with Metal What you ll learn What is data-parallel computing? Data-parallel computing in Metal Writing data-parallel kernels in Metal
96 Data-Parallel Computing with Metal What you ll learn What is data-parallel computing? Data-parallel computing in Metal Writing data-parallel kernels in Metal Executing kernels in Metal
97 Data-Parallel Computing A brief introduction
98 Data-Parallel Computing A brief introduction Similar and independent computations on multiple data elements
99 Data-Parallel Computing A brief introduction Similar and independent computations on multiple data elements Example Blurring an image Same computation for each input All results are independent
100 Data-Parallelism in Metal
101 Data-Parallelism in Metal Code that describes computation is called a kernel
102 Data-Parallelism in Metal Code that describes computation is called a kernel Independent computation instance Work-item
103 Data-Parallelism in Metal Code that describes computation is called a kernel Independent computation instance Work-item Work-items that execute together Work-group Cooperate by sharing data Can synchronize execution
104 Data-Parallelism in Metal Computation domain
105 Data-Parallelism in Metal Computation domain Number of dimensions 1D, 2D, or 3D
106 Data-Parallelism in Metal Computation domain Number of dimensions 1D, 2D, or 3D For each dimension specify Number of work-items in work-group also known as work-group size Number of work-groups
107 Data-Parallelism in Metal Computation domain Number of dimensions 1D, 2D, or 3D For each dimension specify Number of work-items in work-group also known as work-group size Number of work-groups Choose the dimensions that are best for your algorithm
108 Pseudo Code for a Data-Parallel Kernel void square(const float* input, float* output, uint id { output[id] = input[id] * input[id]; }
109 Pseudo Code for a Data-Parallel Kernel #include <metal_stdlib> using namespace metal; void square(const float* input, float* output, uint id { output[id] = input[id] * input[id]; }
110 Pseudo Code for a Data-Parallel Kernel #include <metal_stdlib> using namespace metal; kernel void square(const float* input, float* output, uint id { output[id] = input[id] * input[id]; }
111 Pseudo Code for a Data-Parallel Kernel #include <metal_stdlib> using namespace metal; kernel void square(const global float* input [[ buffer(0) ]], global float* output [[ buffer(1) ]], uint id { output[id] = input[id] * input[id]; }
112 Metal Kernel #include <metal_stdlib> using namespace metal; kernel void square(const global float* input [[ buffer(0) ]], global float* output [[ buffer(1) ]], uint id [[ global_id ]]) { output[id] = input[id] * input[id]; }
113 Another Kernel Example in Metal Using images in a kernel
114 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
115 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
116 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
117 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
118 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
119 Another Kernel Example in Metal Using images in a kernel kernel void horizontal_reflect(texture2d<float> src [[ texture(0) ]], texture2d<float, access::write> dst [[ texture(1) ]], uint2 id [[ global_id ]]) { float4 c = src.read(uint2(src.get_width()-1-id.x, id.y)); dst.write(c, id); }
120 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
121 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
122 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
123 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
124 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
125 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
126 Built-in Kernel Variables Attributes for kernel arguments kernel void my_kernel(texture2d<float> img [[ texture(0) ]], ushort2 gid [[ global_id ]], uint glinear [[ global_linear_id ]], ushort2 lid [[ local_id ]], ushort linear [[ local_linear_id ]], uint wgid [[ work_group_id ]], ) { }
127 Executing Kernels in Metal Post-processing example
128 Post-Processing Kernel Kernel source
129 Post-Processing Kernel Kernel source kernel void postprocess_filter(texture2d<float> inimage [[ texture(0) ]], texture2d<float, access::write> outimage [[ texture(1) ]], texture2d<float> curveimage [[ texture(2) ]], constant Parameters& param [[ buffer(0) ]], uint2 gid [[ global_id ]]) { // Transform global ID using param.transformmatrix float4 color = inimage.sample(s, transformedcoord); } // Apply post-processing effect outimage.write(color, gid);
130 Post-Processing Kernel Kernel source kernel void postprocess_filter(texture2d<float> inimage [[ texture(0) ]], texture2d<float, access::write> outimage [[ texture(1) ]], texture2d<float> curveimage [[ texture(2) ]], constant Parameters& param [[ buffer(0) ]], uint2 gid [[ global_id ]]) { // Transform global ID using param.transformmatrix float4 color = inimage.sample(s, transformedcoord); } // Apply post-processing effect outimage.write(color, gid);
131 Post-Processing Kernel Kernel source kernel void postprocess_filter(texture2d<float> inimage [[ texture(0) ]], texture2d<float, access::write> outimage [[ texture(1) ]], texture2d<float> curveimage [[ texture(2) ]], constant Parameters& param [[ buffer(0) ]], uint2 gid [[ global_id ]]) { // Transform global ID using param.transformmatrix float4 color = inimage.sample(s, transformedcoord); } // Apply post-processing effect outimage.write(color, gid);
132 Post-Processing Kernel Kernel source kernel void postprocess_filter(texture2d<float> inimage [[ texture(0) ]], texture2d<float, access::write> outimage [[ texture(1) ]], texture2d<float> curveimage [[ texture(2) ]], constant Parameters& param [[ buffer(0) ]], uint2 gid [[ global_id ]]) { // Transform global ID using param.transformmatrix float4 color = inimage.sample(s, transformedcoord); } // Apply post-processing effect outimage.write(color, gid);
133 Post-Processing Kernel Processing multiple pixels/work-item constexpr constant int num_pixels_work_item = 4; kernel void postprocess_filter(, uint2 gid [[global_id]], uint2 lsize [[local_size]]) { for (int i=0; i<num_pixels_work_item; i++) { uint2 gid_new = uint2(gid.x+i*lsize.x, gid.y); // Transform gid_new using param.transformmatrix // Read from input image float4 color = inimage.sample(s, transformedcoord); // apply post-processing effect } } // Write to output image outimage.write(color, gid_new);
134 Post-Processing Kernel Processing multiple pixels/work-item constexpr constant int num_pixels_work_item = 4; kernel void postprocess_filter(, uint2 gid [[global_id]], uint2 lsize [[local_size]]) { for (int i=0; i<num_pixels_work_item; i++) { uint2 gid_new = uint2(gid.x+i*lsize.x, gid.y); // Transform gid_new using param.transformmatrix // Read from input image float4 color = inimage.sample(s, transformedcoord); // apply post-processing effect } } // Write to output image outimage.write(color, gid_new);
135 Post-Processing Kernel Processing multiple pixels/work-item constexpr constant int num_pixels_work_item = 4; kernel void postprocess_filter(, uint2 gid [[global_id]], uint2 lsize [[local_size]]) { for (int i=0; i<num_pixels_work_item; i++) { uint2 gid_new = uint2(gid.x+i*lsize.x, gid.y); // Transform gid_new using param.transformmatrix // Read from input image float4 color = inimage.sample(s, transformedcoord); // apply post-processing effect } } // Write to output image outimage.write(color, gid_new);
136 Executing a Kernel Compute command encoder
137 Executing a Kernel Compute command encoder // Load library and kernel function id <MTLLibrary> library = [device newlibrarywithfile:libname error:&err]; id <MTLFunction> filterfunc = [library newfunctionwithname:@ postprocess_filter ];
138 Executing a Kernel Compute command encoder // Load library and kernel function id <MTLLibrary> library = [device newlibrarywithfile:libname error:&err]; id <MTLFunction> filterfunc = [library newfunctionwithname:@ postprocess_filter ]; // Create compute state id <MTLComputePipelineState> filterkernel = [device newcomputepipelinestatewithfunction:filterfunc error:&err];
139 Executing a Kernel Compute command encoder // Load library and kernel function id <MTLLibrary> library = [device newlibrarywithfile:libname error:&err]; id <MTLFunction> filterfunc = [library newfunctionwithname:@ postprocess_filter ]; // Create compute state id <MTLComputePipelineState> filterkernel = [device newcomputepipelinestatewithfunction:filterfunc error:&err]; // Create compute command encoder
140 Executing a Kernel Compute command encoder // Load library and kernel function id <MTLLibrary> library = [device newlibrarywithfile:libname error:&err]; id <MTLFunction> filterfunc = [library newfunctionwithname:@ postprocess_filter ]; // Create compute state id <MTLComputePipelineState> filterkernel = [device newcomputepipelinestatewithfunction:filterfunc error:&err]; // Create compute command encoder id <MTLComputeCommandEncoder> computeencoder = [commandbuffer computecommandencoder];
141 Executing a Kernel Encode compute commands
142 Executing a Kernel Encode compute commands // Set compute state [computeencoder setcomputepipelinestate:filterkernel];
143 Executing a Kernel Encode compute commands // Set compute state [computeencoder setcomputepipelinestate:filterkernel]; // Set Resources used by kernel [computeencoder settexture:inputimage atindex:0]; [computeencoder settexture:outputimage atindex:1]; [computeencoder settexture:curveimage atindex:2]; [computeencoder setbuffer:params offset:0 atindex:0];
144 Executing a Kernel Encode compute commands
145 Executing a Kernel Encode compute commands // Calculate the work-group size and number of work-groups MTLSize wgsize = { 16, 16, 1 }; MTLSize numworkgroups = { (outputimage.width + wgsize - 1)/wgSize.x, (outputimage.height + wgsize - 1)/wgSize.y, 1 };
146 Executing a Kernel Encode compute commands // Calculate the work-group size and number of work-groups MTLSize wgsize = { 16, 16, 1 }; MTLSize numworkgroups = { (outputimage.width + wgsize - 1)/wgSize.x, (outputimage.height + wgsize - 1)/wgSize.y, 1 };
147 Executing a Kernel Encode compute commands // Calculate the work-group size and number of work-groups MTLSize wgsize = { 16, 16, 1 }; MTLSize numworkgroups = { (outputimage.width + wgsize - 1)/wgSize.x, (outputimage.height + wgsize - 1)/wgSize.y, 1 }; // Execute Kernel [computeencoder executekernelwithworkgroupsize:wgsize workgroupcount:numworkgroups];
148 Executing a Kernel Encode compute commands // Calculate the work-group size and number of work-groups MTLSize wgsize = { 16, 16, 1 }; MTLSize numworkgroups = { (outputimage.width + wgsize - 1)/wgSize.x, (outputimage.height + wgsize - 1)/wgSize.y, 1 }; // Execute Kernel [computeencoder executekernelwithworkgroupsize:wgsize workgroupcount:numworkgroups];
149 Executing a Kernel Encode compute commands // Calculate the work-group size and number of work-groups MTLSize wgsize = { 16, 16, 1 }; MTLSize numworkgroups = { (outputimage.width + wgsize - 1)/wgSize.x, (outputimage.height + wgsize - 1)/wgSize.y, 1 }; // Execute Kernel [computeencoder executekernelwithworkgroupsize:wgsize workgroupcount:numworkgroups]; // Finish encoding [computeencoder endencoding];
150 Executing a Kernel Submit commands to the GPU // Commit the command buffer [commandbuffer commit];
151 Demo Post-processing kernels
152 Agenda Introduction to Metal Fundamentals of Metal Building a Metal application Metal shading language Advanced Metal Deep dive into creating a graphics application with Metal Data-Parallel Computing with Metal Developer Tools Review
153 Tools Debugging and profiling Metal applications in Xcode
154 Summary
155 Summary A deeper dive into Metal Structuring your application for Metal Using descriptors and state objects for rendering Multi-pass encoding in Metal
156 Summary A deeper dive into Metal Structuring your application for Metal Using descriptors and state objects for rendering Multi-pass encoding in Metal Data-parallel computing in Metal How data-parallelism works in Metal Write and execute kernels in Metal
157 Summary A deeper dive into Metal Structuring your application for Metal Using descriptors and state objects for rendering Multi-pass encoding in Metal Data-parallel computing in Metal How data-parallelism works in Metal Write and execute kernels in Metal Tools How to create and compile Metal Shaders in Xcode Debug and profile a Metal application
158 More Information Filip Iliescu Graphics and Games Technologies Evangelist Allan Schaffer Graphics and Games Technologies Evangelist Documentation Apple Developer Forums
159 Related Sessions Working with Metal Overview Pacific Heights Wednesday 9:00AM Working with Metal Fundamentals Pacific Heights Wednesday 10:15AM Tools Location Sunday 0:00PM Media Location Sunday 0:00PM Graphics and Games Location Sunday 0:00PM Core OS Location Sunday 0:00PM Special Events Location Sunday 0:00PM
160 Labs Metal Lab Graphics and Games Lab A Wednesday 2:00PM Metal Lab Graphics and Games Lab B Thursday 10:15AM Tools Location Sunday 0:00PM Media Location Sunday 0:00PM Graphics and Games Location Sunday 0:00PM Core OS Location Sunday 0:00PM Special Events Location Sunday 0:00PM
161
Working with Metal Overview
Graphics and Games #WWDC14 Working with Metal Overview Session 603 Jeremy Sandmel GPU Software 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission
More informationIntroducing Metal 2. Graphics and Games #WWDC17. Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer
Session Graphics and Games #WWDC17 Introducing Metal 2 601 Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public display
More informationMetal for OpenGL Developers
#WWDC18 Metal for OpenGL Developers Dan Omachi, Metal Ecosystem Engineer Sukanya Sudugu, GPU Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without
More informationWhat s New in Metal, Part 2
Graphics and Games #WWDC15 What s New in Metal, Part 2 Session 607 Dan Omachi GPU Software Frameworks Engineer Anna Tikhonova GPU Software Frameworks Engineer 2015 Apple Inc. All rights reserved. Redistribution
More informationMetal. GPU-accelerated advanced 3D graphics rendering and data-parallel computation. source rebelsmarket.com
Metal GPU-accelerated advanced 3D graphics rendering and data-parallel computation source rebelsmarket.com Maths The heart and foundation of computer graphics source wallpoper.com Metalmatics There are
More informationThe Application Stage. The Game Loop, Resource Management and Renderer Design
1 The Application Stage The Game Loop, Resource Management and Renderer Design Application Stage Responsibilities 2 Set up the rendering pipeline Resource Management 3D meshes Textures etc. Prepare data
More informationProgramming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley
OpenGUES 2.0 Programming Guide Aaftab Munshi Dan Ginsburg Dave Shreiner TT r^addison-wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid
More informationMetal Feature Set Tables
Metal Feature Set Tables apple Developer Feature Availability This table lists the availability of major Metal features. OS ios 8 ios 8 ios 9 ios 9 ios 9 ios 10 ios 10 ios 10 ios 11 ios 11 ios 11 ios 11
More informationMetal for Ray Tracing Acceleration
Session #WWDC18 Metal for Ray Tracing Acceleration 606 Sean James, GPU Software Engineer Wayne Lister, GPU Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted
More informationBuilding a Game with SceneKit
Graphics and Games #WWDC14 Building a Game with SceneKit Session 610 Amaury Balliet Software Engineer 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written
More informationRendering Objects. Need to transform all geometry then
Intro to OpenGL Rendering Objects Object has internal geometry (Model) Object relative to other objects (World) Object relative to camera (View) Object relative to screen (Projection) Need to transform
More informationGraphics Processing Unit Architecture (GPU Arch)
Graphics Processing Unit Architecture (GPU Arch) With a focus on NVIDIA GeForce 6800 GPU 1 What is a GPU From Wikipedia : A specialized processor efficient at manipulating and displaying computer graphics
More informationDeferred Rendering Due: Wednesday November 15 at 10pm
CMSC 23700 Autumn 2017 Introduction to Computer Graphics Project 4 November 2, 2017 Deferred Rendering Due: Wednesday November 15 at 10pm 1 Summary This assignment uses the same application architecture
More informationEvolution of GPUs Chris Seitz
Evolution of GPUs Chris Seitz Overview Concepts: Real-time rendering Hardware graphics pipeline Evolution of the PC hardware graphics pipeline: 1995-1998: Texture mapping and z-buffer 1998: Multitexturing
More informationWhat s New in Metal. Part 2 #WWDC16. Graphics and Games. Session 605
Graphics and Games #WWDC16 What s New in Metal Part 2 Session 605 Charles Brissart GPU Software Engineer Dan Omachi GPU Software Engineer Anna Tikhonova GPU Software Engineer 2016 Apple Inc. All rights
More informationLecture 2. Shaders, GLSL and GPGPU
Lecture 2 Shaders, GLSL and GPGPU Is it interesting to do GPU computing with graphics APIs today? Lecture overview Why care about shaders for computing? Shaders for graphics GLSL Computing with shaders
More informationMore frames per second. Alex Kan and Jean-François Roy GPU Software
More frames per second Alex Kan and Jean-François Roy GPU Software 2 OpenGL ES Analyzer Tuning the graphics pipeline Analyzer demo 3 Developer preview Jean-François Roy GPU Software Developer Technologies
More informationNext-Generation Graphics on Larrabee. Tim Foley Intel Corp
Next-Generation Graphics on Larrabee Tim Foley Intel Corp Motivation The killer app for GPGPU is graphics We ve seen Abstract models for parallel programming How those models map efficiently to Larrabee
More informationThe Graphics Pipeline
The Graphics Pipeline Ray Tracing: Why Slow? Basic ray tracing: 1 ray/pixel Ray Tracing: Why Slow? Basic ray tracing: 1 ray/pixel But you really want shadows, reflections, global illumination, antialiasing
More informationBuilding Visually Rich User Experiences
Session App Frameworks #WWDC17 Building Visually Rich User Experiences 235 Noah Witherspoon, Software Engineer Warren Moore, Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public
More informationBest practices for effective OpenGL programming. Dan Omachi OpenGL Development Engineer
Best practices for effective OpenGL programming Dan Omachi OpenGL Development Engineer 2 What Is OpenGL? 3 OpenGL is a software interface to graphics hardware - OpenGL Specification 4 GPU accelerates rendering
More informationProgrammable Graphics Hardware
Programmable Graphics Hardware Outline 2/ 49 A brief Introduction into Programmable Graphics Hardware Hardware Graphics Pipeline Shading Languages Tools GPGPU Resources Hardware Graphics Pipeline 3/ 49
More informationCS4620/5620: Lecture 14 Pipeline
CS4620/5620: Lecture 14 Pipeline 1 Rasterizing triangles Summary 1! evaluation of linear functions on pixel grid 2! functions defined by parameter values at vertices 3! using extra parameters to determine
More informationRendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane
Rendering Pipeline Rendering Converting a 3D scene to a 2D image Rendering Light Camera 3D Model View Plane Rendering Converting a 3D scene to a 2D image Basic rendering tasks: Modeling: creating the world
More informationRasterization Overview
Rendering Overview The process of generating an image given a virtual camera objects light sources Various techniques rasterization (topic of this course) raytracing (topic of the course Advanced Computer
More informationProgramming Graphics Hardware
Tutorial 5 Programming Graphics Hardware Randy Fernando, Mark Harris, Matthias Wloka, Cyril Zeller Overview of the Tutorial: Morning 8:30 9:30 10:15 10:45 Introduction to the Hardware Graphics Pipeline
More informationEECS 487: Interactive Computer Graphics
EECS 487: Interactive Computer Graphics Lecture 21: Overview of Low-level Graphics API Metal, Direct3D 12, Vulkan Console Games Why do games look and perform so much better on consoles than on PCs with
More informationCopyright Khronos Group, Page Graphic Remedy. All Rights Reserved
Avi Shapira Graphic Remedy Copyright Khronos Group, 2009 - Page 1 2004 2009 Graphic Remedy. All Rights Reserved Debugging and profiling 3D applications are both hard and time consuming tasks Companies
More informationReal - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský
Real - Time Rendering Graphics pipeline Michal Červeňanský Juraj Starinský Overview History of Graphics HW Rendering pipeline Shaders Debugging 2 History of Graphics HW First generation Second generation
More informationWindowing System on a 3D Pipeline. February 2005
Windowing System on a 3D Pipeline February 2005 Agenda 1.Overview of the 3D pipeline 2.NVIDIA software overview 3.Strengths and challenges with using the 3D pipeline GeForce 6800 220M Transistors April
More informationReal-Time Rendering (Echtzeitgraphik) Michael Wimmer
Real-Time Rendering (Echtzeitgraphik) Michael Wimmer wimmer@cg.tuwien.ac.at Walking down the graphics pipeline Application Geometry Rasterizer What for? Understanding the rendering pipeline is the key
More informationE.Order of Operations
Appendix E E.Order of Operations This book describes all the performed between initial specification of vertices and final writing of fragments into the framebuffer. The chapters of this book are arranged
More informationAdvanced Rendering Techniques
Advanced Rendering Techniques Lecture Rendering Pipeline (Part I) Professor Leandro Augusto Frata Fernandes laffernandes@ic.uff.br Lecture notes available in http://www.ic.uff.br/~laffernandes/teaching/0./topicos_rendering
More informationMali Demos: Behind the Pixels. Stacy Smith
Mali Demos: Behind the Pixels Stacy Smith Mali Graphics: Behind the demos Mali Demo Team: Doug Day Stacy Smith (Me) Sylwester Bala Roberto Lopez Mendez PHOTOGRAPH UNAVAILABLE These days I spend more time
More informationReal - Time Rendering. Pipeline optimization. Michal Červeňanský Juraj Starinský
Real - Time Rendering Pipeline optimization Michal Červeňanský Juraj Starinský Motivation Resolution 1600x1200, at 60 fps Hw power not enough Acceleration is still necessary 3.3.2010 2 Overview Application
More informationPowerVR Hardware. Architecture Overview for Developers
Public Imagination Technologies PowerVR Hardware Public. This publication contains proprietary information which is subject to change without notice and is supplied 'as is' without warranty of any kind.
More informationOpenGL Status - November 2013 G-Truc Creation
OpenGL Status - November 2013 G-Truc Creation Vendor NVIDIA AMD Intel Windows Apple Release date 02/10/2013 08/11/2013 30/08/2013 22/10/2013 Drivers version 331.10 beta 13.11 beta 9.2 10.18.10.3325 MacOS
More informationPipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11
Pipeline Operations CS 4620 Lecture 11 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION
More informationGetting fancy with texture mapping (Part 2) CS559 Spring Apr 2017
Getting fancy with texture mapping (Part 2) CS559 Spring 2017 6 Apr 2017 Review Skyboxes as backdrops Credits : Flipmode 3D Review Reflection maps Credits : NVidia Review Decal textures Credits : andreucabre.com
More informationBringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games
Bringing AAA graphics to mobile platforms Niklas Smedberg Senior Engine Programmer, Epic Games Who Am I A.k.a. Smedis Platform team at Epic Games Unreal Engine 15 years in the industry 30 years of programming
More informationPipeline Operations. CS 4620 Lecture 14
Pipeline Operations CS 4620 Lecture 14 2014 Steve Marschner 1 Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives
More informationOpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak
OpenGL SUPERBIBLE Fifth Edition Comprehensive Tutorial and Reference Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak AAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San
More informationCS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside
CS230 : Computer Graphics Lecture 4 Tamar Shinar Computer Science & Engineering UC Riverside Shadows Shadows for each pixel do compute viewing ray if ( ray hits an object with t in [0, inf] ) then compute
More informationNVIDIA Parallel Nsight. Jeff Kiel
NVIDIA Parallel Nsight Jeff Kiel Agenda: NVIDIA Parallel Nsight Programmable GPU Development Presenting Parallel Nsight Demo Questions/Feedback Programmable GPU Development More programmability = more
More informationWhat s New in SpriteKit
Graphics and Games #WWDC14 What s New in SpriteKit Session 606 Norman Wang Game Technologies 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission
More informationWhat s New in Core Image
Media #WWDC15 What s New in Core Image Session 510 David Hayward Engineering Manager Tony Chu Engineer Alexandre Naaman Lead Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display
More informationComputer Graphics Shadow Algorithms
Computer Graphics Shadow Algorithms Computer Graphics Computer Science Department University of Freiburg WS 11 Outline introduction projection shadows shadow maps shadow volumes conclusion Motivation shadows
More informationGLSL Applications: 2 of 2
Administrivia GLSL Applications: 2 of 2 Patrick Cozzi University of Pennsylvania CIS 565 - Spring 2011 Assignment 2 due today 11:59pm on Blackboard Assignment 3 handed out today Due Wednesday, 02/09 at
More informationFrom Art to Engine with Model I/O
Session Graphics and Games #WWDC17 From Art to Engine with Model I/O 610 Nick Porcino, Game Technologies Engineer Nicholas Blasingame, Game Technologies Engineer 2017 Apple Inc. All rights reserved. Redistribution
More informationDave Shreiner, ARM March 2009
4 th Annual Dave Shreiner, ARM March 2009 Copyright Khronos Group, 2009 - Page 1 Motivation - What s OpenGL ES, and what can it do for me? Overview - Lingo decoder - Overview of the OpenGL ES Pipeline
More informationAchieving High-performance Graphics on Mobile With the Vulkan API
Achieving High-performance Graphics on Mobile With the Vulkan API Marius Bjørge Graphics Research Engineer GDC 2016 Agenda Overview Command Buffers Synchronization Memory Shaders and Pipelines Descriptor
More informationOptimizing Games for ATI s IMAGEON Aaftab Munshi. 3D Architect ATI Research
Optimizing Games for ATI s IMAGEON 2300 Aaftab Munshi 3D Architect ATI Research A A 3D hardware solution enables publishers to extend brands to mobile devices while remaining close to original vision of
More informationParallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload)
Lecture 2: Parallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload) Visual Computing Systems Today Finishing up from last time Brief discussion of graphics workload metrics
More informationWebGL. Creating Interactive Content with WebGL. Media #WWDC14. Session 509 Dean Jackson and Brady Eidson WebKit Engineers
Media #WWDC14 WebGL Creating Interactive Content with WebGL Session 509 Dean Jackson and Brady Eidson WebKit Engineers 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted
More informationCornell University CS 569: Interactive Computer Graphics. Introduction. Lecture 1. [John C. Stone, UIUC] NASA. University of Calgary
Cornell University CS 569: Interactive Computer Graphics Introduction Lecture 1 [John C. Stone, UIUC] 2008 Steve Marschner 1 2008 Steve Marschner 2 NASA University of Calgary 2008 Steve Marschner 3 2008
More informationWhat s New in Xcode App Signing
Developer Tools #WWDC16 What s New in Xcode App Signing Developing and distributing Session 401 Joshua Pennington Tools Engineering Manager Itai Rom Tools Engineer 2016 Apple Inc. All rights reserved.
More informationGraphics Performance Optimisation. John Spitzer Director of European Developer Technology
Graphics Performance Optimisation John Spitzer Director of European Developer Technology Overview Understand the stages of the graphics pipeline Cherchez la bottleneck Once found, either eliminate or balance
More informationGPU Memory Model Overview
GPU Memory Model Overview John Owens University of California, Davis Department of Electrical and Computer Engineering Institute for Data Analysis and Visualization SciDAC Institute for Ultrascale Visualization
More informationKenneth Dyke Sr. Engineer, Graphics and Compute Architecture
Kenneth Dyke Sr. Engineer, Graphics and Compute Architecture 2 Supporting multiple GPUs in your application Finding all renderers and devices Responding to renderer changes Making use of multiple GPUs
More informationSceneKit: What s New Session 604
Graphics and Games #WWDC17 SceneKit: What s New Session 604 Thomas Goossens, SceneKit engineer Amaury Balliet, SceneKit engineer Anatole Duprat, SceneKit engineer Sébastien Métrot, SceneKit engineer 2017
More informationOUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system
GRAPHICS PIPELINE 1 OUTLINE Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system 2 IMAGE FORMATION REVISITED Can we mimic the synthetic
More informationRSX Best Practices. Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog
RSX Best Practices Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog RSX Best Practices About libgcm Using the SPUs with the RSX Brief overview of GCM Replay December 7 th, 2004
More informationEnhancing Traditional Rasterization Graphics with Ray Tracing. October 2015
Enhancing Traditional Rasterization Graphics with Ray Tracing October 2015 James Rumble Developer Technology Engineer, PowerVR Graphics Overview Ray Tracing Fundamentals PowerVR Ray Tracing Pipeline Using
More informationEnhancing Traditional Rasterization Graphics with Ray Tracing. March 2015
Enhancing Traditional Rasterization Graphics with Ray Tracing March 2015 Introductions James Rumble Developer Technology Engineer Ray Tracing Support Justin DeCell Software Design Engineer Ray Tracing
More informationTutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI
Tutorial on GPU Programming #2 Joong-Youn Lee Supercomputing Center, KISTI Contents Graphics Pipeline Vertex Programming Fragment Programming Introduction to Cg Language Graphics Pipeline The process to
More informationCS 4620 Program 3: Pipeline
CS 4620 Program 3: Pipeline out: Wednesday 14 October 2009 due: Friday 30 October 2009 1 Introduction In this assignment, you will implement several types of shading in a simple software graphics pipeline.
More informationCopyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012
Copyright Khronos Group 2012 Page 1 Teaching GL Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 2 Agenda Overview of OpenGL family of APIs Comparison
More informationRay Casting on Programmable Graphics Hardware. Martin Kraus PURPL group, Purdue University
Ray Casting on Programmable Graphics Hardware Martin Kraus PURPL group, Purdue University Overview Parallel volume rendering with a single GPU Implementing ray casting for a GPU Basics Optimizations Published
More informationRendering Subdivision Surfaces Efficiently on the GPU
Rendering Subdivision Surfaces Efficiently on the GPU Gy. Antal, L. Szirmay-Kalos and L. A. Jeni Department of Algorithms and their Applications, Faculty of Informatics, Eötvös Loránd Science University,
More informationOptimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June
Optimizing and Profiling Unity Games for Mobile Platforms Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June 1 Agenda Introduction ARM and the presenter Preliminary knowledge
More informationCS452/552; EE465/505. Clipping & Scan Conversion
CS452/552; EE465/505 Clipping & Scan Conversion 3-31 15 Outline! From Geometry to Pixels: Overview Clipping (continued) Scan conversion Read: Angel, Chapter 8, 8.1-8.9 Project#1 due: this week Lab4 due:
More informationX. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1
X. GPU Programming 320491: Advanced Graphics - Chapter X 1 X.1 GPU Architecture 320491: Advanced Graphics - Chapter X 2 GPU Graphics Processing Unit Parallelized SIMD Architecture 112 processing cores
More informationCould you make the XNA functions yourself?
1 Could you make the XNA functions yourself? For the second and especially the third assignment, you need to globally understand what s going on inside the graphics hardware. You will write shaders, which
More informationScanline Rendering 2 1/42
Scanline Rendering 2 1/42 Review 1. Set up a Camera the viewing frustum has near and far clipping planes 2. Create some Geometry made out of triangles 3. Place the geometry in the scene using Transforms
More informationCS770/870 Spring 2017 Open GL Shader Language GLSL
Preview CS770/870 Spring 2017 Open GL Shader Language GLSL Review traditional graphics pipeline CPU/GPU mixed pipeline issues Shaders GLSL graphics pipeline Based on material from Angel and Shreiner, Interactive
More informationCS770/870 Spring 2017 Open GL Shader Language GLSL
CS770/870 Spring 2017 Open GL Shader Language GLSL Based on material from Angel and Shreiner, Interactive Computer Graphics, 6 th Edition, Addison-Wesley, 2011 Bailey and Cunningham, Graphics Shaders 2
More informationPerformance OpenGL Programming (for whatever reason)
Performance OpenGL Programming (for whatever reason) Mike Bailey Oregon State University Performance Bottlenecks In general there are four places a graphics system can become bottlenecked: 1. The computer
More informationPowerVR Series5. Architecture Guide for Developers
Public Imagination Technologies PowerVR Series5 Public. This publication contains proprietary information which is subject to change without notice and is supplied 'as is' without warranty of any kind.
More informationAdvanced Debugging and the Address Sanitizer
Developer Tools #WWDC15 Advanced Debugging and the Address Sanitizer Finding your undocumented features Session 413 Mike Swingler Xcode UI Infrastructure Anna Zaks LLVM Program Analysis 2015 Apple Inc.
More informationOpenGL Essentials Training
OpenGL Essentials Training 3-day session Overview Understanding principles of 3D programming Understanding drawing Primitives Understanding transformation matrix and Coloring Understanding Blending and
More informationGraphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal
Graphics Hardware, Graphics APIs, and Computation on GPUs Mark Segal Overview Graphics Pipeline Graphics Hardware Graphics APIs ATI s low-level interface for computation on GPUs 2 Graphics Hardware High
More informationShaders. Slide credit to Prof. Zwicker
Shaders Slide credit to Prof. Zwicker 2 Today Shader programming 3 Complete model Blinn model with several light sources i diffuse specular ambient How is this implemented on the graphics processor (GPU)?
More informationFree Downloads OpenGL ES 3.0 Programming Guide
Free Downloads OpenGL ES 3.0 Programming Guide OpenGLÂ Â ESâ is the industryâ s leading software interface and graphics library for rendering sophisticated 3D graphics on handheld and embedded devices.
More informationIntroduction to Shaders.
Introduction to Shaders Marco Benvegnù hiforce@gmx.it www.benve.org Summer 2005 Overview Rendering pipeline Shaders concepts Shading Languages Shading Tools Effects showcase Setup of a Shader in OpenGL
More information1.2.3 The Graphics Hardware Pipeline
Figure 1-3. The Graphics Hardware Pipeline 1.2.3 The Graphics Hardware Pipeline A pipeline is a sequence of stages operating in parallel and in a fixed order. Each stage receives its input from the prior
More informationCS 179 GPU Programming
CS179: GPU Programming Lecture 7: Render to Texture Lecture originally by Luke Durant, Russell McClellan, Tamas Szalay 1 Today: Render to Texture Render to texture in OpenGL Framebuffers and renderbuffers
More informationVulkan: Architecture positive How Vulkan maps to PowerVR GPUs Kevin sun Lead Developer Support Engineer, APAC PowerVR Graphics.
Vulkan: Architecture positive How Vulkan maps to PowerVR GPUs Kevin sun Lead Developer Support Engineer, APAC PowerVR Graphics www.imgtec.com Introduction Who am I? Kevin Sun Working at Imagination Technologies
More informationApplications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research
Applications of Explicit Early-Z Z Culling Jason Mitchell ATI Research Outline Architecture Hardware depth culling Applications Volume Ray Casting Skin Shading Fluid Flow Deferred Shading Early-Z In past
More informationPractical Texturing (WebGL) CS559 Fall 2016 Lecture 20 November 7th 2016
Practical Texturing (WebGL) CS559 Fall 2016 Lecture 20 November 7th 2016 In brief Starting with a simple model In brief Caveat : Issues with sampling & aliasing associate texture coordinates with primitives
More informationPipeline Operations. CS 4620 Lecture 10
Pipeline Operations CS 4620 Lecture 10 2008 Steve Marschner 1 Hidden surface elimination Goal is to figure out which color to make the pixels based on what s in front of what. Hidden surface elimination
More informationARM. Mali GPU. OpenGL ES Application Optimization Guide. Version: 2.0. Copyright 2011, 2013 ARM. All rights reserved. ARM DUI 0555B (ID051413)
ARM Mali GPU Version: 2.0 OpenGL ES Application Optimization Guide Copyright 2011, 2013 ARM. All rights reserved. ARM DUI 0555B () ARM Mali GPU OpenGL ES Application Optimization Guide Copyright 2011,
More informationOptimizing DirectX Graphics. Richard Huddy European Developer Relations Manager
Optimizing DirectX Graphics Richard Huddy European Developer Relations Manager Some early observations Bear in mind that graphics performance problems are both commoner and rarer than you d think The most
More informationCiril Bohak. - INTRODUCTION TO WEBGL
2016 Ciril Bohak ciril.bohak@fri.uni-lj.si - INTRODUCTION TO WEBGL What is WebGL? WebGL (Web Graphics Library) is an implementation of OpenGL interface for cmmunication with graphical hardware, intended
More informationGPU Memory Model. Adapted from:
GPU Memory Model Adapted from: Aaron Lefohn University of California, Davis With updates from slides by Suresh Venkatasubramanian, University of Pennsylvania Updates performed by Gary J. Katz, University
More informationModule 13C: Using The 3D Graphics APIs OpenGL ES
Module 13C: Using The 3D Graphics APIs OpenGL ES BREW TM Developer Training Module Objectives See the steps involved in 3D rendering View the 3D graphics capabilities 2 1 3D Overview The 3D graphics library
More informationChapter 1 Introduction
Graphics & Visualization Chapter 1 Introduction Graphics & Visualization: Principles & Algorithms Brief History Milestones in the history of computer graphics: 2 Brief History (2) CPU Vs GPU 3 Applications
More informationShadows. Prof. George Wolberg Dept. of Computer Science City College of New York
Shadows Prof. George Wolberg Dept. of Computer Science City College of New York Objectives Introduce Shadow Algorithms Expand to projective textures 2 Flashlight in the Eye Graphics When do we not see
More informationARM. Mali GPU. OpenGL ES Application Optimization Guide. Version: 3.0. Copyright 2011, 2013 ARM. All rights reserved. ARM DUI 0555C (ID102813)
ARM Mali GPU Version: 3.0 OpenGL ES Application Optimization Guide Copyright 2011, 2013 ARM. All rights reserved. ARM DUI 0555C () ARM Mali GPU OpenGL ES Application Optimization Guide Copyright 2011,
More informationIntroduction. What s New in This Edition
Introduction Welcome to the fourth edition of the OpenGL SuperBible. For more than ten years, we have striven to provide the world s best introduction to not only OpenGL, but 3D graphics programming in
More informationToday s Agenda. Basic design of a graphics system. Introduction to OpenGL
Today s Agenda Basic design of a graphics system Introduction to OpenGL Image Compositing Compositing one image over another is most common choice can think of each image drawn on a transparent plastic
More information