{"id":13728279,"url":"https://github.com/KhronosGroup/SPIRV-Reflect","last_synced_at":"2025-05-08T00:31:27.935Z","repository":{"id":40400991,"uuid":"101667566","full_name":"KhronosGroup/SPIRV-Reflect","owner":"KhronosGroup","description":"SPIRV-Reflect is a lightweight library that provides a C/C++ reflection API for SPIR-V shader bytecode in Vulkan applications.","archived":false,"fork":false,"pushed_at":"2025-05-05T21:39:35.000Z","size":1239,"stargazers_count":759,"open_issues_count":46,"forks_count":154,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-05-06T19:06:30.656Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/KhronosGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.adoc","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-28T17:12:19.000Z","updated_at":"2025-04-29T04:57:56.000Z","dependencies_parsed_at":"2023-02-17T03:45:27.936Z","dependency_job_id":"e77ccccc-3749-47ba-94e5-c5a422e5ca02","html_url":"https://github.com/KhronosGroup/SPIRV-Reflect","commit_stats":null,"previous_names":["chaoticbob/spirv-reflect"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhronosGroup%2FSPIRV-Reflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhronosGroup%2FSPIRV-Reflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhronosGroup%2FSPIRV-Reflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhronosGroup%2FSPIRV-Reflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KhronosGroup","download_url":"https://codeload.github.com/KhronosGroup/SPIRV-Reflect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252856565,"owners_count":21814858,"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":[],"created_at":"2024-08-03T02:00:39.733Z","updated_at":"2025-05-08T00:31:27.848Z","avatar_url":"https://github.com/KhronosGroup.png","language":"C","readme":"# SPIRV-Reflect\n\nSPIRV-Reflect is a lightweight library that provides a C/C++ reflection API for\n[SPIR-V](https://www.khronos.org/spir/) shader bytecode in\n[Vulkan](https://www.khronos.org/vulkan/) applications.\n\nSPIRV-Reflect has been tested on Linux and Windows.\n\n## NEWS\n\n- **2023-07-04** -  We have removed support for\n  [Bazel](https://bazel.build).\n- **2023-06-07** -  We are planning to remove support for\n  [Bazel](https://bazel.build/).  If you rely on Bazel for\n  building this code, please let us know in\n  https://github.com/KhronosGroup/SPIRV-Reflect/issues/188.\n- **2023-05-03** -  The `master` branch has been renamed to `main` (see\n  https://github.com/KhronosGroup/SPIRV-Reflect/issues/164 for\n  details).  Please update your fork as per instructions in that\n  issue.\n\n## Features\n\n- Extract descriptor bindings from SPIR-V bytecode, to assist in the generation of\n  Vulkan descriptor set and pipeline layouts.\n- Extract push constant block size from SPIR-V bytecode to assist in the generation\n  of pipeline layouts.\n- Extract full layout data for uniform buffer and push constant blocks from SPIR-V\n  bytecode, to assist in application updates of these structures.\n- Extract input/output variables from SPIR-V bytecode (including semantic decorations\n  for HLSL shaders), to assist in validation of pipeline input/output settings.\n- Remap descriptor bindings at runtime, and update the source SPIR-V bytecode\n  accordingly.\n- Log all reflection data as human-readable text.\n\n## Integration\n\nSPIRV-Reflect is designed to make integration as easy as possible. The only\nexternal dependency is the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home).\n\nTo integrate SPIRV-Reflect into a project, simply add `spirv_reflect.h` and\n`spirv_reflect.c` in the project's build, and include `spirv_reflect.h` from\nthe necessary source files.\n\nIf the project wants to use it's own SPIRV-Header path, it can set `SPIRV_REFLECT_USE_SYSTEM_SPIRV_H`\n\n```cmake\n# CMake example\ntarget_compile_definitions(project_name PUBLIC SPIRV_REFLECT_USE_SYSTEM_SPIRV_H)\n```\n\n## Building Samples\n\n**This step is only necessary when building/running SPIRV-Reflect's example applications.**\n\nSPIRV-Reflect includes a collection of sample programs in the `examples/` directory which\ndemonstrate various use cases:\n\n- **descriptors**: This sample demonstrates the retrieval of descriptor bindings, including\n  the population of `VkDescriptorSetLayoutCreateInfo` structures from reflection data.\n- **hlsl_resource_types**: This sample shows how various HLSL resource types are represented\n  in SPIR-V.\n- **io_variables**: This sample demonstrates the retrieval of input/output variables, including\n  the population of `VkPipelineVertexInputStateCreateInfo` structures from reflection data.\n\nTo build the included sample applications, use [CMake](https://cmake.org/) to generate the\nappropriate project files for your platform, then build them as usual.\n\nNote that you can set VulkanSDK directory as your preference. For example, on Linux:\n```\nVULKAN_SDK=$HOME/VulkanSDK/1.1.70.1/x86_64 cmake -G Ninja  ..\n```\n\n\n## Usage\n\nSPIRV-Reflect's core C API should be familiar to Vulkan developers:\n\n```c++\n#include \"spirv_reflect.h\"\n\nint SpirvReflectExample(const void* spirv_code, size_t spirv_nbytes)\n{\n  // Generate reflection data for a shader\n  SpvReflectShaderModule module;\n  SpvReflectResult result = spvReflectCreateShaderModule(spirv_nbytes, spirv_code, \u0026module);\n  assert(result == SPV_REFLECT_RESULT_SUCCESS);\n\n  // Enumerate and extract shader's input variables\n  uint32_t var_count = 0;\n  result = spvReflectEnumerateInputVariables(\u0026module, \u0026var_count, NULL);\n  assert(result == SPV_REFLECT_RESULT_SUCCESS);\n  SpvReflectInterfaceVariable** input_vars =\n    (SpvReflectInterfaceVariable**)malloc(var_count * sizeof(SpvReflectInterfaceVariable*));\n  result = spvReflectEnumerateInputVariables(\u0026module, \u0026var_count, input_vars);\n  assert(result == SPV_REFLECT_RESULT_SUCCESS);\n\n  // Output variables, descriptor bindings, descriptor sets, and push constants\n  // can be enumerated and extracted using a similar mechanism.\n\n  // Destroy the reflection data when no longer required.\n  spvReflectDestroyShaderModule(\u0026module);\n}\n```\n\nA C++ wrapper is also provided.\n\n## Building Examples\n\nBy adding `-DSPIRV_REFLECT_EXAMPLES=ON` in CMake you can see the use of the API used in action.\n\nThe `main_explorer.cpp` file is designed to allow an user to use their debugger of choice to breakpoint\nand explorer the contents of the `SpvReflectShaderModule` object. Just build with `-DCMAKE_BUILD_TYPE=Debug`\nand setup a debugger to run `./bin/explorer path/to/shader.spv`\n\n## Building Self-Test Suite\n\nSPIRV-Reflect uses [googletest](https://github.com/google/googletest) for self-testing.\nThis component is optional, and generally only of interest to developers modifying SPIRV-Reflect.\nTo run the self-tests:\n\n- `git submodule init`\n- `git submodule update`\n- Enable `SPIRV_REFLECT_BUILD_TESTS` in CMake\n- Build and run the `test-spirv-reflect` project.\n\n## License\n\nCopyright 2017-2018 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["Vulkan Tools, Libraries, and Frameworks","APIs"],"sub_categories":["VS Code Extensions for Developer Productivity","Enable Proton in Steam","Vulkan"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhronosGroup%2FSPIRV-Reflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKhronosGroup%2FSPIRV-Reflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhronosGroup%2FSPIRV-Reflect/lists"}