{"id":19817170,"url":"https://github.com/nvpro-samples/vk_mini_samples","last_synced_at":"2026-03-04T19:31:20.914Z","repository":{"id":86083465,"uuid":"423511757","full_name":"nvpro-samples/vk_mini_samples","owner":"nvpro-samples","description":"Collection of Vulkan samples","archived":false,"fork":false,"pushed_at":"2025-11-19T20:29:14.000Z","size":20509,"stargazers_count":302,"open_issues_count":3,"forks_count":18,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-11-19T22:12:48.811Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nvpro-samples.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-01T15:13:05.000Z","updated_at":"2025-11-19T20:29:18.000Z","dependencies_parsed_at":"2024-01-15T12:43:03.742Z","dependency_job_id":"32d1fc51-1c36-44b4-bc68-b6176fe7906e","html_url":"https://github.com/nvpro-samples/vk_mini_samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nvpro-samples/vk_mini_samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvpro-samples%2Fvk_mini_samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvpro-samples%2Fvk_mini_samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvpro-samples%2Fvk_mini_samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvpro-samples%2Fvk_mini_samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nvpro-samples","download_url":"https://codeload.github.com/nvpro-samples/vk_mini_samples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvpro-samples%2Fvk_mini_samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30090511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T18:31:08.343Z","status":"ssl_error","status_checked_at":"2026-03-04T18:31:07.708Z","response_time":59,"last_error":"SSL_read: 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-11-12T10:11:55.323Z","updated_at":"2026-03-04T19:31:20.895Z","avatar_url":"https://github.com/nvpro-samples.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vulkan Samples\n\nThis repository contains numerous examples demonstrating various aspects of Vulkan, debugging techniques, and integration with other NVIDIA tools. For a comprehensive list, refer to the [Samples](#Samples) section below.\n\nEach sample is accompanied by its own documentation detailing functionality and providing references for further information.\n\n\n## Dependencies\n\n* [nvpro_core](https://github.com/nvpro-samples/nvpro_core): A collection of Vulkan helper classes and utilities.\n\n## Build Instructions\n\n### Cloning Repositories\n\n```bash\ngit clone --recursive --shallow-submodules https://github.com/nvpro-samples/nvpro_core.git\ngit clone https://github.com/nvpro-samples/vk_mini_samples.git\n```\n\n### Generating Solution\n\n```bash\ncd vk_mini_samples\nmkdir build\ncd build\ncmake ..\n```\n\n\n### Additional SDKs\n\nThe Aftermath sample requires the separate download of the [Nsight Aftermath SDK](https://developer.nvidia.com/nsight-aftermath).\n\n### Shader Language Options: GLSL, HLSL, or SLANG\n\nBy default, samples use GLSL shaders. However, many also offer equivalent shaders in [HLSL](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl) and [SLANG](https://github.com/shader-slang/slang). To switch between them, select the desired shader language and regenerate the CMake configuration. The solution will update accordingly with compatible projects and their respective shaders.\n\n![Shader Language Selection](docs/use_shaders.png)\n\n## Samples\n\nFor those new to this repository, the [solid color](samples/solid_color) and [rectangle](samples/rectangle) samples are recommended starting points to better understand the framework.\n\n\n| Name | Description | Image | GLSL | HLSL | Slang |\n| ------ | ------ | ---- | ---- | ---- | ---- |\n| [barycentric_wireframe](samples/barycentric_wireframe) | Single-pass solid-wireframe rendering using `gl_BaryCoordNV` | ![](samples/barycentric_wireframe/docs/bary_wireframe_th.jpg) | [x] |  [x] | [x] |\n| [compute_multi_threaded](samples/compute_multi_threaded) | Executing a compute shader in a separate thread faster than the main thread.| ![](samples/compute_multi_threaded/docs/multi_threaded_th.jpg) | [x] | [x] | [x] |\n| [compute_only](samples/compute_only) | Basic compute and display example | ![](samples/compute_only/docs/compute_only_th.jpg) | [x] | [x] | [x] |\n| [crash_aftermath](samples/crash_aftermath) | Integration of Nsight Aftermath SDK into an existing application | ![](samples/crash_aftermath/docs/aftermath_th.jpg) | [x] | [x] | [x] |\n| [gltf_raytrace](samples/gltf_raytrace) | glTF scene loading with path-tracing renderer |  ![](samples/gltf_raytrace/docs/gltf_th.jpg) | [x] | [x] | [x] |\n| [gpu_monitor](samples/gpu_monitor) | GPU usage visualization | ![](samples/gpu_monitor/gpu_monitor_th.png) | [x] | [x] | [x] |\n| [image_ktx](samples/image_ktx) | KTX image display with tonemapping post-processing | ![](samples/image_ktx/docs/image_ktx_th.jpg) | [x] | [x] | [x] |\n| [image_viewer](samples/image_viewer) | Image loading with zoom and pan functionality | ![](samples/image_viewer/docs/image_viewer_th.jpg) | [x] | [x] | [x] |\n| [line_stipple](samples/line_stipple) | Dashed line rendering with stipple pattern | ![](samples/line_stipple/docs/line_stipple_th.jpg) | [x] | [x] | [x] |\n| [memory_budget](samples/memory_budget) | Dynamic memory allocation within budget constraints | ![](samples/memory_budget/docs/mem_budget_th.jpg) | [x] | [x] | [x] |\n| [mm_opacity](samples/mm_opacity) | Micromap opacity implementation  | ![](samples/mm_opacity/docs/opacity_th.jpg) | [x] | [x] | [x] |\n| [msaa](samples/msaa) | Hardware Multi-Sampling Anti-Aliasing demonstration  | ![](samples/msaa/docs/msaa_th.jpg) | [x] | [x] | [x] |\n| [offscreen](samples/offscreen) | Windowless rendering with image save functionality.  | ![](samples/offscreen/docs/offline_th.jpg) | [x] | [x] | [x] |\n| [ray_query](samples/ray_query) | Inline raytracing in compute shaders | ![](samples/ray_query/docs/ray_query_th.jpg) | [x] | [x] | [x] |\n| [ray_query_position_fetch](samples/ray_query_position_fetch) | Using VK_KHR_ray_tracing_position_fetch usage in ray query | ![](samples/ray_query_position_fetch/docs/ray_query_pos_fetch_th.jpg) | [x] | [ ] | [x] |\n| [ray_trace](samples/ray_trace) | Basic ray tracer with metallic-roughness shading, reflections, shadows, and sky shader.  | ![](samples/ray_trace/docs/raytrace_th.jpg) | [x] | [x] | [x] |\n| [ray_trace_motion_blur](samples/ray_trace_motion_blur) | Motion blur for dynamic objects using NVIDIA raytracing extension | ![](samples/ray_trace_motion_blur/docs/motion_blur_th.jpg) | [x] | [ ] | [x] |\n| [ray_tracing_position_fetch](samples/ray_tracing_position_fetch) | VK_KHR_ray_tracing_position_fetch implementation. | ![](samples/ray_tracing_position_fetch/docs/fetch_th.jpg) | [x] | [ ] | [x] |\n| [realtime_analysis](samples/realtime_analysis) | Real-time GPU information display | ![](samples/realtime_analysis/docs/realtime_analysis_th.jpg) | [x] | [ ] | [x] |\n| [rectangle](samples/rectangle) | 2D rectangle rendering to GBuffer.  | ![](samples/rectangle/docs/rectangle_th.jpg) | [x] | [x] | [x] |\n| [ser_pathtrace](samples/ser_pathtrace) | Shading Execution Reordering (SER) for optimized GPU usage.  | ![](samples/ser_pathtrace/docs/ser_2_th.jpg) | [x] | [x] | [x] |\n| [shader_object](samples/shader_object) | Shader object and dynamic pipeline usage | ![](samples/shader_object/docs/shader_object_th.jpg) | [x] | [x] | [x] |\n| [shader_printf](samples/shader_printf) | Shader debugging with printf functionality  | ![](samples/shader_printf/docs/printf_th.jpg) | [x] | [x] | [x] |\n| [simple_polygons](samples/simple_polygons) | Multi-polygon object rasterization.  | ![](samples/simple_polygons/docs/simple_polygons_th.jpg) | [x] | [x] | [x] |\n| [solid_color](samples/solid_color) | Single-pixel texture creation and display.  | ![](samples/solid_color/docs/solid_color_th.jpg) | [x] | [x] | [x] |\n| [texture 3d](samples/texture_3d) | 3D texture creation and ray marching. | ![](samples/texture_3d/docs/texture_3d_th.jpg) | [x] | [x] | [x] |\n| [tiny_shader_toy](samples/tiny_shader_toy) | Real-time shader compilation with error display and multi-stage pipelines.  | ![](samples/tiny_shader_toy/docs/tiny_shader_toy_th.jpg) | [x] | [ ] | [ ] |\n\n## Rendering Architecture\n\nThose samples demonstrates an indirect rendering approach, diverging from direct swapchain image rendering. The rendering pipeline is structured as follows:\n\n1. **Off-screen Rendering**: The sample renders its content to an off-screen image buffer rather than directly to the swapchain image.\n2. **GUI Integration**: The rendered off-screen image is incorporated as an element within the GUI layout.\n3. **Composite Rendering**: The `nvvkhl::Application` framework manages the final composition step. It combines the GUI elements (including the embedded rendered image) into a unified layout.\n4. **Swapchain Presentation**: The composite result from step 3 is then rendered to the swapchain image for final presentation.\n\nThis architecture provides several advantages:\n- Decouples the sample's rendering from the final presentation\n- Allows for flexible GUI integration of rendered content\n- Facilitates additional post-processing or compositing operations\n\nDevelopers should note that the actual swapchain image rendering is abstracted away within the `nvvkhl::Application` class, providing a clean separation of concerns between sample-specific rendering and final frame composition.\n\n## Application Architecture\n\nThe examples in this repository leverage various utilities from the [nvpro_core](https://github.com/nvpro-samples/nvpro_core) framework. Central to each sample's implementation is the [`Application`](https://github.com/nvpro-samples/nvpro_core/blob/master/nvvkhl/application.hpp) class, which provides core functionality for:\n\n- Window creation and management\n- User interface (UI) initialization\n- Swapchain setup integrated with the ImGui framework\n\nThe `Application` class is an enhanced derivative of the Dear ImGui Vulkan example, optimized for our use cases.\n\n### Modular Design\n\nSamples are implemented as `Elements` and attached to the `Application` instance. This modular approach allows for:\n\n1. Separation of concerns between core application logic and sample-specific code\n2. Consistent handling of UI rendering and frame operations across different samples\n\n### Initialization Process\n\nThe `init()` method orchestrates the following setup procedures:\n\n1. GLFW window initialization\n2. Swapchain setup through `ImplVulkanH_CreateOrResizeWindow`\n\n### Execution Cycle\n\nThe `run()` method implements the main application loop, continuing until a termination event is triggered. Each iteration of this loop invokes the following methods on attached `Elements`, in sequence:\n\n1. `onResize`: Handles viewport dimension changes\n2. `onUIMenu`: Facilitates additions to the menu bar\n3. `onUIRender`: Manages UI-related rendering tasks\n4. `onRender`: Executes sample-specific rendering operations within the current frame's command buffer\n\nPost-element processing, each frame concludes with:\n\n- `frameRender()`: Finalizes the frame's rendering operations\n- `framePresent()`: Submits the completed frame for presentation\n\nThis architecture provides a robust and flexible framework for implementing diverse Vulkan-based graphical samples while maintaining a consistent application structure.\n\n![application-loop](docs/Application-loop.png)\n\n\n## Shader Language Support\n\n### SPIR-V Intermediate Representation\n\nVulkan utilizes SPIR-V as its intermediate shader representation, diverging from the direct consumption of human-readable shader text. This architectural decision enables support for multiple high-level shader languages, provided they can target the Vulkan SPIR-V environment.\n\n### Configuration Options\n\nThe samples in this repository are designed to accommodate multiple shader languages. Language selection is controlled via CMake options:\n\n- `USE_GLSL`: Enables GLSL shader compilation\n- `USE_SLANG`: Enables Slang shader compilation\n- `USE_HLSL`: Enables HLSL shader compilation\n\n\n### Supported Languages\n\n#### Slang\n\n[Slang](https://github.com/shader-slang/slang) is a high-level shader language with syntax resembling C++. It is extensively used in NVIDIA research due to its versatility in targeting multiple backends:\n\n- SPIR-V (Vulkan)\n- DirectX 12\n- CUDA\n- C++\n\nTo specify a custom Slang compiler version, modify the `Slang_VERSION` CMakeLists.txt.\n\n#### HLSL (High Level Shading Language)\n\nMicrosoft's HLSL, primarily associated with DirectX, has been extended to support SPIR-V code generation. Recent versions of the Vulkan SDK include the DXC compiler by default, facilitating HLSL to SPIR-V compilation.\n\nTo use a non-default `dxc` binary, modify the `Vulkan_dxc_EXECUTABLE` path in the `Vulkan` CMake configuration.\n\n#### GLSL (Default)\n\nGLSL (OpenGL Shading Language) serves as the default shader language when neither Slang nor HLSL is explicitly enabled. It is natively supported by the Vulkan ecosystem.\n\nThis multi-language support strategy offers developers flexibility in shader authoring while maintaining compatibility with Vulkan's SPIR-V requirements.\n\n\n### Resources\n\n#### HLSL \n- HLSL to SPIR-V: [Feature Mapping Manual](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst)\n- Ray Tracing: [HLSL](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html)\n- Porting to HLSL:\n  - [GLSL variables](https://learn.microsoft.com/en-us/windows/uwp/gaming/glsl-to-hlsl-reference#porting-glsl-variables-to-hlsl)\n  - [GLSL types](https://learn.microsoft.com/en-us/windows/uwp/gaming/glsl-to-hlsl-reference#porting-glsl-types-to-hlsl)\n  - [Global Variables](https://learn.microsoft.com/en-us/windows/uwp/gaming/glsl-to-hlsl-reference#porting-glsl-pre-defined-global-variables-to-hlsl)\n  - [Mapping between HLSL and GLSL](https://anteru.net/blog/2016/mapping-between-HLSL-and-GLSL/)\n\n#### SLANG\n- [GitHub Repository](https://github.com/shader-slang/slang)\n- [Releases](https://github.com/shader-slang/slang/releases)\n- [Getting Started Guide](https://shader-slang.com/getting-started.html)\n- [User Guide](http://shader-slang.com/slang/user-guide/index.html)\n- [Documentation](https://github.com/shader-slang/slang/tree/master/docs)\n- [GLSL and SPIR-V Interoperability](https://shader-slang.com/slang/user-guide/a1-04-interop.html)\n- [Standard Library Reference](https://shader-slang.com/stdlib-reference/index.html)\n- [Language Specification](https://htmlpreview.github.io/?https://github.com/shader-slang/spec/blob/main/index.html#intro)\n\n#### SPIR-V Intrinsics\n- [GL_EXT_spirv_intrinsics](https://github.com/microsoft/DirectXShaderCompiler/wiki/GL_EXT_spirv_intrinsics-for-SPIR-V-code-gen)\n- [KHR Extensions](https://github.com/KhronosGroup/SPIRV-Registry/tree/main/extensions/KHR)\n- [JSON Specification](https://github.com/KhronosGroup/SPIRV-Headers/blob/main/include/spirv/unified1/spirv.json)\n- [SPIR-V Specification](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)\n\n\n## LICENSE\n\nCopyright 2024-2025 NVIDIA CORPORATION. Released under Apache License,\nVersion 2.0. See \"LICENSE\" file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvpro-samples%2Fvk_mini_samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnvpro-samples%2Fvk_mini_samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvpro-samples%2Fvk_mini_samples/lists"}