{"id":1661,"date":"2014-09-11T10:28:14","date_gmt":"2014-09-11T10:28:14","guid":{"rendered":"https:\/\/www.gravityjack.com\/?p=1661"},"modified":"2023-11-30T10:28:32","modified_gmt":"2023-11-30T10:28:32","slug":"metal-for-ios-8","status":"publish","type":"post","link":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/","title":{"rendered":"Metal for iOS 8 &amp; Gaming | What Developers Need To Know"},"content":{"rendered":"\n<p>With more big announcements from Apple, comes the introduction of Metal. Metal is a new graphics API from Apple for iOS, that is not only extremely efficient, but created specifically for the A7 chip. This means it allows developers to take complete advantage of all of the killer hardware running iOS, and make games far more interactive, real, detailed and engaging.<\/p>\n\n\n\n<p>That&#8217;s a huge deal, and our friends over at Unity did a great job of explaining exactly why&#8230;<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Metal Overview<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create and validate as much state up-front as possible. Shaders can be compiled and partially optimized offline. Everything that is related to rendering pipeline state: shaders, vertex layout, blending modes, render target formats, etc. can be created and validated before rendering even starts. This means no more state checks every draw call and a lot of CPU processing power freed.<\/li>\n\n\n\n<li>Enable much more versatile multi-threading. Resources can be created from any thread and there are several ways to prepare draw call submission from multiple threads in parallel.<\/li>\n\n\n\n<li>All iOS devices have shared memory for CPU &amp; GPU. There\u2019s no need to pretend that data from the CPU has to be \u201ccopied\u201d into some video memory anymore. When you create a buffer, you just get a pointer to it, and that\u2019s&nbsp;<em>the same memory<\/em>&nbsp;that the GPU sees.<\/li>\n\n\n\n<li>Let the user (engine) handle synchronization. OpenGL ES has to jump through lots of hoops and do lots of guesswork in order to behave in every imaginable scenario. In Metal, synchronization of data between CPU &amp; GPU is user\u2019s responsibility. The engine has much better knowledge of what it tries to do, afterall!<\/li>\n\n\n\n<li>All GPUs in iOS devices are using Tile-Based Deferred Rendering architecture. It is explicitly reflected in Metal API, particularly when it comes to render targets. The API does not try to guess anything anymore \u2013 all framebuffer related actions such as tile loads &amp; stores, anti-aliasing resolves are done explicitly.<\/li>\n\n\n\n<li><em>All the points above translate to much lower CPU overhead and much more predictable performance.<\/em><\/li>\n\n\n\n<li>A new C\/C++11-based language is introduced for both graphics &amp; compute shaders. This also means that iOS can do compute shaders, atomics, arbitrary buffer writes and similar fancy sounding tricks on the GPU now.<\/li>\n\n\n\n<li>No legacy baggage, the API is very simple &amp; streamlined. Oh, and it also has a super-helpful optional \u201cdebug layer\u201d that does extra validation and notifies you of any errors or mistakes you make.<\/li>\n<\/ul>\n\n\n\n<p><em>Now let\u2019s go into even more details!<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Draw Call<\/h3>\n\n\n\n<p>If you\u2019re making games, particularly mobile games, you\u2019re probably aware of The Draw Call Problem. Each and every object that is rendered in the game has some CPU cost, and realistically on mobile right now you cannot afford more than a few hundred objects being rendered. In a real game, you also very much want to use CPU for other things \u2013 gameplay logic, physics, AI, animations and so on. Unity has some measures to minimize the number of draw calls being made \u2013 static &amp; dynamic batching, occlusion culling, LOD and distance-based layer culling; you can also merge close objects together, put textures into atlases to reduce number of materials.<\/p>\n\n\n\n<p>A good question is \u2013&nbsp;<em>why<\/em>&nbsp;there has to be a&nbsp;<em>CPU<\/em>&nbsp;cost to render something? After all, it\u2019s the GPU that is doing the&nbsp;<em>actual<\/em>&nbsp;work.<\/p>\n\n\n\n<p>Some of the overhead is on \u201cthe engine\u201d side \u2013 CPU has to iterate over visible objects, figure out which shader passes need to be rendered, which lights affect which objects, which material parameters to apply and so on. Some of that is cached; some of that is multi-threaded; and generally this is platform-independent code. In each Unity release, we try to optimize this part, and Metal generally does not affect this.<\/p>\n\n\n\n<p>However, other part of the CPU overhead is in the \u201cgraphics API &amp; driver\u201d part. Depending on the game, this part&nbsp;<em>can<\/em>&nbsp;be significant. Metal is an attempt to make this part virtually go away, by being a much better match for modern hardware, somewhat lower level and doing massively less guesswork than OpenGL ES used to do. Up-front rendering state creation &amp; validation; explicit actions related to render target loads &amp; stores; no synchronization dances done on the API side \u2014 all these things contribute to much lower CPU overhead.<\/p>\n\n\n\n<p>Based on our testing so far, we have seen API+driver overhead vanish to just a few percent of CPU time. That is a tremendous improvement comparing to 15-40% of CPU time that it used to be before! That means majority of the remaining CPU overhead is in our own code now.&nbsp;<em>I guess we\u2019ll have to continue optimizing that \ud83d\ude42<\/em><\/p>\n\n\n\n<p>We\u2019re also looking forward to using Metal ability to do rendering submissions from multiple threads; this opens up very interesting optimization opportunities as well.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Compute Opportunity<\/h3>\n\n\n\n<p>With Metal, the GPU can be used for doing computation outside of typical vertex+fragment shaders area \u2014 known as \u201ccompute shaders\u201d. Basically, this is an ability to run any kind of \u201cparallel computation\u201d on the many little processors inside a GPU. Compute shaders also have a concept of \u201clocal storage\u201d \u2013 very fast piece of dedicated on-GPU memory that can be used to share data between these parallel work items. This particular piece of memory enables using GPU for things that aren\u2019t easily expressible in ye olde vertex and fragment shaders.<\/p>\n\n\n\n<p>There are tons of interesting areas to use compute shaders for \u2014 optimized post-processing effects, particle systems, shadow and light culling and so on.<\/p>\n\n\n\n<p>While we aren\u2019t using compute shaders much in Unity&nbsp;<em>just yet<\/em>, we\u2019re looking forward to using them for more and more stuff. Exciting times ahead!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With more big announcements from Apple, comes the introduction of Metal. Metal is a new graphics API from Apple for iOS, that is not only extremely efficient, but created specifically for the A7 chip. This means it allows developers to take complete advantage of all of the killer hardware running iOS, and make games far <a href=\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">  Metal for iOS 8 &amp; Gaming | What Developers Need To Know<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":1506,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Metal for iOS 8 - What Game Developers Need To Know<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Metal for iOS 8 - What Game Developers Need To Know\" \/>\n<meta property=\"og:description\" content=\"With more big announcements from Apple, comes the introduction of Metal. Metal is a new graphics API from Apple for iOS, that is not only extremely efficient, but created specifically for the A7 chip. This means it allows developers to take complete advantage of all of the killer hardware running iOS, and make games far ... Metal for iOS 8 &amp; Gaming | What Developers Need To Know\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\" \/>\n<meta property=\"og:site_name\" content=\"Gravity Jack\" \/>\n<meta property=\"article:published_time\" content=\"2014-09-11T10:28:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-30T10:28:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"344\" \/>\n\t<meta property=\"og:image:height\" content=\"194\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gravity Admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gravity Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\",\"url\":\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\",\"name\":\"Metal for iOS 8 - What Game Developers Need To Know\",\"isPartOf\":{\"@id\":\"https:\/\/www.gravityjack.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg\",\"datePublished\":\"2014-09-11T10:28:14+00:00\",\"dateModified\":\"2023-11-30T10:28:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.gravityjack.com\/#\/schema\/person\/63c79a7e30c630a69e6e003ef7476fcc\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage\",\"url\":\"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg\",\"contentUrl\":\"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg\",\"width\":344,\"height\":194,\"caption\":\"Gravity Jack In the Press\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.gravityjack.com\/#website\",\"url\":\"https:\/\/www.gravityjack.com\/\",\"name\":\"Gravity Jack\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.gravityjack.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.gravityjack.com\/#\/schema\/person\/63c79a7e30c630a69e6e003ef7476fcc\",\"name\":\"Gravity Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gravityjack.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/aa3d42e00068a5cdefa39bab3155196c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/aa3d42e00068a5cdefa39bab3155196c?s=96&d=mm&r=g\",\"caption\":\"Gravity Admin\"},\"url\":\"https:\/\/www.gravityjack.com\/author\/gjmagravityjack-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Metal for iOS 8 - What Game Developers Need To Know","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/","og_locale":"en_US","og_type":"article","og_title":"Metal for iOS 8 - What Game Developers Need To Know","og_description":"With more big announcements from Apple, comes the introduction of Metal. Metal is a new graphics API from Apple for iOS, that is not only extremely efficient, but created specifically for the A7 chip. This means it allows developers to take complete advantage of all of the killer hardware running iOS, and make games far ... Metal for iOS 8 &amp; Gaming | What Developers Need To Know","og_url":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/","og_site_name":"Gravity Jack","article_published_time":"2014-09-11T10:28:14+00:00","article_modified_time":"2023-11-30T10:28:32+00:00","og_image":[{"width":344,"height":194,"url":"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg","type":"image\/jpeg"}],"author":"Gravity Admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Gravity Admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/","url":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/","name":"Metal for iOS 8 - What Game Developers Need To Know","isPartOf":{"@id":"https:\/\/www.gravityjack.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage"},"image":{"@id":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage"},"thumbnailUrl":"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg","datePublished":"2014-09-11T10:28:14+00:00","dateModified":"2023-11-30T10:28:32+00:00","author":{"@id":"https:\/\/www.gravityjack.com\/#\/schema\/person\/63c79a7e30c630a69e6e003ef7476fcc"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gravityjack.com\/news\/metal-for-ios-8\/#primaryimage","url":"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg","contentUrl":"https:\/\/www.gravityjack.com\/wp-content\/uploads\/2023\/11\/gj_news_nophoto_.jpg","width":344,"height":194,"caption":"Gravity Jack In the Press"},{"@type":"WebSite","@id":"https:\/\/www.gravityjack.com\/#website","url":"https:\/\/www.gravityjack.com\/","name":"Gravity Jack","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.gravityjack.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.gravityjack.com\/#\/schema\/person\/63c79a7e30c630a69e6e003ef7476fcc","name":"Gravity Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gravityjack.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/aa3d42e00068a5cdefa39bab3155196c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa3d42e00068a5cdefa39bab3155196c?s=96&d=mm&r=g","caption":"Gravity Admin"},"url":"https:\/\/www.gravityjack.com\/author\/gjmagravityjack-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/posts\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":0,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/posts\/1661\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/media\/1506"}],"wp:attachment":[{"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/media?parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gravityjack.com\/wp-json\/wp\/v2\/tags?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}