{"id":45049681,"url":"https://github.com/stripe2933/vk-deferred","last_synced_at":"2026-02-19T08:33:38.896Z","repository":{"id":249434536,"uuid":"830969250","full_name":"stripe2933/vk-deferred","owner":"stripe2933","description":"A minimal Vulkan deferred rendering demonstration.","archived":false,"fork":false,"pushed_at":"2025-01-02T16:59:47.000Z","size":4018,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T17:45:42.915Z","etag":null,"topics":["cpp20-modules","rendering","vulkan"],"latest_commit_sha":null,"homepage":"","language":"C++","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/stripe2933.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-07-19T11:09:15.000Z","updated_at":"2024-11-19T16:20:49.000Z","dependencies_parsed_at":"2024-07-20T19:54:26.376Z","dependency_job_id":"8c4d6e30-889f-4977-96f9-0f93fa40f734","html_url":"https://github.com/stripe2933/vk-deferred","commit_stats":null,"previous_names":["stripe2933/vk-deferred"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stripe2933/vk-deferred","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe2933%2Fvk-deferred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe2933%2Fvk-deferred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe2933%2Fvk-deferred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe2933%2Fvk-deferred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stripe2933","download_url":"https://codeload.github.com/stripe2933/vk-deferred/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe2933%2Fvk-deferred/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29608547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T06:47:36.664Z","status":"ssl_error","status_checked_at":"2026-02-19T06:45:47.551Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["cpp20-modules","rendering","vulkan"],"created_at":"2026-02-19T08:33:38.248Z","updated_at":"2026-02-19T08:33:38.888Z","avatar_url":"https://github.com/stripe2933.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vk-deferred\n\n![Build](https://github.com/stripe2933/vk-deferred/actions/workflows/build.yml/badge.svg)\n\n![Running screenshot](doc/images/running-screenshot.png)\n\nA minimal Vulkan deferred rendering demonstration.\n\n## Usage\n\nThis project requires support for C++20 modules and the C++23 standard library. The supported compiler is:\n- Clang 18.1.2\n- MSVC 19.40\n\nAdditionally, the following build tools are required:\n- CMake 3.30\n- Ninja 1.11\n\n### Dependencies\n\nThis project depends on:\n- [GLFW](https://github.com/glfw/glfw)\n- [glm](https://github.com/g-truc/glm)\n- My own Vulkan-Hpp helper library, [vku](https://github.com/stripe2933/vku/tree/module) (branch `module`), which has the following dependencies:\n  - [Vulkan-Hpp](https://github.com/KhronosGroup/Vulkan-Hpp)\n  - [VulkanMemoryAllocator-Hpp](https://github.com/YaaZ/VulkanMemoryAllocator-Hpp)\n\nDependencies will be automatically fetched using vcpkg.\n\n### Build Steps\n\n\u003e [!TIP]\n\u003e This project uses GitHub Runner to ensure build compatibility on Windows (with MSVC), macOS and Linux (with Clang). You can check the workflow files in the [.github/workflows](.github/workflows) folder.\n\nThis project, along with its dependency `vku`, supports vcpkg for dependency management. Follow these steps to build the project:\n\n```sh\ngit clone https://github.com/stripe2933/vk-deferred\ncd vk-deferred\ncmake --preset=default # Or use your own configuration preset that inherits from the \"default\" preset.\ncmake --build build -t vk-deferred\n```\n\nThe executable will be located in the `build` folder.\n\n### Shader compilation\n\nAll shaders are located in the [shaders](/shaders) folder. They are automatically compiled to SPIR-V and embedded into the binary executable during the build.\n\n## About Render Pass and Attachment Images\n\nSince Vulkan allows explicit management of resource usage and memory properties, all attachment images used only in the render pass can be created with `vk::ImageUsageFlagBits::eTransientAttachment`. Additionally, if the system uses a tile-based GPU, you can use `vk::MemoryPropertyFlagBits::eLazilyAllocated` to avoid expensive memory allocation for the entire image (only each tile region will be allocated when the image is accessed). Therefore, **the memory consumption of the G-buffer in Vulkan is zero-cost (only swapchain images are allocated)** on TBGPU, which is hard to be achieved in OpenGL.\n\nThe project has a render pass with three subpasses. Each subpass does the following:\n1. **G-buffer construction**:\n   The G-buffer stores the rendered meshes' position and normal (for simplicity, other fragment information like albedo and specular are not used) in the first and second color attachment images. It also uses the depth-stencil attachment to render depth and stencil=`1`.\n   ![G-buffer](doc/images/gbuffer-rendering.png)\n2. **Lighting using light volume**:\n   In this subpass, spheres corresponding to the light volumes are rendered (See [LearnOpenGL](https://learnopengl.com/Advanced-Lighting/Deferred-Shading) for details) only for fragments with stencil=`1`. The depth-stencil attachment is reused from the previous subpass, so light accumulation occurs only in previously rendered fragments. Since the swapchain attachments are in SRGB format, light cannot be accumulated directly (it should be done in the linear color space), so the `B10G11R11UfloatPack32` format is used for the color attachment (also preserving additional HDR info).\n   ![Light volume rendering](doc/images/light-volume-rendering.png)\n   Note: Only 20 light volumes are used in the above image to visualize the volume spheres. In the actual implementation, many more light volumes can be used.\n3. **Tone mapping**:\n   As mentioned earlier, the accumulated result is in HDR format, so it should be tone-mapped to the SRGB format. REC.709 tone mapping is used.\n\n### Data Flow Visualization\n\n![Data flow](doc/images/data-flow.png)\n\nScreenshot from Xcode Metal Debugger.\n\nNote that the G-buffer's position and normal attachment images' `loadOp` are `eDontCare`, because only rendered fragments will be referenced in the next subpass due to the stencil test. Similarly, swapchain images have `loadOp=eDontCare` because all regions will be overwritten using a fullscreen quad.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE.txt) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe2933%2Fvk-deferred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstripe2933%2Fvk-deferred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe2933%2Fvk-deferred/lists"}