{"id":17978209,"url":"https://github.com/overv/mantlehellotriangle","last_synced_at":"2026-03-06T11:01:42.194Z","repository":{"id":29013100,"uuid":"32540266","full_name":"Overv/MantleHelloTriangle","owner":"Overv","description":"An implementation of Hello Triangle using the Mantle API on Windows","archived":false,"fork":false,"pushed_at":"2020-09-06T09:14:42.000Z","size":44,"stargazers_count":92,"open_issues_count":3,"forks_count":11,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-06T06:34:39.630Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Overv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-19T18:51:50.000Z","updated_at":"2025-02-12T23:21:03.000Z","dependencies_parsed_at":"2022-08-03T04:30:28.467Z","dependency_job_id":null,"html_url":"https://github.com/Overv/MantleHelloTriangle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Overv/MantleHelloTriangle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overv%2FMantleHelloTriangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overv%2FMantleHelloTriangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overv%2FMantleHelloTriangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overv%2FMantleHelloTriangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Overv","download_url":"https://codeload.github.com/Overv/MantleHelloTriangle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Overv%2FMantleHelloTriangle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30173345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-29T17:32:18.041Z","updated_at":"2026-03-06T11:01:37.184Z","avatar_url":"https://github.com/Overv.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n------------\n\nThis is an effort to implement Hello Triangle using the Mantle API by using the\nAPI reference and reverse engineering public Mantle demos.\n\nSee this blog post for more information:\n\nhttps://medium.com/@Overv/implementing-hello-triangle-in-mantle-4302450fbcd2\n\nApproach\n--------\n\nThe [reference](http://www.amd.com/Documents/Mantle-Programming-Guide-and-API-Reference.pdf)\nis used as primary resource, because it contains a full API reference and some\nsample code. Unfortunately it misses a lot of the constant definitions, like\n`GR_API_VERSION`, but these can be determined by creating a proxy mantle64.dll\nthat logs calls and the contents of structs. This approach is currently used\non the [Star Swarm Stress Test](http://store.steampowered.com/app/267130/) to\nfigure out what calls and data are needed to render a triangle on the screen.\nOther values, like `GR_MAX_HEAPS` can be figured out by querying for the struct\nsize with functions like `grGetObjectInfo`.\n\nThe intermediate language used for Mantle shaders is a subset of AMD IL, for\nwhich CodeXL contains [a compiler](http://developer.amd.com/community/blog/2014/05/16/codexl-game-developers-analyze-hlsl-gcn/).\nThe disassembly it outputs is incorrect, but the bytecode itself is valid.\nMantle appears to accept this code without problems.\n\nStatus\n------\n\nThe code is capable of creating a window using the SDL library, clearing it to\nblack and rendering a per-vertex colored triangle using Mantle.\n\n![Preview of running program](http://i.imgur.com/r5PxoRv.png)\n\nThe vertex shader reads the position (`float4`) and color (`float4`) from a\nbuffer using the `SV_VertexID` built-in variable. Each buffer is assigned a\nmemory view into GPU memory filled with the following data:\n\n    float vertices[] = {\n        // Positions\n        0.0, 0.5, 0.0, 1.0,\n        0.5, -0.5, 0.0, 1.0,\n        -0.5, -0.5, 0.0, 1.0,\n\n        // Colors\n        1.0, 0.0, 0.0, 1.0,\n        0.0, 1.0, 0.0, 1.0,\n        0.0, 0.0, 1.0, 1.0\n    };\n\nShader compilation\n------------------\n\nShaders are written in HLSL and compiled to AMD Intermediate Language using\nthe `CodeXLAnalyzer.exe` tool included in CodeXL using the `--il` flag. A batch\nscript for doing this is included in the `shaders` folder. The hex code on the\nright side can then be converted to a binary file using the `output2binary.py`\nscript, which takes the IL output file name as parameter. The binaries can then\nbe loaded into Mantle using `grCreateShader`, as is demonstrated in the code.\n\nLicense\n-------\n\n    Copyright (c) 2015 Alexander Overvoorde\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to\n    deal in the Software without restriction, including without limitation the\n    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n    sell copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n    IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverv%2Fmantlehellotriangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foverv%2Fmantlehellotriangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foverv%2Fmantlehellotriangle/lists"}