{"id":17771147,"url":"https://github.com/dehesa/sample-metal","last_synced_at":"2025-08-13T18:43:17.193Z","repository":{"id":49404340,"uuid":"100758133","full_name":"dehesa/sample-metal","owner":"dehesa","description":"Examples for Apple's Metal APIs (rendering and compute).","archived":false,"fork":false,"pushed_at":"2024-05-07T19:29:16.000Z","size":5073,"stargazers_count":285,"open_issues_count":0,"forks_count":23,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-31T15:19:49.748Z","etag":null,"topics":["apple","metal","shaders","swift","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dehesa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-18T23:54:58.000Z","updated_at":"2025-03-31T14:36:26.000Z","dependencies_parsed_at":"2024-10-26T22:16:12.128Z","dependency_job_id":"3bbc15bd-6a37-4e1a-990b-7a6abaa40d33","html_url":"https://github.com/dehesa/sample-metal","commit_stats":null,"previous_names":["dehesa/sample-metal"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dehesa%2Fsample-metal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dehesa%2Fsample-metal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dehesa%2Fsample-metal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dehesa%2Fsample-metal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dehesa","download_url":"https://codeload.github.com/dehesa/sample-metal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247713258,"owners_count":20983683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple","metal","shaders","swift","xcode"],"created_at":"2024-10-26T21:29:39.363Z","updated_at":"2025-04-07T19:14:28.826Z","avatar_url":"https://github.com/dehesa.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003cimg src=\"Documentation/Assets/Metal.svg\" alt=\"Metal Logo \u0026 Name\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://swift.org/about/#swiftorg-and-open-source\"\u003e\u003cimg src=\"Documentation/Assets/Badges/Swift.svg\" alt=\"Swift 5.9\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://developer.apple.com/xcode/\"\u003e\u003cimg src=\"Documentation/Assets/Badges/Xcode.svg\" alt=\"Xcode 15\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://developer.apple.com/metal/\"\u003e\u003cimg src=\"Documentation/Assets/Badges/Metal.svg\" alt=\"Metal 3.1\"\u003e\u003c/a\u003e\n    \u003ca href=\"http://doge.mit-license.org\"\u003e\u003cimg src=\"Documentation/Assets/Badges/License.svg\" alt=\"MIT License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThis repo contains code with examples on how to use Apple's Metal GPU APIs. Some sample code has been created entirely by [me](https://github.com/dehesa), while others have been picked from Github. The latter ones are in this repo because they have been heavily modified, not only to support the latest version of Swift and SwiftUI, but also to add support to macOS, iOS, and tvOS. Links to the source Github repos or websites are provided.\n\n## Projects\n\n-   Playgrounds.\n\n    - Memory size, stride, and alignment.\n    - `MTKView` as a Playground live view.\n\n-   Command-Line apps.\n\n    \u003cdiv\u003e\n    \u003cdetails\u003e\u003csummary\u003eGPU Inspector.\u003c/summary\u003e\u003cp\u003e\n\n    Prints on `stdout` a brief description of all your available GPUs. For example:\n\n    ```\n    Apple M1 Max\n      Built-in GPU\n      Unified memory (shared with CPU)\n        max recommended working set: 48 GB\n      Feature set support\n        family: apple 1, apple 2, apple 3, apple 4, apple 5, apple 6, apple 7, metal 3\n      General Purpose Computing\n        max threadgroup memory: 32 kB\n        max threads per threadgroup: [1024, 1024, 1024]\n        threads execution width: 32\n    \n    Intel(R) HD Graphics 530\n      Built-in GPU (low power)\n      Unified memory (shared with CPU)\n        max recommended working set: 1.61 GB\n      Feature set support\n        family: common 1, common 2, common 3, apple 1, apple 2, apple 3, apple 4\n      General Purpose Computing\n        max threadgroup memory: 64 KB\n        max threads per threadgroup: [1024, 1024, 1024]\n        threads execution width: 32\n\n    AMD Radeon Pro 460\n      Built-in GPU\n      Discrete memory\n        max recommended working set: 4.29 GB\n      Feature set support\n        family: common 1, common 2, common 3, apple 1, apple 2, apple 3, apple 4\n      General Purpose Computing\n        max threadgroup memory: 64 KB\n        max threads per threadgroup: [1024, 1024, 1024]\n        threads execution width: 64\n    ```\n\n    \u003c/p\u003e\u003c/details\u003e\n    \u003cdetails\u003e\u003csummary\u003eGray converter.\u003c/summary\u003e\u003cp\u003e\n    \n    Transform an image into its gray-scale version.\n    \n    This command-line utitily expects a single argument indicating the location of the image to transform and outputs the gray scale version to the `~/Desktop` with name `out.png`.\n    You can run it from Xcode by pressing ⌘ + R. This project scheme has an argument where you can specify a different image from the default image.\n\n    This utility is based on [Safx](https://github.com/safx)' gray converter [compute sample](https://github.com/safx/Metal-CommandLine-Sample-Swift).\n\n    \u003c/p\u003e\u003c/details\u003e\n    \u003c/div\u003e\n\n-   [Apple's sample code](https://developer.apple.com/metal/sample-code).\n\n    \u003cdetails\u003e\u003csummary\u003eBasic Tessellation.\u003c/summary\u003e\u003cp\u003e\n\n    [This sample](https://developer.apple.com/library/content/samplecode/MetalBasicTessellation/Introduction/Intro.html) shows how to tessellate a triangle or quad patch with adjustable per-patch tessellation factors.\n\n    \u003c/p\u003e\u003cp align=\"center\"\u003e\n        \u003cimg src=\"Documentation/Assets/Tessellation.png\" alt=\"macOS app tessellating a triangle\"/\u003e\n    \u003c/p\u003e\u003c/details\u003e\n\n-   [Metal by Example](https://metalbyexample.com).\n    \u003cbr\u003e[Warren Moore](https://warrenmoore.net) wrote this book in 2015. It was and it remains one of the best introductions to Metal I have found.\n    I've migrated most chapters to the latest Swift and I've added support to macOS.\n\n    - Clear Screen.\n    - Draw 2D triangle.\n    - Draw spinning 3D cube.\n    - Draw spinning _teapot_ with manual lighting.\n    - Draw spinning _cow_ with manual lighting and custom texture.\n\n-   [**Shader Exam**](https://github.com/leon196/SIGExam).\n    \u003cbr\u003e[Leon Denise](http://leon196.github.io) wrote a [tweet](https://twitter.com/leondenise/status/953716696161882114) with a typical shader exam he gives to his students on [SupInfo.com](https://rubika-edu.com).\n    -   [Page 1](Shader%20Exam/Exam/Page1.png):\n        [pass](Shader%20Exam/Page%201/SecondPass.metal#L35),\n        [mirror](Shader%20Exam/Page%201/SecondPass.metal#L47),\n        [symmetry](Shader%20Exam/Page%201/SecondPass.metal#L57),\n        [rotation](Shader%20Exam/Page%201/SecondPass.metal#L67),\n        [zoom](Shader%20Exam/Page%201/SecondPass.metal#L91),\n        [zoomDistortion](Shader%20Exam/Page%201/SecondPass.metal#L103),\n        [repetition](Shader%20Exam/Page%201/SecondPass.metal#L116),\n        [spiral](Shader%20Exam/Page%201/SecondPass.metal#L128),\n        [thunder](Shader%20Exam/Page%201/SecondPass.metal#L145).\n    -   [Page 2](Shader%20Exam/Exam/Page2.png): clamp, pli, color direction, pixelated, vague, column, crash, scanline, double frequency.\n    -   [Page 3](Shader%20Exam/Exam/Page3.png): black \u0026 white, threshold, thresholds, sonar, grill, stamp, local negative, chromatic aberration, chroma key\n    -   [Page 4](Shader%20Exam/Exam/Page4.png): vague, chubby, skinny, twist, glitch, voxel glitch, basic shading, toon shading, cell shading\n    -   [Page 5](Shader%20Exam/Exam/Page5.png): sphere, sphere repeat, pyramid, polar module, tube twist, tube web, volumetric cloud, strangler fig, kirby\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdehesa%2Fsample-metal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdehesa%2Fsample-metal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdehesa%2Fsample-metal/lists"}