gfx-playground

cross platform rendering playground

branch out

Arjun Choudhary contact@arjunchoudhary.com

commit: 72fd352

213 files changed, 79888 insertions(+), 0 deletions(-)
ADD.clang-format+31-0
ADD.clang-tidy+33-0
ADD.clangd+2-0
ADD.gitattributes+20-0
ADD.gitignore+13-0
ADD.gitmodules+21-0
ADDCMakeLists.txt+266-0
ADDassets/fonts/Inter-Regular.otf+0-0
ADDassets/fonts/MonaspaceNeon-Regular.otf+0-0
ADDassets/gltf/DamagedHelmet.glb+0-0
ADDassets/gltf/Sponza-KTX.glb+0-0
ADDassets/kloofendal_overcast_puresky_4k.hdr+0-0
ADDassets/venetian_crossroads_4k.hdr+0-0
ADDbuild_linux.sh+261-0
ADDbuild_mac.sh+123-0
ADDbuild_win.bat+299-0
ADDreadme.md+41-0
ADDslang-format.py+185-0
ADDsrc/asset/asset.cpp+19-0
ADDsrc/asset/asset.h+139-0
ADDsrc/asset/gltf.cpp+579-0
ADDsrc/asset/texture.cpp+423-0
ADDsrc/asset/texture.h+62-0
ADDsrc/backend/conformance/descriptor_handle/descriptor_handle.cpp+283-0
ADDsrc/backend/conformance/indexed_quad/indexed_quad.cpp+219-0
ADDsrc/backend/conformance/ndc/ndc.cpp+155-0
ADDsrc/backend/conformance/scene/scene.cpp+330-0
ADDsrc/backend/conformance/triangle/triangle.cpp+181-0
ADDsrc/backend/imgui_backend.cpp+270-0
ADDsrc/backend/imgui_backend.h+22-0
ADDsrc/backend/metal/arguments_table.cpp+212-0
ADDsrc/backend/metal/buffer.cpp+106-0
ADDsrc/backend/metal/cmd.cpp+523-0
ADDsrc/backend/metal/device.cpp+119-0
ADDsrc/backend/metal/image.cpp+172-0
ADDsrc/backend/metal/metal_impl.cpp+13-0
ADDsrc/backend/metal/metal_platform.mm+42-0
ADDsrc/backend/metal/mt_api.h+369-0
ADDsrc/backend/metal/mt_internal.h+25-0
ADDsrc/backend/metal/pipeline.cpp+399-0
ADDsrc/backend/metal/sampler.cpp+84-0
ADDsrc/backend/metal/shader.cpp+253-0
ADDsrc/backend/metal/swapchain.cpp+153-0
ADDsrc/backend/rhi.h+12-0
ADDsrc/backend/rhi_api.h+184-0
ADDsrc/backend/rhi_types.h+705-0
ADDsrc/backend/vulkan/accel_struct.cpp+256-0
ADDsrc/backend/vulkan/allocator.cpp+58-0
ADDsrc/backend/vulkan/buffer.cpp+262-0
ADDsrc/backend/vulkan/cmd_buffer.cpp+585-0
ADDsrc/backend/vulkan/cmd_pool.cpp+35-0
ADDsrc/backend/vulkan/context.cpp+385-0
ADDsrc/backend/vulkan/debug.cpp+146-0
ADDsrc/backend/vulkan/debug.h+87-0
ADDsrc/backend/vulkan/descriptors.cpp+220-0
ADDsrc/backend/vulkan/image.cpp+177-0
ADDsrc/backend/vulkan/pipeline.cpp+350-0
ADDsrc/backend/vulkan/query_pool.cpp+96-0
ADDsrc/backend/vulkan/queue.cpp+163-0
ADDsrc/backend/vulkan/rhi_helpers.cpp+93-0
ADDsrc/backend/vulkan/sampler.cpp+59-0
ADDsrc/backend/vulkan/shader.cpp+181-0
ADDsrc/backend/vulkan/swapchain.cpp+346-0
ADDsrc/backend/vulkan/utils.h+52-0
ADDsrc/backend/vulkan/vk_api.h+322-0
ADDsrc/backend/vulkan/vk_conversion.cpp+649-0
ADDsrc/backend/vulkan/vk_conversion.h+56-0
ADDsrc/core/arena.cpp+52-0
ADDsrc/core/arena.h+32-0
ADDsrc/core/array.h+34-0
ADDsrc/core/frame_stats.h+44-0
ADDsrc/core/globals.h+89-0
ADDsrc/core/gpu_arena.h+49-0
ADDsrc/core/logger.cpp+67-0
ADDsrc/core/logger.h+46-0
ADDsrc/core/math_rtm.cpp+206-0
ADDsrc/core/math_rtm.h+538-0
ADDsrc/core/platform.cpp+338-0
ADDsrc/core/platform.h+67-0
ADDsrc/core/profile.h+12-0
ADDsrc/core/random.h+25-0
ADDsrc/editor/debug_draw.cpp+104-0
ADDsrc/editor/editor.cpp+314-0
ADDsrc/editor/editor.h+190-0
ADDsrc/editor/frame.cpp+133-0
ADDsrc/editor/gizmo.cpp+99-0
ADDsrc/editor/gizmo_common.h+291-0
ADDsrc/editor/hierarchy.cpp+103-0
ADDsrc/editor/inspector.cpp+243-0
ADDsrc/editor/log_viewer.cpp+226-0
ADDsrc/editor/style.cpp+112-0
ADDsrc/editor/targets.cpp+179-0
ADDsrc/editor/texture_viewer.cpp+718-0
ADDsrc/editor/timings.cpp+70-0
ADDsrc/editor/viewport.cpp+109-0
ADDsrc/passes/cluster/cluster_bounds.cpp+79-0
ADDsrc/passes/cluster/cluster_bounds.h+20-0
ADDsrc/passes/cluster/cluster_bounds.slang+86-0
ADDsrc/passes/cluster/light_cull.cpp+94-0
ADDsrc/passes/cluster/light_cull.h+24-0
ADDsrc/passes/cluster/light_cull.slang+85-0
ADDsrc/passes/ddgi/ddgi_classify.cpp+46-0
ADDsrc/passes/ddgi/ddgi_classify.h+13-0
ADDsrc/passes/ddgi/ddgi_classify.slang+46-0
ADDsrc/passes/ddgi/ddgi_probe.slang+117-0
ADDsrc/passes/ddgi/ddgi_probes_dbg.cpp+180-0
ADDsrc/passes/ddgi/ddgi_probes_dbg.h+24-0
ADDsrc/passes/ddgi/ddgi_relocate.cpp+45-0
ADDsrc/passes/ddgi/ddgi_relocate.h+12-0
ADDsrc/passes/ddgi/ddgi_relocate.slang+97-0
ADDsrc/passes/ddgi/ddgi_trace.cpp+195-0
ADDsrc/passes/ddgi/ddgi_trace.h+35-0
ADDsrc/passes/ddgi/ddgi_trace.slang+153-0
ADDsrc/passes/ddgi/ddgi_update.cpp+47-0
ADDsrc/passes/ddgi/ddgi_update.h+16-0
ADDsrc/passes/ddgi/ddgi_update.slang+161-0
ADDsrc/passes/ddgi/ddgi_update_distance.slang+4-0
ADDsrc/passes/ddgi/ddgi_update_irradiance.slang+4-0
ADDsrc/passes/debug/debug_draw.h+215-0
ADDsrc/passes/debug/debug_lines.cpp+183-0
ADDsrc/passes/debug/debug_lines.h+27-0
ADDsrc/passes/debug/debug_lines.slang+94-0
ADDsrc/passes/debug/debug_ray.h+66-0
ADDsrc/passes/debug/pass_frustum_debug.cpp+54-0
ADDsrc/passes/debug/pass_frustum_debug.h+20-0
ADDsrc/passes/depth_pre/depth_normal.cpp+113-0
ADDsrc/passes/depth_pre/depth_normal.h+23-0
ADDsrc/passes/depth_pre/depth_normal.slang+63-0
ADDsrc/passes/dispatch_mdi/build_indirect.cpp+120-0
ADDsrc/passes/dispatch_mdi/build_indirect.h+30-0
ADDsrc/passes/dispatch_mdi/build_indirect.slang+101-0
ADDsrc/passes/fg.cpp+935-0
ADDsrc/passes/fg.h+354-0
ADDsrc/passes/fg_utils.h+137-0
ADDsrc/passes/forward/forward.cpp+170-0
ADDsrc/passes/forward/forward.h+37-0
ADDsrc/passes/forward/forward.slang+153-0
ADDsrc/passes/fullscreen/fullscreen.cpp+101-0
ADDsrc/passes/fullscreen/fullscreen.h+27-0
ADDsrc/passes/fullscreen/fullscreen.slang+73-0
ADDsrc/passes/fwd_cpu/fwd_cpu.cpp+89-0
ADDsrc/passes/fwd_cpu/fwd_cpu.h+17-0
ADDsrc/passes/fwd_cpu/fwd_cpu.slang+44-0
ADDsrc/passes/grid/grid.cpp+102-0
ADDsrc/passes/grid/grid.h+19-0
ADDsrc/passes/grid/grid.slang+112-0
ADDsrc/passes/hiz/hiz.cpp+122-0
ADDsrc/passes/hiz/hiz.h+30-0
ADDsrc/passes/hiz/hiz_downsample.slang+53-0
ADDsrc/passes/id_blit/id_blit.cpp+99-0
ADDsrc/passes/id_blit/id_blit.h+22-0
ADDsrc/passes/id_blit/id_blit.slang+36-0
ADDsrc/passes/imgui/imgui.cpp+27-0
ADDsrc/passes/imgui/imgui.h+17-0
ADDsrc/passes/imgui/imgui.slang+35-0
ADDsrc/passes/rt_build.cpp+123-0
ADDsrc/passes/rt_build.h+9-0
ADDsrc/passes/shadow/shadow.cpp+142-0
ADDsrc/passes/shadow/shadow.h+27-0
ADDsrc/passes/shadow/shadow.slang+33-0
ADDsrc/passes/skybox/skybox.cpp+78-0
ADDsrc/passes/skybox/skybox.h+20-0
ADDsrc/passes/skybox/skybox.slang+43-0
ADDsrc/passes/ssr/ssr.cpp+82-0
ADDsrc/passes/ssr/ssr.h+27-0
ADDsrc/passes/ssr/ssr.slang+90-0
ADDsrc/pipelines.cpp+109-0
ADDsrc/pipelines.h+39-0
ADDsrc/quick_submit.cpp+156-0
ADDsrc/quick_submit.h+47-0
ADDsrc/renderer.cpp+1470-0
ADDsrc/renderer.h+97-0
ADDsrc/scene/camera.h+94-0
ADDsrc/scene/ibl.cpp+450-0
ADDsrc/scene/ibl.h+38-0
ADDsrc/scene/light.h+243-0
ADDsrc/scene/scene.cpp+523-0
ADDsrc/scene/scene.h+90-0
ADDsrc/shaders/conformance/descriptor_handle.slang+45-0
ADDsrc/shaders/conformance/indexed_quad.slang+38-0
ADDsrc/shaders/conformance/ndc.slang+26-0
ADDsrc/shaders/conformance/scene.slang+42-0
ADDsrc/shaders/conformance/triangle.slang+26-0
ADDsrc/shaders/debug/debug_views.slang+178-0
ADDsrc/shaders/debug/frustum_debug.slang+148-0
ADDsrc/shaders/ibl/brdf_lut.slang+25-0
ADDsrc/shaders/ibl/cubemap.slang+30-0
ADDsrc/shaders/ibl/equirect_to_cube.slang+36-0
ADDsrc/shaders/ibl/ibl_lighting.slang+34-0
ADDsrc/shaders/ibl/irradiance_convolution.slang+50-0
ADDsrc/shaders/ibl/prefilter_env.slang+80-0
ADDsrc/shaders/lib/brdf.slang+111-0
ADDsrc/shaders/lib/cluster_lighting.slang+95-0
ADDsrc/shaders/lib/ddgi_common.slang+213-0
ADDsrc/shaders/lib/frustum_culling.slang+156-0
ADDsrc/shaders/lib/octahedral.slang+18-0
ADDsrc/shaders/lib/shadow_sample.slang+125-0
ADDsrc/shaders/renderer_types.h+566-0
ADDsrc/shaders/shared.h+86-0
ADDthird-party/KTX-Software+1-0
ADDthird-party/VMA+1-0
ADDthird-party/cgltf.h+7240-0
ADDthird-party/glfw+1-0
ADDthird-party/imgui+1-0
ADDthird-party/json.hpp+26753-0
ADDthird-party/metal-cpp+1-0
ADDthird-party/mikktspace.c+1899-0
ADDthird-party/mikktspace.h+145-0
ADDthird-party/plog+1-0
ADDthird-party/rtm+1-0
ADDthird-party/stb_image.h+7989-0
ADDthird-party/volk.c+4285-0
ADDthird-party/volk.h+3493-0
ADD · .clang-format +31 -0
--- a/.clang-format
+++ b/.clang-format
@@ -0,0 +1,31 @@
+BasedOnStyle: LLVM
+
+ColumnLimit: 120
+IndentWidth: 4
+
+PointerAlignment: Right
+ReferenceAlignment: Right
+
+BinPackArguments: false
+BinPackParameters: false
+AlignAfterOpenBracket: BlockIndent
+
+BreakBeforeBraces: Attach
+BreakAfterReturnType: ExceptShortType
+AlwaysBreakAfterDefinitionReturnType: None
+
+AllowShortNamespacesOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseExpressionOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+AllowShortEnumsOnASingleLine: false
+
+AlignConsecutiveMacros: true
+
+Macros:
+  - GPU_PTR(x)=x
+  - GPU_HND(x)=x
+  - STATIC_CONST(x)=x
ADD · .clang-tidy +33 -0
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -0,0 +1,33 @@
+Checks: >
+  -*,
+  readability-braces-around-statements,
+  google-runtime-int,
+  readability-identifier-naming,
+  readability-simplify-boolean-expr,
+  readability-else-after-return,
+  readability-avoid-nested-conditional-operator,
+  bugprone-sizeof-expression,
+  bugprone-unused-raii,
+  performance-no-int-to-ptr,
+  cert-err33-c,
+  clang-analyzer-core,
+  clang-analyzer-security,
+  -clang-analyzer-security.insecureAPI.strcpy,
+  -clang-analyzer-security.insecureAPI.gets
+
+CheckOptions:
+  - { key: "google-runtime-int.UnsignedTypePrefix", value: "u" }
+  - { key: "google-runtime-int.SignedTypePrefix", value: "i" }
+  - { key: "readability-identifier-naming.VariableCase", value: "lower_case" }
+  - { key: "readability-identifier-naming.FunctionCase", value: "lower_case" }
+  - {
+      key: "readability-identifier-naming.GlobalVariableCase",
+      value: "UPPER_CASE",
+    }
+  - { key: "readability-identifier-naming.MacroCase", value: "UPPER_CASE" }
+  - { key: "readability-identifier-naming.EnumCase", value: "CamelCase" }
+  - { key: "readability-identifier-naming.StructCase", value: "CamelCase" }
+  - { key: "readability-identifier-naming.TypedefCase", value: "lower_case" }
+
+WarningsAsErrors: "*"
+HeaderFilterRegex: ".*/src/.*"
ADD · .clangd +2 -0
--- a/.clangd
+++ b/.clangd
@@ -0,0 +1,2 @@
+CompileFlags:
+  CompilationDatabase: build
ADD · .gitattributes +20 -0
--- a/.gitattributes
+++ b/.gitattributes
@@ -0,0 +1,20 @@
+* text eol=lf
+*.bat text eol=crlf
+*.ps1 text eol=crlf
+*.sh text=auto eol=lf
+*.md text eol=lf
+
+*.glb binary
+*.gltf text
+*.bin binary
+*.ttf binary
+*.otf binary
+*.woff binary
+*.woff2 binary
+*.eot binary
+*.png  binary
+*.jpg  binary
+*.jpeg binary
+*.gif  binary
+*.webp binary
+*.ico  binary
ADD · .gitignore +13 -0
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,13 @@
+notes/
+.cache/
+.vscode/
+.DS_Store
+.idea/
+*.log
+*.tmp
+build/
+cmake/
+compile_commands.json
+third-party/*/
+assets/
+imgui.ini<
\ No newline at end of file
ADD · .gitmodules +21 -0
--- a/.gitmodules
+++ b/.gitmodules
@@ -0,0 +1,21 @@
+[submodule "third-party/glfw"]
+	path = third-party/glfw
+	url = https://github.com/glfw/glfw.git
+[submodule "third-party/VMA"]
+	path = third-party/VMA
+	url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
+[submodule "third-party/rtm"]
+	path = third-party/rtm
+	url = https://github.com/nfrechette/rtm.git
+[submodule "third-party/imgui"]
+	path = third-party/imgui
+	url = https://github.com/ocornut/imgui.git
+[submodule "third-party/KTX-Software"]
+	path = third-party/KTX-Software
+	url = https://github.com/KhronosGroup/KTX-Software.git
+[submodule "third-party/plog"]
+	path = third-party/plog
+	url = https://github.com/SergiusTheBest/plog
+[submodule "third-party/metal-cpp"]
+	path = third-party/metal-cpp
+	url = https://github.com/apple/metal-cpp
ADD · CMakeLists.txt +266 -0
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -0,0 +1,266 @@
+cmake_minimum_required(VERSION 3.31.0)
+project(vk-renderer)
+
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
+
+find_package(Vulkan REQUIRED)
+
+# glfw
+set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
+set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
+add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/glfw)
+
+# VMA
+add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/VMA)
+
+# KTX
+set(KTX_FEATURE_TESTS OFF CACHE BOOL "" FORCE)
+set(KTX_FEATURE_TOOLS OFF CACHE BOOL "" FORCE)
+set(KTX_FEATURE_DOC OFF CACHE BOOL "" FORCE)
+set(KTX_FEATURE_GL_UPLOAD OFF CACHE BOOL "" FORCE)
+set(KTX_FEATURE_VK_UPLOAD OFF CACHE BOOL "" FORCE)
+set(KTX_FEATURE_LOADTEST_APPS OFF CACHE BOOL "" FORCE)
+add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/KTX-Software)
+
+# plog
+add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/plog)
+
+# rtm (header-only math library)
+add_library(rtm INTERFACE)
+target_include_directories(rtm INTERFACE ${CMAKE_SOURCE_DIR}/third-party/rtm/includes)
+
+# tracy
+set(ENABLE_TRACY OFF)
+if(ENABLE_TRACY)
+    add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/tracy)
+    add_compile_definitions(TRACY_ENABLE)
+endif()
+
+set(ENABLE_EDITOR ON)
+if(ENABLE_EDITOR)
+    add_compile_definitions(ENABLE_EDITOR)
+endif()
+
+# slang
+include(FetchContent)
+set(SLANG_VERSION "2026.17.1")
+
+
+if(WIN32)
+    set(SLANG_URL "https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-windows-x86_64.zip")
+elseif(APPLE)
+    set(SLANG_URL "https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-macos-aarch64.tar.gz")
+else()
+    set(SLANG_URL "https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz")
+endif()
+FetchContent_Declare(slang URL ${SLANG_URL})
+FetchContent_MakeAvailable(slang)
+set(SLANG_ROOT ${slang_SOURCE_DIR})
+if(WIN32)
+    set(SLANG_LIB ${SLANG_ROOT}/lib/slang.lib)
+elseif(APPLE)
+    set(SLANG_LIB ${SLANG_ROOT}/lib/libslang.dylib)
+else()
+    set(SLANG_LIB ${SLANG_ROOT}/lib/libslang.so)
+endif()
+
+set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/third-party/imgui)
+
+add_executable(${PROJECT_NAME}
+    src/renderer.cpp
+    src/quick_submit.cpp
+    src/pipelines.cpp
+    src/passes/fg.cpp
+    #
+    src/asset/asset.cpp
+    src/asset/texture.cpp
+    src/asset/gltf.cpp
+    #
+    third-party/mikktspace.c
+    #
+    src/scene/scene.cpp
+    src/scene/ibl.cpp
+    #
+    src/backend/vulkan/context.cpp
+    src/backend/vulkan/swapchain.cpp
+    src/backend/vulkan/pipeline.cpp
+    src/backend/vulkan/descriptors.cpp
+    src/backend/vulkan/debug.cpp
+    src/backend/vulkan/query_pool.cpp
+    src/backend/vulkan/cmd_pool.cpp
+    src/backend/vulkan/cmd_buffer.cpp
+    src/backend/vulkan/allocator.cpp
+    src/backend/vulkan/queue.cpp
+    src/backend/vulkan/buffer.cpp
+    src/backend/vulkan/image.cpp
+    src/backend/vulkan/sampler.cpp
+    src/backend/vulkan/shader.cpp
+    src/backend/vulkan/accel_struct.cpp
+    src/backend/vulkan/vk_conversion.cpp
+    src/backend/vulkan/rhi_helpers.cpp
+    #
+    src/core/arena.cpp
+    src/core/platform.cpp
+    src/core/math_rtm.cpp
+    src/core/logger.cpp
+    #
+    src/passes/ssr/ssr.cpp
+    # src/passes/pass_frustum_debug.cpp
+    src/passes/depth_pre/depth_normal.cpp
+    src/passes/dispatch_mdi/build_indirect.cpp
+    src/passes/forward/forward.cpp
+    src/passes/fwd_cpu/fwd_cpu.cpp
+    src/passes/shadow/shadow.cpp
+    src/passes/grid/grid.cpp
+    src/passes/id_blit/id_blit.cpp
+    src/passes/fullscreen/fullscreen.cpp
+    src/passes/cluster/cluster_bounds.cpp
+    src/passes/cluster/light_cull.cpp
+    src/passes/hiz/hiz.cpp
+    src/passes/imgui/imgui.cpp
+    src/passes/skybox/skybox.cpp
+    src/passes/rt_build.cpp
+    src/passes/ddgi/ddgi_trace.cpp
+    src/passes/ddgi/ddgi_update.cpp
+    src/passes/ddgi/ddgi_classify.cpp
+    src/passes/ddgi/ddgi_relocate.cpp
+    src/passes/ddgi/ddgi_probes_dbg.cpp
+    src/passes/debug/debug_lines.cpp
+)
+
+if(ENABLE_EDITOR)
+    target_sources(${PROJECT_NAME} PRIVATE
+        src/editor/editor.cpp
+        src/editor/debug_draw.cpp
+        src/editor/frame.cpp
+        src/editor/gizmo.cpp
+        src/editor/style.cpp
+        src/editor/viewport.cpp
+        src/editor/log_viewer.cpp
+        src/editor/texture_viewer.cpp
+        src/editor/targets.cpp
+        src/editor/timings.cpp
+        src/editor/hierarchy.cpp
+        src/editor/inspector.cpp
+        src/backend/imgui_backend.cpp
+        ${IMGUI_DIR}/imgui.cpp
+        ${IMGUI_DIR}/imgui_draw.cpp
+        ${IMGUI_DIR}/imgui_tables.cpp
+        ${IMGUI_DIR}/imgui_widgets.cpp
+        ${IMGUI_DIR}/imgui_demo.cpp
+        ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
+    )
+endif()
+
+# file(GLOB_RECURSE THIRD_PARTY_SOURCES
+#     "${CMAKE_SOURCE_DIR}/third-party/*.c"
+#     "${CMAKE_SOURCE_DIR}/third-party/*.cc"
+#     "${CMAKE_SOURCE_DIR}/third-party/*.cpp"
+#     "${CMAKE_SOURCE_DIR}/third-party/*.cxx"
+# )
+
+# file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/src" CLANG_TIDY_SRC_DIR)
+
+# set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "clang-tidy;--header-filter=${CLANG_TIDY_SRC_DIR}/.*")
+
+# set_source_files_properties(
+#     ${THIRD_PARTY_SOURCES}
+#     PROPERTIES SKIP_LINTING ON
+# )
+
+target_link_libraries(${PROJECT_NAME} PRIVATE
+    Vulkan::Vulkan
+    glfw
+    VulkanMemoryAllocator
+    plog::plog
+    ktx
+    rtm
+    ${SLANG_LIB}
+)
+
+if(WIN32)
+target_link_libraries(${PROJECT_NAME} PRIVATE
+    dwmapi
+)
+endif()
+
+if(ENABLE_TRACY)
+    target_link_libraries(${PROJECT_NAME} PRIVATE TracyClient)
+endif()
+
+target_include_directories(${PROJECT_NAME} PRIVATE
+    ${SLANG_ROOT}/include
+    ${IMGUI_DIR}
+    ${IMGUI_DIR}/backends
+    ${CMAKE_SOURCE_DIR}/src
+    ${CMAKE_SOURCE_DIR}/third-party
+)
+
+target_compile_definitions(${PROJECT_NAME} PRIVATE VK_NO_PROTOTYPES IMGUI_IMPL_VULKAN_USE_VOLK)
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
+if(ipo_supported)
+    message(STATUS "IPO/LTO is supported. Enabling it for Release builds.")
+    set_target_properties(${PROJECT_NAME} PROPERTIES
+        INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
+        INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE
+    )
+else()
+    message(STATUS "IPO/LTO is not supported: ${ipo_output}")
+endif()
+
+if(MSVC)
+    target_compile_options(${PROJECT_NAME} PRIVATE
+        $<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:
+            /O2
+            /Ot
+            /fp:fast
+            /arch:AVX2
+            /GL
+        >
+    )
+    set_property(TARGET ${PROJECT_NAME} PROPERTY
+        LINK_FLAGS_RELEASE "/LTCG"
+    )
+    set_property(TARGET ${PROJECT_NAME} PROPERTY
+        LINK_FLAGS_RELWITHDEBINFO "/LTCG"
+    )
+else()
+    target_compile_options(${PROJECT_NAME} PRIVATE
+        $<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:
+            -O3
+            -march=native
+            -flto
+        >
+    )
+endif()
+
+add_compile_definitions(
+    FMT_USE_CONSTEXPR=0
+    FMT_ENFORCE_COMPILE_STRING=0
+)
+
+if(WIN32)
+    target_compile_definitions(${PROJECT_NAME} PRIVATE
+        _CRT_SECURE_NO_WARNINGS
+    )
+endif()
+
+if(WIN32 OR UNIX)
+    target_compile_definitions(${PROJECT_NAME} PRIVATE
+        RHI_BACKEND_VULKAN
+    )
+elseif(APPLE)
+    target_compile_definitions(${PROJECT_NAME} PRIVATE
+        RHI_BACKEND_METAL
+    )
+
+endif()
ADD · assets/fonts/Inter-Regular.otf +0 -0
--- a/assets/fonts/Inter-Regular.otf
+++ b/assets/fonts/Inter-Regular.otf
ADD · assets/fonts/MonaspaceNeon-Regular.otf +0 -0
--- a/assets/fonts/MonaspaceNeon-Regular.otf
+++ b/assets/fonts/MonaspaceNeon-Regular.otf
ADD · assets/gltf/DamagedHelmet.glb +0 -0
--- a/assets/gltf/DamagedHelmet.glb
+++ b/assets/gltf/DamagedHelmet.glb
ADD · assets/gltf/Sponza-KTX.glb +0 -0
--- a/assets/gltf/Sponza-KTX.glb
+++ b/assets/gltf/Sponza-KTX.glb
ADD · assets/kloofendal_overcast_puresky_4k.hdr +0 -0
--- a/assets/kloofendal_overcast_puresky_4k.hdr
+++ b/assets/kloofendal_overcast_puresky_4k.hdr
ADD · assets/venetian_crossroads_4k.hdr +0 -0
--- a/assets/venetian_crossroads_4k.hdr
+++ b/assets/venetian_crossroads_4k.hdr
ADD · build_linux.sh +261 -0
--- a/build_linux.sh
+++ b/build_linux.sh
@@ -0,0 +1,261 @@
+#!/usr/bin/env bash
+# Vulkan build for vk-renderer + RHI examples (Linux).
+# Usage: build_linux.sh [example] [-r] [-c]
+#   example  Name under src/backend/conformance/ (e.g. triangle). Builds
+#            src/backend/conformance/<example> with core + backend only.
+#            Default (no example): full renderer build.
+#   -r       Release build (default is Debug)
+#   -c       Clean build (delete everything first)
+# All build artifacts and output live under build/.
+# The binary must run from the repo root (shader paths are repo-relative).
+set -e
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
+build_type=debug
+clean_build=0
+example=""
+for arg in "$@"; do
+    case "$arg" in
+        -r|release) build_type=release ;;
+        -c)         clean_build=1 ;;
+        *)          example="$arg" ;;
+    esac
+done
+if [ -n "$example" ]; then
+    echo "[$build_type vulkan build: $example]"
+else
+    echo "[$build_type build]"
+fi
+
+ROOT="$SCRIPT_DIR"
+BUILD="$ROOT/build"
+OBJ="$BUILD/obj"
+DEPS="$ROOT/build/_deps"
+SLANG_DIR="$DEPS/slang-src"
+
+# --- Example mode (positional arg): build src/backend/conformance/<example>
+# --- with core + backend only, instead of the full renderer ------------------
+EXAMPLES="$ROOT/src/backend/conformance"
+if [ -n "$example" ]; then
+    EXAMPLE_SRC="$EXAMPLES/$example/$example.cpp"
+    if [ ! -f "$EXAMPLE_SRC" ]; then
+        echo "[error: no such example: $example (expected $EXAMPLE_SRC)]" >&2
+        exit 1
+    fi
+    OBJ="$ROOT/build/obj-ex-$example"
+fi
+
+# --- Vulkan SDK ----------------------------------------------------------
+VULKAN_CFLAGS=""
+VULKAN_LDFLAGS="-lvulkan"
+if command -v pkg-config >/dev/null 2>&1; then
+    if pkg-config --exists vulkan; then
+        VULKAN_CFLAGS="$(pkg-config --cflags vulkan)"
+        VULKAN_LDFLAGS="$(pkg-config --libs vulkan)"
+        echo "[vulkan] using pkg-config"
+    fi
+fi
+if [ -n "$VULKAN_SDK" ]; then
+    echo "[vulkan] VULKAN_SDK detected, overriding system paths"
+    VULKAN_CFLAGS="-I$VULKAN_SDK/include"
+    VULKAN_LDFLAGS="-L$VULKAN_SDK/lib -lvulkan"
+fi
+
+# --- Download Slang (binary SDK, shared across targets) ----------------------
+if [ ! -f "$SLANG_DIR/include/slang.h" ]; then
+    echo "[downloading slang]"
+    mkdir -p "$SLANG_DIR"
+    SLANG_URL="https://github.com/shader-slang/slang/releases/download/v2026.17.1/slang-2026.17.1-linux-x86_64.tar.gz"
+    curl -sL "$SLANG_URL" -o "$DEPS/slang.tar.gz"
+    tar -xzf "$DEPS/slang.tar.gz" -C "$SLANG_DIR" --strip-components=1
+    rm "$DEPS/slang.tar.gz"
+else
+    echo "[slang already downloaded]"
+fi
+SLANG_INCLUDE="-I$SLANG_DIR/include"
+SLANG_LIB="$SLANG_DIR/lib/libslang.so"
+
+# --- Clean -------------------------------------------------------------------
+if [ "$clean_build" = "1" ]; then
+    if [ -n "$example" ]; then
+        echo "[cleaning example build: $example]"
+        rm -rf "$OBJ"
+    else
+        echo "[cleaning build]"
+        rm -rf "$BUILD"
+    fi
+fi
+mkdir -p "$OBJ" "$DEPS"
+
+# --- glfw (static, shared across targets) ------------------------------------
+if [ ! -f "$DEPS/libglfw3.a" ]; then
+    echo "[building glfw]"
+    mkdir -p "$DEPS/glfw"
+    cmake -G Ninja -S "$ROOT/third-party/glfw" -B "$DEPS/glfw" \
+        -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_EXAMPLES=OFF \
+        -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release >/dev/null 2>&1 || exit 1
+    cmake --build "$DEPS/glfw" >/dev/null 2>&1 || exit 1
+    cp "$DEPS/glfw/src/libglfw3.a" "$DEPS/libglfw3.a"
+else
+    echo "[glfw already built]"
+fi
+
+# --- KTX-Software (examples don't link it: skip) -----------------------------
+if [ -z "$example" ]; then
+if [ ! -f "$BUILD/libktx.a" ]; then
+    echo "[building ktx]"
+    mkdir -p "$DEPS/ktx"
+    cmake -G Ninja -S "$ROOT/third-party/KTX-Software" -B "$DEPS/ktx" \
+        -DKTX_FEATURE_TESTS=OFF -DKTX_FEATURE_TOOLS=OFF -DKTX_FEATURE_DOC=OFF \
+        -DKTX_FEATURE_GL_UPLOAD=OFF -DKTX_FEATURE_VK_UPLOAD=OFF \
+        -DKTX_FEATURE_LOADTEST_APPS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo >/dev/null 2>&1 || exit 1
+    cmake --build "$DEPS/ktx" >/dev/null 2>&1 || exit 1
+    cp "$DEPS/ktx/lib/libktx.a"      "$BUILD/libktx.a"
+    cp "$DEPS/ktx/lib/libktx_read.a" "$BUILD/libktx_read.a"
+else
+    echo "[ktx already built]"
+fi
+fi
+
+# --- Compile flags -------------------------------------------------------
+#CXX="clang++"
+CXX="g++"
+CXX_COMMON="-std=c++20 -fno-rtti -D_USE_MATH_DEFINES -DVK_NO_PROTOTYPES -DRHI_BACKEND_VULKAN -DENABLE_EDITOR -DFMT_USE_CONSTEXPR=0 -DFMT_ENFORCE_COMPILE_STRING=0"
+CXX_INCLUDES="-I$ROOT/src -I$ROOT/third-party -I$ROOT/third-party/glfw/include -I$ROOT/third-party/VMA/include -I$ROOT/third-party/plog/include -I$ROOT/third-party/imgui -I$ROOT/third-party/imgui/backends -I$ROOT/third-party/rtm/includes -I$ROOT/third-party/KTX-Software/include $SLANG_INCLUDE $VULKAN_CFLAGS"
+if [ "$build_type" = "debug" ]; then
+    CXX_FLAGS="-g -O0 -D_DEBUG -DIMGUI_IMPL_VULKAN_USE_VOLK $CXX_COMMON $CXX_INCLUDES"
+else
+    CXX_FLAGS="-g -O2 -DNDEBUG -DIMGUI_IMPL_VULKAN_USE_VOLK $CXX_COMMON $CXX_INCLUDES"
+fi
+
+LD_FLAGS="$VULKAN_LDFLAGS -lX11 -lXrandr -lXinerama -lXcursor -lXi -lpthread -ldl"
+
+# --- Source files (matches CMakeLists.txt; VOLK_IMPLEMENTATION lives in
+# --- renderer.cpp / the example .cpp, so third-party/volk.c is intentionally
+# --- NOT compiled) -----------------------------------------------------------
+SRC="$ROOT/src"
+TP="$ROOT/third-party"
+
+CORE_SRC="\
+    $SRC/core/arena.cpp                  \
+    $SRC/core/platform.cpp               \
+    $SRC/core/math_rtm.cpp               \
+    $SRC/core/logger.cpp"
+
+BACKEND_SRC="\
+    $SRC/backend/vulkan/context.cpp      \
+    $SRC/backend/vulkan/swapchain.cpp    \
+    $SRC/backend/vulkan/pipeline.cpp     \
+    $SRC/backend/vulkan/descriptors.cpp  \
+    $SRC/backend/vulkan/debug.cpp        \
+    $SRC/backend/vulkan/query_pool.cpp   \
+    $SRC/backend/vulkan/cmd_pool.cpp     \
+    $SRC/backend/vulkan/cmd_buffer.cpp   \
+    $SRC/backend/vulkan/allocator.cpp    \
+    $SRC/backend/vulkan/queue.cpp        \
+    $SRC/backend/vulkan/buffer.cpp       \
+    $SRC/backend/vulkan/image.cpp        \
+    $SRC/backend/vulkan/sampler.cpp      \
+    $SRC/backend/vulkan/shader.cpp       \
+    $SRC/backend/vulkan/accel_struct.cpp \
+    $SRC/backend/vulkan/vk_conversion.cpp \
+    $SRC/backend/vulkan/rhi_helpers.cpp"
+
+RENDERER_SRC="\
+    $SRC/renderer.cpp                              \
+    $SRC/quick_submit.cpp                          \
+    $SRC/pipelines.cpp                             \
+    $SRC/passes/fg.cpp                             \
+    $SRC/asset/asset.cpp                           \
+    $SRC/asset/texture.cpp                         \
+    $SRC/asset/gltf.cpp                            \
+    $TP/mikktspace.c                               \
+    $SRC/scene/scene.cpp                           \
+    $SRC/scene/ibl.cpp                             \
+    $SRC/passes/ssr/ssr.cpp                        \
+    $SRC/passes/depth_pre/depth_normal.cpp         \
+    $SRC/passes/dispatch_mdi/build_indirect.cpp    \
+    $SRC/passes/forward/forward.cpp                \
+    $SRC/passes/fwd_cpu/fwd_cpu.cpp                \
+    $SRC/passes/shadow/shadow.cpp                  \
+    $SRC/passes/grid/grid.cpp                      \
+    $SRC/passes/id_blit/id_blit.cpp                \
+    $SRC/passes/fullscreen/fullscreen.cpp          \
+    $SRC/passes/cluster/cluster_bounds.cpp         \
+    $SRC/passes/cluster/light_cull.cpp             \
+    $SRC/passes/hiz/hiz.cpp                        \
+    $SRC/passes/imgui/imgui.cpp                    \
+    $SRC/passes/skybox/skybox.cpp                  \
+    $SRC/passes/rt_build.cpp                       \
+    $SRC/passes/ddgi/ddgi_trace.cpp                \
+    $SRC/passes/ddgi/ddgi_update.cpp               \
+    $SRC/passes/ddgi/ddgi_classify.cpp             \
+    $SRC/passes/ddgi/ddgi_relocate.cpp             \
+    $SRC/passes/ddgi/ddgi_probes_dbg.cpp           \
+    $SRC/passes/debug/debug_lines.cpp              \
+    $SRC/editor/editor.cpp                         \
+    $SRC/editor/debug_draw.cpp                     \
+    $SRC/editor/frame.cpp                          \
+    $SRC/editor/gizmo.cpp                          \
+    $SRC/editor/style.cpp                          \
+    $SRC/editor/viewport.cpp                       \
+    $SRC/editor/log_viewer.cpp                     \
+    $SRC/editor/texture_viewer.cpp                 \
+    $SRC/editor/targets.cpp                        \
+    $SRC/editor/timings.cpp                        \
+    $SRC/editor/hierarchy.cpp                      \
+    $SRC/editor/inspector.cpp                      \
+    $SRC/backend/imgui_backend.cpp                 \
+    $TP/imgui/imgui.cpp                            \
+    $TP/imgui/imgui_draw.cpp                       \
+    $TP/imgui/imgui_tables.cpp                     \
+    $TP/imgui/imgui_widgets.cpp                    \
+    $TP/imgui/imgui_demo.cpp                       \
+    $TP/imgui/backends/imgui_impl_glfw.cpp"
+
+# --- Compile -------------------------------------------------------------
+echo "[compiling]"
+if [ -n "$example" ]; then
+    for src in $EXAMPLE_SRC $CORE_SRC $BACKEND_SRC; do
+        objname=$(basename "$src" | sed 's/\.cpp$/.o/')
+        $CXX -c $CXX_FLAGS "$src" -o "$OBJ/$objname"
+    done
+else
+    for src in $CORE_SRC $BACKEND_SRC $RENDERER_SRC; do
+        objname=$(basename "$src" | sed 's/\.cpp$/.o/;s/\.c$/.o/')
+        $CXX -c $CXX_FLAGS "$src" -o "$OBJ/$objname"
+    done
+    # imgui.o collision: src/passes/imgui/imgui.cpp and third-party/imgui/imgui.cpp
+    # both emit imgui.o in this flat dir: rebuild with distinct names.
+    $CXX -c $CXX_FLAGS "$SRC/passes/imgui/imgui.cpp" -o "$OBJ/imgui_pass.o"
+    $CXX -c $CXX_FLAGS "$TP/imgui/imgui.cpp" -o "$OBJ/imgui_lib.o"
+    rm -f "$OBJ/imgui.o"
+    # stale objs from renamed/removed sources (link uses *.o wildcard)
+    rm -f "$OBJ/descriptor_pool.o" "$OBJ/descriptor_set.o" "$OBJ/gpu_resource.o" \
+        "$OBJ/cmd_buffers.o" "$OBJ/submission_queue.o" "$OBJ/render_target.o" \
+        "$OBJ/renderpass_io.o" "$OBJ/imgui_impl_vulkan.o" \
+        "$OBJ"/ui_*.o "$OBJ"/pass_*.o
+fi
+
+# --- Link -------------------------------------------------------------------
+echo "[linking]"
+if [ -n "$example" ]; then
+    OUT="$BUILD/vk-$example"
+    $CXX "$OBJ"/*.o \
+        "$DEPS/libglfw3.a" \
+        "$SLANG_LIB" \
+        $LD_FLAGS \
+        -o "$OUT"
+else
+    OUT="$BUILD/vk-renderer"
+    $CXX "$OBJ"/*.o \
+        "$BUILD/libglfw3.a" "$BUILD/libktx.a" "$BUILD/libktx_read.a" \
+        "$SLANG_LIB" \
+        $LD_FLAGS \
+        -o "$OUT"
+fi
+
+echo "[done: $OUT]"
+if [ -n "$example" ]; then
+    echo "[run from the repo root: $OUT]"
+fi
ADD · build_mac.sh +123 -0
--- a/build_mac.sh
+++ b/build_mac.sh
@@ -0,0 +1,123 @@
+#!/usr/bin/env bash
+# Metal build for the RHI examples (macOS only; main renderer not supported yet).
+# Usage: build_mac.sh [example] [-r] [-c]
+#   example  Name under src/backend/conformance/ (default: triangle).
+#            Must contain <example>/<example>.cpp.
+#   -r       Release build (default is Debug)
+#   -c       Clean build (delete the example objects first)
+# All build artifacts and output live under build/.
+# The binary must run from the repo root (shader paths are repo-relative).
+set -e
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
+build_type=debug
+clean_build=0
+example="triangle"
+for arg in "$@"; do
+    case "$arg" in
+        -r|release) build_type=release ;;
+        -c)         clean_build=1 ;;
+        *)          example="$arg" ;;
+    esac
+done
+echo "[$build_type metal build: $example]"
+
+ROOT="$SCRIPT_DIR"
+EXAMPLES="$ROOT/src/backend/conformance"
+EXAMPLE_SRC="$EXAMPLES/$example/$example.cpp"
+if [ ! -f "$EXAMPLE_SRC" ]; then
+    echo "[error: no such example: $example (expected $EXAMPLE_SRC)]" >&2
+    exit 1
+fi
+
+BUILD="$ROOT/build/metal-$example"
+OBJ="$ROOT/build/obj-ex-$example"
+DEPS="$ROOT/build/deps"
+
+if [ "$clean_build" = "1" ]; then
+    echo "[cleaning metal build]"
+    rm -rf "$OBJ"
+fi
+
+mkdir -p "$OBJ" "$DEPS" "$BUILD"
+
+# --- Download Slang (binary SDK, shared across examples) --------------------
+SLANG_DIR="$DEPS/slang"
+if [ ! -f "$SLANG_DIR/lib/libslang.dylib" ]; then
+    echo "[downloading slang]"
+    mkdir -p "$SLANG_DIR"
+    SLANG_URL="https://github.com/shader-slang/slang/releases/download/v2026.17.1/slang-2026.17.1-macos-aarch64.tar.gz"
+    curl -sL "$SLANG_URL" -o "$DEPS/slang.tar.gz"
+    tar -xzf "$DEPS/slang.tar.gz" -C "$SLANG_DIR" --strip-components=1
+    rm "$DEPS/slang.tar.gz"
+else
+    echo "[slang already downloaded]"
+fi
+SLANG_INCLUDE="-I$SLANG_DIR/include"
+SLANG_LINK="-L$SLANG_DIR/lib -lslang -Wl,-rpath,$SLANG_DIR/lib"
+
+# --- glfw (static, shared across examples) ----------------------------------
+if [ ! -f "$DEPS/libglfw3.a" ]; then
+    echo "[building glfw]"
+    mkdir -p "$DEPS/glfw"
+    cmake -G Ninja -S "$ROOT/third-party/glfw" -B "$DEPS/glfw" \
+        -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_EXAMPLES=OFF \
+        -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release >/dev/null 2>&1 || exit 1
+    cmake --build "$DEPS/glfw" >/dev/null 2>&1 || exit 1
+    cp "$DEPS/glfw/src/libglfw3.a" "$DEPS/libglfw3.a"
+else
+    echo "[glfw already built]"
+fi
+
+# --- Compile flags ----------------------------------------------------------
+CXX="clang++"
+CXX_COMMON="-std=c++20 -fno-rtti -DRHI_BACKEND_METAL -DFMT_USE_CONSTEXPR=0 -DFMT_ENFORCE_COMPILE_STRING=0"
+CXX_INCLUDES="-I$ROOT/src -I$ROOT/third-party -I$ROOT/third-party/glfw/include -I$ROOT/third-party/plog/include -I$ROOT/third-party/rtm/includes -I$ROOT/third-party/metal-cpp $SLANG_INCLUDE"
+if [ "$build_type" = "debug" ]; then
+    CXX_FLAGS="-g -O0 -D_DEBUG $CXX_COMMON $CXX_INCLUDES"
+else
+    CXX_FLAGS="-g -O2 -DNDEBUG $CXX_COMMON $CXX_INCLUDES"
+fi
+
+# --- Source files -----------------------------------------------------------
+SRC="$ROOT/src"
+SOURCES="\
+    $EXAMPLE_SRC                  \
+    $SRC/core/arena.cpp               \
+    $SRC/core/platform.cpp            \
+    $SRC/core/logger.cpp              \
+    $SRC/core/math_rtm.cpp            \
+    $SRC/backend/metal/metal_impl.cpp \
+    $SRC/backend/metal/device.cpp     \
+    $SRC/backend/metal/swapchain.cpp  \
+    $SRC/backend/metal/cmd.cpp        \
+    $SRC/backend/metal/arguments_table.cpp \
+    $SRC/backend/metal/image.cpp      \
+    $SRC/backend/metal/sampler.cpp    \
+    $SRC/backend/metal/shader.cpp     \
+    $SRC/backend/metal/buffer.cpp     \
+    $SRC/backend/metal/pipeline.cpp   \
+    $SRC/backend/metal/metal_platform.mm"
+
+# --- Compile ----------------------------------------------------------------
+echo "[compiling]"
+for src in $SOURCES; do
+    objname=$(basename "$src" | sed 's/\.mm$/.o/;s/\.cpp$/.o/')
+    case "$src" in
+        *.mm) $CXX -fobjc-arc -c $CXX_FLAGS "$src" -o "$OBJ/$objname" ;;
+        *)    $CXX            -c $CXX_FLAGS "$src" -o "$OBJ/$objname" ;;
+    esac
+done
+
+# --- Link -------------------------------------------------------------------
+echo "[linking]"
+$CXX -fobjc-arc "$OBJ"/*.o \
+    "$DEPS/libglfw3.a" \
+    $SLANG_LINK \
+    -framework Metal -framework QuartzCore -framework Cocoa -framework Foundation \
+    -framework IOKit -framework CoreVideo \
+    -lpthread \
+    -o "$BUILD/metal-$example"
+
+echo "[done: $BUILD/metal-$example]"
+echo "[run from the repo root: ./build/metal-$example/metal-$example]"
ADD · build_win.bat +299 -0
--- a/build_win.bat
+++ b/build_win.bat
@@ -0,0 +1,299 @@
+@echo off
+setlocal enabledelayedexpansion
+cd /D "%~dp0"
+
+:: --- Usage ------------------------------------------------------------------
+::
+:: build_win.bat [example] [-r] [-c]
+::
+::   example  Name under src\backend\conformance\ (e.g. triangle). Builds
+::            src\backend\conformance\<example> with core + backend only.
+::            Default (no example): full renderer build.
+::   -r   Release build (default is Debug)
+::   -c   Clean build (delete everything first)
+
+:: --- Unpack Arguments -------------------------------------------------------
+set build_type=debug
+set clean_build=0
+set example=
+
+:parse_args
+if "%~1"=="" goto :args_done
+if /i "%~1"=="-r"       set build_type=release && shift && goto :parse_args
+if /i "%~1"=="-c"       set clean_build=1 && shift && goto :parse_args
+if /i "%~1"=="release"  set build_type=release && shift && goto :parse_args
+if /i "%~1"=="debug"    set build_type=debug && shift && goto :parse_args
+call :normalize_example "%~1"
+shift
+goto :parse_args
+:args_done
+
+if defined example (
+    echo [%build_type% vulkan build: %example%]
+) else (
+    echo [%build_type% build]
+)
+
+:: --- Find VS Toolchain ------------------------------------------------------
+for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`) do set "VS_PATH=%%i"
+if not defined VS_PATH echo ERROR: Visual Studio installation not found && exit /b 1
+call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64 >nul 2>&1 || exit /b 1
+
+:: --- Vulkan SDK -------------------------------------------------------------
+if not defined VULKAN_SDK (
+    echo ERROR: VULKAN_SDK environment variable not set.
+    exit /b 1
+)
+
+:: --- Project Paths ----------------------------------------------------------
+set ROOT=%~dp0
+set BUILD=%ROOT%build
+set OBJ=%BUILD%\obj
+set DEPS=%BUILD%\_deps
+set SLANG_DIR=%DEPS%\slang-src
+set EXAMPLES_DIR=%ROOT%src\backend\conformance\
+
+:: --- Example mode (positional arg): build src\backend\conformance\<example>
+:: --- with core + backend only, instead of the full renderer ------------------
+if defined example (
+    if "!EXAMPLES_DIR:~-1!"=="\" set "EXAMPLES_DIR=!EXAMPLES_DIR:~0,-1!"
+    set "EXAMPLE_SRC=!EXAMPLES_DIR!\!example!\!example!.cpp"
+    if not exist "!EXAMPLE_SRC!" (
+        echo [error: no such example: !example! ^(expected !EXAMPLE_SRC!^)]
+        exit /b 1
+    )
+    set "OBJ=%BUILD%\obj-ex-!example!"
+)
+
+
+
+:: --- Download Slang (binary SDK) --------------------------------------------
+if not exist "%SLANG_DIR%\lib\slang.lib" (
+    echo [downloading slang]
+    if not exist "%SLANG_DIR%" mkdir "%SLANG_DIR%"
+    powershell -Command "& {param($u,$d); [System.Net.WebClient]::new().DownloadFile($u,$d)}" ^
+	-u "https://github.com/shader-slang/slang/releases/download/v2026.17.1/slang-2026.17.1-windows-x86_64.zip" ^
+        -d "%DEPS%\slang.zip" >nul 2>&1
+    powershell -Command "Expand-Archive -Path '%DEPS%\slang.zip' -DestinationPath '%DEPS%\slang_tmp' -Force" >nul 2>&1
+    xcopy /s /e /q /y "%DEPS%\slang_tmp\*" "%SLANG_DIR%\" >nul 2>&1
+    rmdir /s /q "%DEPS%\slang_tmp" >nul 2>&1
+    del "%DEPS%\slang.zip" >nul 2>&1
+) else (
+    echo [slang already downloaded]
+)
+
+set SLANG_INCLUDE=/I"%SLANG_DIR%\include"
+set SLANG_LIB=%SLANG_DIR%\lib\slang.lib
+
+:: --- Clean ------------------------------------------------------------------
+if "%clean_build%"=="1" (
+    if defined example (
+        echo [cleaning example build: %example%]
+        if exist "%OBJ%" rmdir /s /q "%OBJ%"
+    ) else (
+        echo [cleaning build]
+        if exist "%BUILD%" rmdir /s /q "%BUILD%"
+    )
+)
+
+:: --- Prep Directories -------------------------------------------------------
+if not exist "%OBJ%"  mkdir "%OBJ%"
+if not exist "%DEPS%" mkdir "%DEPS%"
+
+:: --- Build Third-Party Dependencies -----------------------------------------
+
+set KTX_BUILD_TYPE=RelWithDebInfo
+if "%build_type%"=="debug" set KTX_BUILD_TYPE=Debug
+
+:: glfw
+if not exist "%BUILD%\glfw3.lib" (
+    echo [building glfw]
+    if not exist "%DEPS%\glfw" mkdir "%DEPS%\glfw"
+    cmake -G Ninja -S "%ROOT%third-party\glfw" -B "%DEPS%\glfw" ^
+        -DGLFW_BUILD_DOCS=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_EXAMPLES=OFF ^
+        -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=%KTX_BUILD_TYPE% >nul 2>&1 || exit /b 1
+    cmake --build "%DEPS%\glfw" --config %KTX_BUILD_TYPE% >nul 2>&1 || exit /b 1
+    copy "%DEPS%\glfw\src\glfw3.lib" "%BUILD%\glfw3.lib" >nul 2>&1
+) else (
+    echo [glfw already built]
+)
+
+:: KTX-Software (examples don't link it — skip)
+if defined example goto :skip_ktx
+if not exist "%BUILD%\ktx.lib" (
+    echo [building ktx]
+    if not exist "%DEPS%\ktx" mkdir "%DEPS%\ktx"
+    cmake -G Ninja -S "%ROOT%third-party\KTX-Software" -B "%DEPS%\ktx" ^
+        -DKTX_FEATURE_TESTS=OFF -DKTX_FEATURE_TOOLS=OFF -DKTX_FEATURE_DOC=OFF ^
+        -DKTX_FEATURE_GL_UPLOAD=OFF -DKTX_FEATURE_VK_UPLOAD=OFF ^
+        -DKTX_FEATURE_LOADTEST_APPS=OFF -DCMAKE_BUILD_TYPE=%KTX_BUILD_TYPE% >nul 2>&1 || exit /b 1
+    cmake --build "%DEPS%\ktx" --config %KTX_BUILD_TYPE% >nul 2>&1 || exit /b 1
+    copy "%DEPS%\ktx\ktx.lib"               "%BUILD%\ktx.lib" >nul 2>&1
+    copy "%DEPS%\ktx\ktx_read.lib"          "%BUILD%\ktx_read.lib" >nul 2>&1
+    copy "%DEPS%\ktx\external\astc-encoder\Source\astcenc-avx2-static.lib" "%BUILD%\astcenc-avx2-static.lib" >nul 2>&1
+) else (
+    echo [ktx already built]
+)
+:skip_ktx
+
+:: ==== Compile Flags ====
+
+set CL_COMMON=/nologo /FC /Z7 /EHsc /Zc:preprocessor /std:c++20 /permissive- ^
+    /DRHI_BACKEND_VULKAN /DENABLE_EDITOR /D_CRT_SECURE_NO_WARNINGS /DVK_NO_PROTOTYPES /DKHRONOS_STATIC ^
+    /DFMT_USE_CONSTEXPR=0 /DFMT_ENFORCE_COMPILE_STRING=0
+
+set CL_INCLUDES=/I"%ROOT%src" /I"%ROOT%third-party" ^
+    /I"%ROOT%third-party\glfw\include" /I"%ROOT%third-party\VMA\include" ^
+    /I"%ROOT%third-party\plog\include" /I"%ROOT%third-party\imgui" ^
+    /I"%ROOT%third-party\imgui\backends" /I"%ROOT%third-party\rtm\includes" ^
+    /I"%ROOT%third-party\KTX-Software\include" ^
+    %SLANG_INCLUDE% /I"%VULKAN_SDK%\Include"
+
+if "%build_type%"=="debug" (
+    set CL_FLAGS=/Od /Ob1 /MDd /D_DEBUG /DIMGUI_IMPL_VULKAN_USE_VOLK %CL_COMMON% %CL_INCLUDES%
+    set LD_DEBUG=/DEBUG
+) else (
+    set CL_FLAGS=/O2 /MD /DNDEBUG /DIMGUI_IMPL_VULKAN_USE_VOLK %CL_COMMON% %CL_INCLUDES%
+    set LD_DEBUG=
+)
+
+:: ==== Source Files ====
+
+set SRC=%ROOT%src
+set TP=%ROOT%third-party
+
+set CORE_SRC=^
+    %SRC%\core\arena.cpp                            ^
+    %SRC%\core\platform.cpp                         ^
+    %SRC%\core\math_rtm.cpp                         ^
+    %SRC%\core\logger.cpp
+
+set BACKEND_SRC=^
+    %SRC%\backend\vulkan\context.cpp                ^
+    %SRC%\backend\vulkan\swapchain.cpp              ^
+    %SRC%\backend\vulkan\pipeline.cpp               ^
+    %SRC%\backend\vulkan\descriptors.cpp            ^
+    %SRC%\backend\vulkan\debug.cpp                  ^
+    %SRC%\backend\vulkan\query_pool.cpp             ^
+    %SRC%\backend\vulkan\cmd_pool.cpp               ^
+    %SRC%\backend\vulkan\cmd_buffer.cpp             ^
+    %SRC%\backend\vulkan\allocator.cpp              ^
+    %SRC%\backend\vulkan\queue.cpp                  ^
+    %SRC%\backend\vulkan\buffer.cpp                 ^
+    %SRC%\backend\vulkan\image.cpp                  ^
+    %SRC%\backend\vulkan\sampler.cpp                ^
+    %SRC%\backend\vulkan\shader.cpp                 ^
+    %SRC%\backend\vulkan\accel_struct.cpp           ^
+    %SRC%\backend\vulkan\vk_conversion.cpp          ^
+    %SRC%\backend\vulkan\rhi_helpers.cpp
+
+set SOURCES=^
+    %SRC%\renderer.cpp                              ^
+    %SRC%\quick_submit.cpp                          ^
+    %SRC%\pipelines.cpp                             ^
+    %SRC%\passes\fg.cpp                             ^
+    %SRC%\asset\asset.cpp                           ^
+    %SRC%\asset\texture.cpp                         ^
+    %SRC%\asset\gltf.cpp                            ^
+    %TP%\mikktspace.c                               ^
+    %SRC%\scene\scene.cpp                           ^
+    %SRC%\scene\ibl.cpp                             ^
+    %SRC%\passes\ssr\ssr.cpp                        ^
+    %SRC%\passes\depth_pre\depth_normal.cpp         ^
+    %SRC%\passes\dispatch_mdi\build_indirect.cpp    ^
+    %SRC%\passes\forward\forward.cpp                ^
+    %SRC%\passes\fwd_cpu\fwd_cpu.cpp                ^
+    %SRC%\passes\shadow\shadow.cpp                  ^
+    %SRC%\passes\grid\grid.cpp                      ^
+    %SRC%\passes\id_blit\id_blit.cpp                ^
+    %SRC%\passes\fullscreen\fullscreen.cpp          ^
+    %SRC%\passes\cluster\cluster_bounds.cpp         ^
+    %SRC%\passes\cluster\light_cull.cpp             ^
+    %SRC%\passes\hiz\hiz.cpp                        ^
+    %SRC%\passes\imgui\imgui.cpp                    ^
+    %SRC%\passes\skybox\skybox.cpp                  ^
+    %SRC%\passes\rt_build.cpp                       ^
+    %SRC%\passes\ddgi\ddgi_trace.cpp                ^
+    %SRC%\passes\ddgi\ddgi_update.cpp               ^
+    %SRC%\passes\ddgi\ddgi_classify.cpp             ^
+    %SRC%\passes\ddgi\ddgi_relocate.cpp             ^
+    %SRC%\passes\ddgi\ddgi_probes_dbg.cpp           ^
+    %SRC%\passes\debug\debug_lines.cpp              ^
+    %SRC%\editor\editor.cpp                         ^
+    %SRC%\editor\debug_draw.cpp                     ^
+    %SRC%\editor\frame.cpp                          ^
+    %SRC%\editor\gizmo.cpp                          ^
+    %SRC%\editor\style.cpp                          ^
+    %SRC%\editor\viewport.cpp                       ^
+    %SRC%\editor\log_viewer.cpp                     ^
+    %SRC%\editor\texture_viewer.cpp                 ^
+    %SRC%\editor\targets.cpp                       ^
+    %SRC%\editor\timings.cpp                       ^
+    %SRC%\editor\hierarchy.cpp                      ^
+    %SRC%\editor\inspector.cpp                      ^
+    %SRC%\backend\imgui_backend.cpp                 ^
+    %TP%\imgui\imgui.cpp                            ^
+    %TP%\imgui\imgui_draw.cpp                       ^
+    %TP%\imgui\imgui_tables.cpp                     ^
+    %TP%\imgui\imgui_widgets.cpp                    ^
+    %TP%\imgui\imgui_demo.cpp                       ^
+    %TP%\imgui\backends\imgui_impl_glfw.cpp
+
+:: ==== Compile ====
+echo [compiling]
+
+pushd "%OBJ%"
+if defined example goto :compile_example
+cl /c /MP %CL_FLAGS% %CORE_SRC% %BACKEND_SRC% %SOURCES% 2>&1 | findstr /v "Microsoft (R) Copyright (C)" | findstr /v "^$"
+:: imgui.obj collision: src\passes\imgui\imgui.cpp and third-party\imgui\imgui.cpp
+:: both emit imgui.obj in this flat dir — rebuild with distinct names.
+cl /c %CL_FLAGS% /Fo"%OBJ%\imgui_pass.obj" "%SRC%\passes\imgui\imgui.cpp" 2>&1 | findstr /v "Microsoft (R) Copyright (C)" | findstr /v "^$"
+cl /c %CL_FLAGS% /Fo"%OBJ%\imgui_lib.obj" "%TP%\imgui\imgui.cpp" 2>&1 | findstr /v "Microsoft (R) Copyright (C)" | findstr /v "^$"
+if exist "%OBJ%\imgui.obj" del "%OBJ%\imgui.obj"
+:: stale objs from renamed/removed sources (link uses *.obj wildcard)
+if exist "%OBJ%\descriptor_pool.obj" del "%OBJ%\descriptor_pool.obj"
+if exist "%OBJ%\descriptor_set.obj" del "%OBJ%\descriptor_set.obj"
+if exist "%OBJ%\imgui_impl_vulkan.obj" del "%OBJ%\imgui_impl_vulkan.obj"
+del "%OBJ%\pass_*.obj" 2>nul
+goto :compile_done
+:compile_example
+cl /c /MP %CL_FLAGS% "%EXAMPLE_SRC%" %CORE_SRC% %BACKEND_SRC% 2>&1 | findstr /v "Microsoft (R) Copyright (C)" | findstr /v "^$"
+:compile_done
+popd
+
+:: ==== Link ====
+echo [linking]
+
+if defined example (
+    set LIBS="%VULKAN_SDK%\Lib\vulkan-1.lib" ^
+        "%BUILD%\glfw3.lib" "%SLANG_LIB%" ^
+        gdi32.lib user32.lib shell32.lib dwmapi.lib
+    set "OUT=%BUILD%\vk-%example%.exe"
+) else (
+    set LIBS="%VULKAN_SDK%\Lib\vulkan-1.lib" ^
+        "%BUILD%\glfw3.lib" "%BUILD%\ktx.lib" "%BUILD%\ktx_read.lib" ^
+        "%BUILD%\astcenc-avx2-static.lib" "%SLANG_LIB%" ^
+        gdi32.lib user32.lib shell32.lib dwmapi.lib
+    set "OUT=%BUILD%\vk-renderer.exe"
+)
+
+cl %OBJ%\*.obj %LIBS% /link /MANIFEST:EMBED /INCREMENTAL:NO %LD_DEBUG% /OUT:"%OUT%" 2>&1 | findstr /v "Microsoft (R) Copyright (C)" | findstr /v "^$"
+
+echo [done: %OUT%]
+if defined example echo [run from repo root: %OUT%]
+exit /b 0
+
+:: --- Normalize example argument to a bare name ------------------------------
+:: Accepts: triangle, triangle.cpp, triangle\triangle.cpp,
+:: .\triangle\triangle.cpp, ./triangle/triangle.cpp, etc.
+:normalize_example
+set "raw=%~1"
+set "norm=!raw:/=\!"
+:strip_trailing
+if not defined norm goto :normalize_done
+if "!norm:~-1!"=="\" set "norm=!norm:~0,-1!" & goto :strip_trailing
+if "!norm:~-2!"=="\." set "norm=!norm:~0,-2!" & goto :strip_trailing
+:normalize_done
+for %%A in ("!norm!") do set "example=%%~nA"
+if not defined example set "example=!norm!"
+goto :eof
ADD · readme.md +41 -0
--- a/readme.md
+++ b/readme.md
@@ -0,0 +1,41 @@
+### Overview
+
+GPU driven Vulkan/Metal playground renderer (main renderer is Vulkan on Windows/Linux for now), contains a rendering interface, a precompiled frame-graph, `DescriptorHandle<T>` based bindless resource fetching, and a basic ImGui editor. Generally intended to be a gfx lab bench for myself.
+
+- Explicit frame-graph (`src/passes/fg.*`), passes declare read/write states and barriers get baked outside the hot path.
+- GPU-driven MDI forward path: compute shader, build-indirect, HiZ and frustum culling -> depth-pre -> forward.
+- Cascaded shadow maps, clustered point lights, DDGI or infinite IBL for indirect.
+- IBL skybox from HDR, gltf load (cgltf + KTX + mikktspace), ImGui editor with shader reload.
+- Render backend abstraction in `src/backend/rhi.h`. Metal coverage runs `src/backend/conformance/*` for now as I work on expanding the coverage.
+
+### Local setup
+
+- Vulkan SDK 1.4+
+- C++20, CMake 3.31+ (CMake path only), Ninja recommended
+- Windows: VS2022 + `vswhere` on PATH (bat should find it for you). Linux: gcc/clang + dev Vulkan headers. macOS: conformance-only (main renderer unsupported, Metal WIP).
+
+```sh
+git submodule update --init --recursive
+```
+
+Submodules: glfw, VMA, rtm, imgui, KTX-Software, plog. Slang 2026.17.1 is fetched as a binary (CMake FetchContent, or auto-downloaded by the bat/sh scripts)
+
+#### Scripts
+```
+build_win.bat                 # Windows debug
+build_win.bat -r              # Windows release
+build_win.bat -c              # clean rebuild
+build_win.bat triangle        # conformance probe (no renderer)
+./build_linux.sh              # Linux debug (add triangle for probe)
+./build_linux.sh -r           # Linux release
+./build_mac.sh triangle       # macOS probe only
+```
+
+#### CMake
+```
+cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
+cmake --build build
+```
+
+### To-do
+There's generally just a lot to do all over the place in this, but currently I'm just slowly chipping away at the editor and Metal coverage, toward renderer.cpp.<
\ No newline at end of file
ADD · slang-format.py +185 -0
--- a/slang-format.py
+++ b/slang-format.py
@@ -0,0 +1,185 @@
+# LLM generated file
+# based on https://github.com/shader-slang/slang/blob/master/source/slang/slang-language-server-auto-format.cpp
+# slangd just silently does some pre/post processing for clang-format,
+# this is just a tiny file to do the same. I just want some dedicated tool to format all shaders if needed
+
+# single file
+# python format_slang.py myshader.slang
+
+# format directory recursively
+# python format_slang.py ./src
+
+# custom style
+# python format_slang.py --style LLVM ./src
+
+# multiple files
+# python format_slang.py file1.slang file2.slang ./src
+
+
+#!/usr/bin/env python3
+import subprocess
+import re
+import os
+from pathlib import Path
+from xml.etree import ElementTree as ET
+
+
+def find_clang_format():
+    """Find clang-format executable"""
+    # Try PATH first
+    result = subprocess.run(
+        ["where" if os.name == "nt" else "which", "clang-format"],
+        capture_output=True,
+        text=True,
+    )
+    if result.returncode == 0:
+        return result.stdout.strip()
+    return "clang-format"
+
+
+def extract_spirv_asm_ranges(text):
+    """Extract ranges of spirv_asm blocks to exclude from formatting"""
+    ranges = []
+    # Simple regex to find spirv_asm { ... } blocks
+    pattern = r"spirv_asm\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}"
+    for match in re.finditer(pattern, text, re.DOTALL):
+        ranges.append((match.start(), match.end()))
+    return ranges
+
+
+def format_source(text, clang_format_path, style, fallback_style):
+    """Call clang-format and parse XML output"""
+
+    # Build clang-format command
+    cmd = [
+        clang_format_path,
+        "--assume-filename",
+        "file.cs",
+        "--output-replacements-xml",
+    ]
+
+    # Add style arguments
+    if style.startswith("file"):
+        # Check if .clang-format exists
+        if os.path.exists(".clang-format") or os.path.exists("_clang_format"):
+            cmd.extend(["-style", style])
+        elif fallback_style:
+            cmd.extend(["-style", fallback_style])
+    elif style:
+        cmd.extend(["-style", style])
+
+    # Run clang-format with UTF-8 encoding
+    result = subprocess.run(
+        cmd,
+        input=text,
+        capture_output=True,
+        text=True,
+        encoding="utf-8",  # Add this
+        errors="replace",  # Add this to handle any encoding issues gracefully
+    )
+
+    if result.returncode != 0:
+        print(f"clang-format error: {result.stderr}")
+        return []
+
+    # Parse XML output
+    try:
+        root = ET.fromstring(result.stdout)
+        edits = []
+        for replacement in root.findall("replacement"):
+            offset = int(replacement.get("offset", "0"))
+            length = int(replacement.get("length", "0"))
+            new_text = replacement.text or ""
+            # Decode XML entities
+            new_text = new_text.replace("&#13;", "\r").replace("&#10;", "\n")
+            new_text = new_text.replace("&lt;", "<").replace("&gt;", ">")
+            new_text = new_text.replace("&amp;", "&").replace("&apos;", "'")
+            new_text = new_text.replace("&quot;", '"')
+            edits.append((offset, length, new_text))
+        return edits
+    except ET.ParseError as e:
+        print(f"Failed to parse clang-format output: {e}")
+        return []
+
+
+def apply_edits(text, edits, exclusion_ranges):
+    """Apply text edits, respecting exclusion ranges"""
+    # Filter out edits in spirv_asm blocks
+    filtered_edits = []
+    for offset, length, new_text in edits:
+        skip = False
+        for start, end in exclusion_ranges:
+            if start <= offset < end:
+                skip = True
+                break
+        if not skip:
+            # Skip semicolon-after-brace special case
+            if length == 0 and offset < len(text) and text[offset] == ";":
+                if offset > 0 and text[offset - 1] == "}":
+                    skip = True
+            if not skip:
+                filtered_edits.append((offset, length, new_text))
+
+    # Apply edits in reverse order (to preserve offsets)
+    result = text
+    for offset, length, new_text in reversed(filtered_edits):
+        result = result[:offset] + new_text + result[offset + length :]
+
+    return result
+
+
+def format_file(file_path, clang_format_path, style="file", fallback_style=None):
+    """Format a single file"""
+    with open(file_path, "r", encoding="utf-8") as f:
+        content = f.read()
+
+    exclusion_ranges = extract_spirv_asm_ranges(content)
+    edits = format_source(content, clang_format_path, style, fallback_style)
+    formatted = apply_edits(content, edits, exclusion_ranges)
+
+    with open(file_path, "w", encoding="utf-8", newline="") as f:
+        f.write(formatted)
+
+    print(f"Formatted: {file_path}")
+
+
+def main():
+    import argparse
+
+    parser = argparse.ArgumentParser(description="Format Slang files like the LSP does")
+    parser.add_argument(
+        "--style", default="file", help="clang-format style (default: file)"
+    )
+    parser.add_argument(
+        "--fallback-style",
+        default="{BasedOnStyle: Microsoft, BreakBeforeBraces: Allman, ColumnLimit: 0}",
+        help="clang-format fallback style",
+    )
+    parser.add_argument(
+        "--clang-format", default=None, help="Path to clang-format executable"
+    )
+    parser.add_argument("files", nargs="+", help="Files or directories to format")
+
+    args = parser.parse_args()
+
+    clang_format = args.clang_format or find_clang_format()
+    print(f"Using clang-format: {clang_format}")
+
+    # Gather files
+    file_list = []
+    for item in args.files:
+        if os.path.isfile(item):
+            file_list.append(item)
+        elif os.path.isdir(item):
+            file_list.extend(Path(item).rglob("*.slang"))
+
+    # Format files
+    for file_path in file_list:
+        try:
+            format_file(file_path, clang_format, args.style, args.fallback_style)
+        except Exception as e:
+            print(f"Error formatting {file_path}: {e}")
+
+
+if __name__ == "__main__":
+    main()
ADD · src/asset/asset.cpp +19 -0
--- a/src/asset/asset.cpp
+++ b/src/asset/asset.cpp
@@ -0,0 +1,19 @@
+#include "asset.h"
+
+AssetHandle AssetManager::load(const char *path) {
+    AssetHandle h{(u32)assets.size()};
+    assets.emplace_back();
+    if (!load_gltf_asset(path, assets.back())) {
+        assets.pop_back();
+        return {};
+    }
+    return h;
+}
+
+const AssetScene *AssetManager::get(AssetHandle h) const {
+    return h.id < assets.size() ? &assets[h.id] : nullptr;
+}
+
+AssetScene *AssetManager::get(AssetHandle h) {
+    return h.id < assets.size() ? &assets[h.id] : nullptr;
+}
ADD · src/asset/asset.h +139 -0
--- a/src/asset/asset.h
+++ b/src/asset/asset.h
@@ -0,0 +1,139 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "core/globals.h"
+#include "core/math_rtm.h"
+#include "shaders/renderer_types.h"
+
+constexpr u32 ASSET_INVALID = 0xffffffffu;
+
+struct AssetHandle {
+    u32 id = ASSET_INVALID;
+
+    bool valid() const {
+        return id != ASSET_INVALID;
+    }
+    bool operator==(const AssetHandle &o) const {
+        return id == o.id;
+    }
+    explicit operator bool() const {
+        return valid();
+    }
+};
+
+struct AssetGeometry {
+    u32 first_vertex;
+    u32 vertex_count;
+    u32 first_index;
+    u32 index_count;
+};
+
+struct AssetTexture {
+    std::string name;
+    std::string path;
+    u8 *blob = nullptr;
+    usize blob_size = 0;
+    bool is_ktx = false;
+    bool is_srgb = true;
+    bool is_hdr = false;
+};
+
+struct AssetMaterial {
+    std::string name;
+    vec4 base_color = vec4(1.0f, 1.0f, 1.0f, 1.0f);
+    f32 metallic = 0.2f;
+    f32 roughness = 0.8f;
+    vec3 emissive = vec3(0.0f);
+    u32 base_color_tex = ASSET_INVALID;
+    u32 normal_tex = ASSET_INVALID;
+    u32 mr_tex = ASSET_INVALID;
+    u32 emissive_tex = ASSET_INVALID;
+    bool double_sided = false;
+};
+
+struct AssetSubmesh {
+    u32 geometry = ASSET_INVALID;
+    u32 material = ASSET_INVALID;
+    vec3 aabb_min = vec3(0.0f);
+    vec3 aabb_max = vec3(0.0f);
+    vec4 sphere = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+};
+
+struct AssetMesh {
+    u32 first_submesh;
+    u32 submesh_count;
+};
+
+struct AssetCamera {
+    enum Type {
+        Perspective,
+        Orthographic
+    };
+    Type type;
+    f32 yfov;
+    f32 znear;
+    f32 zfar;
+    f32 aspect_ratio;
+};
+
+struct AssetLight {
+    enum Type {
+        Directional,
+        Point
+    };
+    Type type;
+    vec3 color = {1.0f, 1.0f, 1.0f};
+    f32 intensity = 1.0f;
+    f32 range = 0.0f;
+};
+
+struct AssetNode {
+    mat4 local = identity();
+    int parent = -1;
+    u32 first_child;
+    u32 child_count;
+    u32 mesh = ASSET_INVALID;
+    i32 camera = -1;
+    i32 light = -1;
+    u32 first_instance;
+    u32 instance_count;
+};
+
+struct AssetScene {
+    std::string name;
+    std::vector<Vertex> vertices;
+    std::vector<u32> indices;
+    std::vector<AssetGeometry> geometries;
+    std::vector<AssetTexture> textures;
+    std::vector<AssetMaterial> materials;
+    std::vector<AssetSubmesh> submeshes;
+    std::vector<AssetMesh> meshes;
+    std::vector<AssetNode> nodes;
+    std::vector<AssetCamera> cameras;
+    std::vector<AssetLight> lights;
+    std::vector<u32> child_indices;
+    std::vector<u32> mesh_submeshes;
+    std::vector<TRS> instance_locals;
+    std::vector<u32> root_nodes;
+
+    std::vector<std::string> submesh_names;
+    std::vector<std::string> mesh_names;
+    std::vector<std::string> node_names;
+};
+
+class AssetManager {
+  public:
+    AssetHandle load(const char *path);
+    const AssetScene *get(AssetHandle h) const;
+    AssetScene *get(AssetHandle h);
+    u32 count() const {
+        return (u32)assets.size();
+    }
+
+  private:
+    std::vector<AssetScene> assets;
+};
+
+bool load_gltf_asset(const char *path, AssetScene &out);
ADD · src/asset/gltf.cpp +579 -0
--- a/src/asset/gltf.cpp
+++ b/src/asset/gltf.cpp
@@ -0,0 +1,579 @@
+#include <cstddef>
+
+#include "asset.h"
+#include "core/logger.h"
+#include "core/math_rtm.h"
+
+#define CGLTF_IMPLEMENTATION
+#include <cgltf.h>
+#include <mikktspace.h>
+#include <stb_image.h>
+
+#include <filesystem>
+#include <vector>
+
+// clang-format off
+
+// both are right handed
+// my:   right-handed | +X fwd, -Y rgt (+Y lft), +Z up
+// gltf: right-handed | +X rgt, +Y up,           +Z fwd
+
+// maps gltf axes 1:1 directly into my space
+// I think this is pretty common? Unless theres a better solutio?
+// For entire level/world geometry exports so global coordinates don't rotate
+// props/characters will import facing backwards (looking down -X)
+static const mat4 GLTF_TO_ENGINE_PURE = {
+    0.0f, 1.0f, 0.0f, 0.0f,  // col 0: gltf X (rgt) -> my Y (lft)
+    0.0f, 0.0f, 1.0f, 0.0f,  // col 1: gltf Y (up)  -> my Z (up)
+    1.0f, 0.0f, 0.0f, 0.0f,  // col 2: gltf Z (fwd) -> my X (fwd)
+    0.0f, 0.0f, 0.0f, 1.0f
+};
+
+// bakes a 180-degree yaw rot (mind both the flips) into the conversion matrix
+// aligns assets modeled facing the front-camera in blender to automatically
+// face my +X fwd dir ootb preserves winding order (+det)
+static const mat4 GLTF_TO_ENGINE_FLIPPED = {
+     0.0f, -1.0f,  0.0f,  0.0f,  // col 0: gltf X (rgt) -> my -Y (flip rgt)
+     0.0f,  0.0f,  1.0f,  0.0f,  // col 1: gltf Y (up)  -> my  Z
+    -1.0f,  0.0f,  0.0f,  0.0f,  // col 2: gltf Z (fwd) -> my -X (flip fwd)
+     0.0f,  0.0f,  0.0f,  1.0f
+};
+
+// #define GLTF_TO_ENGINE m4_identity()
+#define GLTF_TO_ENGINE GLTF_TO_ENGINE_FLIPPED
+// #define GLTF_TO_ENGINE GLTF_TO_ENGINE_PURE
+// clang-format on
+
+struct MikkUserData {
+    const std::vector<vec3> *positions;
+    const std::vector<vec3> *normals;
+    const std::vector<vec2> *uvs;
+    const std::vector<u32> *indices;
+    std::vector<vec4> *tangents_out;
+};
+
+static int mikk_get_num_faces(const SMikkTSpaceContext *ctx) {
+    auto *d = (MikkUserData *)ctx->m_pUserData;
+    return (int)(d->indices->size() / 3);
+}
+
+static int mikk_get_num_vertices_of_face(const SMikkTSpaceContext *, int) {
+    return 3;
+}
+
+static void mikk_get_position(const SMikkTSpaceContext *ctx, f32 pos[], int face, int vert) {
+    auto *d = (MikkUserData *)ctx->m_pUserData;
+    u32 idx = (*d->indices)[face * 3 + vert];
+    pos[0] = (*d->positions)[idx].x;
+    pos[1] = (*d->positions)[idx].y;
+    pos[2] = (*d->positions)[idx].z;
+}
+
+static void mikk_get_normal(const SMikkTSpaceContext *ctx, f32 nrm[], int face, int vert) {
+    auto *d = (MikkUserData *)ctx->m_pUserData;
+    u32 idx = (*d->indices)[face * 3 + vert];
+    nrm[0] = (*d->normals)[idx].x;
+    nrm[1] = (*d->normals)[idx].y;
+    nrm[2] = (*d->normals)[idx].z;
+}
+
+static void mikk_get_texcoord(const SMikkTSpaceContext *ctx, f32 uv[], int face, int vert) {
+    auto *d = (MikkUserData *)ctx->m_pUserData;
+    u32 idx = (*d->indices)[face * 3 + vert];
+    uv[0] = (*d->uvs)[idx].x;
+    uv[1] = (*d->uvs)[idx].y;
+}
+
+static void
+mikk_set_ts_space_basic(const SMikkTSpaceContext *ctx, const f32 tangent[], const f32 sign, int face, int vert) {
+    auto *d = (MikkUserData *)ctx->m_pUserData;
+    u32 idx = (*d->indices)[face * 3 + vert];
+    (*d->tangents_out)[idx] = vec4(tangent[0], tangent[1], tangent[2], sign);
+}
+
+// helpers
+static u32 add_texture(AssetScene &out, const cgltf_texture_view &view, const std::string &gltf_dir, bool srgb) {
+    if (!view.texture) {
+        return ASSET_INVALID;
+    }
+
+    cgltf_image *img = nullptr;
+
+    AssetTexture tex{};
+
+    tex.is_srgb = srgb;
+
+    if (view.texture->has_basisu) {
+        img = view.texture->basisu_image;
+        tex.is_ktx = true;
+    } else {
+        img = view.texture->image;
+    }
+
+    if (!img) {
+        return ASSET_INVALID;
+    }
+
+    if (img->name) {
+        tex.name = img->name;
+    }
+
+    if (img->uri) {
+        tex.path = gltf_dir + "/" + img->uri;
+    } else if (img->buffer_view) {
+        tex.blob_size = img->buffer_view->size;
+        tex.blob = new u8[tex.blob_size];
+        const u8 *src = (const u8 *)img->buffer_view->buffer->data + img->buffer_view->offset;
+        memcpy(tex.blob, src, tex.blob_size);
+    }
+
+    u32 index = (u32)out.textures.size();
+    out.textures.push_back(tex);
+    return index;
+}
+
+bool load_gltf_asset(const char *path, AssetScene &out) {
+    cgltf_options options{};
+    cgltf_data *data = nullptr;
+
+    if (cgltf_parse_file(&options, path, &data) != cgltf_result_success) {
+        VEL_ERROR("Failed to parse glTF: {}", path);
+        return false;
+    }
+
+    if (cgltf_load_buffers(&options, data, path) != cgltf_result_success) {
+        VEL_ERROR("Failed to load glTF buffers: {}", path);
+
+        cgltf_free(data);
+
+        return false;
+    }
+
+    out = {};
+
+    std::filesystem::path gltf_path(path);
+
+    std::string gltf_dir = gltf_path.parent_path().generic_string();
+
+    // materials
+    out.materials.resize(data->materials_count);
+
+    for (cgltf_size i = 0; i < data->materials_count; ++i) {
+        const cgltf_material &m = data->materials[i];
+
+        AssetMaterial &mat = out.materials[i];
+
+        if (m.name) {
+            mat.name = m.name;
+        }
+
+        mat.double_sided = m.double_sided;
+
+        if (m.has_pbr_metallic_roughness) {
+            const auto &pbr = m.pbr_metallic_roughness;
+
+            mat.base_color = vec4(
+                pbr.base_color_factor[0], pbr.base_color_factor[1], pbr.base_color_factor[2], pbr.base_color_factor[3]
+            );
+
+            mat.metallic = (f32)pbr.metallic_factor;
+            mat.roughness = (f32)pbr.roughness_factor;
+
+            mat.base_color_tex = add_texture(out, pbr.base_color_texture, gltf_dir, true);
+
+            mat.mr_tex = add_texture(out, pbr.metallic_roughness_texture, gltf_dir, false);
+        }
+
+        mat.normal_tex = add_texture(out, m.normal_texture, gltf_dir, false);
+
+        mat.emissive_tex = add_texture(out, m.emissive_texture, gltf_dir, true);
+
+        mat.emissive = vec3((f32)m.emissive_factor[0], (f32)m.emissive_factor[1], (f32)m.emissive_factor[2]);
+    }
+
+    // meshes
+    out.meshes.resize(data->meshes_count);
+    out.mesh_names.resize(data->meshes_count);
+
+    for (cgltf_size mi = 0; mi < data->meshes_count; ++mi) {
+        const cgltf_mesh &src_mesh = data->meshes[mi];
+
+        AssetMesh &mesh = out.meshes[mi];
+        mesh.first_submesh = (u32)out.mesh_submeshes.size();
+
+        if (src_mesh.name) {
+            out.mesh_names[mi] = src_mesh.name;
+        }
+
+        for (cgltf_size pi = 0; pi < src_mesh.primitives_count; ++pi) {
+            const cgltf_primitive &prim = src_mesh.primitives[pi];
+
+            if (prim.type != cgltf_primitive_type_triangles) {
+                continue;
+            }
+
+            std::vector<vec3> positions;
+            std::vector<vec3> normals;
+            std::vector<vec2> uvs;
+            std::vector<vec4> tangents;
+
+            std::vector<f32> float_data;
+
+            for (cgltf_size ai = 0; ai < prim.attributes_count; ++ai) {
+                const cgltf_attribute &attr = prim.attributes[ai];
+
+                cgltf_accessor *accessor = attr.data;
+
+                float_data.resize(accessor->count * cgltf_num_components(accessor->type));
+
+                cgltf_accessor_unpack_floats(accessor, float_data.data(), float_data.size());
+
+                switch (attr.type) {
+                case cgltf_attribute_type_position: {
+                    positions.resize(accessor->count);
+
+                    memcpy(positions.data(), float_data.data(), float_data.size() * sizeof(f32));
+
+                } break;
+
+                case cgltf_attribute_type_normal: {
+                    normals.resize(accessor->count);
+
+                    memcpy(normals.data(), float_data.data(), float_data.size() * sizeof(f32));
+
+                } break;
+
+                case cgltf_attribute_type_texcoord: {
+                    if (attr.index == 0) {
+                        uvs.resize(accessor->count);
+
+                        memcpy(uvs.data(), float_data.data(), float_data.size() * sizeof(f32));
+                    }
+
+                } break;
+
+                case cgltf_attribute_type_tangent: {
+                    tangents.resize(accessor->count);
+
+                    memcpy(tangents.data(), float_data.data(), float_data.size() * sizeof(f32));
+
+                    // gltf tangents are VEC4 (xyz + sign w), but some
+                    // files store VEC3 (xyz only, no w). In that case
+                    // the w component remains 0.0 from resize()
+                    u32 comps = cgltf_num_components(accessor->type);
+                    if (comps < 4) {
+                        for (auto &t : tangents) {
+                            t.w = 1.0f;
+                        }
+                    }
+
+                } break;
+
+                default:
+                    break;
+                }
+            }
+
+            if (positions.empty()) {
+                continue;
+            }
+
+            // indices
+            std::vector<u32> indices;
+
+            if (prim.indices) {
+                indices.resize(prim.indices->count);
+
+                for (cgltf_size i = 0; i < prim.indices->count; ++i) {
+                    indices[i] = (u32)cgltf_accessor_read_index(prim.indices, i);
+                }
+            } else {
+                indices.resize(positions.size());
+
+                for (u32 i = 0; i < positions.size(); ++i) {
+                    indices[i] = i;
+                }
+            }
+
+            // coordinate conversion
+            for (usize i = 0; i < positions.size(); ++i) {
+                vec4 p = transform_point(positions[i], GLTF_TO_ENGINE);
+                positions[i] = {p.x, p.y, p.z};
+
+                if (i < normals.size()) {
+                    normals[i] = transform_direction(normals[i], GLTF_TO_ENGINE).normalized();
+                }
+            }
+
+            if (!tangents.empty()) {
+                for (usize i = 0; i < tangents.size(); ++i) {
+                    vec3 t = vec3(tangents[i].x, tangents[i].y, tangents[i].z);
+                    t = transform_direction(t, GLTF_TO_ENGINE).normalized();
+                    tangents[i].x = t.x;
+                    tangents[i].y = t.y;
+                    tangents[i].z = t.z;
+                }
+            }
+
+            // generate tangents
+            if (tangents.empty() && !normals.empty() && !uvs.empty()) {
+                tangents.resize(positions.size(), vec4(0, 0, 0, 1));
+
+                MikkUserData user{};
+
+                user.positions = &positions;
+                user.normals = &normals;
+                user.uvs = &uvs;
+                user.indices = &indices;
+                user.tangents_out = &tangents;
+
+                SMikkTSpaceInterface iface{};
+
+                iface.m_getNumFaces = mikk_get_num_faces;
+                iface.m_getNumVerticesOfFace = mikk_get_num_vertices_of_face;
+
+                iface.m_getPosition = mikk_get_position;
+                iface.m_getNormal = mikk_get_normal;
+                iface.m_getTexCoord = mikk_get_texcoord;
+                iface.m_setTSpaceBasic = mikk_set_ts_space_basic;
+
+                SMikkTSpaceContext ctx{};
+
+                ctx.m_pInterface = &iface;
+                ctx.m_pUserData = &user;
+
+                genTangSpaceDefault(&ctx);
+
+                for (usize i = 0; i < tangents.size(); ++i) {
+                    tangents[i].w *= -1.0f;
+                }
+            }
+
+            // ---------------------------------------------
+            // out
+            AssetGeometry geom;
+            geom.first_vertex = (u32)out.vertices.size();
+            geom.vertex_count = (u32)positions.size();
+            geom.first_index = (u32)out.indices.size();
+            geom.index_count = (u32)indices.size();
+
+            for (usize i = 0; i < positions.size(); ++i) {
+                Vertex v{};
+
+                v.pos = positions[i];
+
+                v.normal = (i < normals.size()) ? normals[i] : vec3(0, 0, 1);
+
+                v.uv = (i < uvs.size()) ? uvs[i] : vec2(0);
+
+                v.tangent = (i < tangents.size()) ? tangents[i] : vec4(1, 0, 0, 1);
+
+                out.vertices.push_back(v);
+            }
+
+            out.indices.insert(out.indices.end(), indices.begin(), indices.end());
+
+            u32 geom_index = (u32)out.geometries.size();
+
+            out.geometries.push_back(geom);
+
+            AssetSubmesh submesh{};
+
+            submesh.geometry = geom_index;
+
+            submesh.material = prim.material ? (u32)(prim.material - data->materials) : ASSET_INVALID;
+
+            // Compute submesh bounds from converted vertex positions
+            {
+                vec3 min_pos{FLT_MAX, FLT_MAX, FLT_MAX};
+                vec3 max_pos{-FLT_MAX, -FLT_MAX, -FLT_MAX};
+                for (u32 idx : indices) {
+                    const vec3 &p = positions[idx];
+                    min_pos.x = std::min(min_pos.x, p.x);
+                    min_pos.y = std::min(min_pos.y, p.y);
+                    min_pos.z = std::min(min_pos.z, p.z);
+                    max_pos.x = std::max(max_pos.x, p.x);
+                    max_pos.y = std::max(max_pos.y, p.y);
+                    max_pos.z = std::max(max_pos.z, p.z);
+                }
+                submesh.aabb_min = min_pos;
+                submesh.aabb_max = max_pos;
+                vec3 center = (min_pos + max_pos) * 0.5f;
+                f32 radius = (max_pos - min_pos).length() * 0.5f;
+                submesh.sphere = vec4(center.x, center.y, center.z, radius);
+            }
+
+            if (prim.material && prim.material->name) {
+                out.submesh_names.push_back(prim.material->name);
+            } else {
+                out.submesh_names.emplace_back();
+            }
+
+            u32 submesh_index = (u32)out.submeshes.size();
+
+            out.submeshes.push_back(submesh);
+
+            out.mesh_submeshes.push_back(submesh_index);
+        }
+
+        mesh.submesh_count = (u32)out.mesh_submeshes.size() - mesh.first_submesh;
+    }
+
+    // nodes
+    out.nodes.resize(data->nodes_count);
+    out.node_names.resize(data->nodes_count);
+
+    for (cgltf_size ni = 0; ni < data->nodes_count; ++ni) {
+        const cgltf_node &src = data->nodes[ni];
+
+        AssetNode &dst = out.nodes[ni];
+
+        if (src.name) {
+            out.node_names[ni] = src.name;
+        }
+
+        cgltf_node_transform_local(&src, dst.local.m);
+
+        dst.local = inverse(GLTF_TO_ENGINE) * dst.local * GLTF_TO_ENGINE;
+
+        if (src.parent) {
+            dst.parent = (int)(src.parent - data->nodes);
+        }
+
+        if (src.mesh) {
+            dst.mesh = (u32)(src.mesh - data->meshes);
+        }
+
+        if (src.camera) {
+            dst.camera = (i32)(src.camera - data->cameras);
+        }
+
+        if (src.light) {
+            dst.light = (i32)(src.light - data->lights);
+        }
+
+        dst.first_child = (u32)out.child_indices.size();
+        dst.child_count = (u32)src.children_count;
+        for (cgltf_size ci = 0; ci < src.children_count; ++ci) {
+            out.child_indices.push_back((u32)(src.children[ci] - data->nodes));
+        }
+
+        dst.first_instance = (u32)out.instance_locals.size();
+        dst.instance_count = 0;
+        if (src.has_mesh_gpu_instancing) {
+            const cgltf_mesh_gpu_instancing &inst = src.mesh_gpu_instancing;
+            const cgltf_accessor *transl = nullptr;
+            const cgltf_accessor *rot = nullptr;
+            const cgltf_accessor *scale = nullptr;
+            for (cgltf_size ai = 0; ai < inst.attributes_count; ++ai) {
+                const cgltf_attribute &attr = inst.attributes[ai];
+                if (strcmp(attr.name, "TRANSLATION") == 0) {
+                    transl = attr.data;
+                } else if (strcmp(attr.name, "ROTATION") == 0) {
+                    rot = attr.data;
+                } else if (strcmp(attr.name, "SCALE") == 0) {
+                    scale = attr.data;
+                }
+            }
+
+            cgltf_size count = 0;
+            if (transl) {
+                count = transl->count;
+            } else if (rot) {
+                count = rot->count;
+            } else if (scale) {
+                count = scale->count;
+            }
+            dst.instance_count = (u32)count;
+
+            // gltf -> engine frame conversion (a rotation), applied to TRS directly.
+            // Exact for uniform/identity scale; non-uniform scale is approximated by
+            // the TRS decomposition (a TRS cannot represent a rotated non-uniform scale).
+            const quat frame = mat4_to_trs(GLTF_TO_ENGINE).rotation;
+            const quat frame_inv = rtm::quat_conjugate(frame.q);
+
+            out.instance_locals.reserve(out.instance_locals.size() + count);
+            for (cgltf_size ii = 0; ii < count; ++ii) {
+                TRS trs;
+                if (transl) {
+                    f32 v[3];
+                    cgltf_accessor_read_float(transl, ii, v, 3);
+                    trs.translation = vec3(v[0], v[1], v[2]);
+                }
+                if (rot) {
+                    f32 v[4];
+                    cgltf_accessor_read_float(rot, ii, v, 4);
+                    trs.rotation = quat(rtm::quat_normalize(rtm::vector_set(v[0], v[1], v[2], v[3])));
+                }
+                if (scale) {
+                    f32 v[3];
+                    cgltf_accessor_read_float(scale, ii, v, 3);
+                    trs.scale = vec3(v[0], v[1], v[2]);
+                }
+
+                trs.translation = transform_direction(trs.translation, GLTF_TO_ENGINE);
+                trs.rotation = quat(rtm::quat_mul(frame_inv, rtm::quat_mul(trs.rotation.q, frame)));
+                out.instance_locals.push_back(trs);
+            }
+        }
+    }
+
+    // camers
+    out.cameras.resize(data->cameras_count);
+    for (cgltf_size ci = 0; ci < data->cameras_count; ++ci) {
+        const cgltf_camera &src = data->cameras[ci];
+        AssetCamera &dst = out.cameras[ci];
+
+        if (src.type == cgltf_camera_type_perspective) {
+            dst.type = AssetCamera::Perspective;
+            dst.yfov = src.data.perspective.yfov;
+            dst.znear = src.data.perspective.znear;
+            dst.zfar = src.data.perspective.has_zfar ? src.data.perspective.zfar : 1000.0f;
+            dst.aspect_ratio = src.data.perspective.has_aspect_ratio ? src.data.perspective.aspect_ratio : 0.0f;
+        } else {
+            dst.type = AssetCamera::Orthographic;
+            dst.yfov = 0.0f;
+            dst.znear = src.data.orthographic.znear;
+            dst.zfar = src.data.orthographic.zfar;
+        }
+    }
+
+    // lights (KHR_lights_punctual)
+    out.lights.resize(data->lights_count);
+    for (cgltf_size li = 0; li < data->lights_count; ++li) {
+        const cgltf_light &src = data->lights[li];
+        AssetLight &dst = out.lights[li];
+
+        if (src.type == cgltf_light_type_directional) {
+            dst.type = AssetLight::Directional;
+        } else if (src.type == cgltf_light_type_point) {
+            dst.type = AssetLight::Point;
+            dst.range = src.range;
+        }
+        dst.color.x = src.color[0];
+        dst.color.y = src.color[1];
+        dst.color.z = src.color[2];
+        dst.intensity = src.intensity;
+    }
+
+    // root nodes
+    const cgltf_scene *scene = data->scene ? data->scene : &data->scenes[0];
+
+    for (cgltf_size i = 0; i < scene->nodes_count; ++i) {
+        out.root_nodes.push_back((u32)(scene->nodes[i] - data->nodes));
+    }
+
+    VEL_INFO(
+        "Loaded glTF: {} meshes, {} submeshes, {} materials, {} textures, {} cameras, {} lights",
+        out.meshes.size(),
+        out.submeshes.size(),
+        out.materials.size(),
+        out.textures.size(),
+        out.cameras.size(),
+        out.lights.size()
+    );
+
+    cgltf_free(data);
+
+    return true;
+}
ADD · src/asset/texture.cpp +423 -0
--- a/src/asset/texture.cpp
+++ b/src/asset/texture.cpp
@@ -0,0 +1,423 @@
+#include "texture.h"
+
+#include <ktx.h>
+#include <stb_image.h>
+
+#include <cstdio>
+#include <filesystem>
+#include <string>
+
+#include "core/globals.h"
+#include "core/gpu_arena.h"
+#include "quick_submit.h"
+
+static u32 calculate_mip_levels(u32 width, u32 height) {
+    u32 levels = 1;
+    while (width > 1 || height > 1) {
+        width >>= 1;
+        height >>= 1;
+        levels++;
+    }
+    return levels;
+}
+
+static ktx_transcode_fmt_e to_ktx_transcode_format(rhi::ImageFormat fmt) {
+    switch (fmt) {
+    case rhi::ImageFormat::BC7_UNORM:
+    case rhi::ImageFormat::BC7_SRGB:
+        return KTX_TTF_BC7_RGBA;
+    default:
+        return KTX_TTF_RGBA32;
+    }
+}
+
+static rhi::ImageRange whole_range(u32 mip_levels, u32 layers) {
+    rhi::ImageRange r{};
+    r.mip_count = mip_levels;
+    r.layer_count = layers;
+    return r;
+}
+
+static rhi::ImageRange mip_range(u32 mip) {
+    rhi::ImageRange r{};
+    r.mip = mip;
+    r.mip_count = 1;
+    r.layer_count = 1;
+    return r;
+}
+
+static void barrier_image_to_transfer_dst(rhi::CmdBuffer &cmd, rhi::Image *image, u32 mip_levels, u32 layers) {
+    rhi::barrier(
+        cmd, *image, whole_range(mip_levels, layers), rhi::ResourceState::Idle, rhi::ResourceState::TransferTo
+    );
+}
+
+static void barrier_image_to_shader_read(rhi::CmdBuffer &cmd, rhi::Image *image, u32 mip_levels, u32 layers) {
+    rhi::barrier(
+        cmd, *image, whole_range(mip_levels, layers), rhi::ResourceState::TransferTo, rhi::ResourceState::TextureSample
+    );
+}
+
+static void barrier_mip_to_src(rhi::CmdBuffer &cmd, rhi::Image *image, u32 mip) {
+    rhi::barrier(cmd, *image, mip_range(mip), rhi::ResourceState::TransferTo, rhi::ResourceState::TransferFrom);
+}
+
+static void barrier_mip_to_shader_read(rhi::CmdBuffer &cmd, rhi::Image *image, u32 mip) {
+    rhi::barrier(cmd, *image, mip_range(mip), rhi::ResourceState::TransferFrom, rhi::ResourceState::TextureSample);
+}
+
+static void set_view_shader_read(rhi::ImageView *view) {
+    if (view == nullptr || view->desc.image == nullptr) {
+        return;
+    }
+    view->desc.image->state = rhi::ResourceState::TextureSample;
+}
+
+static void generate_mips_2d(rhi::CmdBuffer &cmd, rhi::Image *image, u32 width, u32 height, u32 mip_levels) {
+    u32 mip_w = width;
+    u32 mip_h = height;
+    for (u32 i = 0; i < mip_levels - 1; ++i) {
+        u32 next_w = std::max(mip_w >> 1, 1u);
+        u32 next_h = std::max(mip_h >> 1, 1u);
+
+        barrier_mip_to_src(cmd, image, i);
+
+        rhi::ImageBlit blit{
+            .src_mip = i,
+            .dst_mip = i + 1,
+            .src_x0 = 0,
+            .src_y0 = 0,
+            .src_x1 = static_cast<i32>(mip_w),
+            .src_y1 = static_cast<i32>(mip_h),
+            .dst_x0 = 0,
+            .dst_y0 = 0,
+            .dst_x1 = static_cast<i32>(next_w),
+            .dst_y1 = static_cast<i32>(next_h),
+        };
+        rhi::blit_image(cmd, *image, &blit, 1);
+
+        barrier_mip_to_shader_read(cmd, image, i);
+
+        mip_w = next_w;
+        mip_h = next_h;
+    }
+    // previous mip is still in TransferTo — transition it now
+    rhi::barrier(
+        cmd, *image, mip_range(mip_levels - 1), rhi::ResourceState::TransferTo, rhi::ResourceState::TextureSample
+    );
+}
+
+static bool upload_stb_pixels(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const void *pixels,
+    u32 width,
+    u32 height,
+    u64 pixel_stride, // bytes per pixel × channels (4 or 16)
+    rhi::ImageFormat format,
+    const char *name = nullptr
+) {
+    u32 mip_levels = calculate_mip_levels(width, height);
+    u64 image_size = static_cast<u64>(width) * height * pixel_stride;
+    u64 staging_off = stage_to_arena(staging, pixels, image_size);
+    if (staging_off == SIZE_MAX) {
+        return false;
+    }
+    rhi::buffer_flush(device, staging.buffer, staging_off, image_size);
+
+    rhi::ImageDesc img_desc{};
+    img_desc.width = width;
+    img_desc.height = height;
+    img_desc.mip_levels = mip_levels;
+    if (name != nullptr) {
+        img_desc.name = name;
+    }
+    img_desc.usage = rhi::ImageUsage::Sampled | rhi::ImageUsage::TransferDst | rhi::ImageUsage::TransferSrc;
+    img_desc.format = format;
+    rhi::create_image(device, img_desc, out_image);
+
+    rhi::ImageViewDesc view_desc{};
+    view_desc.image = &out_image;
+    if (!rhi::create_image_view(device, view_desc, out_view)) {
+        rhi::destroy_image(device, out_image);
+        return false;
+    }
+
+    QsCmd *cmd = qs_acquire(qs);
+
+    barrier_image_to_transfer_dst(cmd->cmd, &out_image, mip_levels, 1);
+
+    rhi::BufferTextureCopyRegion region{};
+    region.buffer_offset = staging_off;
+    region.texture_extent_width = width;
+    region.texture_extent_height = height;
+    region.texture_extent_depth = 1;
+    region.base_array_layer = 0;
+    region.mip_level = 0;
+    region.layer_count = 1;
+    rhi::copy_buffer_to_texture(cmd->cmd, staging.buffer, out_view, region);
+
+    if (mip_levels > 1) {
+        generate_mips_2d(cmd->cmd, &out_image, width, height, mip_levels);
+    } else {
+        barrier_image_to_shader_read(cmd->cmd, &out_image, 1, 1);
+    }
+
+    set_view_shader_read(&out_view);
+
+    qs_submit(qs, *cmd);
+    return true;
+}
+
+bool ktx_texture_needs_to_flip_to_top_left(ktxTexture *kTexture) {
+    if (!kTexture) {
+        return false;
+    }
+
+    if (kTexture->orientation.y == 'u') {
+        return true;
+    }
+
+    return false;
+}
+
+static bool upload_ktx2_texture(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    ktxTexture2 *ktx_tex,
+    const char *name = nullptr
+) {
+    ktxTexture *base = ktxTexture(ktx_tex);
+    u32 width = base->baseWidth;
+    u32 height = base->baseHeight;
+    u32 mip_levels = base->numLevels;
+    u32 layers = base->numLayers;
+    u32 faces = base->numFaces;
+    u32 array_layers = (layers > 1) ? layers : faces;
+    bool is_cubemap = (faces == 6);
+
+    rhi::ImageDesc image_desc{};
+    if (name != nullptr) {
+        image_desc.name = name;
+    }
+    image_desc.format = rhi::image_format_from_vk(ktx_tex->vkFormat);
+    image_desc.is_cubemap = is_cubemap;
+    image_desc.width = width;
+    image_desc.height = height;
+    image_desc.mip_levels = mip_levels;
+    image_desc.layers = array_layers;
+    image_desc.usage = rhi::ImageUsage::TransferDst | rhi::ImageUsage::Sampled;
+    rhi::create_image(device, image_desc, out_image);
+
+    rhi::ImageViewDesc view_desc{};
+    view_desc.image = &out_image;
+    view_desc.aspect = rhi::ImageAspect::Color;
+    view_desc.dimension = is_cubemap ? rhi::TextureViewDimension::TEXTURE_CUBE : rhi::TextureViewDimension::TEXTURE_2D;
+    view_desc.layer_count = array_layers;
+    if (!rhi::create_image_view(device, view_desc, out_view)) {
+        rhi::destroy_image(device, out_image);
+        ktxTexture_Destroy(base);
+        return false;
+    }
+
+    ktx_size_t data_size = ktxTexture_GetDataSize(base);
+    u64 staging_off = stage_to_arena(staging, base->pData, data_size);
+    if (staging_off == SIZE_MAX) {
+        ktxTexture_Destroy(base);
+        return false;
+    }
+    rhi::buffer_flush(device, staging.buffer, staging_off, data_size);
+
+    QsCmd *cmd = qs_acquire(qs);
+
+    barrier_image_to_transfer_dst(cmd->cmd, &out_image, mip_levels, array_layers);
+
+    for (u32 level = 0; level < mip_levels; ++level) {
+        for (u32 layer = 0; layer < array_layers; ++layer) {
+            ktx_size_t offset;
+            ktxTexture_GetImageOffset(base, level, layer, 0, &offset);
+
+            rhi::BufferTextureCopyRegion region{};
+            region.buffer_offset = staging_off + offset;
+            region.mip_level = level;
+            region.base_array_layer = layer;
+            region.layer_count = 1;
+            region.texture_extent_width = std::max(width >> level, 1u);
+            region.texture_extent_height = std::max(height >> level, 1u);
+            region.texture_extent_depth = 1;
+            rhi::copy_buffer_to_texture(cmd->cmd, staging.buffer, out_view, region);
+        }
+    }
+
+    barrier_image_to_shader_read(cmd->cmd, &out_image, mip_levels, array_layers);
+
+    set_view_shader_read(&out_view);
+
+    qs_submit(qs, *cmd);
+    ktxTexture_Destroy(base);
+    return true;
+}
+
+////////////
+bool load_texture_from_memory(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const u8 *data,
+    usize size,
+    ImageColorSpace color_space,
+    const char *name
+) {
+    int w, h, channels;
+    stbi_uc *pixels = stbi_load_from_memory(data, static_cast<int>(size), &w, &h, &channels, STBI_rgb_alpha);
+    if (!pixels) {
+        (void)std::fprintf(stderr, "Failed to load texture from memory (size: %zu)\n", size);
+        return false;
+    }
+
+    rhi::ImageFormat fmt =
+        (color_space == ImageColorSpace::SRGB) ? rhi::ImageFormat::RGBA8_SRGB : rhi::ImageFormat::RGBA8_UNORM;
+    bool ok = upload_stb_pixels(
+        device, qs, staging, out_image, out_view, pixels, static_cast<u32>(w), static_cast<u32>(h), 4, fmt, name
+    );
+    stbi_image_free(pixels);
+    return ok;
+}
+
+bool create_texture_from_raw_rgba(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const void *pixels,
+    u32 width,
+    u32 height,
+    u32 pixel_stride,
+    rhi::ImageFormat cs,
+    const char *name
+) {
+    return upload_stb_pixels(device, qs, staging, out_image, out_view, pixels, width, height, pixel_stride, cs, name);
+}
+
+bool load_texture_ktx2_from_memory(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const u8 *data,
+    usize size,
+    ImageColorSpace color_space,
+    const char *name
+) {
+    ktxTexture2 *ktx_tex = nullptr;
+    if (ktxTexture2_CreateFromMemory(data, size, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktx_tex) != KTX_SUCCESS) {
+        return false;
+    }
+
+    if (ktxTexture2_NeedsTranscoding(ktx_tex)) {
+        ktx_transcode_fmt_e tf =
+            to_ktx_transcode_format(rhi::preferred_compressed_format(device, color_space == ImageColorSpace::SRGB));
+
+        if (ktxTexture2_TranscodeBasis(ktx_tex, tf, 0) != KTX_SUCCESS) {
+            (void)std::fprintf(stderr, "KTX2 transcode failed\n");
+            ktxTexture_Destroy(ktxTexture(ktx_tex));
+            return false;
+        }
+    }
+
+    return upload_ktx2_texture(device, qs, staging, out_image, out_view, ktx_tex, name);
+}
+
+bool load_texture(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    const char *path,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    ImageColorSpace color_space
+) {
+    std::filesystem::path p(path);
+    std::string ext = p.extension().string();
+
+    if (ext == ".ktx2") {
+        ktxTexture2 *ktx_tex = nullptr;
+        KTX_error_code err = ktxTexture2_CreateFromNamedFile(path, KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT, &ktx_tex);
+
+        if (err != KTX_SUCCESS) {
+            (void)std::fprintf(stderr, "Failed to load KTX2: %s (error: %d)\n", path, err);
+            return false;
+        }
+
+        if (ktxTexture2_NeedsTranscoding(ktx_tex)) {
+            ktx_transcode_fmt_e tf =
+                to_ktx_transcode_format(rhi::preferred_compressed_format(device, color_space == ImageColorSpace::SRGB));
+
+            if (ktxTexture2_TranscodeBasis(ktx_tex, tf, 0) != KTX_SUCCESS) {
+                (void)std::fprintf(stderr, "KTX2 transcode failed: %s\n", path);
+                ktxTexture_Destroy(ktxTexture(ktx_tex));
+                return false;
+            }
+        }
+
+        return upload_ktx2_texture(device, qs, staging, out_image, out_view, ktx_tex, path);
+    }
+
+    if (ext == ".hdr") {
+        int w, h, channels;
+        f32 *pixels = stbi_loadf(path, &w, &h, &channels, STBI_rgb_alpha);
+        if (!pixels) {
+            (void)std::fprintf(stderr, "Failed to load HDR texture: %s\n", path);
+            return false;
+        }
+
+        bool ok = upload_stb_pixels(
+            device,
+            qs,
+            staging,
+            out_image,
+            out_view,
+            pixels,
+            static_cast<u32>(w),
+            static_cast<u32>(h),
+            sizeof(f32) * 4,
+            rhi::ImageFormat::RGBA32_FLOAT,
+            path
+        );
+        stbi_image_free(pixels);
+        return ok;
+    }
+
+    // fallback: assume PNG / 8-bit
+    int w, h, channels;
+    stbi_uc *pixels = stbi_load(path, &w, &h, &channels, STBI_rgb_alpha);
+    if (!pixels) {
+        (void)std::fprintf(stderr, "Failed to load texture: %s\n", path);
+        return false;
+    }
+
+    rhi::ImageFormat fmt =
+        (color_space == ImageColorSpace::SRGB) ? rhi::ImageFormat::RGBA8_SRGB : rhi::ImageFormat::RGBA8_UNORM;
+    bool ok = upload_stb_pixels(
+        device, qs, staging, out_image, out_view, pixels, static_cast<u32>(w), static_cast<u32>(h), 4, fmt, path
+    );
+    stbi_image_free(pixels);
+    return ok;
+}
+
+void destroy_texture(rhi::Device &device, rhi::Image &image, rhi::ImageView &view) {
+    rhi::destroy_image_view(device, view);
+    rhi::destroy_image(device, image);
+    image = {};
+    view = {};
+}
ADD · src/asset/texture.h +62 -0
--- a/src/asset/texture.h
+++ b/src/asset/texture.h
@@ -0,0 +1,62 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include "core/globals.h"
+
+enum struct ImageColorSpace {
+    SRGB,
+    Linear,
+};
+
+struct Arena;
+struct QuickSubmit;
+
+bool load_texture_from_memory(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const u8 *data,
+    usize size,
+    ImageColorSpace color_space,
+    const char *name = nullptr
+);
+
+bool load_texture_ktx2_from_memory(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const u8 *data,
+    usize size,
+    ImageColorSpace color_space,
+    const char *name = nullptr
+);
+
+bool create_texture_from_raw_rgba(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    const void *pixels,
+    u32 width,
+    u32 height,
+    u32 pixel_stride,
+    rhi::ImageFormat cs,
+    const char *name = nullptr
+);
+
+bool load_texture(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    Arena &staging,
+    const char *path,
+    rhi::Image &out_image,
+    rhi::ImageView &out_view,
+    ImageColorSpace color_space
+);
+
+void destroy_texture(rhi::Device &device, rhi::Image &image, rhi::ImageView &view);
ADD · src/backend/conformance/descriptor_handle/descriptor_handle.cpp +283 -0
--- a/src/backend/conformance/descriptor_handle/descriptor_handle.cpp
+++ b/src/backend/conformance/descriptor_handle/descriptor_handle.cpp
@@ -0,0 +1,283 @@
+#include "backend/rhi.h"
+#include "core/logger.h"
+#include "core/math_rtm.h"
+#include "core/platform.h"
+
+#include <chrono>
+#include <cmath>
+#include <cstring>
+
+static constexpr u32 DH_TEX_W = 2;
+static constexpr u32 DH_TEX_H = 2;
+static constexpr u8 DH_TEX[2][DH_TEX_W * DH_TEX_H * 4] = {
+    {255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255},
+    {0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255},
+};
+static constexpr f32 DH_OFFSET[4] = {0.2f, -0.15f, 0.0f, 0.0f};
+
+struct DhPush {
+    vec4 tint; // 0
+    u64 tex;   // 16, slot (vk) / ResourceID (mtl)
+    u64 samp;  // 24, slot (vk) / ResourceID (mtl)
+    u64 ubo;   // 32, slot (vk) / device address (mtl)
+    u64 cbuf;  // 40, slot (vk) / device address (mtl)
+    u64 bbuf;  // 48, slot (vk) / device address (mtl)
+    u64 addr;  // 56, device address (both)
+};
+static_assert(sizeof(DhPush) == 64, "DhPush size drift");
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+    rhi::CmdPool pool{};
+    rhi::CmdBuffer cmd{};
+    rhi::Sync *frame_sync = nullptr;
+    rhi::ShaderCompiler sc{};
+    rhi::RenderPipeline pipeline{};
+    Platform platform{};
+    platform.width = 800;
+    platform.height = 800;
+
+    init_platform(config.instance_extensions);
+    rhi::create_context(device, config);
+    rhi::create_memory_allocator(device);
+    rhi::init_compiler(sc);
+    create_window(device, platform, "descriptor-handle", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    rhi::create_swapchain(device, swapchain_desc, swapchain);
+
+    rhi::Queue graphics_queue = rhi::graphics_queue(device);
+    rhi::CmdPoolDesc cmd_pool_desc;
+    cmd_pool_desc.queue_family_index = rhi::queue_family_index(graphics_queue);
+    cmd_pool_desc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_desc, pool);
+    rhi::CmdBufferDesc cmd_desc{};
+    cmd_desc.pool = &pool;
+    cmd_desc.level = rhi::CmdBufferLevel::Primary;
+    rhi::create_cmd_buffer(device, cmd_desc, cmd);
+    frame_sync = rhi::sync_create(device, 0);
+
+    rhi::Buffer offset_buf{};
+    rhi::BufferView offset_view{};
+    rhi::BufferView offset_cview{};
+    rhi::BufferView offset_bview{};
+    {
+        rhi::BufferDesc d{};
+        d.size = sizeof(DH_OFFSET);
+        d.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::UniformBuffer | rhi::BufferUsage::ShaderAddr;
+        d.memory = rhi::BufferMemType::Upload;
+        rhi::create_buffer(device, d, offset_buf);
+        std::memcpy(offset_buf.mapped, DH_OFFSET, sizeof(DH_OFFSET));
+        rhi::BufferViewDesc vd{};
+        vd.buffer = &offset_buf;
+        vd.offset = 0;
+        vd.size = sizeof(DH_OFFSET);
+        vd.type = rhi::BufferViewType::Storage;
+        if (!rhi::create_buffer_view(device, vd, offset_view)) {
+            VEL_CRITICAL("descriptor-handle: failed to create buffer view");
+            return 1;
+        }
+        vd.type = rhi::BufferViewType::Uniform;
+        if (!rhi::create_buffer_view(device, vd, offset_cview)) {
+            VEL_CRITICAL("descriptor-handle: failed to create constant buffer view");
+            return 1;
+        }
+        vd.type = rhi::BufferViewType::Storage;
+        if (!rhi::create_buffer_view(device, vd, offset_bview)) {
+            VEL_CRITICAL("descriptor-handle: failed to create byte buffer view");
+            return 1;
+        }
+    }
+
+    rhi::Sampler sampler{};
+    {
+        rhi::SamplerDesc sdesc{};
+        sdesc.filter = rhi::SamplerFilter::LINEAR;
+        sdesc.address = rhi::SamplerAddressMode::CLAMP;
+        rhi::create_sampler(device, sdesc, sampler);
+    }
+
+    rhi::Image tex_img[2];
+    rhi::ImageView tex_view[2];
+    rhi::Buffer staging{};
+    {
+        rhi::BufferDesc d{};
+        d.size = 2 * DH_TEX_W * DH_TEX_H * 4;
+        d.usage = rhi::BufferUsage::CopySrc;
+        d.memory = rhi::BufferMemType::Upload;
+        rhi::create_buffer(device, d, staging);
+    }
+    {
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+        for (int i = 0; i < 2; ++i) {
+            rhi::ImageDesc idesc{};
+            idesc.width = DH_TEX_W;
+            idesc.height = DH_TEX_H;
+            idesc.format = rhi::ImageFormat::RGBA8_UNORM;
+            idesc.usage = rhi::ImageUsage::Sampled | rhi::ImageUsage::TransferDst;
+            rhi::create_image(device, idesc, tex_img[i]);
+            rhi::ImageViewDesc vdesc{};
+            vdesc.image = &tex_img[i];
+            vdesc.aspect = rhi::ImageAspect::Color;
+            rhi::create_image_view(device, vdesc, tex_view[i]);
+            std::memcpy((u8 *)staging.mapped + i * DH_TEX_W * DH_TEX_H * 4, DH_TEX[i], DH_TEX_W * DH_TEX_H * 4);
+            rhi::ImageRange range{};
+            rhi::barrier(cmd, tex_img[i], range, rhi::ResourceState::Idle, rhi::ResourceState::TransferTo);
+            rhi::BufferTextureCopyRegion region{};
+            region.buffer_offset = (u64)i * DH_TEX_W * DH_TEX_H * 4;
+            region.layer_count = 1;
+            region.texture_extent_width = DH_TEX_W;
+            region.texture_extent_height = DH_TEX_H;
+            region.texture_extent_depth = 1;
+            rhi::copy_buffer_to_texture(cmd, staging, tex_view[i], region);
+            rhi::barrier(cmd, tex_img[i], range, rhi::ResourceState::TransferTo, rhi::ResourceState::TextureSample);
+            tex_img[i].state = rhi::ResourceState::TextureSample;
+        }
+        rhi::end_cmd_buffer(cmd);
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        rhi::queue_submit(device, graphics_queue, submit);
+        rhi::queue_wait_idle(device);
+    }
+
+    rhi::RenderPipelineDesc pd{};
+    pd.device = &device;
+    pd.set_shaders(sc, "conformance/descriptor_handle.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::LESS);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::swapchain_format(swapchain));
+    pipeline = pd.build();
+    if (!rhi::valid(pipeline)) {
+        VEL_CRITICAL("descriptor-handle: pipeline build failed");
+        return 1;
+    }
+
+    const auto start = std::chrono::steady_clock::now();
+    u64 frame_count = 0;
+    while (platform_update(platform)) {
+        if (platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain)) {
+            platform.framebuffer_resized = false;
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                break;
+            }
+            rhi::queue_wait_idle(device);
+            rhi::destroy_swapchain(device, swapchain);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            rhi::create_swapchain(device, swapchain_desc, swapchain);
+            continue;
+        }
+        const f32 time = std::chrono::duration<f32>(std::chrono::steady_clock::now() - start).count();
+        const u32 alt = (u32)((u64)time % 2);
+        DhPush push{};
+        const f32 pulse = 0.75f + 0.25f * std::sin(time * 2.0f);
+        push.tint = vec4(pulse, pulse, pulse, 1.0f);
+        push.tex = rhi::handle_id(device, tex_view[alt]);
+        push.samp = rhi::handle_id(device, sampler);
+        push.ubo = rhi::handle_id(device, offset_view);
+        push.cbuf = rhi::handle_id(device, offset_cview);
+        push.bbuf = rhi::handle_id(device, offset_bview);
+        push.addr = rhi::buffer_device_address(device, offset_buf);
+        if (tex_view[alt].slot == UINT64_MAX || sampler.slot == UINT64_MAX || offset_view.slot == UINT64_MAX ||
+            offset_cview.slot == UINT64_MAX || offset_bview.slot == UINT64_MAX || push.addr == 0) {
+            VEL_CRITICAL(
+                "descriptor-handle: null handle (tex={} samp={} ubo={} cbuf={} bbuf={} addr={})",
+                push.tex,
+                push.samp,
+                push.ubo,
+                push.cbuf,
+                push.bbuf,
+                push.addr
+            );
+            return 1;
+        }
+
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+        u32 image_index = 0;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, cmd)) {
+            rhi::reset_cmd_buffer(cmd);
+            continue;
+        }
+        rhi::Image *swap_image = rhi::swapchain_image(swapchain, image_index);
+        rhi::Extent2D extent = rhi::swapchain_extent(swapchain);
+        rhi::ImageView swap_view = rhi::get_cached_image_view(device, *swap_image, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &swap_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.1f;
+        color_att.clearValue.color.float32[1] = 0.1f;
+        color_att.clearValue.color.float32[2] = 0.1f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = extent.width;
+        ri.height = extent.height;
+
+        rhi::begin_rendering(cmd, ri);
+        rhi::set_pipeline(cmd, pipeline);
+        rhi::Viewport vp{};
+        vp.width = (f32)extent.width;
+        vp.height = (f32)extent.height;
+        rhi::set_viewports(cmd, &vp);
+        rhi::Rect scissor{};
+        scissor.width = (i16)extent.width;
+        scissor.height = (i16)extent.height;
+        rhi::set_scissors(cmd, &scissor);
+        rhi::set_constants(cmd, pipeline, rhi::ShaderStage::VERTEX | rhi::ShaderStage::FRAGMENT, sizeof(push), &push);
+        rhi::draw(cmd, 3, 1, 0, 0);
+        rhi::end_rendering(cmd);
+
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, *swap_image, range, swap_image->state, rhi::ResourceState::Display);
+        rhi::end_cmd_buffer(cmd);
+
+        rhi::QueueSignal completion{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        submit.signal_count = 1;
+        submit.signals = &completion;
+        rhi::queue_submit(device, graphics_queue, submit);
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        ++frame_count;
+        rhi::sync_host_wait(frame_sync, frame_count);
+    }
+
+    rhi::device_wait_idle(device);
+    rhi::destroy_pipeline(device, pipeline);
+    rhi::destroy_buffer(device, staging);
+    for (int i = 0; i < 2; ++i) {
+        rhi::destroy_image_view(device, tex_view[i]);
+        rhi::destroy_image(device, tex_img[i]);
+    }
+    rhi::destroy_sampler(device, sampler);
+    rhi::destroy_buffer_view(device, offset_bview);
+    rhi::destroy_buffer_view(device, offset_cview);
+    rhi::destroy_buffer_view(device, offset_view);
+    rhi::destroy_buffer(device, offset_buf);
+    rhi::sync_destroy(frame_sync);
+    rhi::destroy_cmd_buffer(device, pool, cmd);
+    rhi::destroy_cmd_pool(device, pool);
+    rhi::destroy_swapchain(device, swapchain);
+    rhi::destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    rhi::destroy_context(device);
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/backend/conformance/indexed_quad/indexed_quad.cpp +219 -0
--- a/src/backend/conformance/indexed_quad/indexed_quad.cpp
+++ b/src/backend/conformance/indexed_quad/indexed_quad.cpp
@@ -0,0 +1,219 @@
+#include "backend/rhi.h"
+#include "core/logger.h"
+#include "core/platform.h"
+
+#include <chrono>
+#include <cmath>
+#include <cstring>
+#include <stddef.h>
+
+static constexpr u32 QUAD_VERTEX_BINDING = 1;
+
+struct QuadVertex {
+    f32 pos[2];
+    f32 color[3];
+};
+
+static constexpr QuadVertex QUAD_VERTICES[4] = {
+    {{-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}},
+    {{0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}},
+    {{0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}},
+    {{-0.5f, 0.5f}, {1.0f, 1.0f, 1.0f}},
+};
+
+static constexpr u32 QUAD_INDICES[6] = {0, 1, 2, 2, 3, 0};
+
+struct QuadPush {
+    f32 time;
+    f32 _pad0;
+    f32 offset[2];
+    f32 tint[4];
+};
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+    rhi::CmdPool pool{};
+    rhi::CmdBuffer cmd{};
+    rhi::Sync *frame_sync = nullptr;
+    rhi::ShaderCompiler sc{};
+    rhi::Buffer vertex_buffer{};
+    rhi::Buffer index_buffer{};
+    rhi::RenderPipeline pipeline{};
+
+    Platform platform{};
+    platform.width = 800;
+    platform.height = 800;
+
+    init_platform(config.instance_extensions);
+    rhi::create_context(device, config);
+    if (!rhi::create_memory_allocator(device)) {
+        VEL_CRITICAL("indexed-quad-example: failed to create memory allocator");
+        return 1;
+    }
+    if (!rhi::init_compiler(sc)) {
+        VEL_CRITICAL("indexed-quad-example: failed to init shader compiler");
+        return 1;
+    }
+    create_window(device, platform, "indexed-quad-example", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    rhi::create_swapchain(device, swapchain_desc, swapchain);
+
+    rhi::Queue graphics_queue = rhi::graphics_queue(device);
+
+    rhi::CmdPoolDesc cmd_pool_desc;
+    cmd_pool_desc.queue_family_index = rhi::queue_family_index(graphics_queue);
+    cmd_pool_desc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_desc, pool);
+    rhi::CmdBufferDesc cmd_desc{};
+    cmd_desc.pool = &pool;
+    cmd_desc.level = rhi::CmdBufferLevel::Primary;
+    rhi::create_cmd_buffer(device, cmd_desc, cmd);
+
+    frame_sync = rhi::sync_create(device, 0);
+
+    rhi::BufferDesc vb_desc{};
+    vb_desc.size = sizeof(QUAD_VERTICES);
+    vb_desc.usage = rhi::BufferUsage::VertexBuffer;
+    vb_desc.memory = rhi::BufferMemType::Upload;
+    rhi::create_buffer(device, vb_desc, vertex_buffer);
+    std::memcpy(vertex_buffer.mapped, QUAD_VERTICES, sizeof(QUAD_VERTICES));
+
+    rhi::BufferDesc ib_desc{};
+    ib_desc.size = sizeof(QUAD_INDICES);
+    ib_desc.usage = rhi::BufferUsage::IndexBuffer;
+    ib_desc.memory = rhi::BufferMemType::Upload;
+    rhi::create_buffer(device, ib_desc, index_buffer);
+    std::memcpy(index_buffer.mapped, QUAD_INDICES, sizeof(QUAD_INDICES));
+
+    rhi::RenderPipelineDesc pd{};
+    pd.device = &device;
+    pd.set_shaders(sc, "conformance/indexed_quad.slang", "vsMain", "fsMain");
+    pd.add_vertex_binding(QUAD_VERTEX_BINDING, sizeof(QuadVertex));
+    pd.add_vertex_attribute(0, QUAD_VERTEX_BINDING, rhi::ImageFormat::RG32_FLOAT, offsetof(QuadVertex, pos));
+    pd.add_vertex_attribute(1, QUAD_VERTEX_BINDING, rhi::ImageFormat::RGB32_FLOAT, offsetof(QuadVertex, color));
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::LESS);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::swapchain_format(swapchain));
+    pipeline = pd.build();
+
+    const auto start_time = std::chrono::steady_clock::now();
+
+    u64 frame_count = 0;
+    while (platform_update(platform)) {
+        if (platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain)) {
+            platform.framebuffer_resized = false;
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                break;
+            }
+            rhi::queue_wait_idle(device);
+            rhi::destroy_swapchain(device, swapchain);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            rhi::create_swapchain(device, swapchain_desc, swapchain);
+            continue;
+        }
+
+        const f32 time = std::chrono::duration<f32>(std::chrono::steady_clock::now() - start_time).count();
+        QuadPush push{};
+        push.time = time;
+        push.offset[0] = 0.25f * std::sin(time * 0.7f);
+        push.offset[1] = 0.25f * std::cos(time * 0.9f);
+        const f32 pulse = 0.75f + 0.25f * std::sin(time * 2.0f);
+        push.tint[0] = pulse;
+        push.tint[1] = pulse;
+        push.tint[2] = pulse;
+        push.tint[3] = 1.0f;
+
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+
+        u32 image_index = 0;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, cmd)) {
+            rhi::reset_cmd_buffer(cmd);
+            continue;
+        }
+
+        rhi::Image *swap_image = rhi::swapchain_image(swapchain, image_index);
+        rhi::Extent2D extent = rhi::swapchain_extent(swapchain);
+        rhi::ImageView swap_view = rhi::get_cached_image_view(device, *swap_image, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &swap_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.1f;
+        color_att.clearValue.color.float32[1] = 0.1f;
+        color_att.clearValue.color.float32[2] = 0.1f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = extent.width;
+        ri.height = extent.height;
+
+        rhi::begin_rendering(cmd, ri);
+        rhi::set_pipeline(cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)extent.width;
+        vp.height = (f32)extent.height;
+        rhi::set_viewports(cmd, &vp);
+
+        rhi::Rect scissor{};
+        scissor.width = (i16)extent.width;
+        scissor.height = (i16)extent.height;
+        rhi::set_scissors(cmd, &scissor);
+
+        rhi::set_vertex_buffer(cmd, vertex_buffer, QUAD_VERTEX_BINDING, 0);
+        rhi::set_index_buffer(cmd, index_buffer, 0, rhi::IndexType::UINT32);
+        rhi::set_constants(cmd, pipeline, rhi::ShaderStage::VERTEX | rhi::ShaderStage::FRAGMENT, sizeof(push), &push);
+        rhi::draw_indexed(cmd, 6, 1, 0, 0, 0);
+        rhi::end_rendering(cmd);
+
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, *swap_image, range, swap_image->state, rhi::ResourceState::Display);
+        rhi::end_cmd_buffer(cmd);
+
+        rhi::QueueSignal completion{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        submit.signal_count = 1;
+        submit.signals = &completion;
+        rhi::queue_submit(device, graphics_queue, submit);
+
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        ++frame_count;
+
+        rhi::sync_host_wait(frame_sync, frame_count);
+    }
+
+    rhi::device_wait_idle(device);
+
+    rhi::destroy_pipeline(device, pipeline);
+    rhi::destroy_buffer(device, index_buffer);
+    rhi::destroy_buffer(device, vertex_buffer);
+    rhi::sync_destroy(frame_sync);
+    rhi::destroy_cmd_buffer(device, pool, cmd);
+    rhi::destroy_cmd_pool(device, pool);
+    rhi::destroy_swapchain(device, swapchain);
+    rhi::destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    rhi::destroy_context(device);
+
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/backend/conformance/ndc/ndc.cpp +155 -0
--- a/src/backend/conformance/ndc/ndc.cpp
+++ b/src/backend/conformance/ndc/ndc.cpp
@@ -0,0 +1,155 @@
+#include "backend/rhi.h"
+#include "core/logger.h"
+#include "core/platform.h"
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+    rhi::CmdPool pool{};
+    rhi::CmdBuffer cmd{};
+    rhi::Sync *frame_sync = nullptr;
+    rhi::ShaderCompiler sc{};
+    rhi::RenderPipeline pipeline{};
+
+    Platform platform{};
+    platform.width = 1280;
+    platform.height = 720;
+
+    init_platform(config.instance_extensions);
+    rhi::create_context(device, config);
+    if (!rhi::create_memory_allocator(device)) {
+        VEL_CRITICAL("ndc-example: failed to create memory allocator");
+        return 1;
+    }
+    if (!rhi::init_compiler(sc)) {
+        VEL_CRITICAL("ndc-example: failed to init shader compiler");
+        return 1;
+    }
+    create_window(device, platform, "ndc-example", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    rhi::create_swapchain(device, swapchain_desc, swapchain);
+
+    rhi::Queue graphics_queue = rhi::graphics_queue(device);
+
+    rhi::CmdPoolDesc cmd_pool_desc;
+    cmd_pool_desc.queue_family_index = rhi::queue_family_index(graphics_queue);
+    cmd_pool_desc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_desc, pool);
+    rhi::CmdBufferDesc cmd_desc{};
+    cmd_desc.pool = &pool;
+    cmd_desc.level = rhi::CmdBufferLevel::Primary;
+    rhi::create_cmd_buffer(device, cmd_desc, cmd);
+
+    frame_sync = rhi::sync_create(device, 0);
+
+    rhi::RenderPipelineDesc pd{};
+    pd.device = &device;
+    pd.set_shaders(sc, "conformance/ndc.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::LESS);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::swapchain_format(swapchain));
+    pipeline = pd.build();
+
+    u64 frame_count = 0;
+    while (platform_update(platform)) {
+        if (platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain)) {
+            platform.framebuffer_resized = false;
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                break;
+            }
+            rhi::queue_wait_idle(device);
+            rhi::destroy_swapchain(device, swapchain);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            rhi::create_swapchain(device, swapchain_desc, swapchain);
+            continue;
+        }
+
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+
+        u32 image_index = 0;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, cmd)) {
+            rhi::reset_cmd_buffer(cmd);
+            continue;
+        }
+
+        rhi::Image *swap_image = rhi::swapchain_image(swapchain, image_index);
+        rhi::Extent2D extent = rhi::swapchain_extent(swapchain);
+        rhi::ImageView swap_view = rhi::get_cached_image_view(device, *swap_image, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &swap_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.1f;
+        color_att.clearValue.color.float32[1] = 0.1f;
+        color_att.clearValue.color.float32[2] = 0.1f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = extent.width;
+        ri.height = extent.height;
+
+        rhi::begin_rendering(cmd, ri);
+        rhi::set_pipeline(cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)extent.width;
+        vp.height = (f32)extent.height;
+        rhi::set_viewports(cmd, &vp);
+
+        rhi::Rect scissor{};
+        scissor.width = (i16)extent.width;
+        scissor.height = (i16)extent.height;
+        rhi::set_scissors(cmd, &scissor);
+
+        // Fullscreen triangle: 3 vertices, no vertex/index buffers bound.
+        rhi::draw(cmd, 3, 1, 0, 0);
+        rhi::end_rendering(cmd);
+
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, *swap_image, range, swap_image->state, rhi::ResourceState::Display);
+        rhi::end_cmd_buffer(cmd);
+
+        rhi::QueueSignal completion{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        submit.signal_count = 1;
+        submit.signals = &completion;
+        rhi::queue_submit(device, graphics_queue, submit);
+
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        ++frame_count;
+
+        rhi::sync_host_wait(frame_sync, frame_count);
+    }
+
+    rhi::device_wait_idle(device);
+
+    rhi::destroy_pipeline(device, pipeline);
+    rhi::sync_destroy(frame_sync);
+    rhi::destroy_cmd_buffer(device, pool, cmd);
+    rhi::destroy_cmd_pool(device, pool);
+    rhi::destroy_swapchain(device, swapchain);
+    rhi::destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    rhi::destroy_context(device);
+
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/backend/conformance/scene/scene.cpp +330 -0
--- a/src/backend/conformance/scene/scene.cpp
+++ b/src/backend/conformance/scene/scene.cpp
@@ -0,0 +1,330 @@
+#include "backend/rhi.h"
+#include "core/logger.h"
+#include "core/math_rtm.h"
+#include "core/platform.h"
+
+#include <chrono>
+#include <cmath>
+#include <cstring>
+
+struct SceneVertex {
+    f32 pos[3];
+    f32 nrm[3];
+    f32 uv[2];
+};
+
+// Unit cube, 24 verts (split per face for flat normals + full-quad uvs).
+static constexpr SceneVertex SCENE_VERTS[24] = {
+    // +Z front
+    {{-0.5f, -0.5f, 0.5f}, {0, 0, 1}, {0, 0}},
+    {{0.5f, -0.5f, 0.5f}, {0, 0, 1}, {1, 0}},
+    {{0.5f, 0.5f, 0.5f}, {0, 0, 1}, {1, 1}},
+    {{-0.5f, 0.5f, 0.5f}, {0, 0, 1}, {0, 1}},
+    // -Z back
+    {{0.5f, -0.5f, -0.5f}, {0, 0, -1}, {0, 0}},
+    {{-0.5f, -0.5f, -0.5f}, {0, 0, -1}, {1, 0}},
+    {{-0.5f, 0.5f, -0.5f}, {0, 0, -1}, {1, 1}},
+    {{0.5f, 0.5f, -0.5f}, {0, 0, -1}, {0, 1}},
+    // +X right
+    {{0.5f, -0.5f, 0.5f}, {1, 0, 0}, {0, 0}},
+    {{0.5f, -0.5f, -0.5f}, {1, 0, 0}, {1, 0}},
+    {{0.5f, 0.5f, -0.5f}, {1, 0, 0}, {1, 1}},
+    {{0.5f, 0.5f, 0.5f}, {1, 0, 0}, {0, 1}},
+    // -X left
+    {{-0.5f, -0.5f, -0.5f}, {-1, 0, 0}, {0, 0}},
+    {{-0.5f, -0.5f, 0.5f}, {-1, 0, 0}, {1, 0}},
+    {{-0.5f, 0.5f, 0.5f}, {-1, 0, 0}, {1, 1}},
+    {{-0.5f, 0.5f, -0.5f}, {-1, 0, 0}, {0, 1}},
+    // +Y top
+    {{-0.5f, 0.5f, 0.5f}, {0, 1, 0}, {0, 0}},
+    {{0.5f, 0.5f, 0.5f}, {0, 1, 0}, {1, 0}},
+    {{0.5f, 0.5f, -0.5f}, {0, 1, 0}, {1, 1}},
+    {{-0.5f, 0.5f, -0.5f}, {0, 1, 0}, {0, 1}},
+    // -Y bottom
+    {{-0.5f, -0.5f, -0.5f}, {0, -1, 0}, {0, 0}},
+    {{0.5f, -0.5f, -0.5f}, {0, -1, 0}, {1, 0}},
+    {{0.5f, -0.5f, 0.5f}, {0, -1, 0}, {1, 1}},
+    {{-0.5f, -0.5f, 0.5f}, {0, -1, 0}, {0, 1}},
+};
+static constexpr u32 SCENE_INDICES[36] = {
+    0,  1,  2,  2,  3,  0,  // +Z
+    4,  5,  6,  6,  7,  4,  // -Z
+    8,  9,  10, 10, 11, 8,  // +X
+    12, 13, 14, 14, 15, 12, // -X
+    16, 17, 18, 18, 19, 16, // +Y
+    20, 21, 22, 22, 23, 20, // -Y
+};
+
+static constexpr u32 SCENE_TEX_W = 4;
+static constexpr u32 SCENE_TEX_H = 4;
+// Quadrant-asymmetric checker: TL red, TR green, BL blue, BR white.
+static constexpr u8 SCENE_TEX[SCENE_TEX_W * SCENE_TEX_H * 4] = {
+    255, 0,   0,   255, 255, 0,   0,   255, 0, 255, 0,   255, 0,   255, 0,   255, 255, 0,   0,   255, 255, 0,
+    0,   255, 0,   255, 0,   255, 0,   255, 0, 255, 0,   0,   255, 255, 0,   0,   255, 255, 255, 255, 255, 255,
+    255, 255, 255, 255, 0,   0,   255, 255, 0, 0,   255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+};
+
+struct ScenePush {
+    mat4 viewProj; // 0
+    u64 tex;       // 64, rhi::handle_id
+    u64 samp;      // 72, rhi::handle_id
+    vec4 lightDir; // 80, xyz = direction TO light
+};
+static_assert(sizeof(ScenePush) == 96, "ScenePush size drift");
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+    rhi::CmdPool pool{};
+    rhi::CmdBuffer cmd{};
+    rhi::Sync *frame_sync = nullptr;
+    rhi::ShaderCompiler sc{};
+    rhi::RenderPipeline pipeline{};
+    Platform platform{};
+    platform.width = 800;
+    platform.height = 800;
+
+    init_platform(config.instance_extensions);
+    rhi::create_context(device, config);
+    rhi::create_memory_allocator(device);
+    rhi::init_compiler(sc);
+    create_window(device, platform, "scene", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    rhi::create_swapchain(device, swapchain_desc, swapchain);
+
+    rhi::Queue graphics_queue = rhi::graphics_queue(device);
+    rhi::CmdPoolDesc cmd_pool_desc;
+    cmd_pool_desc.queue_family_index = rhi::queue_family_index(graphics_queue);
+    cmd_pool_desc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_desc, pool);
+    rhi::CmdBufferDesc cmd_desc{};
+    cmd_desc.pool = &pool;
+    cmd_desc.level = rhi::CmdBufferLevel::Primary;
+    rhi::create_cmd_buffer(device, cmd_desc, cmd);
+    frame_sync = rhi::sync_create(device, 0);
+
+    rhi::Buffer vertex_buffer{}, index_buffer{}, staging{};
+    {
+        rhi::BufferDesc d{};
+        d.size = sizeof(SCENE_VERTS);
+        d.usage = rhi::BufferUsage::VertexBuffer;
+        d.memory = rhi::BufferMemType::Upload;
+        rhi::create_buffer(device, d, vertex_buffer);
+        std::memcpy(vertex_buffer.mapped, SCENE_VERTS, sizeof(SCENE_VERTS));
+    }
+    {
+        rhi::BufferDesc d{};
+        d.size = sizeof(SCENE_INDICES);
+        d.usage = rhi::BufferUsage::IndexBuffer;
+        d.memory = rhi::BufferMemType::Upload;
+        rhi::create_buffer(device, d, index_buffer);
+        std::memcpy(index_buffer.mapped, SCENE_INDICES, sizeof(SCENE_INDICES));
+    }
+    {
+        rhi::BufferDesc d{};
+        d.size = SCENE_TEX_W * SCENE_TEX_H * 4;
+        d.usage = rhi::BufferUsage::CopySrc;
+        d.memory = rhi::BufferMemType::Upload;
+        rhi::create_buffer(device, d, staging);
+        std::memcpy(staging.mapped, SCENE_TEX, sizeof(SCENE_TEX));
+    }
+
+    rhi::Sampler sampler{};
+    {
+        rhi::SamplerDesc sdesc{};
+        sdesc.filter = rhi::SamplerFilter::LINEAR;
+        sdesc.address = rhi::SamplerAddressMode::CLAMP;
+        rhi::create_sampler(device, sdesc, sampler);
+    }
+
+    rhi::Image tex_img{};
+    rhi::ImageView tex_view{};
+    rhi::Image depth_img{};
+    rhi::ImageView depth_view{};
+    auto create_depth = [&](u32 w, u32 h) {
+        rhi::ImageDesc idesc{};
+        idesc.width = w;
+        idesc.height = h;
+        idesc.format = rhi::ImageFormat::D32_FLOAT;
+        idesc.usage = rhi::ImageUsage::DepthAttachment | rhi::ImageUsage::Sampled;
+        rhi::create_image(device, idesc, depth_img);
+        rhi::ImageViewDesc vdesc{};
+        vdesc.image = &depth_img;
+        vdesc.aspect = rhi::ImageAspect::Depth;
+        rhi::create_image_view(device, vdesc, depth_view);
+    };
+    create_depth(platform.width, platform.height);
+    {
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+        rhi::ImageDesc idesc{};
+        idesc.width = SCENE_TEX_W;
+        idesc.height = SCENE_TEX_H;
+        idesc.format = rhi::ImageFormat::RGBA8_UNORM;
+        idesc.usage = rhi::ImageUsage::Sampled | rhi::ImageUsage::TransferDst;
+        rhi::create_image(device, idesc, tex_img);
+        rhi::ImageViewDesc vdesc{};
+        vdesc.image = &tex_img;
+        vdesc.aspect = rhi::ImageAspect::Color;
+        rhi::create_image_view(device, vdesc, tex_view);
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, tex_img, range, rhi::ResourceState::Idle, rhi::ResourceState::TransferTo);
+        rhi::BufferTextureCopyRegion region{};
+        region.layer_count = 1;
+        region.texture_extent_width = SCENE_TEX_W;
+        region.texture_extent_height = SCENE_TEX_H;
+        region.texture_extent_depth = 1;
+        rhi::copy_buffer_to_texture(cmd, staging, tex_view, region);
+        rhi::barrier(cmd, tex_img, range, rhi::ResourceState::TransferTo, rhi::ResourceState::TextureSample);
+        tex_img.state = rhi::ResourceState::TextureSample;
+        rhi::end_cmd_buffer(cmd);
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        rhi::queue_submit(device, graphics_queue, submit);
+        rhi::queue_wait_idle(device);
+    }
+
+    rhi::RenderPipelineDesc pd{};
+    pd.device = &device;
+    pd.set_shaders(sc, "conformance/scene.slang", "vsMain", "fsMain");
+    pd.add_vertex_binding(0, sizeof(SceneVertex));
+    pd.add_vertex_attribute(0, 0, rhi::ImageFormat::RGB32_FLOAT, offsetof(SceneVertex, pos));
+    pd.add_vertex_attribute(1, 0, rhi::ImageFormat::RGB32_FLOAT, offsetof(SceneVertex, nrm));
+    pd.add_vertex_attribute(2, 0, rhi::ImageFormat::RG32_FLOAT, offsetof(SceneVertex, uv));
+    pd.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::swapchain_format(swapchain));
+    pipeline = pd.build();
+    if (!rhi::valid(pipeline)) {
+        VEL_CRITICAL("scene: pipeline build failed");
+        return 1;
+    }
+
+    ScenePush push{};
+    {
+        const mat4 view = look_at(vec3(1.6f, 1.3f, -2.4f), vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f));
+        const mat4 proj = perspective(radians(60.0f), 1.0f, 0.01f, 1000.0f);
+        push.viewProj = view * proj; // row-vector engine convention: shaders consume vec * mat
+        push.tex = rhi::handle_id(device, tex_view);
+        push.samp = rhi::handle_id(device, sampler);
+        push.lightDir = vec4(0.4f, 0.8f, -0.45f, 0.0f);
+    }
+
+    u64 frame_count = 0;
+    while (platform_update(platform)) {
+        if (platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain)) {
+            platform.framebuffer_resized = false;
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                break;
+            }
+            rhi::queue_wait_idle(device);
+            rhi::destroy_swapchain(device, swapchain);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            rhi::create_swapchain(device, swapchain_desc, swapchain);
+            rhi::destroy_image_view(device, depth_view);
+            rhi::destroy_image(device, depth_img);
+            create_depth(platform.width, platform.height);
+            continue;
+        }
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+        u32 image_index = 0;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, cmd)) {
+            rhi::reset_cmd_buffer(cmd);
+            continue;
+        }
+        rhi::Image *swap_image = rhi::swapchain_image(swapchain, image_index);
+        rhi::Extent2D extent = rhi::swapchain_extent(swapchain);
+        rhi::ImageView swap_view = rhi::get_cached_image_view(device, *swap_image, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::ImageRange depth_range{};
+        depth_range.aspect = rhi::ImageAspect::Depth;
+        if (depth_img.state != rhi::ResourceState::DepthDraw) {
+            rhi::barrier(cmd, depth_img, depth_range, depth_img.state, rhi::ResourceState::DepthDraw);
+        }
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &swap_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.05f;
+        color_att.clearValue.color.float32[1] = 0.05f;
+        color_att.clearValue.color.float32[2] = 0.07f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+        rhi::AttachmentDesc depth_att{};
+        depth_att.img = &depth_view;
+        depth_att.loadOp = rhi::LoadOp::CLEAR;
+        depth_att.storeOp = rhi::StoreOp::STORE;
+        depth_att.clearValue.depthStencil = {0.0f, 0};
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.depthAttachment = depth_att;
+        ri.width = extent.width;
+        ri.height = extent.height;
+
+        rhi::begin_rendering(cmd, ri);
+        rhi::set_pipeline(cmd, pipeline);
+        rhi::Viewport vp{};
+        vp.width = (f32)extent.width;
+        vp.height = (f32)extent.height;
+        rhi::set_viewports(cmd, &vp);
+        rhi::Rect scissor{};
+        scissor.width = (i16)extent.width;
+        scissor.height = (i16)extent.height;
+        rhi::set_scissors(cmd, &scissor);
+        rhi::set_vertex_buffer(cmd, vertex_buffer, 0, 0);
+        rhi::set_index_buffer(cmd, index_buffer, 0, rhi::IndexType::UINT32);
+        rhi::set_constants(cmd, pipeline, rhi::ShaderStage::VERTEX | rhi::ShaderStage::FRAGMENT, sizeof(push), &push);
+        rhi::draw_indexed(cmd, 36, 1, 0, 0, 0);
+        rhi::end_rendering(cmd);
+
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, *swap_image, range, swap_image->state, rhi::ResourceState::Display);
+        rhi::end_cmd_buffer(cmd);
+
+        rhi::QueueSignal completion{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        submit.signal_count = 1;
+        submit.signals = &completion;
+        rhi::queue_submit(device, graphics_queue, submit);
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        ++frame_count;
+        rhi::sync_host_wait(frame_sync, frame_count);
+    }
+
+    rhi::device_wait_idle(device);
+    rhi::destroy_pipeline(device, pipeline);
+    rhi::destroy_buffer(device, staging);
+    rhi::destroy_image_view(device, depth_view);
+    rhi::destroy_image(device, depth_img);
+    rhi::destroy_image_view(device, tex_view);
+    rhi::destroy_image(device, tex_img);
+    rhi::destroy_sampler(device, sampler);
+    rhi::destroy_buffer(device, index_buffer);
+    rhi::destroy_buffer(device, vertex_buffer);
+    rhi::sync_destroy(frame_sync);
+    rhi::destroy_cmd_buffer(device, pool, cmd);
+    rhi::destroy_cmd_pool(device, pool);
+    rhi::destroy_swapchain(device, swapchain);
+    rhi::destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    rhi::destroy_context(device);
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/backend/conformance/triangle/triangle.cpp +181 -0
--- a/src/backend/conformance/triangle/triangle.cpp
+++ b/src/backend/conformance/triangle/triangle.cpp
@@ -0,0 +1,181 @@
+#include "backend/rhi.h"
+#include "core/logger.h"
+#include "core/platform.h"
+
+#include <cstring>
+#include <stddef.h>
+
+struct TriangleVertex {
+    f32 pos[2];
+    f32 color[3];
+};
+
+static constexpr TriangleVertex TRIANGLE_VERTICES[3] = {
+    {{-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}},
+    {{0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}},
+    {{0.0f, 0.5f}, {0.0f, 0.0f, 1.0f}},
+};
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+    rhi::CmdPool pool{};
+    rhi::CmdBuffer cmd{};
+    rhi::Sync *frame_sync = nullptr;
+    rhi::ShaderCompiler sc{};
+    rhi::Buffer vertex_buffer{};
+    rhi::RenderPipeline pipeline{};
+
+    Platform platform{};
+    platform.width = 1280;
+    platform.height = 720;
+
+    init_platform(config.instance_extensions);
+    rhi::create_context(device, config);
+    if (!rhi::create_memory_allocator(device)) {
+        VEL_CRITICAL("triangle-example: failed to create memory allocator");
+        return 1;
+    }
+    if (!rhi::init_compiler(sc)) {
+        VEL_CRITICAL("triangle-example: failed to init shader compiler");
+        return 1;
+    }
+    create_window(device, platform, "triangle-example", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    rhi::create_swapchain(device, swapchain_desc, swapchain);
+
+    rhi::Queue graphics_queue = rhi::graphics_queue(device);
+
+    rhi::CmdPoolDesc cmd_pool_desc;
+    cmd_pool_desc.queue_family_index = rhi::queue_family_index(graphics_queue);
+    cmd_pool_desc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_desc, pool);
+    rhi::CmdBufferDesc cmd_desc{};
+    cmd_desc.pool = &pool;
+    cmd_desc.level = rhi::CmdBufferLevel::Primary;
+    rhi::create_cmd_buffer(device, cmd_desc, cmd);
+
+    frame_sync = rhi::sync_create(device, 0);
+
+    rhi::BufferDesc vb_desc{};
+    vb_desc.size = sizeof(TRIANGLE_VERTICES);
+    vb_desc.usage = rhi::BufferUsage::VertexBuffer;
+    vb_desc.memory = rhi::BufferMemType::Upload;
+    rhi::create_buffer(device, vb_desc, vertex_buffer);
+    std::memcpy(vertex_buffer.mapped, TRIANGLE_VERTICES, sizeof(TRIANGLE_VERTICES));
+
+    rhi::RenderPipelineDesc pd{};
+    pd.device = &device;
+    pd.set_shaders(sc, "conformance/triangle.slang", "vsMain", "fsMain");
+    pd.add_vertex_binding(0, sizeof(TriangleVertex));
+    pd.add_vertex_attribute(0, 0, rhi::ImageFormat::RG32_FLOAT, offsetof(TriangleVertex, pos));
+    pd.add_vertex_attribute(1, 0, rhi::ImageFormat::RGB32_FLOAT, offsetof(TriangleVertex, color));
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::LESS);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::swapchain_format(swapchain));
+    pipeline = pd.build();
+
+    u64 frame_count = 0;
+    while (platform_update(platform)) {
+        if (platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain)) {
+            platform.framebuffer_resized = false;
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                break;
+            }
+            rhi::queue_wait_idle(device);
+            rhi::destroy_swapchain(device, swapchain);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            rhi::create_swapchain(device, swapchain_desc, swapchain);
+            continue;
+        }
+
+        rhi::reset_cmd_buffer(cmd);
+        rhi::begin_cmd_buffer(cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+
+        u32 image_index = 0;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, cmd)) {
+            rhi::reset_cmd_buffer(cmd);
+            continue;
+        }
+
+        rhi::Image *swap_image = rhi::swapchain_image(swapchain, image_index);
+        rhi::Extent2D extent = rhi::swapchain_extent(swapchain);
+        rhi::ImageView swap_view = rhi::get_cached_image_view(device, *swap_image, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &swap_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.1f;
+        color_att.clearValue.color.float32[1] = 0.1f;
+        color_att.clearValue.color.float32[2] = 0.1f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = extent.width;
+        ri.height = extent.height;
+
+        rhi::begin_rendering(cmd, ri);
+        rhi::set_pipeline(cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)extent.width;
+        vp.height = (f32)extent.height;
+        rhi::set_viewports(cmd, &vp);
+
+        rhi::Rect scissor{};
+        scissor.width = (i16)extent.width;
+        scissor.height = (i16)extent.height;
+        rhi::set_scissors(cmd, &scissor);
+
+        rhi::set_vertex_buffer(cmd, vertex_buffer, 0, 0);
+        rhi::draw(cmd, 3, 1, 0, 0);
+        rhi::end_rendering(cmd);
+
+        rhi::ImageRange range{};
+        rhi::barrier(cmd, *swap_image, range, swap_image->state, rhi::ResourceState::Display);
+        rhi::end_cmd_buffer(cmd);
+
+        rhi::QueueSignal completion{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit{};
+        submit.cmd_count = 1;
+        submit.cmds = &cmd;
+        submit.signal_count = 1;
+        submit.signals = &completion;
+        rhi::queue_submit(device, graphics_queue, submit);
+
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        ++frame_count;
+
+        rhi::sync_host_wait(frame_sync, frame_count);
+    }
+
+    rhi::device_wait_idle(device);
+
+    rhi::destroy_pipeline(device, pipeline);
+    rhi::destroy_buffer(device, vertex_buffer);
+    rhi::sync_destroy(frame_sync);
+    rhi::destroy_cmd_buffer(device, pool, cmd);
+    rhi::destroy_cmd_pool(device, pool);
+    rhi::destroy_swapchain(device, swapchain);
+    rhi::destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    rhi::destroy_context(device);
+
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/backend/imgui_backend.cpp +270 -0
--- a/src/backend/imgui_backend.cpp
+++ b/src/backend/imgui_backend.cpp
@@ -0,0 +1,270 @@
+#include "backend/imgui_backend.h"
+
+#include <algorithm>
+#include <cstring>
+
+#include <imgui.h>
+#include <imgui_impl_glfw.h>
+
+#include "GLFW/glfw3.h"
+#include "asset/texture.h"
+#include "core/logger.h"
+#include "core/math_rtm.h"
+#include "passes/fg.h"
+#include "quick_submit.h"
+#include "shaders/renderer_types.h"
+
+namespace imgui_backend {
+
+namespace {
+
+rhi::Device *DEVICE = nullptr;
+
+rhi::Image FONT_IMG = {};
+rhi::ImageView FONT_VIEW = {};
+u64 FONT_HANDLE = 0;
+
+rhi::Sampler IMG_SAMP = {};
+u64 IMG_SAMP_HANDLE = 0;
+
+rhi::Buffer VTX_BUF[MAX_FRAMES_IN_FLIGHT] = {};
+rhi::Buffer IDX_BUF[MAX_FRAMES_IN_FLIGHT] = {};
+
+static void draw_callback_reset_render_state(const ImDrawList *, const ImDrawCmd *) {
+}
+
+void ensure_buffer(rhi::Buffer &buf, u64 bytes, rhi::BufferUsage usage, const char *name) {
+    if (rhi::valid(buf) && buf.desc.size >= bytes) {
+        return;
+    }
+    if (rhi::valid(buf)) {
+        rhi::destroy_buffer(*DEVICE, buf);
+        buf = {};
+    }
+    rhi::BufferDesc desc{};
+    desc.size = bytes;
+    desc.usage = usage;
+    desc.memory = rhi::BufferMemType::Upload;
+    desc.name = name;
+    rhi::create_buffer(*DEVICE, desc, buf);
+}
+
+} // namespace
+
+void init(rhi::Device &device, void *native_window, QuickSubmit &qs, Arena &staging) {
+    DEVICE = &device;
+
+    ImGui_ImplGlfw_InitForVulkan((GLFWwindow *)native_window, true);
+    ImGui::GetPlatformIO().DrawCallback_ResetRenderState = draw_callback_reset_render_state;
+
+    ImGuiIO &io = ImGui::GetIO();
+    io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset;
+    io.BackendRendererName = "gfx-playground-native";
+
+    // font atlas upload (init-time; fonts are static).
+    unsigned char *pixels = nullptr;
+    int atlas_w = 0, atlas_h = 0;
+    io.Fonts->GetTexDataAsRGBA32(&pixels, &atlas_w, &atlas_h);
+    if (!create_texture_from_raw_rgba(
+            device,
+            qs,
+            staging,
+            FONT_IMG,
+            FONT_VIEW,
+            pixels,
+            (u32)atlas_w,
+            (u32)atlas_h,
+            4,
+            rhi::ImageFormat::RGBA8_UNORM,
+            "font/atlas"
+        )) {
+        VEL_CRITICAL("imgui_backend: font atlas upload failed");
+        return;
+    }
+    FONT_HANDLE = rhi::handle_id(device, FONT_VIEW);
+    io.Fonts->SetTexID((ImTextureID)FONT_HANDLE);
+
+    // Own static sampler; handle cached once, carried per-draw in push.
+    {
+        rhi::SamplerDesc sdesc{};
+        sdesc.filter = rhi::SamplerFilter::LINEAR;
+        sdesc.address = rhi::SamplerAddressMode::CLAMP;
+        sdesc.name = "samp/imgui";
+        rhi::create_sampler(device, sdesc, IMG_SAMP);
+        IMG_SAMP_HANDLE = rhi::handle_id(device, IMG_SAMP);
+    }
+
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+        ensure_buffer(
+            VTX_BUF[i], 64 * 1024, rhi::BufferUsage::VertexBuffer | rhi::BufferUsage::CopyDst, "ImGui Vertex Buffer"
+        );
+        ensure_buffer(
+            IDX_BUF[i], 32 * 1024, rhi::BufferUsage::IndexBuffer | rhi::BufferUsage::CopyDst, "ImGui Index Buffer"
+        );
+    }
+}
+
+void shutdown(rhi::Device &device) {
+    ImGui_ImplGlfw_Shutdown();
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+        if (rhi::valid(VTX_BUF[i])) {
+            rhi::destroy_buffer(device, VTX_BUF[i]);
+            VTX_BUF[i] = {};
+        }
+        if (rhi::valid(IDX_BUF[i])) {
+            rhi::destroy_buffer(device, IDX_BUF[i]);
+            IDX_BUF[i] = {};
+        }
+    }
+    if (rhi::valid(FONT_VIEW)) {
+        rhi::destroy_image_view(device, FONT_VIEW);
+        FONT_VIEW = {};
+    }
+    if (rhi::valid(FONT_IMG)) {
+        rhi::destroy_image(device, FONT_IMG);
+        FONT_IMG = {};
+    }
+    if (rhi::valid(IMG_SAMP)) {
+        rhi::destroy_sampler(device, IMG_SAMP);
+        IMG_SAMP = {};
+        IMG_SAMP_HANDLE = 0;
+    }
+    DEVICE = nullptr;
+    FONT_HANDLE = 0;
+}
+
+void begin_frame() {
+    ImGui_ImplGlfw_NewFrame();
+    ImGui::NewFrame();
+}
+
+u64 texture(rhi::ImageView &view) {
+    return rhi::handle_id(*DEVICE, view);
+}
+
+bool prepare(const PassContext &ctx) {
+    ImGui::Render();
+    ImDrawData *draw_data = ImGui::GetDrawData();
+    if (draw_data == nullptr || draw_data->CmdListsCount == 0 || draw_data->TotalVtxCount == 0) {
+        return false;
+    }
+
+    if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) {
+        return false;
+    }
+
+    rhi::Buffer &vtx_buf = VTX_BUF[ctx.frame_index];
+    rhi::Buffer &idx_buf = IDX_BUF[ctx.frame_index];
+    ensure_buffer(
+        vtx_buf,
+        (u64)draw_data->TotalVtxCount * sizeof(ImDrawVert),
+        rhi::BufferUsage::VertexBuffer | rhi::BufferUsage::CopyDst,
+        "ImGui Vertex Buffer"
+    );
+    ensure_buffer(
+        idx_buf,
+        (u64)draw_data->TotalIdxCount * sizeof(ImDrawIdx),
+        rhi::BufferUsage::IndexBuffer | rhi::BufferUsage::CopyDst,
+        "ImGui Index Buffer"
+    );
+
+    u8 *vtx_dst = static_cast<u8 *>(vtx_buf.mapped);
+    u8 *idx_dst = static_cast<u8 *>(idx_buf.mapped);
+    for (int n = 0; n < draw_data->CmdListsCount; ++n) {
+        const ImDrawList *list = draw_data->CmdLists[n];
+        memcpy(vtx_dst, list->VtxBuffer.Data, (usize)list->VtxBuffer.Size * sizeof(ImDrawVert));
+        vtx_dst += (usize)list->VtxBuffer.Size * sizeof(ImDrawVert);
+        memcpy(idx_dst, list->IdxBuffer.Data, (usize)list->IdxBuffer.Size * sizeof(ImDrawIdx));
+        idx_dst += (usize)list->IdxBuffer.Size * sizeof(ImDrawIdx);
+    }
+
+    rhi::barrier(ctx.cmd, vtx_buf, rhi::ResourceState::HostRead, rhi::ResourceState::VertexFetch);
+    rhi::barrier(ctx.cmd, idx_buf, rhi::ResourceState::HostRead, rhi::ResourceState::IndexFetch);
+    return true;
+}
+
+void draw(const PassContext &ctx, rhi::RenderPipeline &pipeline, u32 width, u32 height) {
+    ImDrawData *draw_data = ImGui::GetDrawData();
+    if (draw_data == nullptr || draw_data->CmdListsCount == 0 || draw_data->TotalVtxCount == 0) {
+        return;
+    }
+
+    rhi::Buffer &vtx_buf = VTX_BUF[ctx.frame_index];
+    rhi::Buffer &idx_buf = IDX_BUF[ctx.frame_index];
+
+    rhi::set_pipeline(ctx.cmd, pipeline);
+    rhi::set_vertex_buffer(ctx.cmd, vtx_buf, 0, 0);
+    rhi::set_index_buffer(ctx.cmd, idx_buf, 0, rhi::IndexType::UINT16);
+
+    rhi::Viewport vp{};
+    vp.width = (f32)width;
+    vp.height = (f32)height;
+    rhi::set_viewports(ctx.cmd, &vp);
+
+    const vec2 scale = {draw_data->FramebufferScale.x, draw_data->FramebufferScale.y};
+    const vec2 translate = {
+        -draw_data->DisplayPos.x * draw_data->FramebufferScale.x,
+        -draw_data->DisplayPos.y * draw_data->FramebufferScale.y,
+    };
+    const vec2 display_size = {
+        draw_data->DisplaySize.x * draw_data->FramebufferScale.x,
+        draw_data->DisplaySize.y * draw_data->FramebufferScale.y,
+    };
+
+    u32 vtx_offset = 0;
+    u32 idx_offset = 0;
+    for (int n = 0; n < draw_data->CmdListsCount; ++n) {
+        const ImDrawList *list = draw_data->CmdLists[n];
+        for (int ci = 0; ci < list->CmdBuffer.Size; ++ci) {
+            const ImDrawCmd *cmd = &list->CmdBuffer[ci];
+            if (cmd->UserCallback != nullptr) {
+                if (cmd->UserCallback == ImGui::GetPlatformIO().DrawCallback_ResetRenderState) {
+                    rhi::set_pipeline(ctx.cmd, pipeline);
+                    rhi::set_vertex_buffer(ctx.cmd, vtx_buf, 0, 0);
+                    rhi::set_index_buffer(ctx.cmd, idx_buf, 0, rhi::IndexType::UINT16);
+                    rhi::set_viewports(ctx.cmd, &vp);
+                }
+                continue;
+            }
+            if (cmd->ElemCount == 0) {
+                continue;
+            }
+            vec4 clip = {
+                (cmd->ClipRect.x - draw_data->DisplayPos.x) * draw_data->FramebufferScale.x,
+                (cmd->ClipRect.y - draw_data->DisplayPos.y) * draw_data->FramebufferScale.y,
+                (cmd->ClipRect.z - draw_data->DisplayPos.x) * draw_data->FramebufferScale.x,
+                (cmd->ClipRect.w - draw_data->DisplayPos.y) * draw_data->FramebufferScale.y,
+            };
+            if (clip.x >= clip.z || clip.y >= clip.w) {
+                continue;
+            }
+            rhi::Rect scissor{};
+            scissor.x = (i16)std::max(clip.x, 0.0f);
+            scissor.y = (i16)std::max(clip.y, 0.0f);
+            scissor.width = (i16)std::min(clip.z, display_size.x) - scissor.x;
+            scissor.height = (i16)std::min(clip.w, display_size.y) - scissor.y;
+            if (scissor.width <= 0 || scissor.height <= 0) {
+                continue;
+            }
+            rhi::set_scissors(ctx.cmd, &scissor);
+
+            ImGuiPushConstants pc{};
+            pc.scale = scale;
+            pc.translate = translate;
+            pc.display_size = display_size;
+            pc.tex = (u32)(u64)cmd->GetTexID();
+            pc.samp = IMG_SAMP_HANDLE;
+            {
+                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                char pc128[128] = {};
+                std::memcpy(pc128, &pc, sizeof(pc));
+                rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+            }
+            rhi::draw_indexed(ctx.cmd, cmd->ElemCount, 1, idx_offset + cmd->IdxOffset, vtx_offset + cmd->VtxOffset, 0);
+        }
+        vtx_offset += (u32)list->VtxBuffer.Size;
+        idx_offset += (u32)list->IdxBuffer.Size;
+    }
+}
+
+} // namespace imgui_backend
ADD · src/backend/imgui_backend.h +22 -0
--- a/src/backend/imgui_backend.h
+++ b/src/backend/imgui_backend.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "backend/rhi.h"
+
+struct PassContext;
+struct QuickSubmit;
+struct Arena;
+
+namespace imgui_backend {
+
+void init(rhi::Device &device, void *native_window, QuickSubmit &qs, Arena &staging);
+void shutdown(rhi::Device &device);
+
+void begin_frame();
+
+bool prepare(const PassContext &ctx);
+
+void draw(const PassContext &ctx, rhi::RenderPipeline &pipeline, u32 width, u32 height);
+
+u64 texture(rhi::ImageView &view);
+
+} // namespace imgui_backend
ADD · src/backend/metal/arguments_table.cpp +212 -0
--- a/src/backend/metal/arguments_table.cpp
+++ b/src/backend/metal/arguments_table.cpp
@@ -0,0 +1,212 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+#include <QuartzCore/QuartzCore.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+#include <cstring>
+#include <new>
+
+namespace mt {
+
+// push + vertex table. resources ride in push.
+
+u64 IndexPool::alloc() {
+    if (!free_list.empty()) {
+        u64 s = free_list.back();
+        free_list.pop_back();
+        return s;
+    }
+    if (next >= cap) {
+        return UINT64_MAX;
+    }
+    return next++;
+}
+
+void IndexPool::free(u64 slot) {
+    if (slot == UINT64_MAX) {
+        return;
+    }
+    free_list.push_back((u32)slot);
+}
+
+void reside(rhi::Device &device, const MTL::Allocation *alloc) {
+    if (device.heap && device.heap->residency && alloc) {
+        device.heap->residency->addAllocation(alloc);
+    }
+}
+
+void unreside(rhi::Device &device, const MTL::Allocation *alloc) {
+    if (device.heap && device.heap->residency && alloc) {
+        device.heap->residency->removeAllocation(alloc);
+    }
+}
+
+void create_heap(rhi::Device &device) {
+    MTL::Device *dev = device.handle;
+    Heap *heap = new (std::nothrow) Heap{};
+    if (!heap) {
+        VEL_CRITICAL("arguments_table: out of memory");
+        return;
+    }
+
+    heap->sampler_space = {.cap = kHeapSamplerBudget, .next = 0};
+    heap->texture_space = {.cap = kHeapTextureBudget, .next = 0};
+    heap->texture_ids.assign(kHeapTextureBudget, 0);
+    heap->sampler_ids.assign(kHeapSamplerBudget, 0);
+
+    NS::Error *error = nullptr;
+    MTL4::ArgumentTableDescriptor *td = MTL4::ArgumentTableDescriptor::alloc()->init();
+    td->setMaxBufferBindCount(kMaxBufferBindCount);
+    td->setMaxTextureBindCount(kMaxTextureBindCount);
+    td->setMaxSamplerStateBindCount(kMaxSamplerBindCount);
+    td->setSupportAttributeStrides(true);
+    td->setInitializeBindings(true);
+    heap->table = dev->newArgumentTable(td, &error);
+    td->release();
+    if (!heap->table) {
+        if (error && error->localizedDescription()) {
+            VEL_CRITICAL("arguments_table: newArgumentTable failed: {}", error->localizedDescription()->utf8String());
+            error->release();
+        } else {
+            VEL_CRITICAL("arguments_table: newArgumentTable failed");
+        }
+        delete heap;
+        return;
+    }
+
+    MTL::ResidencySetDescriptor *rd = MTL::ResidencySetDescriptor::alloc()->init();
+    rd->setInitialCapacity(256);
+    error = nullptr;
+    heap->residency = dev->newResidencySet(rd, &error);
+    rd->release();
+    if (!heap->residency) {
+        if (error && error->localizedDescription()) {
+            VEL_CRITICAL("arguments_table: newResidencySet failed: {}", error->localizedDescription()->utf8String());
+            error->release();
+        } else {
+            VEL_CRITICAL("arguments_table: newResidencySet failed");
+        }
+        heap->table->release();
+        delete heap;
+        return;
+    }
+    if (!device.graphics.handle) {
+        VEL_CRITICAL("arguments_table: graphics queue missing, cannot attach residency set");
+        heap->table->release();
+        heap->residency->release();
+        delete heap;
+        return;
+    }
+    device.graphics.handle->addResidencySet(heap->residency);
+    heap->residency->requestResidency();
+    heap->residency->commit();
+
+    device.heap = heap;
+    VEL_INFO("arguments_table: ready (push + vertex table, texture/sampler host heaps + residency)");
+}
+
+void destroy_heap(rhi::Device &device) {
+    Heap *heap = device.heap;
+    device.heap = nullptr;
+    if (!heap) {
+        return;
+    }
+    if (heap->table) {
+        heap->table->release();
+        heap->table = nullptr;
+    }
+    if (heap->residency) {
+        heap->residency->release();
+        heap->residency = nullptr;
+    }
+    delete heap;
+}
+
+u64 write_sampler(rhi::Device &device, rhi::Sampler sampler) {
+    if (!device.heap || !sampler.handle) {
+        return UINT64_MAX;
+    }
+    u64 slot = device.heap->sampler_space.alloc();
+    if (slot == UINT64_MAX) {
+        VEL_ERROR("arguments_table: sampler heap exhausted");
+        return UINT64_MAX;
+    }
+    device.heap->sampler_ids[(size_t)slot] = sampler.handle->gpuResourceID()._impl;
+    return slot;
+}
+
+u64 write_texture(rhi::Device &device, MTL::Texture *view, bool storage) {
+    (void)storage;
+    if (!device.heap || !view) {
+        return UINT64_MAX;
+    }
+    u64 slot = device.heap->texture_space.alloc();
+    if (slot == UINT64_MAX) {
+        VEL_ERROR("arguments_table: texture heap exhausted");
+        return UINT64_MAX;
+    }
+    device.heap->texture_ids[(size_t)slot] = view->gpuResourceID()._impl;
+    if (device.heap->residency) {
+        device.heap->residency->addAllocation(view);
+    }
+    return slot;
+}
+
+void free_texture(rhi::Device &device, u64 slot) {
+    if (device.heap) {
+        device.heap->texture_space.free(slot);
+        if (slot < device.heap->texture_ids.size()) {
+            device.heap->texture_ids[(size_t)slot] = 0;
+        }
+    }
+}
+
+void free_sampler(rhi::Device &device, u64 slot) {
+    if (device.heap) {
+        device.heap->sampler_space.free(slot);
+        if (slot < device.heap->sampler_ids.size()) {
+            device.heap->sampler_ids[(size_t)slot] = 0;
+        }
+    }
+}
+
+u64 heap_texture_id(rhi::Device &device, u64 slot) {
+    if (!device.heap || slot == UINT64_MAX || slot >= device.heap->texture_ids.size()) {
+        return 0;
+    }
+    return device.heap->texture_ids[(size_t)slot];
+}
+
+u64 heap_sampler_id(rhi::Device &device, u64 slot) {
+    if (!device.heap || slot == UINT64_MAX || slot >= device.heap->sampler_ids.size()) {
+        return 0;
+    }
+    return device.heap->sampler_ids[(size_t)slot];
+}
+
+MTL::Buffer *push_bump_alloc(rhi::CmdBuffer &cmd, const void *data, u32 size) {
+    if (!cmd.queue) {
+        return nullptr;
+    }
+    // 16b align. constants need it.
+    const u32 aligned = (size + 15u) & ~15u;
+    MTL::Device *dev = cmd.queue->device();
+    MTL::Buffer *buf = dev->newBuffer(aligned, MTL::StorageModeShared);
+    if (!buf) {
+        return nullptr;
+    }
+    if (cmd.residency) {
+        cmd.residency->addAllocation(buf);
+    }
+    std::memcpy(buf->contents(), data, size);
+    cmd.transients.push_back(buf);
+    return buf;
+}
+
+} // namespace mt
ADD · src/backend/metal/buffer.cpp +106 -0
--- a/src/backend/metal/buffer.cpp
+++ b/src/backend/metal/buffer.cpp
@@ -0,0 +1,106 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+namespace rhi {
+
+bool create_buffer(Device &device, rhi::BufferDesc &desc, Buffer &buffer) {
+    MTL::StorageMode storage = MTL::StorageModePrivate;
+    if (desc.memory == rhi::BufferMemType::Upload || desc.memory == rhi::BufferMemType::Readback) {
+        storage = MTL::StorageModeShared;
+    }
+    MTL::Buffer *handle = device.handle->newBuffer(desc.size, storage);
+    if (!handle) {
+        VEL_ERROR("Failed to create Metal buffer ({} bytes)", desc.size);
+        return false;
+    }
+
+    buffer.desc = desc;
+    buffer.handle = handle;
+    if (!desc.name.empty()) {
+        handle->setLabel(NS::String::string(desc.name.c_str(), NS::UTF8StringEncoding));
+    }
+    buffer.address = handle->gpuAddress();
+    buffer.mapped = (storage == MTL::StorageModeShared) ? handle->contents() : nullptr;
+    mt::reside(device, handle);
+    return true;
+}
+
+void destroy_buffer(Device &device, Buffer &buffer) {
+    if (buffer.handle) {
+        mt::unreside(device, buffer.handle);
+        buffer.handle->release();
+        buffer.handle = nullptr;
+    }
+    buffer.address = 0;
+    buffer.mapped = nullptr;
+}
+
+u64 buffer_device_address(Device &device, Buffer &buffer, u64 offset) {
+    (void)device;
+    if (offset > buffer.desc.size) {
+        VEL_ERROR("buffer_device_address: offset {} exceeds buffer size {}", offset, buffer.desc.size);
+        return 0;
+    }
+    if (!buffer.handle) {
+        return 0;
+    }
+    return buffer.handle->gpuAddress() + offset;
+}
+
+void buffer_flush(Device &device, Buffer &buffer, u64 offset, u64 size) {
+    // upload/readback buffers are shared (CPU-coherent), private buffers are
+    // never CPU-mapped nice little no-ops
+    (void)device;
+    (void)buffer;
+    (void)offset;
+    (void)size;
+}
+
+void buffer_invalidate(Device &device, Buffer &buffer, u64 offset, u64 size) {
+    (void)device;
+    (void)buffer;
+    (void)offset;
+    (void)size;
+}
+
+bool create_buffer_view(Device &device, const BufferViewDesc &desc, BufferView &out) {
+    (void)device;
+    out.buffer = desc.buffer;
+    out.desc = desc;
+    out.handle = desc.buffer ? desc.buffer->handle : nullptr;
+    // bda. no slot.
+    out.slot = 0;
+    if (!out.handle) {
+        VEL_ERROR("create_buffer_view: null buffer");
+        return false;
+    }
+    return true;
+}
+
+u64 handle_id(Device &device, BufferView &view) {
+    if (!view.buffer) {
+        VEL_ERROR("handle_id: buffer view has no buffer");
+        return 0;
+    }
+    return buffer_device_address(device, *view.buffer, view.desc.offset);
+}
+
+void destroy_buffer_view(Device &device, BufferView &view) {
+    (void)device;
+    view.slot = UINT64_MAX;
+    view.handle = nullptr;
+    view.buffer = nullptr;
+}
+
+bool valid(const BufferView &view) {
+    return view.handle != nullptr;
+}
+
+} // namespace rhi
ADD · src/backend/metal/cmd.cpp +523 -0
--- a/src/backend/metal/cmd.cpp
+++ b/src/backend/metal/cmd.cpp
@@ -0,0 +1,523 @@
+#include <math.h>
+#include <new>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+#include <QuartzCore/QuartzCore.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "backend/metal/mt_internal.h"
+#include "core/logger.h"
+
+namespace mt {
+
+static CA::MetalDrawable *g_current_drawable = nullptr;
+static MTL4::CommandBuffer *g_last_committed = nullptr;
+
+void mt_set_current_drawable(CA::MetalDrawable *drawable) {
+    if (g_current_drawable) {
+        g_current_drawable->release();
+    }
+    g_current_drawable = drawable;
+    if (g_current_drawable) {
+        g_current_drawable->retain();
+    }
+}
+
+CA::MetalDrawable *mt_current_drawable() {
+    return g_current_drawable;
+}
+
+void mt_clear_current_drawable() {
+    if (g_current_drawable) {
+        g_current_drawable->release();
+        g_current_drawable = nullptr;
+    }
+}
+
+void mt_wait_idle() {
+    (void)g_last_committed;
+}
+
+} // namespace mt
+
+namespace rhi {
+using namespace mt;
+
+bool create_cmd_pool(Device &device, const rhi::CmdPoolDesc &desc, CmdPool &pool) {
+    (void)device;
+    (void)desc;
+    // no pools on metal
+    pool.handle = (void *)1;
+    return true;
+}
+
+void destroy_cmd_pool(Device &device, CmdPool &pool) {
+    (void)device;
+    pool.handle = nullptr;
+}
+
+void reset_cmd_pool(Device &device, CmdPool &pool, u32 flags) {
+    (void)device;
+    (void)pool;
+    (void)flags;
+}
+
+bool create_cmd_buffer(Device &device, const CmdBufferDesc &desc, CmdBuffer &cmd) {
+    (void)desc;
+    cmd.queue = device.graphics.handle;
+    if (!cmd.queue || !device.heap) {
+        return false;
+    }
+    cmd.table = device.heap->table;
+    cmd.residency = device.heap->residency;
+    cmd.allocator = cmd.queue->device()->newCommandAllocator();
+    return cmd.table && cmd.residency && cmd.allocator;
+}
+
+void destroy_cmd_buffer(Device &device, CmdPool &pool, CmdBuffer &cmd) {
+    (void)device;
+    (void)pool;
+    for (MTL::Buffer *t : cmd.transients) {
+        if (t) {
+            t->release();
+        }
+    }
+    cmd.transients.clear();
+    if (cmd.handle) {
+        cmd.handle->release();
+        cmd.handle = nullptr;
+    }
+    if (cmd.allocator) {
+        cmd.allocator->release();
+        cmd.allocator = nullptr;
+    }
+    cmd.encoder = nullptr;
+    cmd.queue = nullptr;
+    cmd.table = nullptr;
+    cmd.residency = nullptr;
+    cmd.is_rendering = false;
+}
+
+bool begin_cmd_buffer(CmdBuffer &cmd, const rhi::CmdBufferBeginDesc &desc) {
+    (void)desc;
+    for (MTL::Buffer *t : cmd.transients) {
+        if (t) {
+            t->release();
+        }
+    }
+    cmd.transients.clear();
+    if (cmd.handle) {
+        cmd.handle->release();
+        cmd.handle = nullptr;
+    }
+    if (!cmd.queue || !cmd.allocator || !cmd.residency) {
+        return false;
+    }
+    cmd.allocator->reset();
+    MTL::Device *dev = cmd.queue->device();
+    cmd.handle = dev->newCommandBuffer();
+    if (!cmd.handle) {
+        return false;
+    }
+    cmd.handle->beginCommandBuffer(cmd.allocator);
+    cmd.handle->useResidencySet(cmd.residency);
+    return true;
+}
+
+bool end_cmd_buffer(CmdBuffer &cmd) {
+    if (cmd.handle) {
+        cmd.handle->endCommandBuffer();
+    }
+    return true;
+}
+
+bool reset_cmd_buffer(CmdBuffer &cmd) {
+    (void)cmd;
+    return true;
+}
+
+void begin_rendering(CmdBuffer &cmd, RenderingInfo &ri) {
+    MTL4::RenderPassDescriptor *rpd = MTL4::RenderPassDescriptor::alloc()->init();
+    MTL::RenderPassColorAttachmentDescriptor *att = rpd->colorAttachments()->object(0);
+    att->setTexture(mt_current_drawable()->texture());
+    att->setLoadAction(MTL::LoadActionClear);
+    att->setStoreAction(MTL::StoreActionStore);
+
+    if (ri.colorAttachmentCount > 0) {
+        auto &ca = ri.colorAttachments[0];
+        if (ca.loadOp == rhi::LoadOp::LOAD) {
+            att->setLoadAction(MTL::LoadActionLoad);
+        } else {
+            att->setLoadAction(MTL::LoadActionClear);
+            att->setClearColor(
+                MTL::ClearColor(
+                    ca.clearValue.color.float32[0],
+                    ca.clearValue.color.float32[1],
+                    ca.clearValue.color.float32[2],
+                    ca.clearValue.color.float32[3]
+                )
+            );
+        }
+    }
+    rpd->setRenderTargetWidth(ri.width);
+    rpd->setRenderTargetHeight(ri.height);
+
+    // depth opt-in. pipeline must match pass.
+    if (ri.depthAttachment.img && ri.depthAttachment.img->handle) {
+        MTL::RenderPassDepthAttachmentDescriptor *datt = rpd->depthAttachment();
+        datt->setTexture(ri.depthAttachment.img->handle);
+        if (ri.depthAttachment.loadOp == rhi::LoadOp::LOAD) {
+            datt->setLoadAction(MTL::LoadActionLoad);
+        } else {
+            datt->setLoadAction(MTL::LoadActionClear);
+            datt->setClearDepth(ri.depthAttachment.clearValue.depthStencil.depth);
+        }
+        datt->setStoreAction(
+            ri.depthAttachment.storeOp == rhi::StoreOp::STORE ? MTL::StoreActionStore : MTL::StoreActionDontCare
+        );
+    }
+
+    cmd.encoder = cmd.handle->renderCommandEncoder(rpd);
+    // retain. outlives pool.
+    cmd.encoder->retain();
+    cmd.is_rendering = true;
+
+    rpd->release();
+}
+
+void end_rendering(CmdBuffer &cmd) {
+    if (!cmd.encoder) {
+        return;
+    }
+    cmd.encoder->endEncoding();
+    cmd.encoder->release();
+    cmd.encoder = nullptr;
+    cmd.is_rendering = false;
+}
+
+static void submit_cmds(const CmdBuffer *cmds, u32 cmd_count) {
+    for (u32 i = 0; i < cmd_count; ++i) {
+        const CmdBuffer &c = cmds[i];
+        MTL4::CommandBuffer *cb = c.handle;
+        if (!cb || !c.queue) {
+            continue;
+        }
+        MTL4::CommandBuffer *arr[1] = {cb};
+        c.queue->commit(arr, 1);
+        if (g_current_drawable) {
+            c.queue->signalDrawable(g_current_drawable);
+            g_current_drawable->present();
+        }
+        if (g_last_committed) {
+            g_last_committed->release();
+        }
+        g_last_committed = cb;
+        g_last_committed->retain();
+    }
+}
+
+void queue_submit(Device &device, Queue queue, const QueueSubmitDesc &desc) {
+    (void)queue;
+    // no waits/signals
+    (void)desc.waits;
+    (void)desc.signals;
+
+    // page in late adds before commit
+    if (device.heap && device.heap->residency) {
+        device.heap->residency->requestResidency();
+        device.heap->residency->commit();
+    }
+
+    submit_cmds(desc.cmds, desc.cmd_count);
+
+    mt_clear_current_drawable();
+}
+
+Sync *sync_create(Device &device, u64 initial_value, const char *name) {
+    (void)name; // Metal has no timeline-semaphore naming hook here; kept for API parity.
+    (void)device;
+    (void)initial_value;
+    Sync *sync = new (std::nothrow) Sync{};
+    if (sync == nullptr) {
+        return nullptr;
+    }
+    sync->timeline = (void *)1;
+    return sync;
+}
+
+void sync_destroy(Sync *sync) {
+    delete sync;
+}
+
+u64 sync_get_completed_value(Sync *sync) {
+    if (sync == nullptr || sync->timeline == nullptr) {
+        return 0;
+    }
+    return UINT64_MAX;
+}
+
+bool sync_host_wait(Sync *sync, u64 value, u64 timeout_ns) {
+    (void)value;
+    (void)timeout_ns;
+    if (sync == nullptr || sync->timeline == nullptr) {
+        return false;
+    }
+    return true;
+}
+
+void set_pipeline(CmdBuffer &cmd, RenderPipeline &pipeline) {
+    if (cmd.encoder && pipeline.handle && cmd.table) {
+        cmd.encoder->setRenderPipelineState(pipeline.handle);
+        if (pipeline.depth_stencil) {
+            cmd.encoder->setDepthStencilState(pipeline.depth_stencil);
+        }
+        cmd.encoder->setArgumentTable(cmd.table, MTL::RenderStageVertex | MTL::RenderStageFragment);
+    }
+}
+
+void set_pipeline(CmdBuffer &cmd, ComputePipeline &pipeline) {
+    (void)cmd;
+    (void)pipeline;
+    VEL_ERROR("set_pipeline(compute) is not implemented on Metal");
+}
+
+void destroy_pipeline(Device &device, RenderPipeline &p) {
+    (void)device;
+    p.const_blocks.clear();
+    if (p.depth_stencil) {
+        p.depth_stencil->release();
+        p.depth_stencil = nullptr;
+    }
+    if (p.handle) {
+        p.handle->release();
+        p.handle = nullptr;
+    }
+}
+
+void destroy_pipeline(Device &device, ComputePipeline &p) {
+    (void)device;
+    (void)p;
+    VEL_ERROR("destroy_pipeline(compute) is not implemented on Metal");
+}
+
+void set_vertex_buffer(CmdBuffer &cmd, Buffer &buffer, u32 binding, u64 offset) {
+    // binding b -> index 2+b. matches pipeline.
+    (void)offset;
+    if (!cmd.encoder || !buffer.handle || !cmd.table) {
+        return;
+    }
+    if (binding >= kMaxVertexBindings) {
+        VEL_ERROR("set_vertex_buffer: binding {} exceeds max {}", binding, kMaxVertexBindings);
+        return;
+    }
+    cmd.table->setAddress(buffer.handle->gpuAddress(), kVertexBaseIndex + binding);
+}
+
+void set_index_buffer(CmdBuffer &cmd, Buffer &buffer, u32 offset, IndexType type) {
+    cmd.index_buffer = buffer.handle;
+    cmd.index_type = type;
+    cmd.index_offset = offset;
+}
+
+void set_constants(CmdBuffer &cmd, RenderPipeline &pipeline, rhi::ShaderStage stage, u32 size, const void *data) {
+    (void)stage;
+    if (!cmd.encoder || !cmd.table || size == 0 || !data) {
+        return;
+    }
+    u32 table_index = 0;
+    if (!pipeline.const_blocks.empty()) {
+        u32 matches = 0;
+        for (auto &b : pipeline.const_blocks) {
+            if (b.byte_size == size) {
+                table_index = b.table_index;
+                ++matches;
+            }
+        }
+        if (matches != 1) {
+            VEL_ERROR("set_constants: size {} matches {} constant blocks (need exactly 1)", size, matches);
+            return;
+        }
+    }
+    MTL::Buffer *tmp = mt::push_bump_alloc(cmd, data, size);
+    if (tmp) {
+        cmd.table->setAddress(tmp->gpuAddress(), table_index);
+    }
+}
+
+void draw(CmdBuffer &cmd, u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance) {
+    if (cmd.encoder) {
+        cmd.encoder->drawPrimitives(MTL::PrimitiveTypeTriangle, firstVertex, vertexCount, instanceCount, firstInstance);
+    }
+}
+
+void draw_indexed(CmdBuffer &cmd, u32 indexCount, u32 instanceCount, u32 firstIndex, u32 vtxOff, u32 firstInstance) {
+    if (!cmd.encoder) {
+        return;
+    }
+    if (!cmd.index_buffer) {
+        VEL_ERROR("draw_indexed: no index buffer bound (call set_index_buffer first)");
+        return;
+    }
+    MTL::IndexType type = (cmd.index_type == IndexType::UINT16) ? MTL::IndexTypeUInt16 : MTL::IndexTypeUInt32;
+    NS::UInteger index_size = (cmd.index_type == IndexType::UINT16) ? sizeof(u16) : sizeof(u32);
+    MTL::GPUAddress addr = cmd.index_buffer->gpuAddress();
+    addr += cmd.index_offset + (u64)firstIndex * index_size;
+    cmd.encoder->drawIndexedPrimitives(
+        MTL::PrimitiveTypeTriangle,
+        indexCount,
+        type,
+        addr,
+        (NS::UInteger)indexCount * index_size,
+        instanceCount,
+        (NS::Integer)vtxOff,
+        firstInstance
+    );
+}
+
+void set_viewports(CmdBuffer &cmd, Viewport *viewports, u32 viewportCount) {
+    if (!cmd.encoder || !viewports || viewportCount == 0) {
+        return;
+    }
+    const Viewport &vp = viewports[0];
+    MTL::Viewport mvp;
+    mvp.originX = vp.x;
+    mvp.originY = vp.y;
+    mvp.width = vp.width;
+    mvp.height = vp.height;
+    mvp.znear = vp.depth_min;
+    mvp.zfar = vp.depth_max;
+    cmd.encoder->setViewport(mvp);
+}
+
+void set_scissors(CmdBuffer &cmd, const Rect *rects, u32 rectCount) {
+    if (!cmd.encoder || !rects || rectCount == 0) {
+        return;
+    }
+    const Rect &r = rects[0];
+    MTL::ScissorRect sr;
+    sr.x = r.x > 0 ? (NS::UInteger)r.x : 0;
+    sr.y = r.y > 0 ? (NS::UInteger)r.y : 0;
+    sr.width = r.width > 0 ? (NS::UInteger)r.width : 0;
+    sr.height = r.height > 0 ? (NS::UInteger)r.height : 0;
+    cmd.encoder->setScissorRect(sr);
+}
+
+bool valid(const CmdBuffer &cmd) {
+    return cmd.handle != nullptr;
+}
+
+bool valid(const CmdPool &pool) {
+    return pool.handle != nullptr;
+}
+
+bool valid(const Swapchain &swapchain) {
+    return swapchain.layer != nullptr;
+}
+
+bool valid(const Sync *sync) {
+    return sync != nullptr && sync->timeline != nullptr;
+}
+
+bool valid(const Buffer &buffer) {
+    return buffer.handle != nullptr;
+}
+
+bool valid(const RenderPipeline &pipeline) {
+    return pipeline.handle != nullptr;
+}
+
+bool valid(const ComputePipeline &pipeline) {
+    return pipeline.handle != nullptr;
+}
+
+void set_constants(CmdBuffer &cmd, ComputePipeline &pipeline, rhi::ShaderStage stage, u32 size, const void *data) {
+    (void)cmd;
+    (void)pipeline;
+    (void)stage;
+    (void)size;
+    (void)data;
+    VEL_ERROR("set_constants(compute) is not implemented on Metal");
+}
+
+void barrier(CmdBuffer &cmd, ResourceState before, ResourceState after) {
+    (void)cmd;
+    (void)before;
+    (void)after;
+}
+
+void barrier(CmdBuffer &cmd, Buffer &buffer, ResourceState before, ResourceState after) {
+    (void)cmd;
+    (void)buffer;
+    (void)before;
+    (void)after;
+}
+
+void barrier(CmdBuffer &cmd, Image &image, const ImageRange &range, ResourceState before, ResourceState after) {
+    (void)cmd;
+    (void)image;
+    (void)range;
+    (void)before;
+    (void)after;
+}
+
+void blit_image(CmdBuffer &cmd, Image &image, const ImageBlit *regions, u32 region_count) {
+    (void)cmd;
+    (void)image;
+    (void)regions;
+    (void)region_count;
+    VEL_ERROR("blit_image is not implemented on Metal");
+}
+
+void copy_buffer_to_texture(
+    CmdBuffer &cmd, Buffer &srcBuffer, ImageView &dstView, const BufferTextureCopyRegion &region
+) {
+    (void)cmd;
+    if (!srcBuffer.handle || !dstView.desc.image || !dstView.desc.image->handle) {
+        VEL_ERROR("copy_buffer_to_texture: null source buffer or destination image");
+        return;
+    }
+    if (region.mip_level != 0 || region.base_array_layer != 0 || region.layer_count != 1 ||
+        region.texture_offset_z != 0 || region.texture_extent_depth != 1) {
+        VEL_ERROR("copy_buffer_to_texture: only mip-0/layer-0/depth-1 copies are supported on Metal");
+        return;
+    }
+    MTL::Texture *tex = dstView.desc.image->handle;
+    u32 bytes_per_pixel = 0;
+    switch (tex->pixelFormat()) {
+    case MTL::PixelFormatR8Unorm:
+        bytes_per_pixel = 1;
+        break;
+    case MTL::PixelFormatRGBA8Unorm:
+    case MTL::PixelFormatRGBA8Unorm_sRGB:
+    case MTL::PixelFormatBGRA8Unorm:
+    case MTL::PixelFormatR32Float:
+        bytes_per_pixel = 4;
+        break;
+    case MTL::PixelFormatRGBA16Float:
+        bytes_per_pixel = 8;
+        break;
+    default:
+        break;
+    }
+    if (bytes_per_pixel == 0) {
+        VEL_ERROR("copy_buffer_to_texture: unsupported Metal pixel format for upload");
+        return;
+    }
+    const u8 *src = (const u8 *)srcBuffer.handle->contents();
+    if (!src) {
+        VEL_ERROR("copy_buffer_to_texture: staging buffer is not CPU-visible");
+        return;
+    }
+    src += region.buffer_offset;
+    u32 row_pixels = region.buffer_row_length != 0 ? region.buffer_row_length : region.texture_extent_width;
+    NS::UInteger src_bytes_per_row = (NS::UInteger)row_pixels * bytes_per_pixel;
+    MTL::Region dst = MTL::Region(
+        region.texture_offset_x, region.texture_offset_y, region.texture_extent_width, region.texture_extent_height
+    );
+    tex->replaceRegion(dst, 0, src, src_bytes_per_row);
+}
+
+} // namespace rhi
ADD · src/backend/metal/device.cpp +119 -0
--- a/src/backend/metal/device.cpp
+++ b/src/backend/metal/device.cpp
@@ -0,0 +1,119 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+
+#include <cstdlib>
+
+#include "backend/metal/mt_api.h"
+#include "backend/metal/mt_internal.h"
+#include "core/logger.h"
+
+namespace rhi {
+using namespace mt;
+
+static void set_default_env(const char *name, const char *value) {
+    if (::getenv(name) == nullptr) {
+        ::setenv(name, value, 0);
+    }
+}
+
+void create_context(Device &device, rhi::Config &cfg) {
+    if (cfg.enable_validation) {
+        set_default_env("MTL_DEBUG_LAYER", "1");
+        set_default_env("MTL_DEBUG_LAYER_ERROR_MODE", "assert");
+        set_default_env("MTL_DEBUG_LAYER_VALIDATE_LOAD_ACTIONS", "1");
+        set_default_env("MTL_DEBUG_LAYER_VALIDATE_STORE_ACTIONS", "1");
+        set_default_env("MTL_SHADER_VALIDATION", "1");
+        set_default_env("MTL_SHADER_VALIDATION_REPORT_TO_STDERR", "1");
+    }
+    VEL_INFO("Initializing Metal Context");
+
+    MTL::Device *dev = MTL::CreateSystemDefaultDevice();
+    if (!dev) {
+        VEL_CRITICAL("Failed to create a Metal device");
+        std::abort();
+    }
+
+    MTL4::CommandQueue *queue = dev->newMTL4CommandQueue();
+    if (!queue) {
+        VEL_CRITICAL("Failed to create MTL4 command queue");
+        std::abort();
+    }
+
+    device.handle = dev;
+    device.graphics.handle = queue;
+
+    mt::create_heap(device);
+    if (!device.heap) {
+        VEL_CRITICAL("Failed to create Metal argument heap");
+        std::abort();
+    }
+
+    VEL_INFO("Selected GPU: {}", dev->name()->utf8String());
+    if (::getenv("MTL_DEBUG_LAYER") != nullptr || ::getenv("MTL_SHADER_VALIDATION") != nullptr) {
+        VEL_INFO(
+            "Metal validation: API={} Shader={}",
+            ::getenv("MTL_DEBUG_LAYER") ? ::getenv("MTL_DEBUG_LAYER") : "0",
+            ::getenv("MTL_SHADER_VALIDATION") ? ::getenv("MTL_SHADER_VALIDATION") : "0"
+        );
+    }
+}
+
+void destroy_context(Device &device) {
+    VEL_INFO("Shutting down Metal Context...");
+
+    mt::destroy_heap(device);
+
+    if (device.graphics.handle) {
+        device.graphics.handle->release();
+        device.graphics.handle = nullptr;
+    }
+    if (device.handle) {
+        device.handle->release();
+        device.handle = nullptr;
+    }
+}
+
+void device_wait_idle(Device &device) {
+    (void)device;
+    mt_wait_idle();
+}
+
+void queue_wait_idle(Device &device) {
+    (void)device;
+    mt_wait_idle();
+}
+
+bool create_memory_allocator(Device &device) {
+    (void)device;
+    // unified. nothing to do.
+    return true;
+}
+
+void destroy_memory_allocator(Device &device) {
+    (void)device;
+}
+
+MemoryStats memory_stats(Device &device) {
+    (void)device;
+    return {};
+}
+
+Queue find_queue(Device &device, u32 required, u32 excluded) {
+    (void)required;
+    (void)excluded;
+    return device.graphics;
+}
+
+Queue graphics_queue(Device &device) {
+    return device.graphics;
+}
+
+u32 queue_family_index(const Queue &queue) {
+    return queue.family_index;
+}
+
+} // namespace rhi
ADD · src/backend/metal/image.cpp +172 -0
--- a/src/backend/metal/image.cpp
+++ b/src/backend/metal/image.cpp
@@ -0,0 +1,172 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+namespace rhi {
+
+void destroy_image_views(Device &device, Image &image);
+
+static MTL::PixelFormat to_pixel_format(rhi::ImageFormat format) {
+    switch (format) {
+    case rhi::ImageFormat::R8_UNORM:
+        return MTL::PixelFormatR8Unorm;
+    case rhi::ImageFormat::RGBA8_UNORM:
+        return MTL::PixelFormatRGBA8Unorm;
+    case rhi::ImageFormat::RGBA8_SRGB:
+        return MTL::PixelFormatRGBA8Unorm_sRGB;
+    case rhi::ImageFormat::BGRA8_UNORM:
+        return MTL::PixelFormatBGRA8Unorm;
+    case rhi::ImageFormat::RGBA16_FLOAT:
+        return MTL::PixelFormatRGBA16Float;
+    case rhi::ImageFormat::R32_FLOAT:
+        return MTL::PixelFormatR32Float;
+    case rhi::ImageFormat::D32_FLOAT:
+        return MTL::PixelFormatDepth32Float;
+    default:
+        return MTL::PixelFormatRGBA8Unorm;
+    }
+}
+
+bool create_image(Device &device, ImageDesc &desc, Image &out) {
+    MTL::TextureDescriptor *td = MTL::TextureDescriptor::texture2DDescriptor(
+        to_pixel_format(desc.format), desc.width, desc.height, desc.mip_levels > 1
+    );
+
+    MTL::TextureUsage usage = MTL::TextureUsageShaderRead;
+    if (rhi::Any(desc.usage, rhi::ImageUsage::ColorAttachment)) {
+        usage |= MTL::TextureUsageRenderTarget;
+    }
+    if (rhi::Any(desc.usage, rhi::ImageUsage::DepthAttachment)) {
+        usage |= MTL::TextureUsageRenderTarget;
+    }
+    if (rhi::Any(desc.usage, rhi::ImageUsage::Storage)) {
+        usage |= MTL::TextureUsageShaderWrite;
+    }
+    td->setUsage(usage);
+    td->setStorageMode(MTL::StorageModeShared);
+
+    MTL::Texture *tex = device.handle->newTexture(td);
+    td->release();
+    if (!tex) {
+        VEL_ERROR("Failed to create Metal texture ({}x{}x{})", desc.width, desc.height, desc.depth);
+        return false;
+    }
+
+    out.desc = desc;
+    out.handle = tex;
+    if (!desc.name.empty()) {
+        tex->setLabel(NS::String::string(desc.name.c_str(), NS::UTF8StringEncoding));
+    }
+    mt::reside(device, tex);
+    return true;
+}
+
+void destroy_image(Device &device, Image &img) {
+    destroy_image_views(device, img);
+    if (img.handle) {
+        mt::unreside(device, img.handle);
+        img.handle->release();
+        img.handle = nullptr;
+    }
+}
+
+bool create_image_view(Device &device, const ImageViewDesc &desc, ImageView &out) {
+    (void)device;
+    out.desc = desc;
+    out.handle = desc.image ? desc.image->handle : nullptr;
+    if (out.handle) {
+        out.handle->retain();
+    }
+    out.slot = mt::write_texture(device, out.handle, desc.type == rhi::ImageViewType::Storage);
+    return out.handle != nullptr;
+}
+
+u64 handle_id(Device &device, ImageView &view) {
+    if (view.slot == UINT64_MAX) {
+        VEL_ERROR("handle_id: image view carries no heap slot (cached views are not shader-visible)");
+        return 0;
+    }
+    return mt::heap_texture_id(device, view.slot);
+}
+
+void destroy_image_view(Device &device, ImageView &view) {
+    mt::free_texture(device, view.slot);
+    view.slot = UINT64_MAX;
+    if (view.handle) {
+        view.handle->release();
+        view.handle = nullptr;
+    }
+}
+
+static bool same_view_key(const ImageViewDesc &a, const ImageViewDesc &b) {
+    return a.aspect == b.aspect && a.mip_start == b.mip_start && a.mip_count == b.mip_count &&
+           a.layer_start == b.layer_start && a.layer_count == b.layer_count && a.dimension == b.dimension &&
+           a.type == b.type;
+}
+
+ImageView get_cached_image_view(Device &device, Image &image, const ImageViewDesc &desc) {
+    (void)device;
+    ImageViewDesc key = desc;
+    key.image = &image;
+    for (auto &entry : image.view_cache) {
+        if (same_view_key(entry.first, key)) {
+            ImageView out{};
+            out.desc = key;
+            out.handle = entry.second;
+            return out;
+        }
+    }
+    if (image.handle) {
+        image.handle->retain();
+    }
+    image.view_cache.emplace_back(key, image.handle);
+    ImageView out{};
+    out.desc = key;
+    out.handle = image.handle;
+    return out;
+}
+
+void destroy_image_views(Device &device, Image &image) {
+    (void)device;
+    for (auto &entry : image.view_cache) {
+        if (entry.second) {
+            entry.second->release();
+        }
+    }
+    image.view_cache.clear();
+}
+
+void destroy_buffer_views(Device &device, Buffer &buffer) {
+    (void)device;
+    (void)buffer;
+}
+
+bool valid(const Image &img) {
+    return img.handle != nullptr;
+}
+
+bool valid(const ImageView &view) {
+    // cached views. no slot.
+    return view.handle != nullptr;
+}
+
+} // namespace rhi
+
+namespace mt {
+
+void upload_image_data(rhi::Device &device, rhi::Image &image, const void *data, u32 bytes_per_row) {
+    (void)device;
+    if (!image.handle) {
+        return;
+    }
+    MTL::Region region = MTL::Region(0, 0, image.desc.width, image.desc.height);
+    image.handle->replaceRegion(region, 0, data, bytes_per_row);
+}
+
+} // namespace mt
ADD · src/backend/metal/metal_impl.cpp +13 -0
--- a/src/backend/metal/metal_impl.cpp
+++ b/src/backend/metal/metal_impl.cpp
@@ -0,0 +1,13 @@
+// metal-cpp impl. one home.
+#define NS_PRIVATE_IMPLEMENTATION
+#define CA_PRIVATE_IMPLEMENTATION
+#define MTL_PRIVATE_IMPLEMENTATION
+
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+#include <QuartzCore/QuartzCore.hpp>
ADD · src/backend/metal/metal_platform.mm +42 -0
--- a/src/backend/metal/metal_platform.mm
+++ b/src/backend/metal/metal_platform.mm
@@ -0,0 +1,42 @@
+// objc++ only. appkit lives here.
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX __FLT_MAX__
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX __DBL_MAX__
+#endif
+#include <AppKit/AppKit.h>
+#include <QuartzCore/CAMetalLayer.h>
+
+#define GLFW_EXPOSE_NATIVE_COCOA
+#include <GLFW/glfw3.h>
+#include <GLFW/glfw3native.h>
+
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+#include <QuartzCore/QuartzCore.hpp>
+
+#include "backend/metal/mt_internal.h"
+
+namespace mt {
+
+CA::MetalLayer *mt_attach_metal_layer(void *glfw_window, MTL::Device *device) {
+    NSView *view = glfwGetCocoaView(static_cast<GLFWwindow *>(glfw_window));
+
+    CA::MetalLayer *layer = CA::MetalLayer::layer();
+    layer->setDevice(device);
+    // caller frees.
+    layer->retain();
+
+    CAMetalLayer *objc_layer = (__bridge CAMetalLayer *)layer;
+    view.wantsLayer = YES;
+    view.layer = objc_layer;
+
+    return layer;
+}
+
+} // namespace mt
ADD · src/backend/metal/mt_api.h +369 -0
--- a/src/backend/metal/mt_api.h
+++ b/src/backend/metal/mt_api.h
@@ -0,0 +1,369 @@
+#pragma once
+
+#include "backend/rhi_types.h"
+
+#include <slang-com-helper.h>
+#include <slang-com-ptr.h>
+#include <slang.h>
+
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace MTL {
+class Allocation;
+class ArgumentEncoder;
+class Device;
+class CommandQueue;
+class CommandBuffer;
+class RenderCommandEncoder;
+class RenderPipelineState;
+class Library;
+class Function;
+class Buffer;
+class Texture;
+class SamplerState;
+class DepthStencilState;
+class DepthStencilDescriptor;
+class ResidencySet;
+class ResidencySetDescriptor;
+} // namespace MTL
+
+namespace MTL4 {
+class ArgumentTable;
+class ArgumentTableDescriptor;
+class CommandAllocator;
+class CommandAllocatorDescriptor;
+class CommandBuffer;
+class CommandQueue;
+class RenderCommandEncoder;
+class RenderPassDescriptor;
+} // namespace MTL4
+
+namespace CA {
+class MetalLayer;
+class MetalDrawable;
+} // namespace CA
+
+namespace rhi {
+struct Device;
+struct Sampler;
+struct Image;
+struct CmdBuffer;
+struct ShaderCompiler;
+} // namespace rhi
+
+// mt only. not rhi.
+namespace mt {
+
+struct IndexPool {
+    u32 cap = 0;
+    u32 next = 0;
+    std::vector<u32> free_list;
+    u64 alloc();
+    void free(u64 slot);
+};
+
+// table: 0 push, 2..17 vertex fetch. rest rides in push.
+static constexpr u32 kPushTableIndex = 0;
+static constexpr u32 kVertexBaseIndex = 2;
+static constexpr u32 kMaxVertexBindings = 16;
+static constexpr u32 kMaxBufferBindCount = kVertexBaseIndex + kMaxVertexBindings; // 18
+static_assert(kMaxBufferBindCount <= 31, "MTL4 argument table allows at most 31 buffer binds");
+// unused. keeps validator quiet.
+static constexpr u32 kMaxTextureBindCount = 1;
+static constexpr u32 kMaxSamplerBindCount = 1;
+static_assert(kMaxTextureBindCount <= 128, "MTL4 argument table allows at most 128 texture binds");
+static_assert(kMaxSamplerBindCount <= 16, "MTL4 argument table allows at most 16 sampler binds");
+
+// host id lists. no gpu mirror.
+static constexpr u32 kHeapTextureBudget = 8192;
+static constexpr u32 kHeapSamplerBudget = 32;
+
+struct Heap {
+    MTL4::ArgumentTable *table = nullptr;
+    MTL::ResidencySet *residency = nullptr;
+    // slot -> id. buffers use addresses.
+    std::vector<u64> texture_ids;
+    std::vector<u64> sampler_ids;
+    IndexPool sampler_space;
+    IndexPool texture_space;
+};
+
+std::string compile_msl(rhi::ShaderCompiler &sc, const char *path, const char *entryName);
+std::string compile_msl_linked(rhi::ShaderCompiler &sc, const char *path, const char *const *entries, u32 entry_count);
+
+void upload_image_data(rhi::Device &device, rhi::Image &image, const void *data, u32 bytes_per_row);
+
+void create_heap(rhi::Device &device);
+void destroy_heap(rhi::Device &device);
+u64 write_sampler(rhi::Device &device, rhi::Sampler sampler);
+u64 write_texture(rhi::Device &device, MTL::Texture *view, bool storage);
+// 8b handles. slang reads them raw.
+u64 heap_texture_id(rhi::Device &device, u64 slot);
+u64 heap_sampler_id(rhi::Device &device, u64 slot);
+void free_texture(rhi::Device &device, u64 slot);
+void free_sampler(rhi::Device &device, u64 slot);
+// gpu must see it. add here, drop at destroy.
+void reside(rhi::Device &device, const MTL::Allocation *alloc);
+void unreside(rhi::Device &device, const MTL::Allocation *alloc);
+// scratch push. cmd frees it.
+MTL::Buffer *push_bump_alloc(rhi::CmdBuffer &cmd, const void *data, u32 size);
+
+} // namespace mt
+
+namespace rhi {
+
+struct ShaderCompiler {
+    Slang::ComPtr<slang::IGlobalSession> global;
+    Slang::ComPtr<slang::ISession> session;
+
+    bool recreate_session();
+};
+
+struct ShaderModule {
+    void *handle = nullptr;
+    rhi::ShaderStage stage = rhi::ShaderStage::NONE;
+};
+
+struct Memory {
+    void *handle = nullptr;
+};
+
+struct Queue {
+    MTL4::CommandQueue *handle = nullptr;
+    u32 family_index = 0;
+    u32 queue_index = 0;
+};
+
+struct Device {
+    MTL::Device *handle = nullptr;
+    Queue graphics;
+    rhi::ImageFormat format = rhi::ImageFormat::BGRA8_UNORM;
+
+    u32 min_ubo_alignment = 16;
+    u64 timestamp_period = 1;
+
+    mt::Heap *heap = nullptr;
+};
+
+struct Swapchain {
+    CA::MetalLayer *layer = nullptr;
+    CA::MetalDrawable *current = nullptr;
+    rhi::ImageFormat format = rhi::ImageFormat::BGRA8_UNORM;
+    rhi::Extent2D extent = {};
+    u32 maximumDrawableCount = 3;
+    bool recreate = false;
+};
+
+struct Buffer {
+    rhi::BufferDesc desc{};
+    MTL::Buffer *handle = nullptr;
+    void *mapped = nullptr;
+    u64 address = 0;
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+};
+
+struct Image {
+    rhi::ImageDesc desc{};
+    MTL::Texture *handle = nullptr;
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+    std::vector<std::pair<ImageViewDesc, MTL::Texture *>> view_cache;
+};
+
+struct ImageView {
+    rhi::ImageViewDesc desc{};
+    MTL::Texture *handle = nullptr;
+    u64 slot = UINT64_MAX;
+};
+
+struct BufferView {
+    Buffer *buffer = nullptr;
+    rhi::BufferViewDesc desc{};
+    MTL::Buffer *handle = nullptr;
+    u64 slot = UINT64_MAX;
+};
+
+struct Sampler {
+    MTL::SamplerState *handle = nullptr;
+    u64 slot = UINT64_MAX;
+};
+
+struct RenderPipeline {
+    Device *device = nullptr;
+    MTL::RenderPipelineState *handle = nullptr;
+    MTL::DepthStencilState *depth_stencil = nullptr;
+
+    // push lookup by size.
+    struct ConstBlock {
+        u32 byte_size = 0;
+        u32 table_index = 0;
+    };
+    std::vector<ConstBlock> const_blocks;
+};
+
+// no compute yet.
+struct ComputePipeline {
+    Device *device = nullptr;
+    void *handle = nullptr;
+};
+
+struct QueryPool {
+    void *handle = nullptr;
+    rhi::QueryPoolDesc desc{};
+};
+
+struct AccelStruct {
+    void *handle = nullptr;
+    Buffer *buffer = nullptr;
+};
+
+struct ComputePipelineDesc {
+    Device *device = nullptr;
+
+    std::string shader_path;
+    std::string cs_entry;
+    std::vector<ShaderModule> shader_modules;
+
+    ComputePipelineDesc() = default;
+    ComputePipelineDesc(const ComputePipelineDesc &) = default;
+    ComputePipelineDesc &operator=(const ComputePipelineDesc &) = default;
+
+    ComputePipelineDesc &set_shader(ShaderCompiler &sc, const char *path, const char *cs);
+
+    ComputePipeline build();
+};
+
+struct RenderPipelineDesc {
+    Device *device = nullptr;
+
+    std::vector<rhi::ImageFormat> color_attachment_formats;
+    rhi::ImageFormat depth_attachment_format = rhi::ImageFormat::UNDEFINED;
+
+    std::string shader_path;
+    std::string vs_entry, fs_entry;
+    std::vector<ShaderModule> shader_modules;
+
+    std::string msl_source;
+
+    std::vector<VertexAttribute> vertex_attributes;
+    std::vector<VertexBinding> vertex_bindings;
+
+    rhi::PipelineTopology topology = rhi::PipelineTopology::TRIANGLES;
+    rhi::PipelineFillMode fill_mode = rhi::PipelineFillMode::SOLID;
+    rhi::PipelineCullMode cull_mode = rhi::PipelineCullMode::BACK;
+    rhi::PipelineTriangleWindingOrder winding = rhi::PipelineTriangleWindingOrder::CCW;
+
+    rhi::SampleCount samples = rhi::SampleCount::Sample1;
+
+    bool depth_test_enable = true;
+    bool depth_write_enable = true;
+    bool depth_bias_enable = false;
+    f32 depth_bias_constant = 0.0;
+    f32 depth_bias_clamp = 0.0;
+    f32 depth_bias_slope = 0.0;
+    bool depth_clamp_enable = false;
+    rhi::PipelineCompareOp depth_compare_op = rhi::PipelineCompareOp::LESS;
+    bool enable_dynamic_polygon_mode = false;
+    bool enable_dynamic_depth_write = false;
+
+    // reflection opt-in.
+    bool enable_abi_blocks = false;
+
+    bool blend_enable = false;
+    rhi::PipelineBlendFactor src_color_blend_factor = rhi::PipelineBlendFactor::SRC_ALPHA;
+    rhi::PipelineBlendFactor dst_color_blend_factor = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA;
+    rhi::PipelineBlendOp color_blend_op = rhi::PipelineBlendOp::ADD;
+    rhi::PipelineBlendFactor src_alpha_blend_factor = rhi::PipelineBlendFactor::SRC_ALPHA;
+    rhi::PipelineBlendFactor dst_alpha_blend_factor = rhi::PipelineBlendFactor::SRC_ALPHA;
+    rhi::PipelineBlendOp alpha_blend_op = rhi::PipelineBlendOp::ADD;
+
+    RenderPipelineDesc() = default;
+    RenderPipelineDesc(const RenderPipelineDesc &) = default;
+    RenderPipelineDesc &operator=(const RenderPipelineDesc &) = default;
+
+    RenderPipelineDesc &set_shaders(ShaderCompiler &sc, const char *path, const char *vs, const char *fs);
+    RenderPipelineDesc &set_input_topology(rhi::PipelineTopology topology);
+    RenderPipelineDesc &add_vertex_binding(u32 binding, u32 stride = 0, bool is_instanced = false);
+    RenderPipelineDesc &add_vertex_attribute(u32 location, u32 binding, ImageFormat format, u32 offset = 0);
+    RenderPipelineDesc &set_polygon_mode(rhi::PipelineFillMode mode);
+    RenderPipelineDesc &set_color_format(rhi::ImageFormat format);
+    RenderPipelineDesc &set_depth_format(rhi::ImageFormat format);
+    RenderPipelineDesc &set_cull_mode(rhi::PipelineCullMode cull_mode, rhi::PipelineTriangleWindingOrder winding);
+    RenderPipelineDesc &set_multisampling(rhi::SampleCount count = rhi::SampleCount::Sample1);
+    RenderPipelineDesc &set_depth_testing(bool do_test, bool do_write, rhi::PipelineCompareOp op);
+    RenderPipelineDesc &set_depth_bias(bool enabled, f32 constant, f32 clamp, f32 slope);
+    RenderPipelineDesc &set_depth_clamp(bool enabled);
+    RenderPipelineDesc &set_dynamic_polygon_mode(bool enable = true) {
+        enable_dynamic_polygon_mode = enable;
+        return *this;
+    }
+    RenderPipelineDesc &set_dynamic_depth_write(bool enable = true) {
+        enable_dynamic_depth_write = enable;
+        return *this;
+    }
+    RenderPipelineDesc &set_blending(
+        rhi::PipelineBlendFactor src_color = rhi::PipelineBlendFactor::SRC_ALPHA,
+        rhi::PipelineBlendFactor dst_color = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA,
+        rhi::PipelineBlendOp color_op = rhi::PipelineBlendOp::ADD,
+        rhi::PipelineBlendFactor src_alpha = rhi::PipelineBlendFactor::SRC_ALPHA,
+        rhi::PipelineBlendFactor dst_alpha = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA,
+        rhi::PipelineBlendOp alpha_op = rhi::PipelineBlendOp::ADD
+    );
+
+    RenderPipeline build();
+};
+
+struct CmdPool;
+
+struct CmdPool {
+    void *handle = nullptr;
+};
+
+struct CmdBuffer {
+    MTL4::CommandBuffer *handle = nullptr;
+    MTL4::RenderCommandEncoder *encoder = nullptr;
+    MTL4::CommandQueue *queue = nullptr;
+    MTL4::CommandAllocator *allocator = nullptr;
+    MTL4::ArgumentTable *table = nullptr;
+    MTL::ResidencySet *residency = nullptr;
+    bool is_rendering = false;
+
+    // scratch. freed on begin.
+    std::vector<MTL::Buffer *> transients;
+
+    // read at draw.
+    MTL::Buffer *index_buffer = nullptr;
+    rhi::IndexType index_type = rhi::IndexType::UINT32;
+    u64 index_offset = 0;
+};
+
+struct Sync {
+    void *timeline = nullptr;
+    void *device = nullptr;
+};
+
+struct SyncPoint {
+    Sync *sync = nullptr;
+    u64 value = 0;
+};
+
+struct QueueWait {
+    SyncPoint point;
+    rhi::PipelineStages stage_mask;
+};
+
+struct QueueSignal {
+    SyncPoint point;
+};
+
+struct QueueSubmitDesc {
+    u32 wait_count = 0;
+    const QueueWait *waits = nullptr;
+    u32 cmd_count = 0;
+    const CmdBuffer *cmds = nullptr;
+    u32 signal_count = 0;
+    const QueueSignal *signals = nullptr;
+};
+
+} // namespace rhi
ADD · src/backend/metal/mt_internal.h +25 -0
--- a/src/backend/metal/mt_internal.h
+++ b/src/backend/metal/mt_internal.h
@@ -0,0 +1,25 @@
+#pragma once
+
+namespace MTL {
+class Device;
+} // namespace MTL
+
+namespace CA {
+class MetalLayer;
+class MetalDrawable;
+} // namespace CA
+
+namespace mt {
+
+CA::MetalLayer *mt_attach_metal_layer(void *glfw_window, MTL::Device *device);
+
+// +1. caller frees.
+void mt_set_current_drawable(CA::MetalDrawable *drawable);
+// borrowed.
+CA::MetalDrawable *mt_current_drawable();
+// drop current.
+void mt_clear_current_drawable();
+
+void mt_wait_idle();
+
+} // namespace mt
ADD · src/backend/metal/pipeline.cpp +399 -0
--- a/src/backend/metal/pipeline.cpp
+++ b/src/backend/metal/pipeline.cpp
@@ -0,0 +1,399 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+namespace {
+
+// has texture/sampler?
+static bool struct_has_opaque_members(MTL::StructType *st) {
+    if (!st || !st->members()) {
+        return false;
+    }
+    auto *members = st->members();
+    for (NS::UInteger i = 0; i < members->count(); ++i) {
+        MTL::StructMember *m = static_cast<MTL::StructMember *>(members->object(i));
+        MTL::DataType dt = m->dataType();
+        if (dt == MTL::DataTypeTexture || dt == MTL::DataTypeSampler) {
+            return true;
+        }
+        if (dt == MTL::DataTypeStruct) {
+            if (struct_has_opaque_members(m->structType())) {
+                return true;
+            }
+        }
+        if (dt == MTL::DataTypeArray) {
+            MTL::ArrayType *at = m->arrayType();
+            if (!at) {
+                continue;
+            }
+            MTL::DataType et = at->elementType();
+            if (et == MTL::DataTypeTexture || et == MTL::DataTypeSampler) {
+                return true;
+            }
+            if (et == MTL::DataTypeStruct) {
+                if (struct_has_opaque_members(at->elementStructType())) {
+                    return true;
+                }
+            }
+        }
+    }
+    return false;
+}
+
+static bool arg_struct_has_opaque_members(MTL::Argument *arg) {
+    return struct_has_opaque_members(arg->bufferStructType());
+}
+
+template <typename TArray> static void record_stage_args(rhi::RenderPipeline &out, TArray *args, const char *stage) {
+    for (NS::UInteger i = 0; i < args->count(); ++i) {
+        MTL::Argument *a = static_cast<MTL::Argument *>(args->object(i));
+        if (a->type() != MTL::ArgumentTypeBuffer) {
+            continue;
+        }
+        MTL::StructType *st = a->bufferStructType();
+        if (!st) {
+            continue;
+        }
+        if (arg_struct_has_opaque_members(a)) {
+            continue;
+        }
+        rhi::RenderPipeline::ConstBlock cb{};
+        cb.byte_size = (u32)a->bufferDataSize();
+        cb.table_index = (u32)a->index();
+        bool known = false;
+        for (auto &e : out.const_blocks) {
+            if (e.table_index == cb.table_index) {
+                known = true;
+                break;
+            }
+        }
+        if (!known) {
+            out.const_blocks.push_back(cb);
+            VEL_INFO("metal const: {} bytes at table index {} ({} stage)", cb.byte_size, cb.table_index, stage);
+        }
+    }
+}
+
+} // namespace
+
+namespace rhi {
+
+static NS::String *str(const std::string &s) {
+    return NS::String::string(s.c_str(), NS::UTF8StringEncoding);
+}
+
+static MTL::VertexFormat to_vertex_format(rhi::ImageFormat format) {
+    switch (format) {
+    case rhi::ImageFormat::R32_FLOAT:
+        return MTL::VertexFormatFloat;
+    case rhi::ImageFormat::RG32_FLOAT:
+        return MTL::VertexFormatFloat2;
+    case rhi::ImageFormat::RGB32_FLOAT:
+        return MTL::VertexFormatFloat3;
+    case rhi::ImageFormat::RGBA32_FLOAT:
+        return MTL::VertexFormatFloat4;
+    default:
+        return MTL::VertexFormatFloat2;
+    }
+}
+
+static MTL::PixelFormat to_pixel_format(rhi::ImageFormat format) {
+    switch (format) {
+    case rhi::ImageFormat::RGBA8_UNORM:
+        return MTL::PixelFormatRGBA8Unorm;
+    case rhi::ImageFormat::RGBA8_SRGB:
+        return MTL::PixelFormatRGBA8Unorm_sRGB;
+    case rhi::ImageFormat::BGRA8_UNORM:
+        return MTL::PixelFormatBGRA8Unorm;
+    default:
+        return MTL::PixelFormatBGRA8Unorm;
+    }
+}
+
+static MTL::CullMode to_cull_mode(rhi::PipelineCullMode mode) {
+    switch (mode) {
+    case rhi::PipelineCullMode::NONE:
+        return MTL::CullModeNone;
+    case rhi::PipelineCullMode::FRONT:
+        return MTL::CullModeFront;
+    case rhi::PipelineCullMode::BACK:
+    default:
+        return MTL::CullModeBack;
+    }
+}
+
+static MTL::Winding to_winding(rhi::PipelineTriangleWindingOrder winding) {
+    switch (winding) {
+    case rhi::PipelineTriangleWindingOrder::CW:
+        return MTL::WindingClockwise;
+    case rhi::PipelineTriangleWindingOrder::CCW:
+    default:
+        return MTL::WindingCounterClockwise;
+    }
+}
+
+static MTL::PixelFormat to_depth_format(rhi::ImageFormat format) {
+    switch (format) {
+    case rhi::ImageFormat::D32_FLOAT:
+        return MTL::PixelFormatDepth32Float;
+    default:
+        return MTL::PixelFormatInvalid;
+    }
+}
+
+static MTL::CompareFunction to_compare(rhi::PipelineCompareOp op) {
+    switch (op) {
+    case rhi::PipelineCompareOp::NEVER:
+        return MTL::CompareFunctionNever;
+    case rhi::PipelineCompareOp::EQUAL:
+        return MTL::CompareFunctionEqual;
+    case rhi::PipelineCompareOp::LESS_EQUAL:
+        return MTL::CompareFunctionLessEqual;
+    case rhi::PipelineCompareOp::GREATER:
+        return MTL::CompareFunctionGreater;
+    case rhi::PipelineCompareOp::NOT_EQUAL:
+        return MTL::CompareFunctionNotEqual;
+    case rhi::PipelineCompareOp::GREATER_EQUAL:
+        return MTL::CompareFunctionGreaterEqual;
+    case rhi::PipelineCompareOp::ALWAYS:
+        return MTL::CompareFunctionAlways;
+    case rhi::PipelineCompareOp::LESS:
+    default:
+        return MTL::CompareFunctionLess;
+    }
+}
+
+static rhi::ImageFormat first_color_format(const RenderPipelineDesc &desc) {
+    if (!desc.color_attachment_formats.empty()) {
+        return desc.color_attachment_formats[0];
+    }
+    return rhi::ImageFormat::BGRA8_UNORM;
+}
+
+RenderPipelineDesc &
+RenderPipelineDesc::set_shaders(ShaderCompiler &sc, const char *path, const char *vs, const char *fs) {
+    shader_path = path ? path : "";
+    vs_entry = vs ? vs : "";
+    fs_entry = fs ? fs : "";
+    const char *entries[] = {vs, fs};
+    msl_source = mt::compile_msl_linked(sc, path, entries, 2);
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_input_topology(rhi::PipelineTopology topo) {
+    topology = topo;
+    return *this;
+}
+
+RenderPipelineDesc &
+RenderPipelineDesc::add_vertex_attribute(u32 location, u32 binding, rhi::ImageFormat format, u32 offset) {
+    vertex_attributes.push_back({location, binding, format, offset});
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::add_vertex_binding(u32 binding, u32 stride, bool is_instanced) {
+    if (binding >= mt::kMaxVertexBindings) {
+        VEL_ERROR("add_vertex_binding: binding {} exceeds max {}", binding, mt::kMaxVertexBindings);
+        return *this;
+    }
+    vertex_bindings.push_back({binding, stride, is_instanced});
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_polygon_mode(rhi::PipelineFillMode mode) {
+    fill_mode = mode;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_color_format(rhi::ImageFormat format) {
+    color_attachment_formats.clear();
+    color_attachment_formats.push_back(format);
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_format(rhi::ImageFormat format) {
+    depth_attachment_format = format;
+    return *this;
+}
+
+RenderPipelineDesc &
+RenderPipelineDesc::set_cull_mode(rhi::PipelineCullMode mode, rhi::PipelineTriangleWindingOrder wind) {
+    cull_mode = mode;
+    winding = wind;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_multisampling(rhi::SampleCount count) {
+    samples = count;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_testing(bool do_test, bool do_write, rhi::PipelineCompareOp op) {
+    depth_test_enable = do_test;
+    depth_write_enable = do_write;
+    depth_compare_op = op;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_bias(bool enabled, f32 constant, f32 clamp, f32 slope) {
+    depth_bias_enable = enabled;
+    depth_bias_constant = constant;
+    depth_bias_clamp = clamp;
+    depth_bias_slope = slope;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_clamp(bool enabled) {
+    depth_clamp_enable = enabled;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_blending(
+    rhi::PipelineBlendFactor src_color,
+    rhi::PipelineBlendFactor dst_color,
+    rhi::PipelineBlendOp color_op,
+    rhi::PipelineBlendFactor src_alpha,
+    rhi::PipelineBlendFactor dst_alpha,
+    rhi::PipelineBlendOp alpha_op
+) {
+    blend_enable = true;
+    src_color_blend_factor = src_color;
+    dst_color_blend_factor = dst_color;
+    color_blend_op = color_op;
+    src_alpha_blend_factor = src_alpha;
+    dst_alpha_blend_factor = dst_alpha;
+    alpha_blend_op = alpha_op;
+    return *this;
+}
+
+ComputePipelineDesc &ComputePipelineDesc::set_shader(ShaderCompiler &sc, const char *path, const char *cs) {
+    (void)sc;
+    shader_path = path ? path : "";
+    cs_entry = cs ? cs : "";
+    VEL_ERROR("ComputePipeline is not implemented on Metal");
+    return *this;
+}
+
+ComputePipeline ComputePipelineDesc::build() {
+    VEL_ERROR("ComputePipeline::build is not implemented on Metal");
+    ComputePipeline out{};
+    out.device = device;
+    return out;
+}
+
+RenderPipeline RenderPipelineDesc::build() {
+    RenderPipeline out{};
+    out.device = device;
+    MTL::Device *dev = device ? device->handle : nullptr;
+    if (!dev) {
+        VEL_ERROR("RenderPipeline::build: null device");
+        return out;
+    }
+    NS::Error *error = nullptr;
+
+    MTL::Library *lib = dev->newLibrary(str(msl_source), nullptr, &error);
+    if (!lib) {
+        VEL_ERROR(
+            "Failed to compile Metal library: {}", error ? error->localizedDescription()->utf8String() : "unknown error"
+        );
+        return out;
+    }
+
+    MTL::Function *vs = lib->newFunction(str(vs_entry));
+    MTL::Function *fs = lib->newFunction(str(fs_entry));
+    if (!vs || !fs) {
+        VEL_ERROR("Failed to find entry points '{}'/'{}' in Metal library", vs_entry, fs_entry);
+        lib->release();
+        return out;
+    }
+
+    MTL::RenderPipelineDescriptor *rpd = MTL::RenderPipelineDescriptor::alloc()->init();
+    rpd->setVertexFunction(vs);
+    rpd->setFragmentFunction(fs);
+    rpd->colorAttachments()->object(0)->setPixelFormat(to_pixel_format(first_color_format(*this)));
+    // pipeline depth must match pass.
+    if (depth_attachment_format != rhi::ImageFormat::UNDEFINED) {
+        rpd->setDepthAttachmentPixelFormat(to_depth_format(depth_attachment_format));
+    }
+
+    if (!vertex_attributes.empty()) {
+        // fetch at 2+binding. matches cmd.
+        MTL::VertexDescriptor *vd = MTL::VertexDescriptor::vertexDescriptor();
+        for (const auto &attr : vertex_attributes) {
+            MTL::VertexAttributeDescriptor *a = vd->attributes()->object(attr.location);
+            a->setFormat(to_vertex_format(attr.format));
+            a->setOffset(attr.offset);
+            a->setBufferIndex(mt::kVertexBaseIndex + attr.binding);
+        }
+        for (const auto &binding : vertex_bindings) {
+            MTL::VertexBufferLayoutDescriptor *l = vd->layouts()->object(mt::kVertexBaseIndex + binding.binding);
+            l->setStride(binding.stride);
+            l->setStepFunction(
+                binding.is_instanced ? MTL::VertexStepFunctionPerInstance : MTL::VertexStepFunctionPerVertex
+            );
+        }
+        rpd->setVertexDescriptor(vd);
+    }
+
+    (void)to_cull_mode(cull_mode);
+    (void)to_winding(winding);
+
+    MTL::RenderPipelineState *ps = nullptr;
+    if (enable_abi_blocks) {
+        MTL::RenderPipelineReflection *refl = nullptr;
+        ps = dev->newRenderPipelineState(rpd, MTL::PipelineOptionArgumentInfo, &refl, &error);
+        if (!ps || !refl) {
+            VEL_ERROR(
+                "Failed to create render pipeline state: {}",
+                error ? error->localizedDescription()->utf8String() : "unknown error"
+            );
+            vs->release();
+            fs->release();
+            rpd->release();
+            lib->release();
+            return out;
+        }
+        record_stage_args(out, refl->vertexArguments(), "vertex");
+        record_stage_args(out, refl->fragmentArguments(), "fragment");
+        refl->release();
+    } else {
+        ps = dev->newRenderPipelineState(rpd, &error);
+        if (!ps) {
+            VEL_ERROR(
+                "Failed to create render pipeline state: {}",
+                error ? error->localizedDescription()->utf8String() : "unknown error"
+            );
+            vs->release();
+            fs->release();
+            rpd->release();
+            lib->release();
+            return out;
+        }
+    }
+
+    vs->release();
+    fs->release();
+    rpd->release();
+    lib->release();
+
+    out.handle = ps;
+    if (depth_attachment_format != rhi::ImageFormat::UNDEFINED && (depth_test_enable || depth_write_enable)) {
+        MTL::DepthStencilDescriptor *dd = MTL::DepthStencilDescriptor::alloc()->init();
+        dd->setDepthCompareFunction(to_compare(depth_compare_op));
+        dd->setDepthWriteEnabled(depth_write_enable);
+        out.depth_stencil = dev->newDepthStencilState(dd);
+        dd->release();
+        if (!out.depth_stencil) {
+            VEL_ERROR("RenderPipeline::build: newDepthStencilState failed (depth runs untested)");
+        }
+    }
+    return out;
+}
+
+} // namespace rhi
ADD · src/backend/metal/sampler.cpp +84 -0
--- a/src/backend/metal/sampler.cpp
+++ b/src/backend/metal/sampler.cpp
@@ -0,0 +1,84 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+namespace rhi {
+
+static MTL::SamplerMinMagFilter to_filter(rhi::SamplerFilter filter) {
+    switch (filter) {
+    case rhi::SamplerFilter::POINT:
+        return MTL::SamplerMinMagFilterNearest;
+    case rhi::SamplerFilter::LINEAR:
+    case rhi::SamplerFilter::ANISOTROPIC:
+    default:
+        return MTL::SamplerMinMagFilterLinear;
+    }
+}
+
+static MTL::SamplerAddressMode to_address(rhi::SamplerAddressMode mode) {
+    switch (mode) {
+    case rhi::SamplerAddressMode::WRAP:
+        return MTL::SamplerAddressModeRepeat;
+    case rhi::SamplerAddressMode::MIRROR:
+        return MTL::SamplerAddressModeMirrorRepeat;
+    case rhi::SamplerAddressMode::CLAMP:
+        return MTL::SamplerAddressModeClampToEdge;
+    case rhi::SamplerAddressMode::BORDER:
+    default:
+        return MTL::SamplerAddressModeClampToEdge;
+    }
+}
+
+bool create_sampler(Device &device, SamplerDesc &desc, Sampler &sampler) {
+    MTL::SamplerDescriptor *sd = MTL::SamplerDescriptor::alloc()->init();
+    sd->setMinFilter(to_filter(desc.filter));
+    sd->setMagFilter(to_filter(desc.filter));
+    sd->setSAddressMode(to_address(desc.address));
+    sd->setTAddressMode(to_address(desc.address));
+    if (desc.use_mips) {
+        sd->setMipFilter(MTL::SamplerMipFilterLinear);
+    }
+
+    MTL::SamplerState *state = device.handle->newSamplerState(sd);
+    sd->release();
+    if (!state) {
+        VEL_ERROR("Failed to create Metal sampler state");
+        return false;
+    }
+
+    sampler.handle = state;
+    if (!desc.name.empty()) {
+        state->setLabel(NS::String::string(desc.name.c_str(), NS::UTF8StringEncoding));
+    }
+    sampler.slot = mt::write_sampler(device, sampler);
+    return true;
+}
+
+u64 handle_id(Device &device, Sampler &sampler) {
+    if (sampler.slot == UINT64_MAX) {
+        VEL_ERROR("handle_id: sampler carries no heap slot");
+        return 0;
+    }
+    return mt::heap_sampler_id(device, sampler.slot);
+}
+
+void destroy_sampler(Device &device, Sampler &sampler) {
+    mt::free_sampler(device, sampler.slot);
+    sampler.slot = UINT64_MAX;
+    if (sampler.handle) {
+        sampler.handle->release();
+        sampler.handle = nullptr;
+    }
+}
+
+bool valid(const Sampler &sampler) {
+    return sampler.handle != nullptr;
+}
+
+} // namespace rhi
ADD · src/backend/metal/shader.cpp +253 -0
--- a/src/backend/metal/shader.cpp
+++ b/src/backend/metal/shader.cpp
@@ -0,0 +1,253 @@
+#include <array>
+#include <cstdio>
+#include <string>
+#include <vector>
+
+#include "backend/metal/mt_api.h"
+#include "core/logger.h"
+
+namespace {
+
+// handles come with the lowering. no patching.
+static bool is_msl_space(char c) {
+    return c == ' ' || c == '\t' || c == '\r' || c == '\n';
+}
+
+static bool is_msl_ident(char c) {
+    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
+}
+
+// slang moves push around. pin it to 0.
+static std::string normalize_push_index(const std::string &msl) {
+    std::string out = msl;
+    size_t i = 0;
+    while (i < out.size()) {
+        size_t p = out.find("constant* ", i);
+        if (p == std::string::npos) {
+            break;
+        }
+        size_t s = p + sizeof("constant* ") - 1;
+        while (s < out.size() && out[s] == ' ') {
+            ++s;
+        }
+        if (s >= out.size() || !is_msl_ident(out[s]) || (out[s] >= '0' && out[s] <= '9')) {
+            i = s;
+            continue;
+        }
+        while (s < out.size() && is_msl_ident(out[s])) {
+            ++s;
+        }
+        size_t t = s;
+        while (t < out.size() && out[t] == ' ') {
+            ++t;
+        }
+        constexpr char kBuf[] = "[[buffer(";
+        if (out.compare(t, sizeof(kBuf) - 1, kBuf) != 0) {
+            i = s;
+            continue;
+        }
+        size_t d0 = t + sizeof(kBuf) - 1, d1 = d0;
+        while (d1 < out.size() && out[d1] >= '0' && out[d1] <= '9') {
+            ++d1;
+        }
+        if (d1 == d0 || d1 + 3 > out.size() || out.compare(d1, 3, ")]]") != 0) {
+            i = s;
+            continue;
+        }
+        if (out.compare(d0, d1 - d0, "0") != 0) {
+            VEL_INFO("metal shader: push [[buffer({})]] -> [[buffer(0)]]", out.substr(d0, d1 - d0));
+        }
+        out.replace(d0, d1 - d0, "0");
+        i = d0 + 1;
+    }
+    return out;
+}
+
+} // namespace
+
+namespace rhi {
+
+static bool build_session(ShaderCompiler &sc, slang::ISession **out) {
+    constexpr slang::CompilerOptionEntry optimization_level = {
+        .name = slang::CompilerOptionName::Optimization,
+        .value = {
+            .kind = slang::CompilerOptionValueKind::Int,
+            .intValue0 = SLANG_OPTIMIZATION_LEVEL_NONE,
+        }
+    };
+
+    constexpr slang::CompilerOptionEntry debug_info_level = {
+        .name = slang::CompilerOptionName::DebugInformation,
+        .value = {
+            .kind = slang::CompilerOptionValueKind::Int,
+            .intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD,
+        }
+    };
+
+    constexpr slang::CompilerOptionEntry entries[] = {
+        optimization_level,
+        debug_info_level,
+    };
+
+    slang::TargetDesc target = {};
+    target.format = SLANG_METAL;
+    target.flags = SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM;
+    target.compilerOptionEntries = entries;
+    target.compilerOptionEntryCount = std::size(entries);
+
+    const char *search_path[] = {"src/shaders"};
+    slang::SessionDesc desc = {};
+    desc.targets = &target;
+    desc.targetCount = 1;
+    desc.allowGLSLSyntax = true;
+    desc.searchPaths = search_path;
+    desc.searchPathCount = 1;
+
+    return SLANG_SUCCEEDED(sc.global->createSession(desc, out));
+}
+
+bool ShaderCompiler::recreate_session() {
+    Slang::ComPtr<slang::ISession> new_session;
+    if (!build_session(*this, new_session.writeRef())) {
+        VEL_ERROR("Failed to create fresh Slang session for reload");
+        return false;
+    }
+    session = new_session;
+    return true;
+}
+
+bool init_compiler(ShaderCompiler &sc) {
+    VEL_INFO("Initializing Slang Shader Compiler (Metal target)...");
+    if (SLANG_FAILED(slang::createGlobalSession(sc.global.writeRef()))) {
+        VEL_ERROR("Failed to create Slang global session");
+        return false;
+    }
+    if (!build_session(sc, sc.session.writeRef())) {
+        VEL_ERROR("Failed to create Slang session");
+        return false;
+    }
+    return true;
+}
+
+} // namespace rhi
+
+namespace mt {
+
+std::string compile_msl(rhi::ShaderCompiler &sc, const char *path, const char *entryName) {
+    Slang::ComPtr<slang::IBlob> diagnostics;
+    slang::IModule *module_ptr = sc.session->loadModule(path, diagnostics.writeRef());
+    if (!module_ptr) {
+        if (diagnostics) {
+            VEL_ERROR("Slang Load Module Error ({}): {}", path, (const char *)diagnostics->getBufferPointer());
+        } else {
+            VEL_ERROR("Slang Load Module Error ({}): Unknown error", path);
+        }
+        return {};
+    }
+    Slang::ComPtr<slang::IModule> module(module_ptr);
+
+    Slang::ComPtr<slang::IEntryPoint> entry_point;
+    if (SLANG_FAILED(module->findEntryPointByName(entryName, entry_point.writeRef()))) {
+        if (diagnostics) {
+            VEL_ERROR(
+                "Slang Find Entry Point Error ({}): {}", entryName, (const char *)diagnostics->getBufferPointer()
+            );
+        } else {
+            VEL_ERROR("Slang Find Entry Point Error ({}): Entry point not found", entryName);
+        }
+        return {};
+    }
+
+    slang::IComponentType *components[] = {module.get(), entry_point.get()};
+    Slang::ComPtr<slang::IComponentType> composed;
+    if (SLANG_FAILED(
+            sc.session->createCompositeComponentType(components, 2, composed.writeRef(), diagnostics.writeRef())
+        )) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IComponentType> linked;
+    if (SLANG_FAILED(composed->link(linked.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IBlob> code;
+    if (SLANG_FAILED(linked->getEntryPointCode(0, 0, code.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    std::string msl(static_cast<const char *>(code->getBufferPointer()), code->getBufferSize());
+    return normalize_push_index(msl);
+}
+
+std::string compile_msl_linked(rhi::ShaderCompiler &sc, const char *path, const char *const *entries, u32 entry_count) {
+    Slang::ComPtr<slang::IBlob> diagnostics;
+    slang::IModule *module_ptr = sc.session->loadModule(path, diagnostics.writeRef());
+    if (!module_ptr) {
+        if (diagnostics) {
+            VEL_ERROR("Slang Load Module Error ({}): {}", path, (const char *)diagnostics->getBufferPointer());
+        } else {
+            VEL_ERROR("Slang Load Module Error ({}): Unknown error", path);
+        }
+        return {};
+    }
+    Slang::ComPtr<slang::IModule> module(module_ptr);
+
+    std::vector<Slang::ComPtr<slang::IEntryPoint>> ep_ptrs;
+    ep_ptrs.reserve(entry_count);
+    for (u32 i = 0; i < entry_count; ++i) {
+        Slang::ComPtr<slang::IEntryPoint> ep;
+        if (SLANG_FAILED(module->findEntryPointByName(entries[i], ep.writeRef()))) {
+            VEL_ERROR("Slang Find Entry Point Error ({}): {}", entries[i], path);
+            return {};
+        }
+        ep_ptrs.push_back(ep);
+    }
+
+    std::vector<slang::IComponentType *> components;
+    components.reserve(1 + entry_count);
+    components.push_back(module.get());
+    for (u32 i = 0; i < entry_count; ++i) {
+        components.push_back(ep_ptrs[i].get());
+    }
+
+    Slang::ComPtr<slang::IComponentType> composed;
+    if (SLANG_FAILED(sc.session->createCompositeComponentType(
+            components.data(), (u32)components.size(), composed.writeRef(), diagnostics.writeRef()
+        ))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IComponentType> linked;
+    if (SLANG_FAILED(composed->link(linked.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IBlob> code;
+    if (SLANG_FAILED(linked->getTargetCode(0, code.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    std::string msl(static_cast<const char *>(code->getBufferPointer()), code->getBufferSize());
+    return normalize_push_index(msl);
+}
+
+} // namespace mt
ADD · src/backend/metal/swapchain.cpp +153 -0
--- a/src/backend/metal/swapchain.cpp
+++ b/src/backend/metal/swapchain.cpp
@@ -0,0 +1,153 @@
+#include <math.h>
+#ifndef INFINITY
+#define INFINITY __builtin_huge_valf()
+#endif
+#include <Foundation/Foundation.hpp>
+#include <Metal/Metal.hpp>
+#include <QuartzCore/QuartzCore.hpp>
+
+#include <GLFW/glfw3.h>
+
+#include "backend/metal/mt_api.h"
+#include "backend/metal/mt_internal.h"
+#include "core/logger.h"
+
+namespace mt {
+void mt_refresh_swapchain_wrapper(MTL::Texture *tex, const rhi::Swapchain &swapchain);
+} // namespace mt
+
+namespace rhi {
+using namespace mt;
+
+static MTL::PixelFormat to_mtl_pixel_format(rhi::ImageFormat format) {
+    switch (format) {
+    case rhi::ImageFormat::RGBA8_UNORM:
+        return MTL::PixelFormatRGBA8Unorm;
+    case rhi::ImageFormat::RGBA8_SRGB:
+        return MTL::PixelFormatRGBA8Unorm_sRGB;
+    case rhi::ImageFormat::BGRA8_UNORM:
+        return MTL::PixelFormatBGRA8Unorm;
+    default:
+        return MTL::PixelFormatBGRA8Unorm;
+    }
+}
+
+void create_swapchain(Device &device, const rhi::SwapchainDesc &desc, Swapchain &swapchain) {
+    CA::MetalLayer *layer = mt_attach_metal_layer(desc.native_window, device.handle);
+    layer->setPixelFormat(to_mtl_pixel_format(desc.format));
+
+    GLFWwindow *window = static_cast<GLFWwindow *>(desc.native_window);
+    int fb_width = 0;
+    int fb_height = 0;
+    glfwGetFramebufferSize(window, &fb_width, &fb_height);
+
+    u32 width = desc.width > 0 ? desc.width : (u32)fb_width;
+    u32 height = desc.height > 0 ? desc.height : (u32)fb_height;
+    layer->setDrawableSize(CGSizeMake(width, height));
+    layer->setMaximumDrawableCount(desc.image_count);
+    layer->setDisplaySyncEnabled(desc.vsync_enabled);
+
+    swapchain.layer = layer;
+    swapchain.current = nullptr;
+    swapchain.format = (desc.format != rhi::ImageFormat::UNDEFINED) ? desc.format : rhi::ImageFormat::BGRA8_UNORM;
+    swapchain.extent.width = width;
+    swapchain.extent.height = height;
+    swapchain.maximumDrawableCount = desc.image_count;
+
+    VEL_INFO("Created Metal swapchain ({}x{})", width, height);
+}
+
+void destroy_swapchain(Device &device, Swapchain &swapchain) {
+    (void)device;
+    mt_clear_current_drawable();
+    if (swapchain.layer) {
+        swapchain.layer->release();
+        swapchain.layer = nullptr;
+    }
+    swapchain.current = nullptr;
+}
+
+bool acquire_swapchain_image(Device &device, Swapchain &swapchain, u32 &out_image_index, CmdBuffer &cmd) {
+    // no acquire step.
+    (void)cmd;
+
+    CA::MetalDrawable *drawable = swapchain.layer->nextDrawable();
+    if (!drawable) {
+        return false;
+    }
+
+    mt::reside(device, drawable->texture());
+    // drawable lives in layer set. use both sets.
+    if (cmd.handle && device.heap && device.heap->residency) {
+        MTL::ResidencySet *layer_set = swapchain.layer->residencySet();
+        if (layer_set) {
+            const MTL::ResidencySet *sets[2] = {device.heap->residency, layer_set};
+            cmd.handle->useResidencySets(sets, 2);
+        }
+    }
+    swapchain.current = drawable;
+    mt_set_current_drawable(drawable);
+    out_image_index = 0;
+
+    mt::mt_refresh_swapchain_wrapper(drawable->texture(), swapchain);
+    return true;
+}
+
+void present_swapchain(Device &device, Swapchain &swapchain, u32 image_index, SyncPoint frame_done) {
+    (void)device;
+    (void)swapchain;
+    (void)image_index;
+    (void)frame_done;
+    // present runs at submit.
+}
+
+ImageFormat swapchain_format(const Swapchain &swapchain) {
+    return swapchain.format;
+}
+
+Extent2D swapchain_extent(const Swapchain &swapchain) {
+    return swapchain.extent;
+}
+
+bool swapchain_needs_recreate(const Swapchain &swapchain) {
+    return swapchain.recreate;
+}
+
+static Image s_swap_images[SWAPCHAIN_IMAGE_COUNT];
+
+} // namespace rhi
+
+namespace mt {
+
+void mt_refresh_swapchain_wrapper(MTL::Texture *tex, const rhi::Swapchain &swapchain) {
+    rhi::Image &img = rhi::s_swap_images[0];
+    for (auto &entry : img.view_cache) {
+        if (entry.second) {
+            entry.second->release();
+        }
+    }
+    img.view_cache.clear();
+    img.desc.width = swapchain.extent.width;
+    img.desc.height = swapchain.extent.height;
+    img.desc.format = swapchain.format;
+    img.desc.usage = rhi::ImageUsage::ColorAttachment;
+    img.handle = tex;
+    img.state = rhi::ResourceState::ColorDraw;
+}
+
+} // namespace mt
+
+namespace rhi {
+
+Image *swapchain_image(Swapchain &swapchain, u32 index) {
+    (void)swapchain;
+    if (index >= SWAPCHAIN_IMAGE_COUNT) {
+        return nullptr;
+    }
+    if (!s_swap_images[index].handle) {
+        return nullptr;
+    }
+    return &s_swap_images[index];
+}
+
+} // namespace rhi
ADD · src/backend/rhi.h +12 -0
--- a/src/backend/rhi.h
+++ b/src/backend/rhi.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#ifdef RHI_BACKEND_VULKAN
+#include "backend/vulkan/vk_api.h"
+#endif
+
+#ifdef RHI_BACKEND_METAL
+#include "backend/metal/mt_api.h"
+#endif
+
+#include "rhi_api.h"
+#include "rhi_types.h"
ADD · src/backend/rhi_api.h +184 -0
--- a/src/backend/rhi_api.h
+++ b/src/backend/rhi_api.h
@@ -0,0 +1,184 @@
+#pragma once
+
+#include "rhi_types.h"
+
+#include <cstdint>
+
+namespace rhi {
+
+// Device / Context
+void create_context(Device &device, Config &cfg);
+void destroy_context(Device &device);
+bool create_memory_allocator(Device &device);
+void destroy_memory_allocator(Device &device);
+MemoryStats memory_stats(Device &device);
+
+// Queue
+Queue find_queue(Device &device, u32 required = 1u << 0, u32 excluded = 0);
+Queue graphics_queue(Device &device);
+u32 queue_family_index(const Queue &queue);
+
+// Buffer
+bool create_buffer(Device &device, BufferDesc &desc, Buffer &buffer);
+void destroy_buffer(Device &device, Buffer &buffer);
+u64 buffer_device_address(Device &device, Buffer &buffer, u64 offset = 0);
+
+void buffer_flush(Device &device, Buffer &buffer, u64 offset, u64 size);
+void buffer_invalidate(Device &device, Buffer &buffer, u64 offset, u64 size);
+
+// Image
+bool create_image(Device &device, ImageDesc &desc, Image &out);
+void destroy_image(Device &device, Image &img);
+
+// Views (descriptors/views idk the term I'll settle on)
+bool create_image_view(Device &device, const ImageViewDesc &desc, ImageView &out);
+void destroy_image_view(Device &device, ImageView &view);
+bool create_buffer_view(Device &device, const BufferViewDesc &desc, BufferView &out);
+void destroy_buffer_view(Device &device, BufferView &view);
+
+u64 handle_id(Device &device, ImageView &view);
+u64 handle_id(Device &device, Sampler &sampler);
+u64 handle_id(Device &device, BufferView &view);
+
+void create_swapchain(Device &device, const SwapchainDesc &desc, Swapchain &swapchain);
+void destroy_swapchain(Device &device, Swapchain &swapchain);
+
+bool acquire_swapchain_image(Device &device, Swapchain &swapchain, u32 &out_image_index, CmdBuffer &cmd);
+void present_swapchain(Device &device, Swapchain &swapchain, u32 image_index, SyncPoint frame_done);
+ImageFormat swapchain_format(const Swapchain &swapchain);
+Extent2D swapchain_extent(const Swapchain &swapchain);
+Image *swapchain_image(Swapchain &swapchain, u32 index);
+bool swapchain_needs_recreate(const Swapchain &swapchain);
+
+// CmdPool
+bool create_cmd_pool(Device &device, const CmdPoolDesc &desc, CmdPool &pool);
+void destroy_cmd_pool(Device &device, CmdPool &pool);
+void reset_cmd_pool(Device &device, CmdPool &pool, u32 flags = 0);
+
+// CmdBuffer
+bool create_cmd_buffer(Device &device, const CmdBufferDesc &desc, CmdBuffer &cmd);
+void destroy_cmd_buffer(Device &device, CmdPool &pool, CmdBuffer &cmd);
+bool begin_cmd_buffer(CmdBuffer &cmd, const CmdBufferBeginDesc &desc = {});
+bool end_cmd_buffer(CmdBuffer &cmd);
+bool reset_cmd_buffer(CmdBuffer &cmd);
+void begin_rendering(CmdBuffer &cmd, RenderingInfo &ri);
+void end_rendering(CmdBuffer &cmd);
+void set_viewports(CmdBuffer &cmd, Viewport *viewports, u32 viewportCount = 1);
+void set_scissors(CmdBuffer &cmd, const Rect *rects, u32 rectCount = 1);
+void fill_buffer(CmdBuffer &cmd, Buffer &buffer, u64 offset, u64 size, u32 value);
+void dispatch(CmdBuffer &cmd, u32 x = 1, u32 y = 1, u32 z = 1);
+
+// avoid calling while cmd.is_rendering: vkCmdPipelineBarrier2 inside a
+// dynamic rendering instance is illegal without, VK_KHR_dynamic_rendering_local_read
+// hoist the barrier before begin_rendering instead
+void barrier(CmdBuffer &cmd, ResourceState before, ResourceState after);
+void barrier(CmdBuffer &cmd, Buffer &buffer, ResourceState before, ResourceState after);
+void barrier(CmdBuffer &cmd, Image &image, const ImageRange &range, ResourceState before, ResourceState after);
+
+void draw(CmdBuffer &cmd, u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance);
+void draw_indexed(CmdBuffer &cmd, u32 indexCount, u32 instanceCount, u32 firstIndex, u32 vtxOff, u32 firstInstance);
+void draw_indirect(CmdBuffer &cmd, Buffer &buffer, u32 drawCount, u32 stride, u64 offset);
+void draw_indirect_count(
+    CmdBuffer &cmd, Buffer &buffer, Buffer &countBuffer, u32 drawCount, u32 stride, u64 offset, u32 countOffset
+);
+void draw_indexed_indirect(
+    CmdBuffer &cmd, Buffer &buffer, Buffer *countBuffer, u32 drawCount, u32 stride, u64 offset = 0, u32 countOffset = 0
+);
+void set_vertex_buffer(CmdBuffer &cmd, Buffer &buffer, u32 binding = 0, u64 offset = 0);
+void set_index_buffer(CmdBuffer &cmd, Buffer &buffer, u32 offset = 0, IndexType type = IndexType::UINT32);
+
+void set_pipeline(CmdBuffer &cmd, RenderPipeline &pipeline);
+void set_pipeline(CmdBuffer &cmd, ComputePipeline &pipeline);
+void set_constants(CmdBuffer &cmd, RenderPipeline &pipeline, ShaderStage stage, u32 size, const void *data);
+void set_constants(CmdBuffer &cmd, ComputePipeline &pipeline, ShaderStage stage, u32 size, const void *data);
+void copy_buffer_to_texture(
+    CmdBuffer &cmd, Buffer &srcBuffer, ImageView &dstView, const BufferTextureCopyRegion &region
+);
+void copy_image_to_buffer(CmdBuffer &cmd, ImageView &srcView, Buffer &dstBuffer, const BufferTextureCopyRegion &region);
+void blit_image(CmdBuffer &cmd, Image &image, const ImageBlit *regions, u32 region_count);
+void set_polygon_mode(CmdBuffer &cmd, PipelineFillMode mode);
+void set_depth_write_enable(CmdBuffer &cmd, bool enable);
+void cmd_build_acceleration_structures(
+    CmdBuffer &cmd,
+    const AccelStructBuildGeometryInfo *build_infos,
+    const AccelStructBuildRangeInfo *const *ranges,
+    u32 count
+);
+void copy_buffer_to_device(
+    Device &device, Buffer &src, u64 src_offset, Buffer &dst, u64 dst_offset, u64 size, CmdBuffer &cmd
+);
+
+// Attachment view cache, might not stick around
+ImageView get_cached_image_view(Device &device, Image &image, const ImageViewDesc &desc);
+void destroy_image_views(Device &device, Image &image);
+void destroy_buffer_views(Device &device, Buffer &buffer);
+
+// Pipelines (type-safe: render vs compute)
+void destroy_pipeline(Device &device, RenderPipeline &p);
+void destroy_pipeline(Device &device, ComputePipeline &p);
+
+// Sampler
+bool create_sampler(Device &device, SamplerDesc &desc, Sampler &sampler);
+void destroy_sampler(Device &device, Sampler &sampler);
+
+// Shader
+bool init_compiler(ShaderCompiler &sc);
+u64 get_file_last_write_time(const char *path);
+
+// Queue submission. Pure-SyncPoint edges (sync_refactor.md end-state).
+void queue_submit(Device &device, Queue queue, const QueueSubmitDesc &desc);
+
+// QueryPool
+bool create_query_pool(Device &device, const QueryPoolDesc &desc, QueryPool &pool);
+void reset_query_pool(CmdBuffer &cmd, QueryPool &queryPool, u32 offset, u32 count);
+void write_timestamp(CmdBuffer &cmd, QueryPool &queryPool, u32 queryIndex, PipelineStages stage);
+void destroy_query_pool(Device &device, QueryPool &queryPool);
+bool query_pool_results(
+    Device &device,
+    const QueryPool &pool,
+    u32 first_query,
+    u32 query_count,
+    u64 *out,
+    usize data_size_bytes,
+    usize stride_bytes,
+    bool with_availability
+);
+
+// AccelStruct
+bool get_acceleration_structure_build_sizes(
+    Device &device,
+    const AccelStructBuildGeometryInfo &build_info,
+    const u32 *max_primitive_counts,
+    AccelStructBuildSizesInfo &sizes
+);
+bool create_acceleration_structure(Device &device, const AccelStructCreateInfo &info, AccelStruct &out);
+void destroy_acceleration_structure(Device &device, AccelStruct &as);
+u64 get_acceleration_structure_device_address(Device &device, const AccelStruct &as);
+
+Sync *sync_create(Device &device, u64 initial_value = 0, const char *name = nullptr); // nullptr on failure
+void sync_destroy(Sync *sync);                                                        // null-safe
+bool sync_host_wait(Sync *sync, u64 value, u64 timeout_ns = UINT64_MAX);              // CPU-blocking wait
+u64 sync_get_completed_value(Sync *sync);                                             // completed counter, 0 if null
+bool valid(const Sync *sync);
+void device_wait_idle(Device &device);
+void queue_wait_idle(Device &device);
+
+// TODO: rm
+ImageFormat image_format_from_vk(u32 format);
+ImageFormat preferred_compressed_format(Device &device, bool srgb);
+
+// TODO: per backend template/macro
+bool valid(const Image &img);
+bool valid(const Buffer &buffer);
+bool valid(const ImageView &view);
+bool valid(const BufferView &view);
+bool valid(const CmdBuffer &cmd);
+bool valid(const CmdPool &pool);
+bool valid(const RenderPipeline &pipeline);
+bool valid(const ComputePipeline &pipeline);
+bool valid(const AccelStruct &as);
+bool valid(const Sampler &sampler);
+bool valid(const QueryPool &pool);
+bool valid(const Swapchain &swapchain);
+
+} // namespace rhi
ADD · src/backend/rhi_types.h +705 -0
--- a/src/backend/rhi_types.h
+++ b/src/backend/rhi_types.h
@@ -0,0 +1,705 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "core/globals.h"
+
+namespace rhi {
+
+struct Memory;
+struct Queue;
+struct Buffer;
+struct BufferView;
+struct Image;
+struct ImageView;
+struct CmdPool;
+struct CmdBuffer;
+struct RenderPipeline;
+struct ComputePipeline;
+struct Sampler;
+struct QueryPool;
+struct AccelStruct;
+struct Swapchain;
+struct Device;
+struct Sync;
+struct SyncPoint;
+struct QueueWait;
+struct QueueSignal;
+struct QueueSubmitDesc;
+struct ShaderCompiler;
+struct ShaderModule;
+
+enum class PipelineTopology : u8 {
+    TRIANGLES,
+    LINES,
+    POINTS
+};
+
+enum class PipelineFillMode : u8 {
+    SOLID,
+    WIREFRAME
+};
+
+enum class PipelineCullMode : u8 {
+    NONE,
+    FRONT,
+    BACK
+};
+
+enum class PipelineTriangleWindingOrder : u8 {
+    CW,
+    CCW,
+};
+
+enum class PipelineCompareOp : u8 {
+    NEVER,
+    LESS,
+    EQUAL,
+    LESS_EQUAL,
+    GREATER,
+    NOT_EQUAL,
+    GREATER_EQUAL,
+    ALWAYS
+};
+
+enum class PipelineBlendFactor : u8 {
+    ZERO,
+    ONE,
+    SRC_ALPHA,
+    ONE_MINUS_SRC_ALPHA,
+    DST_ALPHA,
+    ONE_MINUS_DST_ALPHA,
+    SRC_COLOR,
+    ONE_MINUS_SRC_COLOR,
+    DST_COLOR,
+    ONE_MINUS_DST_COLOR,
+    SRC_ALPHA_SATURATE,
+};
+
+enum class PipelineBlendOp : u8 {
+    ADD,
+    SUBTRACT,
+    REVERSE_SUBTRACT,
+    MIN,
+    MAX,
+};
+
+enum class SampleCount : u8 {
+    Sample1 = 1,
+    Sample2 = 2,
+    Sample4 = 4,
+    Sample8 = 8,
+    Sample16 = 16,
+    Sample32 = 32,
+    Sample64 = 64
+};
+
+enum class ShaderStage : u32 {
+    NONE = BIT(0),
+    VERTEX = BIT(1),
+    FRAGMENT = BIT(2),
+    COMPUTE = BIT(3),
+    MESH = BIT(4),
+    TASK = BIT(5),
+    GEOMETRY = BIT(6),
+    RAYGEN = BIT(9),
+    CLOSEST_HIT = BIT(10),
+    ANY_HIT = BIT(11),
+    MISS = BIT(12),
+    INTERSECTION = BIT(13),
+    CALLABLE = BIT(14),
+    ALL = BIT(8)
+};
+ENUM_BIT_OPS(ShaderStage);
+
+enum class ImageType : u8 {
+    TYPE_2D,
+    TYPE_3D,
+    TYPE_CUBE
+};
+
+struct Extent2D {
+    u32 width = 0;
+    u32 height = 0;
+};
+
+enum class BufferUsage : u32 {
+    None = 0,
+    VertexBuffer = BIT(1),
+    IndexBuffer = BIT(2),
+    UniformBuffer = BIT(3),
+    StorageBuffer = BIT(4),
+    IndirectBuffer = BIT(5),
+    CopySrc = BIT(6),
+    CopyDst = BIT(7),
+    ShaderAddr = BIT(8),
+    AccelStructBuildInput = BIT(9),
+    AccelStructStorage = BIT(10),
+};
+ENUM_BIT_OPS(BufferUsage);
+
+enum class BufferMemType : u8 {
+    Device,
+    Upload,   // cpu write, mapped for lifetime
+    Readback, // gpu write, mapped for lifetime
+};
+
+struct BufferDesc {
+    u64 size = 0;
+    BufferUsage usage = BufferUsage::StorageBuffer;
+    BufferMemType memory = BufferMemType::Device;
+    bool dedicated = false; // VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, Metal MTLStorageModePrivate
+    std::string name;
+};
+
+enum class BufferViewType : u8 {
+    Uniform,
+    Storage,
+    Vertex,
+    Index,
+    Indirect,
+    Texel,
+};
+
+enum class ImageViewType : u8 {
+    Sampled,
+    Storage,
+    // Sentinel: "no view declared,
+    // ImageResource uses it to mean "not shader-visible".
+    // Kind of a sentinal hack for FG, need a better solution
+    None,
+};
+
+enum class ImageUsage : u32 {
+    None = 0,
+    ColorAttachment = BIT(1),
+    DepthAttachment = BIT(2),
+    StencilAttachment = BIT(3),
+    Sampled = BIT(4),
+    Storage = BIT(5),
+    TransferSrc = BIT(6),
+    TransferDst = BIT(7),
+    InputAttachment = BIT(8),
+};
+ENUM_BIT_OPS(ImageUsage);
+
+enum class ImageAspect : u32 {
+    None = BIT(0),
+    Color = BIT(1),
+    Depth = BIT(2),
+    Stencil = BIT(3),
+};
+ENUM_BIT_OPS(ImageAspect);
+
+enum class ImageFormat : u8 {
+    UNDEFINED,
+    R8_UNORM,
+    RGBA8_UNORM,
+    RGBA8_SRGB,
+    BGRA8_UNORM,
+    D32_FLOAT,
+    RGBA16_FLOAT,
+    RGBA32_FLOAT,
+    RGB32_FLOAT,
+    R10G10B10A2_UNORM,
+    RG16_FLOAT,
+    RG32_FLOAT,
+    R32_FLOAT,
+    R32_UINT,
+    R16_FLOAT,
+    BC7_UNORM,
+    BC7_SRGB,
+    ASTC6X6_UNORM,
+    ASTC6X6_SRGB
+};
+
+enum class TextureViewDimension : u8 {
+    TEXTURE_2D,
+    TEXTURE_2D_ARRAY,
+    TEXTURE_3D,
+    TEXTURE_CUBE
+};
+
+enum class ComponentSwizzle : u8 {
+    Identity,
+    R,
+    G,
+    B,
+    A,
+    Zero,
+    One
+};
+
+struct ImageDesc {
+    u32 width = 0;
+    u32 height = 0;
+    u32 depth = 1;
+    u32 mip_levels = 1;
+    u32 layers = 1;
+    bool is_cubemap = false;
+    SampleCount sample_count = SampleCount::Sample1;
+    ImageFormat format = ImageFormat::UNDEFINED;
+    ImageUsage usage = ImageUsage::Sampled;
+    std::string name;
+};
+
+enum class CmdPoolUsage : u32 {
+    None = BIT(0),
+    Transient = BIT(1),
+    ResetCommandBuffer = BIT(2),
+    Protected = BIT(3),
+};
+ENUM_BIT_OPS(CmdPoolUsage);
+
+struct CmdPoolDesc {
+    u32 queue_family_index = UINT32_MAX;
+    CmdPoolUsage flags;
+};
+
+struct Viewport {
+    f32 x = 0.0f;
+    f32 y = 0.0f;
+    f32 width;
+    f32 height;
+    f32 depth_min = 0.0f;
+    f32 depth_max = 1.0f;
+    bool flip_y = true;
+};
+
+struct Rect {
+    i16 x = 0;
+    i16 y = 0;
+    i16 width;
+    i16 height;
+};
+
+enum class IndexType : u8 {
+    UINT16,
+    UINT32,
+};
+
+enum class CmdBufferLevel : u8 {
+    Primary,
+    Secondary,
+};
+
+enum class CmdBufferUsage : u32 {
+    None = BIT(0),
+    OneTimeSubmit = BIT(1),
+    RenderPassContinue = BIT(2),
+    SimultaneousUse = BIT(3),
+};
+ENUM_BIT_OPS(CmdBufferUsage);
+
+struct CmdBufferBeginDesc {
+    CmdBufferUsage usage;
+};
+
+enum class PipelineStages : u64 {
+    NONE = 0,
+    TOP_OF_PIPE = 0x1,
+    DRAW_INDIRECT = 0x2,
+    VERTEX_INPUT = 0x4,
+    VERTEX_SHADER = 0x8,
+    TESS_CONTROL_SHADER = 0x10,
+    TESS_EVALUATION_SHADER = 0x20,
+    GEOMETRY_SHADER = 0x40,
+    FRAGMENT_SHADER = 0x80,
+    EARLY_FRAGMENT_TESTS = 0x100,
+    LATE_FRAGMENT_TESTS = 0x200,
+    COLOR_ATTACHMENT_OUTPUT = 0x400,
+    COMPUTE_SHADER = 0x800,
+    // ALL_TRANSFER = 0x1000, // vksync2 mismatch?
+    BOTTOM_OF_PIPE = 0x2000,
+    HOST = 0x4000,
+    ALL_GRAPHICS = 0x8000,
+    ALL_COMMANDS = 0x10000,
+    TASK_SHADER = 0x80000,
+    MESH_SHADER = 0x100000,
+    RAY_TRACING_SHADER = 0x200000,
+    ACCELERATION_STRUCTURE_BUILD = 0x2000000,
+    ACCELERATION_STRUCTURE_COPY = 0x10000000,
+    MICROMAP_BUILD = 0x4000000,
+    COPY = 0x100000000ULL,
+    RESOLVE = 0x200000000ULL,
+    BLIT = 0x400000000ULL,
+    CLEAR = 0x800000000ULL,
+    INDEX_INPUT = 0x1000000000ULL,
+    VERTEX_ATTRIBUTE_INPUT = 0x2000000000ULL,
+    PRE_RASTERIZATION_SHADERS = 0x4000000000ULL,
+
+    // backwards compat names, remove
+    COLOR_ATTACHMENT = COLOR_ATTACHMENT_OUTPUT,
+    INDIRECT = DRAW_INDIRECT,
+    CLEAR_STORAGE = CLEAR,
+    ACCELERATION_STRUCTURE = ACCELERATION_STRUCTURE_BUILD,
+    MICROMAP = MICROMAP_BUILD,
+
+    // wrapper aliases
+    DEPTH_STENCIL_ATTACHMENT = EARLY_FRAGMENT_TESTS | LATE_FRAGMENT_TESTS,
+    TESSELLATION_SHADERS = TESS_CONTROL_SHADER | TESS_EVALUATION_SHADER,
+    MESH_SHADERS = TASK_SHADER | MESH_SHADER,
+    RASTER_SHADERS = INDEX_INPUT | VERTEX_SHADER | FRAGMENT_SHADER | DEPTH_STENCIL_ATTACHMENT | COLOR_ATTACHMENT_OUTPUT,
+
+    // Legacy alias
+    ALL = ALL_COMMANDS,
+};
+ENUM_BIT_OPS_64(PipelineStages);
+
+enum class ResourceState : u8 {
+    Idle = 0,                 // no access, no stage (fresh / aliased transient)
+    ColorDraw,                // write in color-output stage
+    ColorFetch,               // read in color-output stage (blend / input / resolve-src)
+    DepthDraw,                // write in depth-stencil-test stage
+    DepthFetch,               // read in depth-stencil-test stage
+    TextureSample,            // read in fragment/vertex stage (sampled texture)
+    TextureSampleNonFragment, // read in vertex/compute stage (sampled texture)
+    StorageRead,              // read in compute stage (storage image/buffer)
+    StorageReadWrite,         // read+write in compute stage (storage image/buffer)
+    VertexFetch,              // read in vertex-fetch stage (vertex buffer)
+    IndexFetch,               // read in index-fetch stage (index buffer)
+    IndirectFetch,            // read in indirect-draw stage (indirect args)
+    UniformRead,              // read in any shader stage (uniform buffer)
+    TransferFrom,             // read in transfer stage (copy/blit/resolve src)
+    TransferTo,               // write in transfer stage (copy/blit/resolve dst, clear dst)
+    HostRead,                 // read by host stage (destination-only barrier)
+    AccelBuild,               // read+write in accel-build stage (TLAS/BLAS build)
+    AccelTrace,               // read in accel-trace stage (ray trace / AS read)
+    Display,                  // no access, handed to swapchain (was Present)
+};
+
+struct ImageRange {
+    u32 mip = 0;
+    u32 mip_count = REMAINING_MIPS;
+    u32 layer = 0;
+    u32 layer_count = REMAINING_LAYERS;
+    ImageAspect aspect = ImageAspect::Color;
+};
+
+struct MemoryStats {
+    u32 block_count = 0;
+    u32 allocation_count = 0;
+    u64 allocation_bytes = 0;
+    u64 used_bytes = 0;
+};
+
+enum class LoadOp : u8 {
+    LOAD,
+    CLEAR
+};
+
+enum class StoreOp : u8 {
+    STORE,
+    DISCARD
+};
+
+enum class ResolveOp : u8 {
+    NONE,
+    AVERAGE,
+    MIN,
+    MAX,
+    SAMPLE_ZERO,
+};
+
+struct ClearDepthStencil {
+    f32 depth;
+    u32 stencil;
+};
+
+union ClearColorValue {
+    f32 float32[4];
+    i32 int32[4];
+    u32 uint32[4];
+};
+
+union ClearValue {
+    ClearColorValue color;
+    ClearDepthStencil depthStencil;
+};
+
+struct TextureCopyRegion {
+    u32 SrcMipLevel;
+    u32 SrcBaseArrayLayer;
+    u32 SrcOffsetX;
+    u32 SrcOffsetY;
+    u32 SrcOffsetZ;
+    u32 DstMipLevel;
+    u32 DstBaseArrayLayer;
+    u32 DstOffsetX;
+    u32 DstOffsetY;
+    u32 DstOffsetZ;
+    u32 ExtentWidth;
+    u32 ExtentHeight;
+    u32 ExtentDepth;
+};
+
+struct BufferTextureCopyRegion {
+    u64 buffer_offset;
+    u32 buffer_row_length;
+    u32 buffer_image_height;
+    u32 mip_level;
+    u32 base_array_layer;
+    u32 layer_count;
+    u32 texture_offset_x;
+    u32 texture_offset_y;
+    u32 texture_offset_z;
+    u32 texture_extent_width;
+    u32 texture_extent_height;
+    u32 texture_extent_depth;
+};
+
+#define SWAPCHAIN_IMAGE_COUNT 3
+
+#define MAX_FRAMES_IN_FLIGHT 2
+
+struct Config {
+    bool enable_validation = false;
+    void *app_info = nullptr;
+    std::vector<const char *> device_extensions;
+    std::vector<const char *> instance_extensions;
+    std::vector<const char *> instance_layers;
+
+    u32 swapchain_image_count = SWAPCHAIN_IMAGE_COUNT;
+    u32 max_frames_in_flight = MAX_FRAMES_IN_FLIGHT;
+    bool vsync_enabled = true;
+};
+
+struct SwapchainDesc {
+    void *native_window = nullptr;
+    u32 width = 0;
+    u32 height = 0;
+    ImageFormat format = ImageFormat::UNDEFINED;
+    u32 image_count = SWAPCHAIN_IMAGE_COUNT;
+    bool vsync_enabled = true;
+};
+
+struct BufferViewDesc {
+    Buffer *buffer = nullptr;
+    u64 offset = 0;
+    u64 size = 0;
+    BufferViewType type = BufferViewType::Storage;
+};
+
+struct ImageViewDesc {
+    Image *image = nullptr;
+    ImageAspect aspect = ImageAspect::None;
+    TextureViewDimension dimension = TextureViewDimension::TEXTURE_2D;
+    ImageViewType type = ImageViewType::Sampled;
+    u32 mip_start = 0;
+    u32 mip_count = 1;
+    u32 layer_start = 0;
+    u32 layer_count = 1;
+    ComponentSwizzle swizzle_r = ComponentSwizzle::Identity;
+    ComponentSwizzle swizzle_g = ComponentSwizzle::Identity;
+    ComponentSwizzle swizzle_b = ComponentSwizzle::Identity;
+    ComponentSwizzle swizzle_a = ComponentSwizzle::Identity;
+};
+
+enum class SamplerAddressMode : u8 {
+    WRAP,
+    MIRROR,
+    CLAMP,
+    BORDER
+};
+
+enum class SamplerFilter : u8 {
+    POINT,
+    LINEAR,
+    ANISOTROPIC
+};
+
+enum class SamplerComparisonFunc : u8 {
+    NEVER,
+    LESS,
+    EQUAL,
+    LESS_EQUAL,
+    GREATER,
+    NOT_EQUAL,
+    GREATER_EQUAL,
+    ALWAYS
+};
+
+struct SamplerDesc {
+    SamplerAddressMode address = SamplerAddressMode::WRAP;
+    SamplerFilter filter = SamplerFilter::LINEAR;
+    SamplerComparisonFunc comparison_func = SamplerComparisonFunc::NEVER;
+    bool use_mips = false;
+    std::string name;
+};
+
+enum class QueryType : u8 {
+    TIMESTAMP,
+    TIMESTAMP_COPY_QUEUE,
+    OCCLUSION,
+    PIPELINE_STATISTICS,
+    ACCELERATION_STRUCTURE_SIZE,
+    ACCELERATION_STRUCTURE_COMPACTED_SIZE,
+    MICROMAP_COMPACTED_SIZE
+};
+
+struct QueryPoolDesc {
+    QueryType queryType;
+    u32 capacity;
+    std::string name;
+};
+
+struct AccelStructTransform {
+    f32 matrix[3][4];
+};
+
+struct AccelStructInstance {
+    AccelStructTransform transform;
+    u32 instance_custom_index : 24;
+    u32 mask : 8;
+    u32 sbt_record_offset : 24;
+    u32 flags : 8;
+    u64 acceleration_structure_reference;
+};
+
+enum class AccelStructInstanceFlags : u8 {
+    None = 0,
+    TriangleFacingCullDisable = BIT(0),
+    TriangleFlipFacing = BIT(1),
+    ForceOpaque = BIT(2),
+    ForceNoOpaque = BIT(3),
+};
+ENUM_BIT_OPS(AccelStructInstanceFlags);
+
+enum class AccelStructType : u8 {
+    BottomLevel,
+    TopLevel,
+};
+
+enum class AccelStructGeometryType : u8 {
+    Triangles,
+    Instances,
+};
+
+enum class AccelStructGeometryFlags : u8 {
+    None = 0,
+    Opaque = BIT(0),
+    NoDuplicateAnyHitInvocation = BIT(1),
+};
+ENUM_BIT_OPS(AccelStructGeometryFlags);
+
+enum class AccelStructBuildFlags : u8 {
+    None = 0,
+    AllowUpdate = BIT(0),
+    AllowCompaction = BIT(1),
+    PreferFastTrace = BIT(2),
+    PreferFastBuild = BIT(3),
+    LowMemory = BIT(4),
+};
+ENUM_BIT_OPS(AccelStructBuildFlags);
+
+enum class VertexFormat : u8 {
+    Undefined,
+    R32G32B32_FLOAT,
+    R32G32B32A32_FLOAT,
+};
+
+struct AccelStructGeometryTrianglesData {
+    VertexFormat vertex_format = VertexFormat::R32G32B32_FLOAT;
+    u64 vertex_data = 0;
+    u64 vertex_stride = 0;
+    u32 max_vertex = 0;
+    IndexType index_type = IndexType::UINT32;
+    u64 index_data = 0;
+    u64 transform_data = 0;
+};
+
+struct AccelStructGeometryInstancesData {
+    u64 data = 0;
+    bool array_of_pointers = false;
+};
+
+struct AccelStructGeometry {
+    AccelStructGeometryType type = AccelStructGeometryType::Triangles;
+    AccelStructGeometryFlags flags = AccelStructGeometryFlags::None;
+    union {
+        AccelStructGeometryTrianglesData triangles;
+        AccelStructGeometryInstancesData instances;
+    };
+};
+
+struct AccelStructBuildRangeInfo {
+    u32 primitive_count = 0;
+    u32 primitive_offset = 0;
+    u32 first_vertex = 0;
+    u32 transform_offset = 0;
+};
+
+struct AccelStructBuildSizesInfo {
+    u64 acceleration_structure_size = 0;
+    u64 update_scratch_size = 0;
+    u64 build_scratch_size = 0;
+};
+
+struct ImageBlit {
+    u32 src_mip = 0;
+    u32 dst_mip = 0;
+    u32 src_layer = 0;
+    u32 dst_layer = 0;
+    i32 src_x0 = 0, src_y0 = 0, src_x1 = 0, src_y1 = 0;
+    i32 dst_x0 = 0, dst_y0 = 0, dst_x1 = 0, dst_y1 = 0;
+};
+
+// VkDrawIndexedIndirectCommand
+inline constexpr u32 DRAW_INDEXED_INDIRECT_STRIDE = 5 * sizeof(u32);
+
+struct CmdBufferDesc {
+    CmdPool *pool = nullptr;
+    CmdBufferLevel level = CmdBufferLevel::Primary;
+};
+
+struct AttachmentDesc {
+    ImageView *img = nullptr;
+    ImageView *resolveImg = nullptr;
+    LoadOp loadOp = LoadOp::LOAD;
+    StoreOp storeOp = StoreOp::STORE;
+    ResolveOp resolveOp = ResolveOp::NONE;
+    ClearValue clearValue{};
+};
+
+struct RenderingInfo {
+    AttachmentDesc colorAttachments[8];
+    u32 colorAttachmentCount;
+    AttachmentDesc depthAttachment;
+    u32 width;
+    u32 height;
+};
+
+// Barrier descs removed; see barrier() overloads in rhi_api.h.
+
+struct VertexAttribute {
+    u32 location;
+    u32 binding;
+    ImageFormat format;
+    u32 offset;
+};
+
+struct VertexBinding {
+    u32 binding;
+    u32 stride;
+    bool is_instanced{false};
+};
+
+struct AccelStructBuildGeometryInfo {
+    AccelStructType type = AccelStructType::BottomLevel;
+    AccelStructBuildFlags flags = AccelStructBuildFlags::None;
+    AccelStruct *dst_acceleration_structure = nullptr;
+    AccelStructGeometry *geometries = nullptr;
+    u32 geometry_count = 0;
+    u64 scratch_data = 0;
+};
+
+struct AccelStructCreateInfo {
+    Buffer *buffer = nullptr;
+    u64 offset = 0;
+    u64 size = 0;
+    AccelStructType type = AccelStructType::BottomLevel;
+    std::string name;
+};
+
+} // namespace rhi
ADD · src/backend/vulkan/accel_struct.cpp +256 -0
--- a/src/backend/vulkan/accel_struct.cpp
+++ b/src/backend/vulkan/accel_struct.cpp
@@ -0,0 +1,256 @@
+
+#include <volk.h>
+
+#include <cstring>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+static_assert(
+    sizeof(AccelStructInstance) == sizeof(VkAccelerationStructureInstanceKHR), "AccelStructInstance size mismatch"
+);
+static_assert(
+    alignof(AccelStructInstance) == alignof(VkAccelerationStructureInstanceKHR),
+    "AccelStructInstance alignment mismatch"
+);
+static_assert(
+    static_cast<u32>(AccelStructInstanceFlags::TriangleFacingCullDisable) ==
+    VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR
+);
+static_assert(
+    static_cast<u32>(AccelStructInstanceFlags::TriangleFlipFacing) == VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR
+);
+static_assert(static_cast<u32>(AccelStructInstanceFlags::ForceOpaque) == VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR);
+static_assert(
+    static_cast<u32>(AccelStructInstanceFlags::ForceNoOpaque) == VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR
+);
+
+static VkAccelerationStructureTypeKHR to_vk_accel_struct_type(AccelStructType type) {
+    switch (type) {
+    case AccelStructType::BottomLevel:
+        return VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
+    case AccelStructType::TopLevel:
+        return VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR;
+    }
+    return VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
+}
+
+static VkGeometryTypeKHR to_vk_geometry_type(AccelStructGeometryType type) {
+    switch (type) {
+    case AccelStructGeometryType::Triangles:
+        return VK_GEOMETRY_TYPE_TRIANGLES_KHR;
+    case AccelStructGeometryType::Instances:
+        return VK_GEOMETRY_TYPE_INSTANCES_KHR;
+    }
+    return VK_GEOMETRY_TYPE_TRIANGLES_KHR;
+}
+
+static VkBuildAccelerationStructureFlagsKHR to_vk_build_flags(AccelStructBuildFlags flags) {
+    VkBuildAccelerationStructureFlagsKHR result = 0;
+    if (Any(flags, AccelStructBuildFlags::AllowUpdate)) {
+        result |= VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR;
+    }
+    if (Any(flags, AccelStructBuildFlags::AllowCompaction)) {
+        result |= VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR;
+    }
+    if (Any(flags, AccelStructBuildFlags::PreferFastTrace)) {
+        result |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR;
+    }
+    if (Any(flags, AccelStructBuildFlags::PreferFastBuild)) {
+        result |= VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR;
+    }
+    if (Any(flags, AccelStructBuildFlags::LowMemory)) {
+        result |= VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR;
+    }
+    return result;
+}
+
+static VkGeometryFlagsKHR to_vk_geometry_flags(AccelStructGeometryFlags flags) {
+    VkGeometryFlagsKHR result = 0;
+    if (Any(flags, AccelStructGeometryFlags::Opaque)) {
+        result |= VK_GEOMETRY_OPAQUE_BIT_KHR;
+    }
+    if (Any(flags, AccelStructGeometryFlags::NoDuplicateAnyHitInvocation)) {
+        result |= VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR;
+    }
+    return result;
+}
+
+static VkGeometryInstanceFlagsKHR to_vk_instance_flag(AccelStructInstanceFlags flags) {
+    VkGeometryInstanceFlagsKHR result = 0;
+    if (Any(flags, AccelStructInstanceFlags::TriangleFacingCullDisable)) {
+        result |= VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR;
+    }
+    if (Any(flags, AccelStructInstanceFlags::TriangleFlipFacing)) {
+        result |= VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR;
+    }
+    if (Any(flags, AccelStructInstanceFlags::ForceOpaque)) {
+        result |= VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR;
+    }
+    if (Any(flags, AccelStructInstanceFlags::ForceNoOpaque)) {
+        result |= VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR;
+    }
+    return result;
+}
+
+static VkFormat to_vk_vertex_format(VertexFormat format) {
+    switch (format) {
+    case VertexFormat::R32G32B32_FLOAT:
+        return VK_FORMAT_R32G32B32_SFLOAT;
+    case VertexFormat::R32G32B32A32_FLOAT:
+        return VK_FORMAT_R32G32B32A32_SFLOAT;
+    default:
+        return VK_FORMAT_UNDEFINED;
+    }
+}
+
+static VkAccelerationStructureInstanceKHR to_vk_instance(const AccelStructInstance &in) {
+    VkAccelerationStructureInstanceKHR out{};
+    memcpy(&out.transform, &in.transform, sizeof(out.transform));
+    out.instanceCustomIndex = in.instance_custom_index;
+    out.mask = in.mask;
+    out.instanceShaderBindingTableRecordOffset = in.sbt_record_offset;
+    out.flags = to_vk_instance_flag(static_cast<AccelStructInstanceFlags>(in.flags));
+    out.accelerationStructureReference = in.acceleration_structure_reference;
+    return out;
+}
+
+static VkAccelerationStructureGeometryKHR to_vk_geometry(const AccelStructGeometry &in) {
+    VkAccelerationStructureGeometryKHR out{};
+    out.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
+    out.geometryType = to_vk_geometry_type(in.type);
+    out.flags = to_vk_geometry_flags(in.flags);
+
+    if (in.type == AccelStructGeometryType::Triangles) {
+        out.geometry.triangles.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
+        out.geometry.triangles.vertexFormat = to_vk_vertex_format(in.triangles.vertex_format);
+        out.geometry.triangles.vertexData = vk::device_address_const_to_vk(in.triangles.vertex_data);
+        out.geometry.triangles.vertexStride = in.triangles.vertex_stride;
+        out.geometry.triangles.maxVertex = in.triangles.max_vertex;
+        out.geometry.triangles.indexType =
+            in.triangles.index_type == IndexType::UINT32 ? VK_INDEX_TYPE_UINT32 : VK_INDEX_TYPE_UINT16;
+        out.geometry.triangles.indexData = vk::device_address_const_to_vk(in.triangles.index_data);
+        out.geometry.triangles.transformData = vk::device_address_const_to_vk(in.triangles.transform_data);
+    } else {
+        out.geometry.instances.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR;
+        out.geometry.instances.arrayOfPointers = in.instances.array_of_pointers ? VK_TRUE : VK_FALSE;
+        out.geometry.instances.data = vk::device_address_const_to_vk(in.instances.data);
+    }
+
+    return out;
+}
+
+bool get_acceleration_structure_build_sizes(
+    Device &device,
+    const AccelStructBuildGeometryInfo &build_info,
+    const u32 *max_primitive_counts,
+    AccelStructBuildSizesInfo &sizes
+) {
+    std::vector<VkAccelerationStructureGeometryKHR> geometries;
+    geometries.reserve(build_info.geometry_count);
+    for (u32 i = 0; i < build_info.geometry_count; ++i) {
+        geometries.push_back(to_vk_geometry(build_info.geometries[i]));
+    }
+
+    VkAccelerationStructureBuildGeometryInfoKHR vk_build_info{};
+    vk_build_info.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
+    vk_build_info.type = to_vk_accel_struct_type(build_info.type);
+    vk_build_info.flags = to_vk_build_flags(build_info.flags);
+    vk_build_info.geometryCount = build_info.geometry_count;
+    vk_build_info.pGeometries = geometries.data();
+
+    VkAccelerationStructureBuildSizesInfoKHR vk_sizes{};
+    vk_sizes.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR;
+
+    vkGetAccelerationStructureBuildSizesKHR(
+        device.logical, VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR, &vk_build_info, max_primitive_counts, &vk_sizes
+    );
+
+    sizes.acceleration_structure_size = vk_sizes.accelerationStructureSize;
+    sizes.update_scratch_size = vk_sizes.updateScratchSize;
+    sizes.build_scratch_size = vk_sizes.buildScratchSize;
+    return true;
+}
+
+bool create_acceleration_structure(Device &device, const AccelStructCreateInfo &info, AccelStruct &out) {
+    VkAccelerationStructureCreateInfoKHR create_info{};
+    create_info.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR;
+    create_info.buffer = info.buffer->_handle;
+    create_info.offset = info.offset;
+    create_info.size = info.size;
+    create_info.type = to_vk_accel_struct_type(info.type);
+
+    VkAccelerationStructureKHR as = VK_NULL_HANDLE;
+    VK_CHECK(vkCreateAccelerationStructureKHR(device.logical, &create_info, nullptr, &as));
+    out.handle = as;
+    out.buffer = info.buffer;
+    if (!info.name.empty()) {
+        VK_NAME_EX(device, as, info.name.c_str());
+    }
+    return true;
+}
+
+void destroy_acceleration_structure(Device &device, AccelStruct &as) {
+    if (as.handle) {
+        vkDestroyAccelerationStructureKHR(device.logical, as.handle, nullptr);
+        as.handle = VK_NULL_HANDLE;
+        as.buffer = nullptr;
+    }
+}
+
+u64 get_acceleration_structure_device_address(Device &device, const AccelStruct &as) {
+    VkAccelerationStructureDeviceAddressInfoKHR addr_info{};
+    addr_info.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR;
+    addr_info.accelerationStructure = as.handle;
+    return vkGetAccelerationStructureDeviceAddressKHR(device.logical, &addr_info);
+}
+
+void cmd_build_acceleration_structures(
+    CmdBuffer &cmd,
+    const AccelStructBuildGeometryInfo *build_infos,
+    const AccelStructBuildRangeInfo *const *ranges,
+    u32 count
+) {
+    std::vector<VkAccelerationStructureBuildGeometryInfoKHR> vk_build_infos(count);
+    std::vector<VkAccelerationStructureGeometryKHR> vk_geometries;
+    std::vector<VkAccelerationStructureBuildRangeInfoKHR> vk_ranges(count);
+    std::vector<const VkAccelerationStructureBuildRangeInfoKHR *> vk_range_ptrs(count);
+
+    for (u32 i = 0; i < count; ++i) {
+        const AccelStructBuildGeometryInfo &in = build_infos[i];
+        for (u32 g = 0; g < in.geometry_count; ++g) {
+            vk_geometries.push_back(to_vk_geometry(in.geometries[g]));
+        }
+    }
+
+    u32 geometry_offset = 0;
+    for (u32 i = 0; i < count; ++i) {
+        const AccelStructBuildGeometryInfo &in = build_infos[i];
+
+        vk_build_infos[i].sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
+        vk_build_infos[i].type = to_vk_accel_struct_type(in.type);
+        vk_build_infos[i].flags = to_vk_build_flags(in.flags);
+        vk_build_infos[i].geometryCount = in.geometry_count;
+        vk_build_infos[i].pGeometries = vk_geometries.data() + geometry_offset;
+        if (in.dst_acceleration_structure) {
+            vk_build_infos[i].dstAccelerationStructure = in.dst_acceleration_structure->handle;
+        }
+        vk_build_infos[i].scratchData.deviceAddress = in.scratch_data;
+        geometry_offset += in.geometry_count;
+
+        vk_ranges[i].primitiveCount = ranges[i]->primitive_count;
+        vk_ranges[i].primitiveOffset = ranges[i]->primitive_offset;
+        vk_ranges[i].firstVertex = ranges[i]->first_vertex;
+        vk_ranges[i].transformOffset = ranges[i]->transform_offset;
+        vk_range_ptrs[i] = &vk_ranges[i];
+    }
+
+    vkCmdBuildAccelerationStructuresKHR(cmd.handle, count, vk_build_infos.data(), vk_range_ptrs.data());
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/allocator.cpp +58 -0
--- a/src/backend/vulkan/allocator.cpp
+++ b/src/backend/vulkan/allocator.cpp
@@ -0,0 +1,58 @@
+#define VMA_IMPLEMENTATION
+#define VMA_STATIC_VULKAN_FUNCTIONS  0
+#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
+
+#include <vk_mem_alloc.h>
+
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+#include "core/logger.h"
+
+namespace rhi {
+using namespace vk;
+
+bool create_memory_allocator(Device &device) {
+    VEL_INFO("Creating GPU Memory Allocator...");
+    VmaVulkanFunctions funcs{};
+    funcs.vkGetInstanceProcAddr = vkGetInstanceProcAddr;
+    funcs.vkGetDeviceProcAddr = vkGetDeviceProcAddr;
+
+    VmaAllocatorCreateInfo ci{};
+    ci.instance = device.instance;
+    ci.physicalDevice = device.physical;
+    ci.device = device.logical;
+    ci.vulkanApiVersion = VK_API_VERSION_1_3;
+    ci.pVulkanFunctions = &funcs;
+    ci.flags = VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT | VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
+    VmaAllocator vk_allocator;
+    if (vmaCreateAllocator(&ci, &vk_allocator) != VK_SUCCESS) {
+        return false;
+    }
+    device.memory.allocator = vk_allocator;
+    return true;
+}
+
+void destroy_memory_allocator(Device &device) {
+    Memory mem = device.memory;
+    VEL_INFO("Destroying GPU Memory Allocator...");
+    if (mem.allocator != VK_NULL_HANDLE) {
+        vmaDestroyAllocator(mem.allocator);
+        mem.allocator = VK_NULL_HANDLE;
+    }
+}
+
+rhi::MemoryStats memory_stats(Device &device) {
+    rhi::MemoryStats out;
+    if (device.memory.allocator == VK_NULL_HANDLE) {
+        return out;
+    }
+    VmaTotalStatistics stats;
+    vmaCalculateStatistics(device.memory.allocator, &stats);
+    out.block_count = stats.total.statistics.blockCount;
+    out.allocation_count = stats.total.statistics.allocationCount;
+    out.allocation_bytes = stats.total.statistics.allocationBytes;
+    out.used_bytes = stats.total.statistics.allocationBytes;
+    return out;
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/buffer.cpp +262 -0
--- a/src/backend/vulkan/buffer.cpp
+++ b/src/backend/vulkan/buffer.cpp
@@ -0,0 +1,262 @@
+
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <vk_mem_alloc.h>
+#include <volk.h>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+#include "core/logger.h"
+
+namespace rhi {
+using namespace vk;
+
+static inline VkBufferUsageFlags translate_buffer_usage(BufferUsage usage) {
+    VkBufferUsageFlags flags = 0;
+    u32 bits = static_cast<u32>(usage);
+    if (bits & static_cast<u32>(BufferUsage::VertexBuffer)) {
+        flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::IndexBuffer)) {
+        flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::UniformBuffer)) {
+        flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::StorageBuffer)) {
+        flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::IndirectBuffer)) {
+        flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::CopySrc)) {
+        flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::CopyDst)) {
+        flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::ShaderAddr)) {
+        flags |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
+    }
+    if (bits & static_cast<u32>(BufferUsage::AccelStructBuildInput)) {
+        flags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR;
+    }
+    if (bits & static_cast<u32>(BufferUsage::AccelStructStorage)) {
+        flags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR;
+    }
+    flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+    return flags;
+}
+
+struct VmaMemSelect {
+    VmaMemoryUsage usage;
+    VmaAllocationCreateFlags flags;
+};
+
+static inline VmaMemSelect vma_mem_select(const BufferDesc &desc) {
+    VmaMemSelect out{VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, 0};
+    switch (desc.memory) {
+    case BufferMemType::Device:
+        out.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
+        break;
+    case BufferMemType::Upload:
+        out.usage = VMA_MEMORY_USAGE_AUTO;
+        out.flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT;
+        out.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
+        break;
+    case BufferMemType::Readback:
+        out.usage = VMA_MEMORY_USAGE_AUTO;
+        out.flags |= VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT;
+        out.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT;
+        break;
+    }
+    if (desc.dedicated) {
+        out.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
+    }
+    return out;
+}
+
+bool create_buffer(Device &device, BufferDesc &desc, Buffer &buffer) {
+    VkBufferCreateInfo bi{};
+    bi.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+    bi.size = desc.size;
+    bi.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+    bi.usage = translate_buffer_usage(desc.usage);
+
+    VmaAllocationCreateInfo mi{};
+    const VmaMemSelect mem = vma_mem_select(desc);
+    mi.usage = mem.usage;
+    mi.flags = mem.flags;
+
+    VmaAllocationInfo ai{};
+    VkBuffer vk_buf;
+    VK_CHECK(vmaCreateBuffer(device.memory.allocator, &bi, &mi, &vk_buf, &buffer._allocation, &ai));
+    buffer._handle = vk_buf;
+    if (desc.name.size() > 0) {
+        VK_NAME_EX(device, vk_buf, desc.name.c_str());
+    }
+
+    if (Any(desc.usage, BufferUsage::ShaderAddr)) {
+        VkBufferDeviceAddressInfo info{
+            .sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
+            .buffer = buffer._handle,
+        };
+
+        buffer.address = vkGetBufferDeviceAddress(device.logical, &info);
+    }
+
+    buffer.mapped = ai.pMappedData;
+    buffer.desc = desc;
+
+    return true;
+}
+
+static bool
+create_vk_buffer_view(Device &device, const BufferViewDesc &desc, VkBufferView &out, BufferViewDesc &out_desc) {
+    if (desc.buffer == nullptr || desc.buffer->_handle == 0) {
+        return false;
+    }
+    out_desc = desc;
+    if (out_desc.size == 0) {
+        out_desc.size = desc.buffer->desc.size;
+    }
+    if (desc.type == BufferViewType::Texel) {
+        VkBufferViewCreateInfo ci{};
+        ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
+        ci.buffer = desc.buffer->_handle;
+        ci.format = VK_FORMAT_R32_UINT;
+        ci.offset = desc.offset;
+        ci.range = desc.size;
+        VkBufferView vk_view;
+        VK_CHECK(vkCreateBufferView(device.logical, &ci, nullptr, &vk_view));
+        out = vk_view;
+    } else {
+        out = NON_TEXEL_BUFFER_VIEW_SENTINEL;
+    }
+    return true;
+}
+
+void destroy_buffer(Device &device, Buffer &buffer) {
+    vmaDestroyBuffer(device.memory.allocator, buffer._handle, buffer._allocation);
+    buffer = {};
+}
+
+u64 buffer_device_address(Device &device, Buffer &buffer, u64 offset) {
+    if (offset > buffer.desc.size) {
+        VEL_CRITICAL("buffer_device_address: offset {} exceeds buffer size {}", offset, buffer.desc.size);
+        std::abort();
+    }
+
+    if (buffer.address == 0) {
+        assert(Any(buffer.desc.usage, BufferUsage::ShaderAddr) && "ShaderAddr usage invalid");
+
+        VkBufferDeviceAddressInfo info{
+            .sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
+            .buffer = buffer._handle,
+        };
+
+        buffer.address = vkGetBufferDeviceAddress(device.logical, &info);
+    }
+
+    return buffer.address + offset;
+}
+
+bool create_buffer_view(Device &device, const BufferViewDesc &desc, BufferView &out) {
+    if (desc.buffer == nullptr || desc.buffer->_handle == 0) {
+        return false;
+    }
+    switch (desc.type) {
+    case BufferViewType::Storage:
+        assert(Any(desc.buffer->desc.usage, BufferUsage::StorageBuffer) && "Storage view needs StorageBuffer usage");
+        break;
+    case BufferViewType::Uniform:
+        assert(Any(desc.buffer->desc.usage, BufferUsage::UniformBuffer) && "Uniform view needs UniformBuffer usage");
+        break;
+    case BufferViewType::Vertex:
+        assert(Any(desc.buffer->desc.usage, BufferUsage::VertexBuffer) && "Vertex view needs VertexBuffer usage");
+        break;
+    case BufferViewType::Index:
+        assert(Any(desc.buffer->desc.usage, BufferUsage::IndexBuffer) && "Index view needs IndexBuffer usage");
+        break;
+    case BufferViewType::Indirect:
+        assert(Any(desc.buffer->desc.usage, BufferUsage::IndirectBuffer) && "Indirect view needs IndirectBuffer usage");
+        break;
+    default:
+        break;
+    }
+    BufferViewDesc full = desc;
+    if (full.size == 0) {
+        full.size = desc.buffer->desc.size;
+    }
+    VkBufferView vk_view = VK_NULL_HANDLE;
+    BufferViewDesc out_desc{};
+    if (!create_vk_buffer_view(device, full, vk_view, out_desc)) {
+        return false;
+    }
+    const bool writeable = (full.type != BufferViewType::Uniform);
+    u64 slot = vk::write_buffer_view(device, full.buffer, full.offset, full.size, writeable);
+    if (slot == UINT64_MAX) {
+        if (full.type == BufferViewType::Texel && vk_view != VK_NULL_HANDLE &&
+            vk_view != NON_TEXEL_BUFFER_VIEW_SENTINEL) {
+            vkDestroyBufferView(device.logical, vk_view, nullptr);
+        }
+        return false;
+    }
+    out.buffer = full.buffer;
+    out.desc = out_desc;
+    out._handle = vk_view;
+    out.slot = slot;
+    if (vk_view != VK_NULL_HANDLE && vk_view != NON_TEXEL_BUFFER_VIEW_SENTINEL && full.buffer != nullptr &&
+        !full.buffer->desc.name.empty()) {
+        char view_name[256];
+        (void)snprintf(view_name, sizeof(view_name), "%s.view", full.buffer->desc.name.c_str());
+        VK_NAME_EX(device, vk_view, view_name);
+    }
+    return true;
+}
+
+u64 handle_id(Device &device, BufferView &view) {
+    (void)device;
+    return view.slot;
+}
+
+void buffer_flush(Device &device, Buffer &buffer, u64 offset, u64 size) {
+    if (buffer._allocation == VK_NULL_HANDLE) {
+        return;
+    }
+    vmaFlushAllocation(device.memory.allocator, buffer._allocation, offset, size);
+}
+
+void buffer_invalidate(Device &device, Buffer &buffer, u64 offset, u64 size) {
+    if (buffer._allocation == VK_NULL_HANDLE) {
+        return;
+    }
+    vmaInvalidateAllocation(device.memory.allocator, buffer._allocation, offset, size);
+}
+
+void destroy_buffer_view(Device &device, BufferView &view) {
+    if (view._handle != VK_NULL_HANDLE && view._handle != NON_TEXEL_BUFFER_VIEW_SENTINEL) {
+        vkDestroyBufferView(device.logical, view._handle, nullptr);
+    }
+    view._handle = nullptr;
+    if (view.slot != UINT64_MAX) {
+        RESOURCE_SLOTS.free(view.slot);
+        view.slot = UINT64_MAX;
+    }
+    view.buffer = nullptr;
+    view.desc = {};
+}
+
+void destroy_buffer_views(Device &device, Buffer &buffer) {
+    for (auto &[k, v] : buffer.view_cache) {
+        if (k.type == BufferViewType::Texel && v != VK_NULL_HANDLE && v != NON_TEXEL_BUFFER_VIEW_SENTINEL) {
+            vkDestroyBufferView(device.logical, v, nullptr);
+        }
+    }
+    buffer.view_cache.clear();
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/cmd_buffer.cpp +585 -0
--- a/src/backend/vulkan/cmd_buffer.cpp
+++ b/src/backend/vulkan/cmd_buffer.cpp
@@ -0,0 +1,585 @@
+
+#include <volk.h>
+
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
+
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+static VkAttachmentLoadOp to_vk_load_op(LoadOp value) {
+    switch (value) {
+    case LoadOp::LOAD:
+        return VK_ATTACHMENT_LOAD_OP_LOAD;
+    case LoadOp::CLEAR:
+        return VK_ATTACHMENT_LOAD_OP_CLEAR;
+    }
+
+    return VK_ATTACHMENT_LOAD_OP_LOAD;
+}
+
+static VkAttachmentStoreOp to_vk_store_op(StoreOp value) {
+    switch (value) {
+    case StoreOp::STORE:
+        return VK_ATTACHMENT_STORE_OP_STORE;
+    case StoreOp::DISCARD:
+        return VK_ATTACHMENT_STORE_OP_DONT_CARE;
+    }
+
+    return VK_ATTACHMENT_STORE_OP_STORE;
+}
+
+static VkResolveModeFlagBits to_vk_resolve_mode(ResolveOp value) {
+    switch (value) {
+    case ResolveOp::NONE:
+        return VK_RESOLVE_MODE_NONE;
+    case ResolveOp::AVERAGE:
+        return VK_RESOLVE_MODE_AVERAGE_BIT;
+    case ResolveOp::MIN:
+        return VK_RESOLVE_MODE_MIN_BIT;
+    case ResolveOp::MAX:
+        return VK_RESOLVE_MODE_MAX_BIT;
+    case ResolveOp::SAMPLE_ZERO:
+        return VK_RESOLVE_MODE_SAMPLE_ZERO_BIT;
+    }
+
+    return VK_RESOLVE_MODE_NONE;
+}
+
+static VkClearValue to_vk_clear_value(const ClearValue &value) {
+    VkClearValue result{};
+    memcpy(&result, &value, sizeof(VkClearValue));
+    return result;
+}
+
+static VkRenderingAttachmentInfo to_vk_rendering_attachment(const AttachmentDesc &attachment) {
+    VkRenderingAttachmentInfo info{};
+    if (attachment.img == nullptr || attachment.img->_handle == nullptr) {
+        VEL_CRITICAL("ToVkRenderingAttachment: null or zero-handle attachment image");
+        return info;
+    }
+    info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO;
+
+    info.imageView = attachment.img->_handle;
+    auto aspects = attachment.img->desc.aspect;
+    const bool depth_read_only =
+        attachment.img->desc.image != nullptr && attachment.img->desc.image->state == ResourceState::DepthFetch;
+    if (Any(aspects, ImageAspect::Depth) && Any(aspects, ImageAspect::Stencil)) {
+        info.imageLayout = depth_read_only ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
+                                           : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+    } else if (Any(aspects, ImageAspect::Depth)) {
+        info.imageLayout = depth_read_only ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
+                                           : VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
+    } else if (Any(aspects, ImageAspect::Stencil)) {
+        info.imageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
+    } else {
+        info.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+    }
+    info.loadOp = to_vk_load_op(attachment.loadOp);
+    info.storeOp = to_vk_store_op(attachment.storeOp);
+
+    if (attachment.resolveImg) {
+        info.resolveMode = to_vk_resolve_mode(attachment.resolveOp);
+        info.resolveImageView = attachment.resolveImg->_handle;
+        auto resolve_aspects = attachment.resolveImg->desc.aspect;
+        if (Any(resolve_aspects, ImageAspect::Depth) && Any(resolve_aspects, ImageAspect::Stencil)) {
+            info.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+        } else if (Any(resolve_aspects, ImageAspect::Depth)) {
+            info.resolveImageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL;
+        } else if (Any(resolve_aspects, ImageAspect::Stencil)) {
+            info.resolveImageLayout = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL;
+        } else {
+            info.resolveImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+        }
+    }
+
+    if (Any(attachment.img->desc.aspect, ImageAspect::Depth) ||
+        Any(attachment.img->desc.aspect, ImageAspect::Stencil)) {
+        info.clearValue.depthStencil = {
+            attachment.clearValue.depthStencil.depth, attachment.clearValue.depthStencil.stencil
+        };
+    } else {
+        info.clearValue.color.float32[0] = attachment.clearValue.color.float32[0];
+        info.clearValue.color.float32[1] = attachment.clearValue.color.float32[1];
+        info.clearValue.color.float32[2] = attachment.clearValue.color.float32[2];
+        info.clearValue.color.float32[3] = attachment.clearValue.color.float32[3];
+    }
+
+    return info;
+}
+
+bool create_cmd_buffer(Device &device, const CmdBufferDesc &desc, CmdBuffer &cmd) {
+    VkCommandBufferAllocateInfo alloc_ci{};
+    alloc_ci.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+    alloc_ci.commandPool = desc.pool->handle;
+    alloc_ci.level = vk::to_vk_cmd_buffer_level(desc.level);
+    alloc_ci.commandBufferCount = 1;
+
+    VkCommandBuffer vk_cmd;
+    VK_CHECK(vkAllocateCommandBuffers(device.logical, &alloc_ci, &vk_cmd));
+    cmd.handle = vk_cmd;
+    return true;
+}
+
+void destroy_cmd_buffer(Device &device, CmdPool &pool, CmdBuffer &cmd) {
+    if (cmd.handle != VK_NULL_HANDLE) {
+        VkCommandBuffer vk_cmd = cmd.handle;
+        vkFreeCommandBuffers(device.logical, pool.handle, 1, &vk_cmd);
+    }
+
+    cmd = {};
+}
+
+bool begin_cmd_buffer(CmdBuffer &cmd, const CmdBufferBeginDesc &desc) {
+    VkCommandBufferBeginInfo begin_ci{};
+    begin_ci.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+    begin_ci.flags = vk::to_vk_cmd_buffer_usage_flags(desc.usage);
+
+    VK_CHECK(vkBeginCommandBuffer(cmd.handle, &begin_ci));
+    return true;
+}
+
+bool end_cmd_buffer(CmdBuffer &cmd) {
+    VK_CHECK(vkEndCommandBuffer(cmd.handle));
+    return true;
+}
+
+bool reset_cmd_buffer(CmdBuffer &cmd) {
+    VK_CHECK(vkResetCommandBuffer(cmd.handle, 0));
+    return true;
+}
+
+void begin_rendering(CmdBuffer &cmd, RenderingInfo &ri) {
+    std::vector<VkRenderingAttachmentInfo> colors;
+    colors.reserve(ri.colorAttachmentCount);
+
+    VkRenderingInfo rendering_info{
+        .sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
+        .renderArea = {{0, 0}, {ri.width, ri.height}},
+        .layerCount = 1,
+    };
+
+    rendering_info.colorAttachmentCount = ri.colorAttachmentCount;
+    for (u32 i = 0; i < ri.colorAttachmentCount; i++) {
+        colors.push_back(to_vk_rendering_attachment(ri.colorAttachments[i]));
+    }
+    rendering_info.pColorAttachments = colors.data();
+
+    VkRenderingAttachmentInfo depth_attach = {VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO};
+    VkRenderingAttachmentInfo stencil_attach = {VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO};
+    if (ri.depthAttachment.img != nullptr && ri.depthAttachment.img->_handle != nullptr) {
+        auto aspects = ri.depthAttachment.img->desc.aspect;
+        if (Any(aspects, ImageAspect::Depth)) {
+            depth_attach = to_vk_rendering_attachment(ri.depthAttachment);
+            rendering_info.pDepthAttachment = &depth_attach;
+        }
+        if (Any(aspects, ImageAspect::Stencil)) {
+            stencil_attach = to_vk_rendering_attachment(ri.depthAttachment);
+            rendering_info.pStencilAttachment = &stencil_attach;
+        }
+    }
+
+    vkCmdBeginRendering(cmd.handle, &rendering_info);
+    cmd.is_rendering = true;
+}
+
+void end_rendering(CmdBuffer &cmd) {
+    vkCmdEndRendering(cmd.handle);
+    cmd.is_rendering = false;
+}
+
+void set_viewports(CmdBuffer &cmd, Viewport *viewports, u32 viewportCount) {
+    std::vector<VkViewport> vk_viewports = {};
+    for (u32 i = 0; i < viewportCount; i++) {
+        const Viewport &in = viewports[i];
+        VkViewport out;
+        out.x = in.x;
+        out.y = in.y;
+        out.width = in.width;
+        out.height = in.height;
+        out.minDepth = in.depth_min;
+        out.maxDepth = in.depth_max;
+        // flip for vulkan ndc
+        if (in.flip_y) {
+            out.y += in.height;
+            out.height = -in.height;
+        }
+        vk_viewports.push_back(out);
+    }
+    vkCmdSetViewportWithCount(cmd.handle, viewportCount, vk_viewports.data());
+};
+
+void set_scissors(CmdBuffer &cmd, const Rect *rects, u32 rectCount) {
+    std::vector<VkRect2D> vk_rects = {};
+    for (u32 i = 0; i < rectCount; i++) {
+        const Rect &in = rects[i];
+        VkRect2D out;
+        out.offset.x = in.x;
+        out.offset.y = in.y;
+        out.extent.width = in.width;
+        out.extent.height = in.height;
+        vk_rects.push_back(out);
+    }
+    vkCmdSetScissorWithCount(cmd.handle, rectCount, vk_rects.data());
+}
+
+void set_vertex_buffer(CmdBuffer &cmd, Buffer &buffer, u32 binding, u64 offset) {
+    VkBuffer buffers[] = {buffer._handle};
+    VkDeviceSize offsets[] = {offset};
+
+    vkCmdBindVertexBuffers(cmd.handle, binding, 1, buffers, offsets);
+}
+
+void set_index_buffer(CmdBuffer &cmd, Buffer &buffer, u32 offset, IndexType type) {
+    u64 size = buffer.desc.size - offset;
+    vkCmdBindIndexBuffer(
+        cmd.handle, buffer._handle, offset, type == IndexType::UINT32 ? VK_INDEX_TYPE_UINT32 : VK_INDEX_TYPE_UINT16
+    );
+}
+
+void set_pipeline(CmdBuffer &cmd, RenderPipeline &pipeline) {
+    VEL_ASSERT_HANDLE(cmd.handle, "SetPipeline: null command buffer");
+    VEL_ASSERT_HANDLE(pipeline._handle, "SetPipeline: null pipeline handle");
+    assert(pipeline.device != nullptr && "SetPipeline: pipeline has no device");
+    vkCmdBindPipeline(cmd.handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline._handle);
+    vkCmdBindDescriptorSets(
+        cmd.handle,
+        VK_PIPELINE_BIND_POINT_GRAPHICS,
+        pipeline.device->pipeline_layout,
+        0,
+        1,
+        &pipeline.device->descriptor_set,
+        0,
+        nullptr
+    );
+}
+
+void set_pipeline(CmdBuffer &cmd, ComputePipeline &pipeline) {
+    VEL_ASSERT_HANDLE(cmd.handle, "SetPipeline: null command buffer");
+    VEL_ASSERT_HANDLE(pipeline._handle, "SetPipeline: null pipeline handle");
+    assert(pipeline.device != nullptr && "SetPipeline: pipeline has no device");
+    vkCmdBindPipeline(cmd.handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline._handle);
+    vkCmdBindDescriptorSets(
+        cmd.handle,
+        VK_PIPELINE_BIND_POINT_COMPUTE,
+        pipeline.device->pipeline_layout,
+        0,
+        1,
+        &pipeline.device->descriptor_set,
+        0,
+        nullptr
+    );
+}
+
+void set_constants(CmdBuffer &cmd, RenderPipeline &pipeline, rhi::ShaderStage stage, u32 size, const void *data) {
+    (void)stage;
+    assert(pipeline.device != nullptr && "SetConstants: pipeline has no device");
+    vkCmdPushConstants(
+        cmd.handle, pipeline.device->pipeline_layout, VK_SHADER_STAGE_ALL | VK_SHADER_STAGE_COMPUTE_BIT, 0, size, data
+    );
+}
+
+void set_constants(CmdBuffer &cmd, ComputePipeline &pipeline, rhi::ShaderStage stage, u32 size, const void *data) {
+    (void)stage;
+    assert(pipeline.device != nullptr && "SetConstants: pipeline has no device");
+    vkCmdPushConstants(
+        cmd.handle, pipeline.device->pipeline_layout, VK_SHADER_STAGE_ALL | VK_SHADER_STAGE_COMPUTE_BIT, 0, size, data
+    );
+}
+
+void draw(CmdBuffer &cmd, u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance) {
+    vkCmdDraw(cmd.handle, vertexCount, instanceCount, firstVertex, firstInstance);
+}
+
+void draw_indexed(CmdBuffer &cmd, u32 indexCount, u32 instanceCount, u32 firstIndex, u32 vtxOff, u32 firstInstance) {
+    vkCmdDrawIndexed(cmd.handle, indexCount, instanceCount, firstIndex, vtxOff, firstInstance);
+}
+
+void draw_indirect(CmdBuffer &cmd, Buffer &buffer, u32 drawCount, u32 stride, u64 offset) {
+    vkCmdDrawIndirect(cmd.handle, buffer._handle, offset, drawCount, stride);
+}
+
+void draw_indirect_count(
+    CmdBuffer &cmd, Buffer &buffer, Buffer &countBuffer, u32 drawCount, u32 stride, u64 offset, u32 countOffset
+) {
+    vkCmdDrawIndirectCount(cmd.handle, buffer._handle, offset, countBuffer._handle, countOffset, drawCount, stride);
+}
+
+void draw_indexed_indirect(
+    CmdBuffer &cmd, Buffer &buffer, Buffer *countBuffer, u32 drawCount, u32 stride, u64 offset, u32 countOffset
+) {
+    if (countBuffer) {
+        vkCmdDrawIndexedIndirectCount(
+            cmd.handle, buffer._handle, offset, countBuffer->_handle, countOffset, drawCount, stride
+        );
+    } else {
+        vkCmdDrawIndexedIndirect(cmd.handle, buffer._handle, offset, drawCount, stride);
+    }
+}
+
+void fill_buffer(CmdBuffer &cmd, Buffer &buffer, u64 offset, u64 size, u32 value) {
+    vkCmdFillBuffer(cmd.handle, buffer._handle, offset, size, value);
+}
+
+void dispatch(CmdBuffer &cmd, u32 x, u32 y, u32 z) {
+    VEL_ASSERT_HANDLE(cmd.handle, "Dispatch: null command buffer");
+    vkCmdDispatch(cmd.handle, x, y, z);
+};
+
+static bool state_is_read_only(ResourceState s) {
+    switch (s) {
+    case ResourceState::Idle:
+    case ResourceState::ColorFetch:
+    case ResourceState::DepthFetch:
+    case ResourceState::TextureSample:
+    case ResourceState::TextureSampleNonFragment:
+    case ResourceState::StorageRead:
+    case ResourceState::VertexFetch:
+    case ResourceState::IndexFetch:
+    case ResourceState::IndirectFetch:
+    case ResourceState::UniformRead:
+    case ResourceState::TransferFrom:
+    case ResourceState::HostRead:
+    case ResourceState::AccelTrace:
+    case ResourceState::Display:
+        return true;
+    default:
+        return false;
+    }
+}
+
+static VkImageMemoryBarrier2
+image_barrier_for(Image &image, const ImageRange &range, ResourceState before, ResourceState after) {
+    vk::StateSync src = vk::image_state_to_vk(before, range.aspect);
+    vk::StateSync dst = vk::image_state_to_vk(after, range.aspect);
+    VkImageMemoryBarrier2 out{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2};
+    out.srcStageMask = src.stages;
+    out.srcAccessMask = src.access;
+    out.dstStageMask = dst.stages;
+    out.dstAccessMask = dst.access;
+    out.oldLayout = src.layout == VK_IMAGE_LAYOUT_UNDEFINED && before == ResourceState::Idle ? VK_IMAGE_LAYOUT_UNDEFINED
+                                                                                             : src.layout;
+    out.newLayout = dst.layout;
+    out.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    out.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    out.image = image._handle;
+    out.subresourceRange = {
+        vk::image_aspect_bit_to_vk(range.aspect),
+        range.mip,
+        (range.mip_count == REMAINING_MIPS) ? VK_REMAINING_MIP_LEVELS : range.mip_count,
+        range.layer,
+        (range.layer_count == REMAINING_LAYERS) ? VK_REMAINING_ARRAY_LAYERS : range.layer_count,
+    };
+    return out;
+}
+
+// no barriers inside rendering
+static void require_outside_rendering(const CmdBuffer &cmd) {
+    if (cmd.is_rendering) {
+        VEL_CRITICAL("barrier() called inside dynamic rendering — hoist it before begin_rendering");
+        std::abort();
+    }
+}
+
+void barrier(CmdBuffer &cmd, ResourceState before, ResourceState after) {
+    require_outside_rendering(cmd);
+    vk::StateSync src = vk::buffer_state_to_vk(before);
+    vk::StateSync dst = vk::buffer_state_to_vk(after);
+    VkMemoryBarrier2 mem{VK_STRUCTURE_TYPE_MEMORY_BARRIER_2};
+    mem.srcStageMask = src.stages;
+    mem.srcAccessMask = src.access;
+    mem.dstStageMask = dst.stages;
+    mem.dstAccessMask = dst.access;
+    VkDependencyInfo dep{VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
+    dep.memoryBarrierCount = 1;
+    dep.pMemoryBarriers = &mem;
+    vkCmdPipelineBarrier2(cmd.handle, &dep);
+}
+
+void barrier(CmdBuffer &cmd, Buffer &buffer, ResourceState before, ResourceState after) {
+    require_outside_rendering(cmd);
+    if (before == after && before != ResourceState::Idle && state_is_read_only(before)) {
+        return;
+    }
+    vk::StateSync src = vk::buffer_state_to_vk(before);
+    vk::StateSync dst = vk::buffer_state_to_vk(after);
+    VkBufferMemoryBarrier2 out{VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2};
+    out.srcStageMask = src.stages;
+    out.srcAccessMask = src.access;
+    out.dstStageMask = dst.stages;
+    out.dstAccessMask = dst.access;
+    out.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    out.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    out.buffer = buffer._handle;
+    out.offset = 0;
+    out.size = VK_WHOLE_SIZE;
+    VkDependencyInfo dep{VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
+    dep.bufferMemoryBarrierCount = 1;
+    dep.pBufferMemoryBarriers = &out;
+    vkCmdPipelineBarrier2(cmd.handle, &dep);
+    buffer.state = after;
+}
+
+void barrier(CmdBuffer &cmd, Image &image, const ImageRange &range, ResourceState before, ResourceState after) {
+    require_outside_rendering(cmd);
+    if (before == after && before != ResourceState::Idle && state_is_read_only(before)) {
+        return;
+    }
+    VkImageMemoryBarrier2 out = image_barrier_for(image, range, before, after);
+    const bool region_local = cmd.is_rendering && after == ResourceState::ColorFetch;
+    VkDependencyInfo dep{VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
+    if (region_local) {
+        dep.dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
+    }
+    dep.imageMemoryBarrierCount = 1;
+    dep.pImageMemoryBarriers = &out;
+    vkCmdPipelineBarrier2(cmd.handle, &dep);
+    if (range.mip_count == REMAINING_MIPS && range.layer_count == REMAINING_LAYERS) {
+        image.state = after;
+    }
+}
+
+static void copy_buffer_to_image(
+    CmdBuffer &cmd, Buffer &srcBuffer, Image &dstImage, ImageAspect aspect, const BufferTextureCopyRegion &region
+) {
+    VkBuffer vk_src_buffer = srcBuffer._handle;
+    VkImage vk_dst_image = dstImage._handle;
+
+    VkBufferImageCopy2 copy_region{};
+    copy_region.sType = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2;
+    copy_region.bufferOffset = region.buffer_offset;
+    copy_region.bufferRowLength = region.buffer_row_length;
+    copy_region.bufferImageHeight = region.buffer_image_height;
+
+    copy_region.imageSubresource.aspectMask = vk::image_aspect_to_vk(aspect);
+    copy_region.imageSubresource.mipLevel = region.mip_level;
+    copy_region.imageSubresource.baseArrayLayer = region.base_array_layer;
+    copy_region.imageSubresource.layerCount = region.layer_count;
+
+    copy_region.imageOffset = {
+        static_cast<i32>(region.texture_offset_x),
+        static_cast<i32>(region.texture_offset_y),
+        static_cast<i32>(region.texture_offset_z)
+    };
+
+    copy_region.imageExtent = {
+        static_cast<u32>(region.texture_extent_width),
+        static_cast<u32>(region.texture_extent_height),
+        static_cast<u32>(region.texture_extent_depth)
+    };
+
+    VkCopyBufferToImageInfo2 copy_info{};
+    copy_info.sType = VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2;
+    copy_info.srcBuffer = vk_src_buffer;
+    copy_info.dstImage = vk_dst_image;
+    copy_info.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+    copy_info.regionCount = 1;
+    copy_info.pRegions = &copy_region;
+
+    vkCmdCopyBufferToImage2(cmd.handle, &copy_info);
+}
+
+void copy_buffer_to_texture(
+    CmdBuffer &cmd, Buffer &srcBuffer, ImageView &dstView, const BufferTextureCopyRegion &region
+) {
+    if (dstView.desc.image == nullptr || dstView.desc.image->_handle == 0) {
+        VEL_CRITICAL("CopyBufferToTexture: invalid destination image view");
+        return;
+    }
+    copy_buffer_to_image(cmd, srcBuffer, *dstView.desc.image, dstView.desc.aspect, region);
+}
+
+static void copy_image_to_buf(
+    CmdBuffer &cmd, Image &srcImage, ImageAspect aspect, Buffer &dstBuffer, const rhi::BufferTextureCopyRegion &region
+) {
+    VkImage vk_src_image = srcImage._handle;
+    VkBuffer vk_dst_buffer = dstBuffer._handle;
+
+    VkBufferImageCopy2 copy_region{};
+    copy_region.sType = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2;
+    copy_region.bufferOffset = region.buffer_offset;
+    copy_region.bufferRowLength = region.buffer_row_length;
+    copy_region.bufferImageHeight = region.buffer_image_height;
+
+    copy_region.imageSubresource.aspectMask = vk::image_aspect_to_vk(aspect);
+    copy_region.imageSubresource.mipLevel = region.mip_level;
+    copy_region.imageSubresource.baseArrayLayer = region.base_array_layer;
+    copy_region.imageSubresource.layerCount = region.layer_count;
+
+    copy_region.imageOffset = {
+        static_cast<i32>(region.texture_offset_x),
+        static_cast<i32>(region.texture_offset_y),
+        static_cast<i32>(region.texture_offset_z)
+    };
+
+    copy_region.imageExtent = {
+        static_cast<u32>(region.texture_extent_width),
+        static_cast<u32>(region.texture_extent_height),
+        static_cast<u32>(region.texture_extent_depth)
+    };
+
+    VkCopyImageToBufferInfo2 copy_info{};
+    copy_info.sType = VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2;
+    copy_info.srcImage = vk_src_image;
+    copy_info.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
+    copy_info.dstBuffer = vk_dst_buffer;
+    copy_info.regionCount = 1;
+    copy_info.pRegions = &copy_region;
+
+    vkCmdCopyImageToBuffer2(cmd.handle, &copy_info);
+}
+
+void copy_image_to_buffer(
+    CmdBuffer &cmd, ImageView &srcView, Buffer &dstBuffer, const rhi::BufferTextureCopyRegion &region
+) {
+    if (srcView.desc.image == nullptr || srcView.desc.image->_handle == 0) {
+        VEL_CRITICAL("CopyImageToBuffer: invalid source image view");
+        return;
+    }
+    copy_image_to_buf(cmd, *srcView.desc.image, srcView.desc.aspect, dstBuffer, region);
+}
+
+void copy_buffer_to_device(
+    Device &device, Buffer &src, u64 src_offset, Buffer &dst, u64 dst_offset, u64 size, CmdBuffer &cmd
+) {
+    VkBufferCopy region{.srcOffset = src_offset, .dstOffset = dst_offset, .size = size};
+    vkCmdCopyBuffer(cmd.handle, src._handle, dst._handle, 1, &region);
+}
+
+void blit_image(CmdBuffer &cmd, Image &image, const rhi::ImageBlit *regions, u32 region_count) {
+    std::vector<VkImageBlit> vk_blits(region_count);
+    for (u32 i = 0; i < region_count; ++i) {
+        const rhi::ImageBlit &r = regions[i];
+        vk_blits[i] = VkImageBlit{
+            .srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, r.src_mip, r.src_layer, 1},
+            .srcOffsets = {{r.src_x0, r.src_y0, 0}, {r.src_x1, r.src_y1, 1}},
+            .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, r.dst_mip, r.dst_layer, 1},
+            .dstOffsets = {{r.dst_x0, r.dst_y0, 0}, {r.dst_x1, r.dst_y1, 1}},
+        };
+    }
+    vkCmdBlitImage(
+        cmd.handle,
+        image._handle,
+        VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
+        image._handle,
+        VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+        region_count,
+        vk_blits.data(),
+        VK_FILTER_LINEAR
+    );
+}
+
+void set_polygon_mode(CmdBuffer &cmd, rhi::PipelineFillMode mode) {
+    vkCmdSetPolygonModeEXT(cmd.handle, vk::pipeline_fill_mode_to_vk(mode));
+}
+
+void set_depth_write_enable(CmdBuffer &cmd, bool enable) {
+    vkCmdSetDepthWriteEnableEXT(cmd.handle, enable ? VK_TRUE : VK_FALSE);
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/cmd_pool.cpp +35 -0
--- a/src/backend/vulkan/cmd_pool.cpp
+++ b/src/backend/vulkan/cmd_pool.cpp
@@ -0,0 +1,35 @@
+
+#include <volk.h>
+
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+bool create_cmd_pool(Device &device, const CmdPoolDesc &desc, CmdPool &pool) {
+    VkCommandPoolCreateInfo pool_ci{};
+    pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+    pool_ci.flags = vk::to_vk_cmd_pool_flags(desc.flags);
+    pool_ci.queueFamilyIndex = desc.queue_family_index;
+
+    VkCommandPool vk_pool;
+    VK_CHECK(vkCreateCommandPool(device.logical, &pool_ci, nullptr, &vk_pool));
+    pool.handle = vk_pool;
+    return true;
+}
+
+void destroy_cmd_pool(Device &device, CmdPool &pool) {
+    if (pool.handle != VK_NULL_HANDLE) {
+        vkDestroyCommandPool(device.logical, pool.handle, nullptr);
+    }
+
+    pool = {};
+}
+
+void reset_cmd_pool(Device &device, CmdPool &pool, u32 flags) {
+    VK_CHECK(vkResetCommandPool(device.logical, pool.handle, flags));
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/context.cpp +385 -0
--- a/src/backend/vulkan/context.cpp
+++ b/src/backend/vulkan/context.cpp
@@ -0,0 +1,385 @@
+#define VOLK_IMPLEMENTATION
+#include <volk.h>
+
+#include <cstring>
+
+#include "backend/rhi_api.h"
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+static bool ext_available(const char *name, const std::vector<VkExtensionProperties> &list) {
+    for (auto &e : list) {
+        if (strcmp(name, e.extensionName) == 0) {
+            return true;
+        }
+    }
+    return false;
+}
+
+static void create_instance(Device &device, Config &cfg, VkInstance &vk_instance) {
+    VEL_INFO("Initializing Vulkan Context...");
+
+    u32 extension_count = 0;
+    VK_CHECK(vkEnumerateInstanceExtensionProperties(nullptr, &extension_count, nullptr));
+
+    std::vector<VkExtensionProperties> available(extension_count);
+    VK_CHECK(vkEnumerateInstanceExtensionProperties(nullptr, &extension_count, available.data()));
+
+    cfg.instance_extensions.push_back(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
+
+    VkDebugUtilsMessengerCreateInfoEXT debug_ci{
+        .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
+        .pNext = nullptr,
+        .messageSeverity =
+            VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
+        .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
+                       VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
+        .pfnUserCallback = debug_callback,
+    };
+
+    static constexpr VkValidationFeatureEnableEXT val_enable[] = {
+        VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT,
+        VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT,
+        // VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,
+        // VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT,
+        // VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT, // Keep disabled if GPU_ASSISTED is active
+    };
+
+    VkValidationFeaturesEXT val_features{
+        .sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT,
+        .pNext = &debug_ci, // Chain debug messenger into validation setup
+        .enabledValidationFeatureCount = static_cast<u32>(std::size(val_enable)),
+        .pEnabledValidationFeatures = val_enable,
+    };
+
+    void *pnext_chain = nullptr;
+
+    if (cfg.enable_validation) {
+        cfg.instance_layers.push_back("VK_LAYER_KHRONOS_validation");
+
+        if (ext_available(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, available)) {
+            cfg.instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
+        }
+        if (ext_available(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME, available)) {
+            cfg.instance_extensions.push_back(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME);
+        }
+
+        pnext_chain = &val_features;
+    }
+
+    const VkApplicationInfo app_info{
+        .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
+        .pApplicationName = "vel-renderer",
+        .applicationVersion = VK_MAKE_VERSION(1, 0, 0),
+        .pEngineName = "vel-renderer",
+        .engineVersion = VK_MAKE_VERSION(1, 0, 0),
+        .apiVersion = VK_API_VERSION_1_3,
+    };
+
+    const VkInstanceCreateInfo ci{
+        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+        .pNext = pnext_chain,
+        .pApplicationInfo = &app_info,
+        .enabledLayerCount = static_cast<u32>(cfg.instance_layers.size()),
+        .ppEnabledLayerNames = cfg.instance_layers.data(),
+        .enabledExtensionCount = static_cast<u32>(cfg.instance_extensions.size()),
+        .ppEnabledExtensionNames = cfg.instance_extensions.data(),
+    };
+
+    VK_CHECK(vkCreateInstance(&ci, nullptr, &vk_instance));
+
+    device.instance = vk_instance;
+    volkLoadInstance(vk_instance);
+
+    if (cfg.enable_validation) {
+        create_debug_messenger(device);
+    }
+}
+
+static void create_phys_device(Device &device, Config &cfg, VkInstance &vk_instance, VkPhysicalDevice &vk_physical) {
+    u32 n = 0;
+    VK_CHECK(vkEnumeratePhysicalDevices(vk_instance, &n, nullptr));
+    if (n == 0) {
+        VEL_CRITICAL("No Vulkan physical devices found");
+        std::abort();
+    }
+
+    std::vector<VkPhysicalDevice> devices(n);
+    VK_CHECK(vkEnumeratePhysicalDevices(vk_instance, &n, devices.data()));
+
+    for (auto pd : devices) {
+        VkPhysicalDeviceProperties props;
+        vkGetPhysicalDeviceProperties(pd, &props);
+        if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
+            vk_physical = pd;
+            break;
+        }
+    }
+    if (!vk_physical) {
+        vk_physical = devices[0];
+    }
+
+    VkPhysicalDeviceProperties props;
+    vkGetPhysicalDeviceProperties(vk_physical, &props);
+    const char *type_str = (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) ? "Discrete" : "Integrated/Other";
+    VEL_INFO("Selected GPU: {} ({})", props.deviceName, type_str);
+    VEL_INFO(
+        "Driver: {}.{}.{}",
+        VK_API_VERSION_MAJOR(props.driverVersion),
+        VK_API_VERSION_MINOR(props.driverVersion),
+        VK_API_VERSION_PATCH(props.driverVersion)
+    );
+
+    device.physical = vk_physical;
+    device.min_ubo_alignment = props.limits.minUniformBufferOffsetAlignment;
+    device.timestamp_period = props.limits.timestampPeriod;
+
+    VkPhysicalDeviceDescriptorIndexingProperties indexing{
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES
+    };
+    VkPhysicalDeviceAccelerationStructurePropertiesKHR accel_structure_props{
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR,
+        .pNext = &indexing,
+    };
+    VkPhysicalDeviceVulkan12Properties props12{
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES,
+        .pNext = &accel_structure_props,
+    };
+    VkPhysicalDeviceProperties2 props2{
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
+        .pNext = &props12,
+    };
+    vkGetPhysicalDeviceProperties2(vk_physical, &props2);
+
+    device.max_sampled_textures = props12.maxDescriptorSetUpdateAfterBindSampledImages;
+    device.max_storage_buffers = props12.maxDescriptorSetUpdateAfterBindStorageBuffers;
+    device.max_storage_images = props12.maxDescriptorSetUpdateAfterBindStorageImages;
+    device.max_uniform_buffers = props12.maxDescriptorSetUpdateAfterBindUniformBuffers;
+    device.max_samplers = props12.maxDescriptorSetUpdateAfterBindSamplers;
+    device.max_acceleration_structures = accel_structure_props.maxDescriptorSetUpdateAfterBindAccelerationStructures;
+};
+
+static void create_logi_device(
+    Device &device, Config &cfg, VkInstance &vk_instance, VkPhysicalDevice &vk_physical, VkDevice &vk_device
+) {
+    device.graphics = find_queue(device, VK_QUEUE_GRAPHICS_BIT, 0);
+
+    f32 priority = 1.0f;
+    std::vector<VkDeviceQueueCreateInfo> queue_infos;
+    if (device.graphics.family_index != UINT32_MAX) {
+        queue_infos.push_back(
+            VkDeviceQueueCreateInfo{
+                .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
+                .queueFamilyIndex = device.graphics.family_index,
+                .queueCount = 1,
+                .pQueuePriorities = &priority,
+            }
+        );
+    }
+
+    std::vector<VkExtensionProperties> available_exts;
+    {
+        u32 n = 0;
+        VK_CHECK(vkEnumerateDeviceExtensionProperties(vk_physical, nullptr, &n, nullptr));
+        available_exts.resize(n);
+        VK_CHECK(vkEnumerateDeviceExtensionProperties(vk_physical, nullptr, &n, available_exts.data()));
+    }
+
+    std::vector<const char *> exts = cfg.device_extensions;
+    auto push_ext = [&](const char *name) {
+        if (ext_available(name, available_exts)) {
+            exts.push_back(name);
+        }
+    };
+    push_ext(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
+    push_ext(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME);
+    push_ext(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
+    push_ext(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
+    push_ext(VK_KHR_RAY_QUERY_EXTENSION_NAME);
+    push_ext(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
+    push_ext(VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME);
+    push_ext(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
+
+    // gate behind validation?
+    push_ext(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
+
+    VkPhysicalDeviceFeatures2 features{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
+    PNEXTCHAIN_DECLARE(features.pNext);
+
+    VkPhysicalDeviceVulkan11Features f11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES};
+    PNEXTCHAIN_APPEND_STRUCT(f11);
+
+    VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
+    PNEXTCHAIN_APPEND_STRUCT(f12);
+
+    VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES};
+    PNEXTCHAIN_APPEND_STRUCT(f13);
+
+    VkPhysicalDeviceExtendedDynamicState2FeaturesEXT eds2{
+        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT
+    };
+    PNEXTCHAIN_APPEND_STRUCT(eds2);
+
+    VkPhysicalDeviceAccelerationStructureFeaturesKHR as_f{
+        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR
+    };
+    PNEXTCHAIN_APPEND_STRUCT(as_f);
+
+    VkPhysicalDeviceRayQueryFeaturesKHR rq_f{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR};
+    PNEXTCHAIN_APPEND_STRUCT(rq_f);
+
+    VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT mutable_f{
+        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT
+    };
+    PNEXTCHAIN_APPEND_STRUCT(mutable_f);
+
+    vkGetPhysicalDeviceFeatures2(vk_physical, &features);
+
+    // VK 1.0 features
+    features.features.samplerAnisotropy = VK_TRUE;
+    features.features.multiDrawIndirect = VK_TRUE;
+    features.features.drawIndirectFirstInstance = VK_TRUE;
+    features.features.fillModeNonSolid = VK_TRUE;
+    features.features.depthClamp = VK_TRUE;
+
+    // needed for vk shader validation as well
+    features.features.vertexPipelineStoresAndAtomics = VK_TRUE;
+    features.features.fragmentStoresAndAtomics = VK_TRUE;
+
+    features.features.shaderInt64 = VK_TRUE;
+    features.features.shaderStorageImageReadWithoutFormat = VK_TRUE;
+    features.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
+
+    // VK 1.1 features
+    f11.shaderDrawParameters = VK_TRUE;
+
+    // VK 1.2 features (bindless architecture base)
+    f12.descriptorIndexing = VK_TRUE;
+    f12.runtimeDescriptorArray = VK_TRUE;
+    f12.descriptorBindingPartiallyBound = VK_TRUE;
+    f12.descriptorBindingVariableDescriptorCount = VK_TRUE;
+    f12.descriptorBindingUpdateUnusedWhilePending = VK_TRUE;
+    f12.descriptorBindingUniformBufferUpdateAfterBind = VK_TRUE;
+    f12.descriptorBindingStorageBufferUpdateAfterBind = VK_TRUE;
+    f12.descriptorBindingStorageImageUpdateAfterBind = VK_TRUE;
+    f12.descriptorBindingSampledImageUpdateAfterBind = VK_TRUE;
+    f12.shaderSampledImageArrayNonUniformIndexing = VK_TRUE;
+    f12.shaderStorageBufferArrayNonUniformIndexing = VK_TRUE;
+    f12.shaderUniformBufferArrayNonUniformIndexing = VK_TRUE;
+    f12.shaderStorageImageArrayNonUniformIndexing = VK_TRUE;
+    f12.shaderUniformTexelBufferArrayNonUniformIndexing = VK_TRUE;
+    f12.shaderStorageTexelBufferArrayNonUniformIndexing = VK_TRUE;
+    f12.timelineSemaphore = VK_TRUE;
+    f12.drawIndirectCount = VK_TRUE;
+
+    // I just end up manually aligning stuff anyway, but a nice to have
+    f12.scalarBlockLayout = VK_TRUE;
+    f12.bufferDeviceAddress = VK_TRUE;
+
+    // VK 1.3 features
+    f13.synchronization2 = VK_TRUE;
+    f13.dynamicRendering = VK_TRUE;
+    f13.pipelineCreationCacheControl = VK_TRUE;
+    f13.shaderDemoteToHelperInvocation = VK_TRUE;
+
+    eds2.extendedDynamicState2 = VK_TRUE;
+    as_f.accelerationStructure = VK_TRUE;
+    as_f.descriptorBindingAccelerationStructureUpdateAfterBind = VK_TRUE;
+    rq_f.rayQuery = VK_TRUE;
+    mutable_f.mutableDescriptorType = VK_TRUE;
+
+    // requirements check
+    if (!f13.synchronization2) {
+        VEL_CRITICAL("synchronization2 not supported (Vulkan 1.3 required)");
+        std::abort();
+    }
+    if (!f13.dynamicRendering) {
+        VEL_CRITICAL("dynamicRendering not supported (Vulkan 1.3 required)");
+        std::abort();
+    }
+    if (!f12.bufferDeviceAddress) {
+        VEL_CRITICAL("bufferDeviceAddress not supported (Vulkan 1.2 required)");
+        std::abort();
+    }
+    if (!f12.descriptorIndexing) {
+        VEL_CRITICAL("descriptorIndexing not supported (Vulkan 1.2 required)");
+        std::abort();
+    }
+    if (!mutable_f.mutableDescriptorType) {
+        VEL_CRITICAL("VK_EXT_mutable_descriptor_type not supported (required)");
+        std::abort();
+    }
+
+    VkDeviceCreateInfo ci{VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO};
+    ci.pNext = &features;
+    ci.queueCreateInfoCount = (u32)queue_infos.size();
+    ci.pQueueCreateInfos = queue_infos.data();
+    ci.enabledExtensionCount = (u32)exts.size();
+    ci.ppEnabledExtensionNames = exts.data();
+
+    VK_CHECK(vkCreateDevice(vk_physical, &ci, nullptr, &vk_device));
+    device.logical = vk_device;
+
+    if (device.graphics.family_index != UINT32_MAX) {
+        VkQueue q;
+        vkGetDeviceQueue(vk_device, device.graphics.family_index, 0, &q);
+        device.graphics.handle = q;
+    }
+}
+
+void create_context(Device &device, Config &cfg) {
+    VEL_INFO("Initializing Vulkan Context...");
+
+    volkInitialize();
+
+    VkInstance vk_inst{};
+    create_instance(device, cfg, vk_inst);
+    VkPhysicalDevice vk_phys{};
+    create_phys_device(device, cfg, vk_inst, vk_phys);
+    VkDevice vk_dev{};
+    create_logi_device(device, cfg, vk_inst, vk_phys, vk_dev);
+
+    volkLoadDevice(vk_dev);
+
+    VK_NAME(device, device.instance);
+    VK_NAME(device, device.logical);
+    VK_NAME(device, device.graphics.handle);
+
+    create_global_descriptors(device);
+}
+
+void destroy_context(Device &device) {
+    VEL_INFO("Shutting down Vulkan Context...");
+    vkDeviceWaitIdle(device.logical);
+
+    destroy_global_descriptors(device);
+
+    if (device.debug_messenger && device.instance) {
+        destory_debug_messenger(device);
+        device.debug_messenger = VK_NULL_HANDLE;
+    }
+
+    vkDestroyDevice(device.logical, nullptr);
+    device.logical = VK_NULL_HANDLE;
+
+    vkDestroyInstance(device.instance, nullptr);
+    device.instance = VK_NULL_HANDLE;
+
+    device.physical = VK_NULL_HANDLE;
+    device.graphics = {};
+    device.pipeline_cache = VK_NULL_HANDLE;
+}
+
+void device_wait_idle(Device &device) {
+    VK_CHECK(vkDeviceWaitIdle(device.logical));
+}
+
+void queue_wait_idle(Device &device) {
+    VK_CHECK(vkQueueWaitIdle(device.graphics.handle));
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/debug.cpp +146 -0
--- a/src/backend/vulkan/debug.cpp
+++ b/src/backend/vulkan/debug.cpp
@@ -0,0 +1,146 @@
+#include "backend/vulkan/debug.h"
+
+#include <volk.h>
+
+#include "backend/vulkan/vk_conversion.h"
+
+namespace vk {
+const char *vk_result_to_string(VkResult res) {
+    switch (res) {
+    case VK_SUCCESS:
+        return "VK_SUCCESS";
+    case VK_NOT_READY:
+        return "VK_NOT_READY";
+    case VK_TIMEOUT:
+        return "VK_TIMEOUT";
+    case VK_EVENT_SET:
+        return "VK_EVENT_SET";
+    case VK_EVENT_RESET:
+        return "VK_EVENT_RESET";
+    case VK_INCOMPLETE:
+        return "VK_INCOMPLETE";
+    case VK_ERROR_OUT_OF_HOST_MEMORY:
+        return "VK_ERROR_OUT_OF_HOST_MEMORY";
+    case VK_ERROR_OUT_OF_DEVICE_MEMORY:
+        return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
+    case VK_ERROR_INITIALIZATION_FAILED:
+        return "VK_ERROR_INITIALIZATION_FAILED";
+    case VK_ERROR_DEVICE_LOST:
+        return "VK_ERROR_DEVICE_LOST";
+    case VK_ERROR_MEMORY_MAP_FAILED:
+        return "VK_ERROR_MEMORY_MAP_FAILED";
+    case VK_ERROR_LAYER_NOT_PRESENT:
+        return "VK_ERROR_LAYER_NOT_PRESENT";
+    case VK_ERROR_EXTENSION_NOT_PRESENT:
+        return "VK_ERROR_EXTENSION_NOT_PRESENT";
+    case VK_ERROR_FEATURE_NOT_PRESENT:
+        return "VK_ERROR_FEATURE_NOT_PRESENT";
+    case VK_ERROR_INCOMPATIBLE_DRIVER:
+        return "VK_ERROR_INCOMPATIBLE_DRIVER";
+    case VK_ERROR_TOO_MANY_OBJECTS:
+        return "VK_ERROR_TOO_MANY_OBJECTS";
+    case VK_ERROR_FORMAT_NOT_SUPPORTED:
+        return "VK_ERROR_FORMAT_NOT_SUPPORTED";
+    case VK_ERROR_FRAGMENTED_POOL:
+        return "VK_ERROR_FRAGMENTED_POOL";
+    case VK_ERROR_UNKNOWN:
+        return "VK_ERROR_UNKNOWN";
+    case VK_ERROR_OUT_OF_POOL_MEMORY:
+        return "VK_ERROR_OUT_OF_POOL_MEMORY";
+    case VK_ERROR_INVALID_EXTERNAL_HANDLE:
+        return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
+    case VK_ERROR_FRAGMENTATION:
+        return "VK_ERROR_FRAGMENTATION";
+    case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS:
+        return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS";
+    case VK_PIPELINE_COMPILE_REQUIRED:
+        return "VK_PIPELINE_COMPILE_REQUIRED";
+    case VK_ERROR_SURFACE_LOST_KHR:
+        return "VK_ERROR_SURFACE_LOST_KHR";
+    case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
+        return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
+    case VK_SUBOPTIMAL_KHR:
+        return "VK_SUBOPTIMAL_KHR";
+    case VK_ERROR_OUT_OF_DATE_KHR:
+        return "VK_ERROR_OUT_OF_DATE_KHR";
+    case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
+        return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
+    case VK_ERROR_VALIDATION_FAILED_EXT:
+        return "VK_ERROR_VALIDATION_FAILED_EXT";
+    case VK_ERROR_INVALID_SHADER_NV:
+        return "VK_ERROR_INVALID_SHADER_NV";
+    case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT:
+        return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT";
+    case VK_ERROR_NOT_PERMITTED_EXT:
+        return "VK_ERROR_NOT_PERMITTED_EXT";
+    case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:
+        return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT";
+    case VK_THREAD_IDLE_KHR:
+        return "VK_THREAD_IDLE_KHR";
+    case VK_THREAD_DONE_KHR:
+        return "VK_THREAD_DONE_KHR";
+    case VK_OPERATION_DEFERRED_KHR:
+        return "VK_OPERATION_DEFERRED_KHR";
+    case VK_OPERATION_NOT_DEFERRED_KHR:
+        return "VK_OPERATION_NOT_DEFERRED_KHR";
+    default:
+        return "UNKNOWN_RESULT";
+    }
+} // vk_result_to_string
+
+VKAPI_ATTR VkBool32 VKAPI_CALL debug_callback(
+    VkDebugUtilsMessageSeverityFlagBitsEXT severity,
+    VkDebugUtilsMessageTypeFlagsEXT type,
+    const VkDebugUtilsMessengerCallbackDataEXT *data,
+    void *user
+) {
+    if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) {
+        VEL_TRACE("[VULKAN] {}", data->pMessage);
+    } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
+        VEL_INFO("[VULKAN] {}", data->pMessage);
+    } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
+        VEL_WARN("[VULKAN] {}", data->pMessage);
+    } else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
+        VEL_ERROR("[VULKAN] {}", data->pMessage);
+    } else {
+        VEL_DEBUG("[VULKAN] {}", data->pMessage);
+    }
+
+    return VK_FALSE;
+}
+
+void create_debug_messenger(Device &device) {
+    if (device.debug_messenger != 0) {
+        return;
+    }
+    VkDebugUtilsMessengerCreateInfoEXT ci{};
+    ci.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
+    ci.messageSeverity =
+        VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
+    ci.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
+                     VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
+    ci.pfnUserCallback = debug_callback;
+
+    auto fn =
+        (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(device.instance, "vkCreateDebugUtilsMessengerEXT");
+
+    if (!fn) {
+        VEL_CRITICAL("vkCreateDebugUtilsMessengerEXT not found");
+        std::abort();
+    }
+
+    VkDebugUtilsMessengerEXT vk_messenger;
+    VK_CHECK(fn(device.instance, &ci, nullptr, &vk_messenger));
+    device.debug_messenger = vk_messenger;
+}
+
+void destory_debug_messenger(Device &device) {
+    auto destroy_dbg =
+        (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(device.instance, "vkDestroyDebugUtilsMessengerEXT");
+
+    if (destroy_dbg && device.debug_messenger) {
+        destroy_dbg(device.instance, device.debug_messenger, nullptr);
+    }
+}
+
+} // namespace vk
ADD · src/backend/vulkan/debug.h +87 -0
--- a/src/backend/vulkan/debug.h
+++ b/src/backend/vulkan/debug.h
@@ -0,0 +1,87 @@
+#pragma once
+
+#include <type_traits>
+
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+
+namespace vk {
+
+VKAPI_ATTR VkBool32 VKAPI_CALL debug_callback(
+    VkDebugUtilsMessageSeverityFlagBitsEXT severity,
+    VkDebugUtilsMessageTypeFlagsEXT type,
+    const VkDebugUtilsMessengerCallbackDataEXT *data,
+    void *user
+);
+
+void create_debug_messenger(Device &device);
+void destory_debug_messenger(Device &device);
+
+inline void set_debug_name(Device &device, VkObjectType object_type, u64 object_handle, const char *name) {
+    VkDebugUtilsObjectNameInfoEXT info{VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT};
+    info.objectType = object_type;
+    info.objectHandle = object_handle;
+    info.pObjectName = name;
+
+    if (vkSetDebugUtilsObjectNameEXT) {
+        vkSetDebugUtilsObjectNameEXT(device.logical, &info);
+    }
+}
+
+template <typename T> struct VkTypeMap;
+
+#define REGISTER_VK_TYPE(type, enum_val)                                                                               \
+    template <> struct VkTypeMap<type> {                                                                               \
+        static constexpr VkObjectType value = enum_val;                                                                \
+    }
+
+REGISTER_VK_TYPE(VkInstance, VK_OBJECT_TYPE_INSTANCE);
+REGISTER_VK_TYPE(VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
+REGISTER_VK_TYPE(VkDevice, VK_OBJECT_TYPE_DEVICE);
+REGISTER_VK_TYPE(VkQueue, VK_OBJECT_TYPE_QUEUE);
+REGISTER_VK_TYPE(VkCommandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER);
+REGISTER_VK_TYPE(VkDeviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY);
+
+REGISTER_VK_TYPE(VkBuffer, VK_OBJECT_TYPE_BUFFER);
+REGISTER_VK_TYPE(VkBufferView, VK_OBJECT_TYPE_BUFFER_VIEW);
+REGISTER_VK_TYPE(VkImage, VK_OBJECT_TYPE_IMAGE);
+REGISTER_VK_TYPE(VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW);
+REGISTER_VK_TYPE(VkSampler, VK_OBJECT_TYPE_SAMPLER);
+
+REGISTER_VK_TYPE(VkPipeline, VK_OBJECT_TYPE_PIPELINE);
+REGISTER_VK_TYPE(VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT);
+REGISTER_VK_TYPE(VkPipelineCache, VK_OBJECT_TYPE_PIPELINE_CACHE);
+REGISTER_VK_TYPE(VkDescriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET);
+REGISTER_VK_TYPE(VkShaderModule, VK_OBJECT_TYPE_SHADER_MODULE);
+
+REGISTER_VK_TYPE(VkFence, VK_OBJECT_TYPE_FENCE);
+REGISTER_VK_TYPE(VkSemaphore, VK_OBJECT_TYPE_SEMAPHORE);
+REGISTER_VK_TYPE(VkEvent, VK_OBJECT_TYPE_EVENT);
+REGISTER_VK_TYPE(VkCommandPool, VK_OBJECT_TYPE_COMMAND_POOL);
+REGISTER_VK_TYPE(VkQueryPool, VK_OBJECT_TYPE_QUERY_POOL);
+
+REGISTER_VK_TYPE(VkRenderPass, VK_OBJECT_TYPE_RENDER_PASS);
+REGISTER_VK_TYPE(VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER);
+REGISTER_VK_TYPE(VkSurfaceKHR, VK_OBJECT_TYPE_SURFACE_KHR);
+REGISTER_VK_TYPE(VkSwapchainKHR, VK_OBJECT_TYPE_SWAPCHAIN_KHR);
+
+REGISTER_VK_TYPE(VkAccelerationStructureKHR, VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR);
+REGISTER_VK_TYPE(VkDeferredOperationKHR, VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR);
+
+REGISTER_VK_TYPE(VkDebugUtilsMessengerEXT, VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT);
+
+template <typename T> inline void set_name(Device &device, T handle, const char *name) {
+    if constexpr (std::is_same_v<T, u64>) {
+        (void)device;
+        (void)handle;
+        (void)name;
+        return; // no type for u64
+    } else {
+        set_debug_name(device, VkTypeMap<T>::value, reinterpret_cast<u64>(handle), name);
+    }
+}
+
+#define VK_NAME_EX(device, obj, name) set_name(device, obj, name)
+#define VK_NAME(device, obj)          set_name(device, obj, #obj)
+
+} // namespace vk
ADD · src/backend/vulkan/descriptors.cpp +220 -0
--- a/src/backend/vulkan/descriptors.cpp
+++ b/src/backend/vulkan/descriptors.cpp
@@ -0,0 +1,220 @@
+#include <volk.h>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "shaders/renderer_types.h"
+
+namespace vk {
+
+// gave up on trying to somewhat unify this in a clean(ish) api
+// its better if each platform writes as much backend code as possible for this,  bindless or not,
+// not sure if mutable stays here, just experimenting
+void create_global_descriptors(Device &device) {
+    // descriptor pool
+    //
+    // set 0, two bindings: resource heap (mutable) + sampler heap.
+    // addressed only through DescriptorHandle fetches (rhi_abi.slang).
+    constexpr VkDescriptorPoolSize pool_sizes[] = {
+        {VK_DESCRIPTOR_TYPE_MUTABLE_EXT, MAX_RESOURCES},
+        {VK_DESCRIPTOR_TYPE_SAMPLER, MAX_SAMPLERS},
+    };
+
+    VkDescriptorPoolCreateInfo pool_info = {
+        .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
+        .flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT | VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
+        .maxSets = 1,
+        .poolSizeCount = std::size(pool_sizes),
+        .pPoolSizes = pool_sizes,
+    };
+    VK_CHECK(vkCreateDescriptorPool(device.logical, &pool_info, nullptr, &device.descriptor_pool));
+
+    // descriptor set layout
+    // Binding 0: every image/buffer descriptor (General heap, mutable).
+    // Binding 1: every sampler descriptor (Sampler heap).
+    // Binding numbers must match rhi_abi.slang's fetch heaps.
+    constexpr VkDescriptorSetLayoutBinding bindings[] = {
+        {
+            .binding = VK_MUTABLE_BINDING,
+            .descriptorType = VK_DESCRIPTOR_TYPE_MUTABLE_EXT,
+            .descriptorCount = MAX_RESOURCES,
+            .stageFlags = VK_SHADER_STAGE_ALL,
+        },
+        {
+            .binding = VK_SAMPLER_BINDING,
+            .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER,
+            .descriptorCount = MAX_SAMPLERS,
+            .stageFlags = VK_SHADER_STAGE_ALL,
+        },
+
+    };
+    constexpr VkDescriptorBindingFlags binding_flags[std::size(bindings)] = {
+        VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT | VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT, // binding 0
+        VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,                                               // binding 1
+    };
+
+    // binding 0 is mutable so just the prep work for it
+    constexpr VkDescriptorType mutable_types[] = {
+        VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
+        VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
+        VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
+        VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
+        VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
+        VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
+    };
+
+    VkMutableDescriptorTypeListEXT mutable_lists[std::size(bindings)];
+    mutable_lists[VK_MUTABLE_BINDING] = {
+        .descriptorTypeCount = std::size(mutable_types),
+        // everything in the list is valid, a single descriptor is padded out to
+        // be the size of the largest one
+        .pDescriptorTypes = mutable_types,
+    };
+    // still have to decalare in mutables
+    mutable_lists[VK_SAMPLER_BINDING] = {
+        .descriptorTypeCount = 0,
+        .pDescriptorTypes = nullptr, // empty, sampler is the only valid type
+    };
+
+    VkMutableDescriptorTypeCreateInfoEXT mutable_info{
+        .sType = VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT,
+        .mutableDescriptorTypeListCount = std::size(mutable_lists),
+        .pMutableDescriptorTypeLists = mutable_lists,
+    };
+
+    VkDescriptorSetLayoutBindingFlagsCreateInfo flags_info{
+        .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO,
+        .pNext = &mutable_info,
+        .bindingCount = std::size(bindings),
+        .pBindingFlags = binding_flags,
+    };
+
+    VkDescriptorSetLayoutCreateInfo set_layout_info = {
+        .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
+        .pNext = &flags_info,
+        .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT,
+        .bindingCount = std::size(bindings),
+        .pBindings = bindings,
+    };
+    VK_CHECK(vkCreateDescriptorSetLayout(device.logical, &set_layout_info, nullptr, &device.descriptor_set_layout));
+
+    // descriptor sets
+    VkDescriptorSetAllocateInfo alloc_info = {
+        .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
+        .descriptorPool = device.descriptor_pool,
+        .descriptorSetCount = 1,
+        .pSetLayouts = &device.descriptor_set_layout,
+    };
+    VK_CHECK(vkAllocateDescriptorSets(device.logical, &alloc_info, &device.descriptor_set));
+    VK_NAME_EX(device, device.descriptor_set, "bindless-global");
+
+    // pipeline layout, hopefully VK_EXT_Descriptor_heap soon, so I can get rid of this
+    VkPushConstantRange push_constant_range = {
+        .stageFlags = VK_SHADER_STAGE_ALL | VK_SHADER_STAGE_COMPUTE_BIT,
+        .offset = 0,
+        .size = 128,
+    };
+    VkPipelineLayoutCreateInfo pipeline_layout_info = {
+        .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
+        .setLayoutCount = 1,
+        .pSetLayouts = &device.descriptor_set_layout,
+        .pushConstantRangeCount = 1,
+        .pPushConstantRanges = &push_constant_range
+    };
+    VK_CHECK(vkCreatePipelineLayout(device.logical, &pipeline_layout_info, nullptr, &device.pipeline_layout));
+}
+
+void destroy_global_descriptors(rhi::Device device) {
+    vkDestroyPipelineLayout(device.logical, device.pipeline_layout, nullptr);
+    vkFreeDescriptorSets(device.logical, device.descriptor_pool, 1, &device.descriptor_set);
+    vkDestroyDescriptorPool(device.logical, device.descriptor_pool, nullptr);
+    vkDestroyDescriptorSetLayout(device.logical, device.descriptor_set_layout, nullptr);
+
+    device.pipeline_layout = VK_NULL_HANDLE;
+    device.descriptor_pool = VK_NULL_HANDLE;
+    device.descriptor_set_layout = VK_NULL_HANDLE;
+    device.descriptor_set = VK_NULL_HANDLE;
+}
+
+u64 write_sampler_descriptor(Device &device, Sampler sampler) {
+    u64 slot = SAMPLER_SLOTS.allocate();
+    if (slot == UINT64_MAX) {
+        return UINT64_MAX;
+    }
+
+    VkDescriptorImageInfo image_info = {};
+    image_info.sampler = sampler._handle;
+
+    VkWriteDescriptorSet write = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET};
+    write.dstSet = device.descriptor_set;
+    write.dstBinding = 1;
+    write.dstArrayElement = static_cast<u32>(slot);
+    write.descriptorCount = 1;
+    write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+    write.pImageInfo = &image_info;
+    vkUpdateDescriptorSets(device.logical, 1, &write, 0, nullptr);
+
+    return slot;
+};
+
+u64 write_image_view(Device &device, VkImageView view, bool storage) {
+    if (view == VK_NULL_HANDLE) {
+        return UINT64_MAX;
+    }
+    u64 slot = RESOURCE_SLOTS.allocate();
+    if (slot == UINT64_MAX) {
+        return UINT64_MAX;
+    }
+
+    VkDescriptorImageInfo image_info = {};
+    image_info.sampler = VK_NULL_HANDLE;
+    image_info.imageView = view;
+    image_info.imageLayout = storage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+
+    VkWriteDescriptorSet write = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET};
+    write.dstSet = device.descriptor_set;
+    write.dstBinding = 0;
+    write.dstArrayElement = static_cast<u32>(slot);
+    write.descriptorCount = 1;
+    write.descriptorType = storage ? VK_DESCRIPTOR_TYPE_STORAGE_IMAGE : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+    write.pImageInfo = &image_info;
+    vkUpdateDescriptorSets(device.logical, 1, &write, 0, nullptr);
+
+    return slot;
+};
+
+u64 write_buffer_view(Device &device, rhi::Buffer *buffer, u64 offset, u64 size, bool writeable) {
+    if (buffer == nullptr || buffer->_handle == 0) {
+        return UINT64_MAX;
+    }
+    u64 slot = RESOURCE_SLOTS.allocate();
+    if (slot == UINT64_MAX) {
+        return UINT64_MAX;
+    }
+
+    VkDescriptorBufferInfo buffer_info = {};
+    buffer_info.buffer = buffer->_handle;
+    buffer_info.offset = offset;
+    buffer_info.range = (size == 0) ? VK_WHOLE_SIZE : size;
+
+    VkWriteDescriptorSet write = {VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET};
+    write.dstSet = device.descriptor_set;
+    write.dstBinding = 0;
+    write.dstArrayElement = static_cast<u32>(slot);
+    write.descriptorCount = 1;
+    write.descriptorType = writeable ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER : VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+    write.pBufferInfo = &buffer_info;
+    vkUpdateDescriptorSets(device.logical, 1, &write, 0, nullptr);
+
+    return slot;
+};
+
+void free_resource_slot(u64 slot) {
+    RESOURCE_SLOTS.free(slot);
+}
+
+void free_sampler_slot(u64 slot) {
+    SAMPLER_SLOTS.free(slot);
+}
+
+} // namespace vk
ADD · src/backend/vulkan/image.cpp +177 -0
--- a/src/backend/vulkan/image.cpp
+++ b/src/backend/vulkan/image.cpp
@@ -0,0 +1,177 @@
+
+#include <cassert>
+#include <cstdio>
+#include <vk_mem_alloc.h>
+#include <volk.h>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+bool create_image(Device &device, ImageDesc &desc, Image &out) {
+    VkImageCreateInfo ci{};
+    ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+    if (desc.is_cubemap) {
+        ci.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
+    }
+    ci.imageType = desc.depth > 1 ? VK_IMAGE_TYPE_3D : VK_IMAGE_TYPE_2D;
+    ci.extent.width = desc.width;
+    ci.extent.height = desc.height;
+    ci.extent.depth = desc.depth;
+    ci.mipLevels = desc.mip_levels;
+    ci.arrayLayers = desc.layers;
+    ci.format = image_format_to_vk(desc.format);
+    ci.tiling = VK_IMAGE_TILING_OPTIMAL;
+    ci.usage = image_usage_to_vk(device, desc);
+    ci.samples = sample_count_to_vk(desc.sample_count);
+    ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+    VmaAllocationCreateInfo alloc_ci = {};
+    alloc_ci.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE;
+    ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+    VkImage vk_image;
+    VmaAllocation vk_alloc;
+    VK_CHECK(vmaCreateImage(device.memory.allocator, &ci, &alloc_ci, &vk_image, &vk_alloc, nullptr));
+    out._handle = vk_image;
+    out._alloc = vk_alloc;
+    out.desc = desc;
+    if (!desc.name.empty()) {
+        VK_NAME_EX(device, vk_image, desc.name.c_str());
+    }
+    return true;
+}
+
+static rhi::ImageAspect aspect_from_format(rhi::ImageFormat fmt) {
+    return (fmt == rhi::ImageFormat::D32_FLOAT) ? rhi::ImageAspect::Depth : rhi::ImageAspect::Color;
+}
+
+static bool
+create_vk_image_view(Device &device, const ImageViewDesc &desc, VkImageView &out, rhi::ImageAspect &out_aspect) {
+    if (desc.image == nullptr || desc.image->_handle == 0) {
+        return false;
+    }
+    rhi::ImageAspect aspect = desc.aspect;
+    if (aspect == rhi::ImageAspect::None) {
+        aspect = aspect_from_format(desc.image->desc.format);
+    }
+    VkImageViewCreateInfo ci{};
+    ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+    ci.image = desc.image->_handle;
+    ci.viewType = image_view_type_to_vk(desc.dimension);
+    ci.format = image_format_to_vk(desc.image->desc.format);
+    ci.subresourceRange.aspectMask = image_aspect_to_vk(aspect);
+    ci.subresourceRange.baseMipLevel = desc.mip_start;
+    ci.subresourceRange.levelCount = desc.mip_count;
+    ci.subresourceRange.baseArrayLayer = desc.layer_start;
+    ci.subresourceRange.layerCount = desc.layer_count;
+    ci.components.r = component_swizzle_to_vk(desc.swizzle_r);
+    ci.components.g = component_swizzle_to_vk(desc.swizzle_g);
+    ci.components.b = component_swizzle_to_vk(desc.swizzle_b);
+    ci.components.a = component_swizzle_to_vk(desc.swizzle_a);
+    VK_CHECK(vkCreateImageView(device.logical, &ci, nullptr, &out));
+    out_aspect = aspect;
+    return true;
+}
+
+void destroy_image(Device &device, Image &img) {
+    vmaDestroyImage(device.memory.allocator, img._handle, img._alloc);
+    img = {};
+}
+
+bool create_image_view(Device &device, const ImageViewDesc &desc, ImageView &out) {
+    if (desc.image != nullptr) {
+        if (desc.type == ImageViewType::Storage) {
+            assert(
+                Any(desc.image->desc.usage, ImageUsage::Storage) &&
+                "Storage view requires ImageUsage::Storage at creation"
+            );
+        } else if (desc.type == ImageViewType::Sampled) {
+            assert(
+                Any(desc.image->desc.usage, ImageUsage::Sampled) &&
+                "Sampled view requires ImageUsage::Sampled at creation"
+            );
+        }
+    }
+    VkImageView vk_view = VK_NULL_HANDLE;
+    rhi::ImageAspect aspect = rhi::ImageAspect::None;
+    if (!create_vk_image_view(device, desc, vk_view, aspect)) {
+        return false;
+    }
+    const bool storage = (desc.type == ImageViewType::Storage);
+    u64 slot = write_image_view(device, vk_view, storage);
+    if (slot == UINT64_MAX) {
+        vkDestroyImageView(device.logical, vk_view, nullptr);
+        return false;
+    }
+    out._handle = vk_view;
+    out.slot = slot;
+    out.desc = desc;
+    out.desc.aspect = aspect;
+    if (desc.image != nullptr && !desc.image->desc.name.empty()) {
+        const char *kind = (desc.type == ImageViewType::Storage) ? "storage" : "sampled";
+        char view_name[256];
+        (void)snprintf(view_name, sizeof(view_name), "%s.view:%s", desc.image->desc.name.c_str(), kind);
+        VK_NAME_EX(device, vk_view, view_name);
+    }
+    return true;
+}
+
+u64 handle_id(Device &device, ImageView &view) {
+    (void)device;
+    return view.slot;
+}
+
+ImageView get_cached_image_view(Device &device, Image &image, const ImageViewDesc &desc) {
+    ImageViewDesc key = desc;
+    key.image = &image;
+    if (key.aspect == rhi::ImageAspect::None) {
+        key.aspect = aspect_from_format(image.desc.format);
+    }
+    if (key.dimension == rhi::TextureViewDimension::TEXTURE_2D && image.desc.is_cubemap) {
+        key.dimension = rhi::TextureViewDimension::TEXTURE_CUBE;
+    }
+    for (auto &[k, v] : image.view_cache) {
+        if (k.image == key.image && k.aspect == key.aspect && k.type == key.type && k.dimension == key.dimension &&
+            k.mip_start == key.mip_start && k.mip_count == key.mip_count && k.layer_start == key.layer_start &&
+            k.layer_count == key.layer_count) {
+            ImageView out{};
+            out.desc = k;
+            out._handle = v;
+            out.slot = UINT64_MAX;
+            return out;
+        }
+    }
+    VkImageView vk_view = VK_NULL_HANDLE;
+    rhi::ImageAspect aspect = rhi::ImageAspect::None;
+    create_vk_image_view(device, key, vk_view, aspect);
+    key.aspect = aspect;
+    image.view_cache.emplace_back(key, vk_view);
+    ImageView out{};
+    out.desc = key;
+    out._handle = vk_view;
+    out.slot = UINT64_MAX;
+    return out;
+}
+
+void destroy_image_views(Device &device, Image &image) {
+    for (auto &[k, v] : image.view_cache) {
+        vkDestroyImageView(device.logical, v, nullptr);
+    }
+    image.view_cache.clear();
+}
+
+void destroy_image_view(Device &device, ImageView &view) {
+    if (view._handle != nullptr) {
+        vkDestroyImageView(device.logical, view._handle, nullptr);
+        view._handle = nullptr;
+    }
+    if (view.slot != UINT64_MAX) {
+        RESOURCE_SLOTS.free(view.slot);
+        view.slot = UINT64_MAX;
+    }
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/pipeline.cpp +350 -0
--- a/src/backend/vulkan/pipeline.cpp
+++ b/src/backend/vulkan/pipeline.cpp
@@ -0,0 +1,350 @@
+
+#include <volk.h>
+
+#include <cstdio>
+#include <vector>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+#include "shaders/renderer_types.h"
+
+namespace rhi {
+using namespace vk;
+
+RenderPipelineDesc &
+RenderPipelineDesc::set_shaders(ShaderCompiler &sc, const char *path, const char *vs, const char *fs) {
+    assert(device != nullptr && "RenderPipelineDesc::device must be assigned before set_shaders");
+    shader_modules.clear();
+
+    shader_modules.push_back(load_shader(sc, *device, path, vs, ShaderStage::VERTEX));
+    shader_modules.push_back(load_shader(sc, *device, path, fs, ShaderStage::FRAGMENT));
+
+    shader_path = path;
+    vs_entry = vs;
+    fs_entry = fs;
+    return *this;
+}
+
+ComputePipelineDesc &ComputePipelineDesc::set_shader(ShaderCompiler &sc, const char *path, const char *cs) {
+    assert(device != nullptr && "ComputePipelineDesc::device must be assigned before set_shader");
+    shader_modules.clear();
+    shader_modules.push_back(load_shader(sc, *device, path, cs, ShaderStage::COMPUTE));
+    shader_path = path;
+    cs_entry = cs;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_input_topology(rhi::PipelineTopology topology) {
+    this->topology = topology;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_polygon_mode(rhi::PipelineFillMode mode) {
+    fill_mode = mode;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_color_format(ImageFormat format) {
+    color_attachment_formats.push_back(format);
+    return *this;
+};
+
+RenderPipelineDesc &RenderPipelineDesc::add_vertex_binding(u32 binding, u32 stride, bool is_instanced) {
+    vertex_bindings.push_back({binding, stride, is_instanced});
+    return *this;
+}
+
+RenderPipelineDesc &
+RenderPipelineDesc::add_vertex_attribute(u32 location, u32 binding, ImageFormat format, u32 offset) {
+    vertex_attributes.push_back({location, binding, format, offset});
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_format(ImageFormat format) {
+    depth_attachment_format = format;
+    return *this;
+};
+
+RenderPipelineDesc &
+RenderPipelineDesc::set_cull_mode(rhi::PipelineCullMode mode, rhi::PipelineTriangleWindingOrder winding) {
+    cull_mode = mode;
+    this->winding = winding;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_multisampling(rhi::SampleCount count) {
+    samples = count;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_testing(bool do_test, bool do_write, rhi::PipelineCompareOp op) {
+    depth_test_enable = do_test;
+    depth_write_enable = do_write;
+    depth_compare_op = op;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_bias(bool enabled, f32 constant, f32 clamp, f32 slope) {
+    depth_bias_enable = enabled;
+    depth_bias_constant = constant;
+    depth_bias_clamp = clamp;
+    depth_bias_slope = slope;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_depth_clamp(bool enabled) {
+    depth_clamp_enable = enabled;
+    return *this;
+}
+
+RenderPipelineDesc &RenderPipelineDesc::set_blending(
+    rhi::PipelineBlendFactor src_color,
+    rhi::PipelineBlendFactor dst_color,
+    rhi::PipelineBlendOp color_op,
+    rhi::PipelineBlendFactor src_alpha,
+    rhi::PipelineBlendFactor dst_alpha,
+    rhi::PipelineBlendOp alpha_op
+) {
+    blend_enable = true;
+    src_color_blend_factor = src_color;
+    dst_color_blend_factor = dst_color;
+    color_blend_op = color_op;
+    src_alpha_blend_factor = src_alpha;
+    dst_alpha_blend_factor = dst_alpha;
+    alpha_blend_op = alpha_op;
+    return *this;
+}
+
+RenderPipeline RenderPipelineDesc::build() {
+    assert(device != nullptr && "RenderPipelineDesc::device must be assigned before build");
+    if (shader_modules.empty()) {
+        VEL_ERROR("Cannot build render pipeline: no shader modules set");
+        return {};
+    }
+
+    std::vector<VkPipelineShaderStageCreateInfo> shader_stages;
+    for (auto &mod : shader_modules) {
+        VkShaderModule vk_mod = mod.handle;
+        if (vk_mod == VK_NULL_HANDLE) {
+            VEL_ERROR("Cannot build render pipeline: one or more shader modules are null");
+            for (auto &stage : shader_stages) {
+                vkDestroyShaderModule(device->logical, stage.module, nullptr);
+            }
+            return {};
+        }
+        VkPipelineShaderStageCreateInfo stage_info = {};
+        stage_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+        stage_info.stage = static_cast<VkShaderStageFlagBits>(vk::shader_stage_to_vk(mod.stage));
+        stage_info.module = vk_mod;
+        stage_info.pName = "main";
+        shader_stages.push_back(stage_info);
+    }
+
+    RenderPipeline result;
+    result.device = device;
+
+    {
+
+        VkDynamicState dynamic_states[8];
+        u32 ds_count = 0;
+        dynamic_states[ds_count++] = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT;
+        dynamic_states[ds_count++] = VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT;
+        if (enable_dynamic_polygon_mode) {
+            dynamic_states[ds_count++] = VK_DYNAMIC_STATE_POLYGON_MODE_EXT;
+        }
+        if (enable_dynamic_depth_write) {
+            dynamic_states[ds_count++] = VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE;
+        }
+        VkPipelineDynamicStateCreateInfo dynamic_info{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
+            .dynamicStateCount = ds_count,
+            .pDynamicStates = dynamic_states
+        };
+
+        std::vector<VkVertexInputBindingDescription> vk_bindings;
+        vk_bindings.reserve(vertex_bindings.size());
+        for (const auto &b : vertex_bindings) {
+            vk_bindings.push_back({
+                .binding = b.binding,
+                .stride = b.stride,
+                .inputRate = b.is_instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX,
+            });
+        }
+
+        std::vector<VkVertexInputAttributeDescription> vk_attributes;
+        vk_attributes.reserve(vertex_attributes.size());
+        for (const auto &a : vertex_attributes) {
+            vk_attributes.push_back({
+                .location = a.location,
+                .binding = a.binding,
+                .format = vk::image_format_to_vk(a.format),
+                .offset = a.offset,
+            });
+        }
+
+        VkPipelineVertexInputStateCreateInfo vertex_input{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
+            .vertexBindingDescriptionCount = (u32)vk_bindings.size(),
+            .pVertexBindingDescriptions = vk_bindings.empty() ? nullptr : vk_bindings.data(),
+            .vertexAttributeDescriptionCount = (u32)vk_attributes.size(),
+            .pVertexAttributeDescriptions = vk_attributes.empty() ? nullptr : vk_attributes.data(),
+        };
+
+        VkPipelineInputAssemblyStateCreateInfo input_assembly{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
+            .topology = vk::pipeline_topology_to_vk(topology),
+        };
+
+        VkPipelineRasterizationStateCreateInfo rasterizer{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
+            .depthClampEnable = depth_clamp_enable ? VK_TRUE : VK_FALSE,
+            .rasterizerDiscardEnable = VK_FALSE,
+            .polygonMode = vk::pipeline_fill_mode_to_vk(fill_mode),
+            .cullMode = vk::pipeline_cull_mode_to_vk(cull_mode),
+            .frontFace = vk::triangle_winding_to_vk(winding),
+            .depthBiasEnable = depth_bias_enable ? VK_TRUE : VK_FALSE,
+            .depthBiasConstantFactor = depth_bias_constant,
+            .depthBiasClamp = depth_bias_clamp,
+            .depthBiasSlopeFactor = depth_bias_slope,
+            .lineWidth = 1.0f
+        };
+
+        VkPipelineMultisampleStateCreateInfo multisampling{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
+            .rasterizationSamples = vk::sample_count_to_vk(samples),
+        };
+
+        VkPipelineDepthStencilStateCreateInfo depth_stencil{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
+            .depthTestEnable = depth_test_enable ? VK_TRUE : VK_FALSE,
+            .depthWriteEnable = depth_write_enable ? VK_TRUE : VK_FALSE,
+            .depthCompareOp = vk::pipeline_compare_op_to_vk(depth_compare_op),
+        };
+
+        VkPipelineViewportStateCreateInfo viewport_state{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
+            .viewportCount = 0,
+            .pViewports = nullptr,
+            .scissorCount = 0,
+            .pScissors = nullptr,
+        };
+
+        std::vector<VkFormat> vk_color_formats;
+        for (auto &format : color_attachment_formats) {
+            vk_color_formats.push_back(vk::image_format_to_vk(format));
+        }
+        VkPipelineRenderingCreateInfo rendering_info{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
+            .colorAttachmentCount = (u32)color_attachment_formats.size(),
+            .pColorAttachmentFormats = vk_color_formats.empty() ? nullptr : vk_color_formats.data(),
+            .depthAttachmentFormat = vk::image_format_to_vk(depth_attachment_format),
+        };
+
+        VkPipelineColorBlendAttachmentState color_blend_attachment{
+            .blendEnable = blend_enable ? VK_TRUE : VK_FALSE,
+            .srcColorBlendFactor = vk::pipeline_blend_factor_to_vk(src_color_blend_factor),
+            .dstColorBlendFactor = vk::pipeline_blend_factor_to_vk(dst_color_blend_factor),
+            .colorBlendOp = vk::pipeline_blend_op_to_vk(color_blend_op),
+            .srcAlphaBlendFactor = vk::pipeline_blend_factor_to_vk(src_alpha_blend_factor),
+            .dstAlphaBlendFactor = vk::pipeline_blend_factor_to_vk(dst_alpha_blend_factor),
+            .alphaBlendOp = vk::pipeline_blend_op_to_vk(alpha_blend_op),
+            .colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT |
+                              VK_COLOR_COMPONENT_A_BIT,
+        };
+
+        std::vector<VkPipelineColorBlendAttachmentState> blend_attachments(
+            rendering_info.colorAttachmentCount, color_blend_attachment
+        );
+
+        VkPipelineColorBlendStateCreateInfo color_blending{
+            .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
+            .attachmentCount = (u32)blend_attachments.size(),
+            .pAttachments = blend_attachments.data()
+        };
+
+        VkGraphicsPipelineCreateInfo pipeline_info = {VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO};
+        pipeline_info.pNext = &rendering_info;
+        pipeline_info.stageCount = (u32)shader_stages.size();
+        pipeline_info.pStages = shader_stages.data();
+        pipeline_info.pVertexInputState = &vertex_input;
+        pipeline_info.pInputAssemblyState = &input_assembly;
+        pipeline_info.pViewportState = &viewport_state;
+        pipeline_info.pRasterizationState = &rasterizer;
+        pipeline_info.pMultisampleState = &multisampling;
+        pipeline_info.pColorBlendState = &color_blending;
+        pipeline_info.pDepthStencilState = &depth_stencil;
+        pipeline_info.pDynamicState = &dynamic_info;
+        pipeline_info.layout = device->pipeline_layout;
+        VK_CHECK(vkCreateGraphicsPipelines(
+            device->logical, device->pipeline_cache, 1, &pipeline_info, nullptr, &result._handle
+        ));
+        if (!name.empty()) {
+            char pipe_name[256];
+            (void)snprintf(pipe_name, sizeof(pipe_name), "pipe/%s", name.c_str());
+            VK_NAME_EX((*device), result._handle, pipe_name);
+        }
+    }
+
+    for (auto &stage : shader_stages) {
+        vkDestroyShaderModule(device->logical, stage.module, nullptr);
+    }
+    shader_modules.clear();
+    vertex_bindings.clear();
+    vertex_attributes.clear();
+
+    return result;
+}
+
+ComputePipeline ComputePipelineDesc::build() {
+    assert(device != nullptr && "ComputePipelineDesc::device must be assigned before build");
+    if (shader_modules.empty()) {
+        VEL_ERROR("Cannot build compute pipeline: no shader modules set");
+        return {};
+    }
+    VkShaderModule vk_mod = shader_modules[0].handle;
+    if (vk_mod == VK_NULL_HANDLE) {
+        VEL_ERROR("Cannot build compute pipeline: shader module is null");
+        return {};
+    }
+    VkPipelineShaderStageCreateInfo stage_info = {};
+    stage_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+    stage_info.stage = static_cast<VkShaderStageFlagBits>(vk::shader_stage_to_vk(shader_modules[0].stage));
+    stage_info.module = vk_mod;
+    stage_info.pName = "main";
+
+    ComputePipeline result;
+    result.device = device;
+
+    VkComputePipelineCreateInfo pipeline_info = {
+        .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
+        .stage = stage_info,
+        .layout = device->pipeline_layout,
+    };
+    VK_CHECK(
+        vkCreateComputePipelines(device->logical, device->pipeline_cache, 1, &pipeline_info, nullptr, &result._handle)
+    );
+    if (!name.empty()) {
+        char pipe_name[256];
+        (void)snprintf(pipe_name, sizeof(pipe_name), "pipe/%s", name.c_str());
+        VK_NAME_EX((*device), result._handle, pipe_name);
+    }
+
+    vkDestroyShaderModule(device->logical, stage_info.module, nullptr);
+    shader_modules.clear();
+
+    return result;
+}
+
+void destroy_pipeline(Device &device, RenderPipeline &p) {
+    vkDestroyPipeline(device.logical, p._handle, nullptr);
+    p = {};
+}
+
+void destroy_pipeline(Device &device, ComputePipeline &p) {
+    vkDestroyPipeline(device.logical, p._handle, nullptr);
+    p = {};
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/query_pool.cpp +96 -0
--- a/src/backend/vulkan/query_pool.cpp
+++ b/src/backend/vulkan/query_pool.cpp
@@ -0,0 +1,96 @@
+
+#include <volk.h>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+bool create_query_pool(Device &device, const QueryPoolDesc &desc, QueryPool &pool) {
+    if (desc.queryType == QueryType::TIMESTAMP || desc.queryType == QueryType::TIMESTAMP_COPY_QUEUE) {
+        pool._type = VK_QUERY_TYPE_TIMESTAMP;
+    } else if (desc.queryType == QueryType::OCCLUSION) {
+        pool._type = VK_QUERY_TYPE_OCCLUSION;
+    } else if (desc.queryType == QueryType::PIPELINE_STATISTICS) {
+        pool._type = VK_QUERY_TYPE_PIPELINE_STATISTICS;
+    } else if (desc.queryType == QueryType::ACCELERATION_STRUCTURE_SIZE) {
+        pool._type = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR;
+    } else if (desc.queryType == QueryType::ACCELERATION_STRUCTURE_COMPACTED_SIZE) {
+        pool._type = VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR;
+    } else if (desc.queryType == QueryType::MICROMAP_COMPACTED_SIZE) {
+        pool._type = VK_QUERY_TYPE_MICROMAP_COMPACTED_SIZE_EXT;
+    } else {
+        return false;
+    }
+
+    VkQueryPipelineStatisticFlags pipeline_statistics =
+        VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT | VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT |
+        VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT;
+
+    // if (m_Device.GetDesc().features.meshShader)
+    //     pipelineStatistics |= VK_QUERY_PIPELINE_STATISTIC_TASK_SHADER_INVOCATIONS_BIT_EXT |
+    //     VK_QUERY_PIPELINE_STATISTIC_MESH_SHADER_INVOCATIONS_BIT_EXT;
+
+    VkQueryPoolCreateInfo pool_info = {
+        VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,
+        nullptr,
+        (VkQueryPoolCreateFlags)0,
+        (VkQueryType)pool._type,
+        desc.capacity,
+        pipeline_statistics
+    };
+
+    VkQueryPool vk_pool;
+    VK_CHECK(vkCreateQueryPool(device.logical, &pool_info, nullptr, &vk_pool));
+    pool._handle = vk_pool;
+    pool.desc = desc;
+    if (!desc.name.empty()) {
+        VK_NAME_EX(device, vk_pool, desc.name.c_str());
+    }
+    return true;
+}
+
+void reset_query_pool(CmdBuffer &cmd, QueryPool &queryPool, u32 offset, u32 count) {
+    vkCmdResetQueryPool(cmd.handle, queryPool._handle, offset, count);
+}
+
+void write_timestamp(CmdBuffer &cmd, QueryPool &queryPool, u32 queryIndex, rhi::PipelineStages stage) {
+    vkCmdWriteTimestamp(cmd.handle, static_cast<VkPipelineStageFlagBits>(stage), queryPool._handle, queryIndex);
+}
+
+void destroy_query_pool(Device &device, QueryPool &queryPool) {
+    vkDestroyQueryPool(device.logical, queryPool._handle, nullptr);
+}
+
+bool query_pool_results(
+    Device &device,
+    const QueryPool &pool,
+    u32 first_query,
+    u32 query_count,
+    u64 *out,
+    usize data_size_bytes,
+    usize stride_bytes,
+    bool with_availability
+) {
+    VkQueryResultFlags flags = VK_QUERY_RESULT_64_BIT;
+    if (with_availability) {
+        flags |= VK_QUERY_RESULT_WITH_AVAILABILITY_BIT;
+    }
+    VkResult res = vkGetQueryPoolResults(
+        device.logical, pool._handle, first_query, query_count, data_size_bytes, out, stride_bytes, flags
+    );
+    return res == VK_SUCCESS;
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/queue.cpp +163 -0
--- a/src/backend/vulkan/queue.cpp
+++ b/src/backend/vulkan/queue.cpp
@@ -0,0 +1,163 @@
+
+#include <volk.h>
+
+#include <cstdio>
+#include <cstdlib>
+#include <new>
+#include <vector>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+Queue find_queue(Device &device, u32 required, u32 excluded) {
+    u32 count = 0;
+    vkGetPhysicalDeviceQueueFamilyProperties(device.physical, &count, nullptr);
+    std::vector<VkQueueFamilyProperties> families(count);
+    vkGetPhysicalDeviceQueueFamilyProperties(device.physical, &count, families.data());
+
+    for (u32 i = 0; i < count; ++i) {
+        bool has_required = (families[i].queueFlags & required) == required;
+        bool has_excluded = (families[i].queueFlags & excluded) != 0;
+        if (has_required && !has_excluded) {
+            return {0, i, 0};
+        }
+    }
+
+    for (u32 i = 0; i < count; ++i) {
+        if (families[i].queueFlags & required) {
+            return {0, i, 0};
+        }
+    }
+    return {};
+}
+
+Queue graphics_queue(Device &device) {
+    return device.graphics;
+}
+
+u32 queue_family_index(const Queue &queue) {
+    return queue.family_index;
+}
+
+u64 sync_get_completed_value(Sync *sync) {
+    if (sync == nullptr || sync->timeline == VK_NULL_HANDLE) {
+        return 0;
+    }
+    u64 value = 0;
+    VK_CHECK(vkGetSemaphoreCounterValue(sync->device, sync->timeline, &value));
+    return value;
+}
+
+static VkSemaphoreSubmitInfo sync_edge_to_vk(const SyncPoint &point, rhi::PipelineStages stages) {
+    if (point.sync == nullptr || point.sync->timeline == VK_NULL_HANDLE || point.value == 0) {
+        VEL_CRITICAL("queue_submit: invalid SyncPoint edge (null sync or zero value)");
+        std::abort();
+    }
+    return VkSemaphoreSubmitInfo{
+        .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
+        .semaphore = point.sync->timeline,
+        .value = point.value,
+        .stageMask = pipeline_stage_flags_to_vk(stages),
+        .deviceIndex = 0,
+    };
+}
+
+void queue_submit(Device &device, Queue queue, const QueueSubmitDesc &desc) {
+    VkDevice vk_dev = device.logical;
+    (void)vk_dev;
+
+    std::vector<VkSemaphoreSubmitInfo> wait_infos(desc.wait_count);
+    for (u32 i = 0; i < desc.wait_count; ++i) {
+        wait_infos[i] = sync_edge_to_vk(desc.waits[i].point, desc.waits[i].stage_mask);
+    }
+
+    std::vector<VkCommandBufferSubmitInfo> cmd_infos(desc.cmd_count);
+    for (u32 i = 0; i < desc.cmd_count; ++i) {
+        cmd_infos[i] = VkCommandBufferSubmitInfo{
+            .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO,
+            .commandBuffer = desc.cmds[i].handle,
+            .deviceMask = 0,
+        };
+    }
+
+    std::vector<VkSemaphoreSubmitInfo> signal_infos(desc.signal_count);
+    for (u32 i = 0; i < desc.signal_count; ++i) {
+        signal_infos[i] = sync_edge_to_vk(desc.signals[i].point, rhi::PipelineStages::ALL_COMMANDS);
+    }
+
+    VkSubmitInfo2 submit_info{
+        .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO_2,
+        .waitSemaphoreInfoCount = desc.wait_count,
+        .pWaitSemaphoreInfos = wait_infos.data(),
+        .commandBufferInfoCount = desc.cmd_count,
+        .pCommandBufferInfos = cmd_infos.data(),
+        .signalSemaphoreInfoCount = desc.signal_count,
+        .pSignalSemaphoreInfos = signal_infos.data(),
+    };
+
+    VK_CHECK(vkQueueSubmit2(queue.handle, 1, &submit_info, VK_NULL_HANDLE));
+}
+
+Sync *sync_create(Device &device, u64 initial_value, const char *name) {
+    VkSemaphoreTypeCreateInfo timeline_ci{
+        .sType = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO,
+        .pNext = nullptr,
+        .semaphoreType = VK_SEMAPHORE_TYPE_TIMELINE,
+        .initialValue = initial_value,
+    };
+    VkSemaphoreCreateInfo ci{};
+    ci.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+    ci.pNext = &timeline_ci;
+    VkSemaphore handle = VK_NULL_HANDLE;
+    if (vkCreateSemaphore(device.logical, &ci, nullptr, &handle) != VK_SUCCESS || handle == VK_NULL_HANDLE) {
+        VEL_CRITICAL("sync_create: timeline semaphore creation failed");
+        return nullptr;
+    }
+    Sync *sync = new (std::nothrow) Sync{};
+    if (sync == nullptr) {
+        vkDestroySemaphore(device.logical, handle, nullptr);
+        return nullptr;
+    }
+    sync->timeline = handle;
+    sync->device = device.logical;
+    if (name != nullptr) {
+        char sync_name[128];
+        (void)snprintf(sync_name, sizeof(sync_name), "sync/%s", name);
+        set_name(device, handle, sync_name);
+    }
+    return sync;
+}
+
+void sync_destroy(Sync *sync) {
+    if (sync == nullptr) {
+        return;
+    }
+    if (sync->timeline != VK_NULL_HANDLE) {
+        vkDestroySemaphore(sync->device, sync->timeline, nullptr);
+        sync->timeline = VK_NULL_HANDLE;
+    }
+    delete sync;
+}
+
+bool sync_host_wait(Sync *sync, u64 value, u64 timeout_ns) {
+    if (sync == nullptr || sync->timeline == VK_NULL_HANDLE) {
+        VEL_CRITICAL("sync_host_wait: null sync object");
+        return false;
+    }
+    VkSemaphoreWaitInfo wait_info{
+        .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
+        .semaphoreCount = 1,
+        .pSemaphores = &sync->timeline,
+        .pValues = &value,
+    };
+    // timeout aborts, no false path
+    VK_CHECK(vkWaitSemaphores(sync->device, &wait_info, timeout_ns));
+    return true;
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/rhi_helpers.cpp +93 -0
--- a/src/backend/vulkan/rhi_helpers.cpp
+++ b/src/backend/vulkan/rhi_helpers.cpp
@@ -0,0 +1,93 @@
+#include <volk.h>
+
+#include <ktx.h>
+
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace vk {
+bool format_supports_sampling(rhi::Device &device, VkFormat format) {
+    VkFormatProperties props{};
+    vkGetPhysicalDeviceFormatProperties(device.physical, format, &props);
+    return (props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0;
+}
+} // namespace vk
+
+namespace rhi {
+using namespace vk;
+
+uintptr_t image_id(const Image &img) {
+    return reinterpret_cast<uintptr_t>(img._handle);
+}
+
+uintptr_t buffer_id(const Buffer &buffer) {
+    return reinterpret_cast<uintptr_t>(buffer._handle);
+}
+
+uintptr_t sampler_id(const Sampler &sampler) {
+    return reinterpret_cast<uintptr_t>(sampler._handle);
+}
+uintptr_t accel_id(const AccelStruct &as) {
+    return reinterpret_cast<uintptr_t>(as.handle);
+}
+
+bool valid(const Image &img) {
+    return img._handle != VK_NULL_HANDLE;
+}
+bool valid(const Buffer &buffer) {
+    return buffer._handle != VK_NULL_HANDLE;
+}
+bool valid(const CmdBuffer &cmd) {
+    return cmd.handle != VK_NULL_HANDLE;
+}
+bool valid(const CmdPool &pool) {
+    return pool.handle != VK_NULL_HANDLE;
+}
+bool valid(const RenderPipeline &pipeline) {
+    return pipeline._handle != VK_NULL_HANDLE;
+}
+bool valid(const ComputePipeline &pipeline) {
+    return pipeline._handle != VK_NULL_HANDLE;
+}
+bool valid(const Sync *sync) {
+    return sync != nullptr && sync->timeline != VK_NULL_HANDLE;
+}
+bool valid(const AccelStruct &as) {
+    return as.handle != VK_NULL_HANDLE;
+}
+bool valid(const Sampler &sampler) {
+    return sampler._handle != VK_NULL_HANDLE;
+}
+bool valid(const QueryPool &pool) {
+    return pool._handle != VK_NULL_HANDLE;
+}
+bool valid(const Swapchain &swapchain) {
+    return swapchain.handle != VK_NULL_HANDLE;
+}
+
+bool valid(const ImageView &view) {
+    return view._handle != VK_NULL_HANDLE && view.slot != UINT64_MAX;
+}
+
+bool valid(const BufferView &view) {
+    return view.buffer != nullptr && view.slot != UINT64_MAX;
+}
+
+rhi::ImageFormat image_format_from_vk(u32 format) {
+    return vk::image_format_from_vk(static_cast<VkFormat>(format));
+}
+
+rhi::ImageFormat preferred_compressed_format(Device &device, bool srgb) {
+    if (srgb) {
+        if (format_supports_sampling(device, VK_FORMAT_BC7_SRGB_BLOCK)) {
+            return ImageFormat::BC7_SRGB;
+        }
+        return ImageFormat::RGBA8_SRGB;
+    }
+    if (format_supports_sampling(device, VK_FORMAT_BC7_UNORM_BLOCK)) {
+        return ImageFormat::BC7_UNORM;
+    }
+    return ImageFormat::RGBA8_UNORM;
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/sampler.cpp +59 -0
--- a/src/backend/vulkan/sampler.cpp
+++ b/src/backend/vulkan/sampler.cpp
@@ -0,0 +1,59 @@
+
+#include <volk.h>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+
+namespace rhi {
+using namespace vk;
+
+bool create_sampler(Device &device, SamplerDesc &desc, Sampler &sampler) {
+    VkSamplerCreateInfo sampler_info = {};
+    sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+    sampler_info.addressModeU = vk::sampler_address_to_vk(desc.address);
+    sampler_info.addressModeV = vk::sampler_address_to_vk(desc.address);
+    sampler_info.addressModeW = vk::sampler_address_to_vk(desc.address);
+    sampler_info.magFilter = vk::sampler_filter_to_vk(desc.filter);
+    sampler_info.minFilter = vk::sampler_filter_to_vk(desc.filter);
+    sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
+    sampler_info.mipLodBias = 0.0f;
+    sampler_info.anisotropyEnable = desc.filter == SamplerFilter::ANISOTROPIC ? VK_TRUE : VK_FALSE;
+    sampler_info.maxAnisotropy = 16;
+    sampler_info.compareEnable = desc.comparison_func != SamplerComparisonFunc::NEVER ? VK_TRUE : VK_FALSE;
+    sampler_info.compareOp = vk::sampler_comparison_to_vk(desc.comparison_func);
+    sampler_info.minLod = 0.0f;
+    sampler_info.maxLod = desc.use_mips ? 16.0f : 0.0f;
+    sampler_info.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
+    sampler_info.unnormalizedCoordinates = VK_FALSE;
+    sampler_info.flags = {};
+
+    VkSampler vk_sampler;
+    VK_CHECK(vkCreateSampler(device.logical, &sampler_info, nullptr, &vk_sampler));
+    sampler._handle = vk_sampler;
+    if (!desc.name.empty()) {
+        VK_NAME_EX(device, vk_sampler, desc.name.c_str());
+    }
+
+    sampler.slot = write_sampler_descriptor(device, sampler);
+
+    return true;
+}
+
+u64 handle_id(Device &device, Sampler &sampler) {
+    (void)device;
+    return sampler.slot;
+}
+
+void destroy_sampler(Device &device, Sampler &sampler) {
+    if (sampler._handle != VK_NULL_HANDLE) {
+        vkDestroySampler(device.logical, sampler._handle, nullptr);
+    }
+    if (sampler.slot != UINT64_MAX) {
+        free_sampler_slot(sampler.slot);
+    }
+    sampler = {};
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/shader.cpp +181 -0
--- a/src/backend/vulkan/shader.cpp
+++ b/src/backend/vulkan/shader.cpp
@@ -0,0 +1,181 @@
+
+#include <volk.h>
+
+#include <array>
+#include <cstdint>
+#include <cstdio>
+#include <filesystem>
+#include <string>
+
+#include <cassert>
+
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+#include "core/globals.h"
+#include "core/logger.h"
+
+namespace rhi {
+using namespace vk;
+
+u64 get_file_last_write_time(const char *path) {
+    std::error_code ec;
+    auto ftime = std::filesystem::last_write_time(path, ec);
+    if (ec) {
+        return {};
+    }
+    return ftime.time_since_epoch().count();
+}
+
+static bool build_session(ShaderCompiler &sc, slang::ISession **out) {
+
+    constexpr slang::CompilerOptionEntry emit_spirv_directly = {
+        .name = slang::CompilerOptionName::EmitSpirvDirectly,
+        .value{
+            .kind = slang::CompilerOptionValueKind::Int,
+            .intValue0 = 1,
+        }
+    };
+
+    constexpr slang::CompilerOptionEntry optimization_level = {
+        .name = slang::CompilerOptionName::Optimization,
+        .value = {
+            .kind = slang::CompilerOptionValueKind::Int,
+            .intValue0 = SLANG_OPTIMIZATION_LEVEL_NONE,
+        }
+    };
+
+    constexpr slang::CompilerOptionEntry debug_info_level = {
+        .name = slang::CompilerOptionName::DebugInformation,
+        .value = {
+            .kind = slang::CompilerOptionValueKind::Int,
+            .intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD,
+        }
+    };
+
+    constexpr slang::CompilerOptionEntry entries[] = {
+        emit_spirv_directly,
+        optimization_level,
+        debug_info_level,
+    };
+
+    slang::TargetDesc target = {};
+    target.format = SLANG_SPIRV;
+    target.profile = sc.global->findProfile("spirv_1_6");
+    target.compilerOptionEntries = entries;
+    target.compilerOptionEntryCount = std::size(entries);
+
+    const char *search_path[] = {"src/shaders"};
+    slang::SessionDesc desc = {};
+    desc.targets = &target;
+    desc.targetCount = 1;
+    desc.allowGLSLSyntax = true;
+    desc.searchPaths = search_path;
+    desc.searchPathCount = 1;
+
+#ifndef NDEBUG
+    slang::PreprocessorMacroDesc debug_flag = {"DEBUG", "1"};
+    desc.preprocessorMacros = &debug_flag;
+    desc.preprocessorMacroCount = 1;
+#endif
+
+    return SLANG_SUCCEEDED(sc.global->createSession(desc, out));
+} // namespace rhi
+
+bool ShaderCompiler::recreate_session() {
+    Slang::ComPtr<slang::ISession> new_session;
+    if (!build_session(*this, new_session.writeRef())) {
+        VEL_ERROR("Failed to create fresh Slang session for reload");
+        return false;
+    }
+    session = new_session;
+    return true;
+}
+
+bool init_compiler(ShaderCompiler &sc) {
+    VEL_INFO("Initializing Slang Shader Compiler...");
+    if (SLANG_FAILED(slang::createGlobalSession(sc.global.writeRef()))) {
+        VEL_ERROR("Failed to create Slang global session");
+        return false;
+    }
+
+    if (!build_session(sc, sc.session.writeRef())) {
+        VEL_ERROR("Failed to create Slang session");
+        return false;
+    }
+
+    return true;
+}
+
+ShaderModule
+load_shader(ShaderCompiler &sc, Device &device, const char *path, const char *entry_name, ShaderStage stage) {
+    Slang::ComPtr<slang::IBlob> diagnostics;
+    slang::IModule *module_ptr = sc.session->loadModule(path, diagnostics.writeRef());
+
+    if (!module_ptr) {
+        if (diagnostics) {
+            VEL_ERROR("Slang Load Module Error ({}): {}", path, (const char *)diagnostics->getBufferPointer());
+        } else {
+            VEL_ERROR("Slang Load Module Error ({}): Unknown error", path);
+        }
+        return {};
+    }
+    Slang::ComPtr<slang::IModule> module(module_ptr);
+
+    Slang::ComPtr<slang::IEntryPoint> entry_point;
+    if (SLANG_FAILED(module->findEntryPointByName(entry_name, entry_point.writeRef()))) {
+        if (diagnostics) {
+            VEL_ERROR(
+                "Slang Find Entry Point Error ({}): {}", entry_name, (const char *)diagnostics->getBufferPointer()
+            );
+        } else {
+            VEL_ERROR("Slang Find Entry Point Error ({}): Entry point not found", entry_name);
+        }
+        return {};
+    }
+
+    slang::IComponentType *components[] = {module.get(), entry_point.get()};
+    Slang::ComPtr<slang::IComponentType> composed;
+    if (SLANG_FAILED(
+            sc.session->createCompositeComponentType(components, 2, composed.writeRef(), diagnostics.writeRef())
+        )) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IComponentType> linked;
+    if (SLANG_FAILED(composed->link(linked.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    Slang::ComPtr<slang::IBlob> spirv;
+    if (SLANG_FAILED(linked->getEntryPointCode(0, 0, spirv.writeRef(), diagnostics.writeRef()))) {
+        if (diagnostics) {
+            (void)std::fprintf(stderr, "%s\n", (const char *)diagnostics->getBufferPointer());
+        }
+        return {};
+    }
+
+    VkShaderModuleCreateInfo create_info{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO};
+    create_info.codeSize = spirv->getBufferSize();
+    create_info.pCode = (const u32 *)spirv->getBufferPointer();
+
+    VkShaderModule shader = VK_NULL_HANDLE;
+    VK_CHECK(vkCreateShaderModule(device.logical, &create_info, nullptr, &shader));
+    {
+        char mod_name[320];
+        (void)snprintf(mod_name, sizeof(mod_name), "shader/%s:%s", path, entry_name);
+        VK_NAME_EX(device, shader, mod_name);
+    }
+
+    VEL_INFO("Shader loaded: {} (Entry: {})", path, entry_name);
+    return {shader, stage};
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/swapchain.cpp +346 -0
--- a/src/backend/vulkan/swapchain.cpp
+++ b/src/backend/vulkan/swapchain.cpp
@@ -0,0 +1,346 @@
+
+#include <cstdio>
+#include <volk.h>
+
+#include <GLFW/glfw3.h>
+
+#include "backend/rhi.h"
+#include "backend/vulkan/debug.h"
+#include "backend/vulkan/utils.h"
+#include "backend/vulkan/vk_api.h"
+#include "backend/vulkan/vk_conversion.h"
+#include "core/globals.h"
+#include "core/logger.h"
+
+namespace rhi {
+using namespace vk;
+
+VkSurfaceFormat2KHR eval_surface_format(const std::vector<VkSurfaceFormat2KHR> &available_formats) {
+    if (available_formats.size() == 1 && available_formats[0].surfaceFormat.format == VK_FORMAT_UNDEFINED) {
+        VkSurfaceFormat2KHR result{
+            .sType = VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR,
+            .surfaceFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}
+        };
+        return result;
+    }
+
+    const VkSurfaceFormat2KHR preferred_formats[] = {
+        {.sType = VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR,
+         .surfaceFormat = {VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}},
+        {.sType = VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR,
+         .surfaceFormat = {VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR}}
+    };
+
+    for (const auto &chosen_preferred_format : preferred_formats) {
+        for (const auto &chosen_available_format : available_formats) {
+            if (chosen_available_format.surfaceFormat.format == chosen_preferred_format.surfaceFormat.format &&
+                chosen_available_format.surfaceFormat.colorSpace == chosen_preferred_format.surfaceFormat.colorSpace) {
+                return chosen_available_format;
+            }
+        }
+    }
+
+    return available_formats[0];
+}
+
+VkPresentModeKHR eval_present_mode(const std::vector<VkPresentModeKHR> &availablePresentModes, bool vSync = true) {
+    if (vSync) {
+        return VK_PRESENT_MODE_FIFO_KHR;
+    }
+
+    bool mailbox_supported = false;
+    bool immediate_supported = false;
+
+    for (VkPresentModeKHR mode : availablePresentModes) {
+        if (mode == VK_PRESENT_MODE_MAILBOX_KHR) {
+            mailbox_supported = true;
+        }
+        if (mode == VK_PRESENT_MODE_IMMEDIATE_KHR) {
+            immediate_supported = true;
+        }
+    }
+
+    if (mailbox_supported) {
+        return VK_PRESENT_MODE_MAILBOX_KHR;
+    }
+
+    if (immediate_supported) {
+        return VK_PRESENT_MODE_IMMEDIATE_KHR;
+    }
+
+    return VK_PRESENT_MODE_FIFO_KHR;
+}
+
+void create_swapchain(Device &device, const rhi::SwapchainDesc &desc, Swapchain &swapchain) {
+    VEL_INFO("Creating Swapchain...");
+
+    VK_CHECK(glfwCreateWindowSurface(
+        device.instance, static_cast<GLFWwindow *>(desc.native_window), nullptr, &device.surface
+    ));
+    VK_NAME(device, device.surface);
+
+    const VkPhysicalDeviceSurfaceInfo2KHR surface_info_2{
+        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, .surface = device.surface
+    };
+    VkSurfaceCapabilities2KHR capabilities2{.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR};
+    VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilities2KHR(device.physical, &surface_info_2, &capabilities2));
+
+    u32 format_count = 0;
+    VK_CHECK(vkGetPhysicalDeviceSurfaceFormats2KHR(device.physical, &surface_info_2, &format_count, nullptr));
+    std::vector<VkSurfaceFormat2KHR> formats(format_count, {.sType = VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR});
+    VK_CHECK(vkGetPhysicalDeviceSurfaceFormats2KHR(device.physical, &surface_info_2, &format_count, formats.data()));
+
+    u32 present_mode_count = 0;
+    VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(device.physical, device.surface, &present_mode_count, nullptr));
+    std::vector<VkPresentModeKHR> present_modes(present_mode_count);
+    VK_CHECK(vkGetPhysicalDeviceSurfacePresentModesKHR(
+        device.physical, device.surface, &present_mode_count, present_modes.data()
+    ));
+
+    const VkSurfaceFormat2KHR surface_format = eval_surface_format(formats);
+    const VkPresentModeKHR present_mode = eval_present_mode(present_modes, desc.vsync_enabled);
+
+    swapchain.format = vk::image_format_from_vk(surface_format.surfaceFormat.format);
+
+    const VkExtent2D &ce = capabilities2.surfaceCapabilities.currentExtent;
+    int fb_width = 0;
+    int fb_height = 0;
+    glfwGetFramebufferSize(static_cast<GLFWwindow *>(desc.native_window), &fb_width, &fb_height);
+    u32 w;
+    if (desc.width > 0) {
+        w = desc.width;
+    } else if (ce.width > 0) {
+        w = ce.width;
+    } else {
+        w = (u32)fb_width;
+    }
+    u32 h;
+    if (desc.height > 0) {
+        h = desc.height;
+    } else if (ce.height > 0) {
+        h = ce.height;
+    } else {
+        h = (u32)fb_height;
+    }
+    swapchain.extent = rhi::Extent2D{w, h};
+
+    VkSwapchainCreateInfoKHR swapchain_ci{};
+    swapchain_ci.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+    swapchain_ci.surface = device.surface;
+    swapchain_ci.minImageCount = desc.image_count;
+    swapchain_ci.imageFormat = vk::image_format_to_vk(swapchain.format);
+    swapchain_ci.imageColorSpace = surface_format.surfaceFormat.colorSpace;
+    VkExtent2D vk_extent = {swapchain.extent.width, swapchain.extent.height};
+    swapchain_ci.imageExtent = vk_extent;
+    swapchain_ci.imageArrayLayers = 1;
+    swapchain_ci.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+    swapchain_ci.preTransform = capabilities2.surfaceCapabilities.currentTransform;
+    swapchain_ci.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+    swapchain_ci.presentMode = present_mode;
+    swapchain_ci.clipped = VK_TRUE;
+    swapchain_ci.oldSwapchain = VK_NULL_HANDLE;
+    VkSwapchainKHR vk_swapchain;
+    VK_CHECK(vkCreateSwapchainKHR(device.logical, &swapchain_ci, nullptr, &vk_swapchain));
+    swapchain.handle = vk_swapchain;
+    VK_NAME_EX(device, swapchain.handle, "swapchain");
+
+    u32 image_count = 0;
+    VK_CHECK(vkGetSwapchainImagesKHR(device.logical, swapchain.handle, &image_count, nullptr));
+    if (desc.image_count <= image_count) {
+        image_count = desc.image_count;
+    }
+    std::vector<VkImage> vk_images(image_count);
+    VK_CHECK(vkGetSwapchainImagesKHR(device.logical, swapchain.handle, &image_count, vk_images.data()));
+
+    VkSemaphoreCreateInfo sem_ci{};
+    sem_ci.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+
+    VkFenceCreateInfo fence_ci{};
+    fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+
+    VkDevice vk_dev = device.logical;
+
+    swapchain.backbuffers.resize(image_count);
+    swapchain.present.resize(image_count);
+
+    VK_CHECK(vkCreateFence(vk_dev, &fence_ci, nullptr, &swapchain.acquire));
+
+    for (u32 i = 0; i < image_count; i++) {
+        Image &backbuffer = swapchain.backbuffers[i];
+
+        backbuffer._handle = vk_images[i];
+        backbuffer.desc.format = swapchain.format;
+        backbuffer.desc.width = swapchain.extent.width;
+        backbuffer.desc.height = swapchain.extent.height;
+        backbuffer.desc.mip_levels = 1;
+        backbuffer.desc.layers = 1;
+        backbuffer.desc.sample_count = rhi::SampleCount::Sample1;
+
+        backbuffer.state = rhi::ResourceState::Idle;
+
+        // per-image, safe to reuse
+        VkSemaphore vk_present = VK_NULL_HANDLE;
+        VK_CHECK(vkCreateSemaphore(vk_dev, &sem_ci, nullptr, &vk_present));
+        swapchain.present[i] = vk_present;
+
+        char name[64];
+        (void)sprintf(name, "swapchain_image[%u]", i);
+        set_name(device, backbuffer._handle, name);
+    }
+
+    swapchain.recreate = false;
+    const char *present_mode_str = "UNKNOWN";
+    switch (present_mode) {
+    case VK_PRESENT_MODE_IMMEDIATE_KHR:
+        present_mode_str = "IMMEDIATE";
+        break;
+    case VK_PRESENT_MODE_MAILBOX_KHR:
+        present_mode_str = "MAILBOX";
+        break;
+    case VK_PRESENT_MODE_FIFO_KHR:
+        present_mode_str = "FIFO";
+        break;
+    case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
+        present_mode_str = "FIFO_RELAXED";
+        break;
+    default:
+        break;
+    }
+    VEL_INFO(
+        "Swapchain created: {}x{} (format: {}, present: {}, vsync: {})",
+        swapchain.extent.width,
+        swapchain.extent.height,
+        static_cast<int>(swapchain.format),
+        present_mode_str,
+        desc.vsync_enabled
+    );
+};
+
+void destroy_swapchain(Device &device, Swapchain &swapchain) {
+    VEL_INFO("Destroying Swapchain...");
+    VkDevice vk_dev = device.logical;
+    for (u32 i = 0; i < (u32)swapchain.backbuffers.size(); ++i) {
+        vkDestroySemaphore(vk_dev, swapchain.present[i], nullptr);
+        swapchain.present[i] = VK_NULL_HANDLE;
+        rhi::destroy_image_views(device, swapchain.backbuffers[i]);
+    }
+    vkDestroyFence(vk_dev, swapchain.acquire, nullptr);
+    swapchain.acquire = VK_NULL_HANDLE;
+    swapchain.backbuffers.clear();
+    swapchain.present.clear();
+    vkDestroySwapchainKHR(vk_dev, swapchain.handle, nullptr);
+
+    if (device.surface != VK_NULL_HANDLE) {
+        vkDestroySurfaceKHR(device.instance, device.surface, nullptr);
+        device.surface = VK_NULL_HANDLE;
+    }
+}
+
+bool acquire_swapchain_image(Device &device, Swapchain &swapchain, u32 &out_image_index, CmdBuffer &cmd) {
+    VkResult res = vkAcquireNextImageKHR(
+        device.logical, swapchain.handle, UINT64_MAX, VK_NULL_HANDLE, swapchain.acquire, &out_image_index
+    );
+
+    if (res == VK_ERROR_OUT_OF_DATE_KHR) {
+        swapchain.recreate = true;
+        return false;
+    }
+
+    if (res == VK_ERROR_SURFACE_LOST_KHR || res == VK_ERROR_DEVICE_LOST) {
+        swapchain.recreate = true;
+        return false;
+    }
+
+    if (res != VK_SUCCESS && res != VK_SUBOPTIMAL_KHR) {
+        VK_CHECK(res);
+    }
+
+    VK_CHECK(vkWaitForFences(device.logical, 1, &swapchain.acquire, VK_TRUE, UINT64_MAX));
+    VK_CHECK(vkResetFences(device.logical, 1, &swapchain.acquire));
+
+    Image &img = swapchain.backbuffers[out_image_index];
+    VkImageMemoryBarrier2 barrier{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2};
+    barrier.srcStageMask = VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT;
+    barrier.srcAccessMask = VK_ACCESS_2_NONE;
+    barrier.dstStageMask = VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT;
+    barrier.dstAccessMask = VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT;
+    barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+    barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+    barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+    barrier.image = img._handle;
+    barrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
+    VkDependencyInfo dep{VK_STRUCTURE_TYPE_DEPENDENCY_INFO};
+    dep.imageMemoryBarrierCount = 1;
+    dep.pImageMemoryBarriers = &barrier;
+    vkCmdPipelineBarrier2(cmd.handle, &dep);
+    img.state = rhi::ResourceState::ColorDraw;
+
+    return true;
+}
+
+void present_swapchain(Device &device, Swapchain &swapchain, u32 image_index, SyncPoint frame_done) {
+    // timeline to binary for present
+    VkSemaphoreSubmitInfo convert_wait{
+        .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
+        .semaphore = frame_done.sync->timeline,
+        .value = frame_done.value,
+        .stageMask = vk::pipeline_stage_flags_to_vk(rhi::PipelineStages::ALL_COMMANDS),
+        .deviceIndex = 0,
+    };
+    VkSemaphoreSubmitInfo convert_signal{
+        .sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO,
+        .semaphore = swapchain.present[image_index],
+        .value = 0, // binary, unused
+        .stageMask = vk::pipeline_stage_flags_to_vk(rhi::PipelineStages::ALL_COMMANDS),
+        .deviceIndex = 0,
+    };
+    VkSubmitInfo2 convert_info{
+        .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO_2,
+        .waitSemaphoreInfoCount = 1,
+        .pWaitSemaphoreInfos = &convert_wait,
+        .commandBufferInfoCount = 0,
+        .pCommandBufferInfos = nullptr,
+        .signalSemaphoreInfoCount = 1,
+        .pSignalSemaphoreInfos = &convert_signal,
+    };
+    VK_CHECK(vkQueueSubmit2(device.graphics.handle, 1, &convert_info, VK_NULL_HANDLE));
+
+    VkSemaphore vk_sem = swapchain.present[image_index];
+    VkSwapchainKHR vk_swap = swapchain.handle;
+    VkPresentInfoKHR present_info{
+        .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
+        .waitSemaphoreCount = 1,
+        .pWaitSemaphores = &vk_sem,
+        .swapchainCount = 1,
+        .pSwapchains = &vk_swap,
+        .pImageIndices = &image_index
+    };
+
+    VkResult res = vkQueuePresentKHR(device.graphics.handle, &present_info);
+
+    if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_SUBOPTIMAL_KHR) {
+        swapchain.recreate = true;
+    }
+}
+
+rhi::ImageFormat swapchain_format(const Swapchain &swapchain) {
+    return swapchain.format;
+}
+
+rhi::Extent2D swapchain_extent(const Swapchain &swapchain) {
+    return swapchain.extent;
+}
+
+Image *swapchain_image(Swapchain &swapchain, u32 index) {
+    if (index >= swapchain.backbuffers.size()) {
+        return nullptr;
+    }
+    return &swapchain.backbuffers[index];
+}
+
+bool swapchain_needs_recreate(const Swapchain &swapchain) {
+    return swapchain.recreate;
+}
+
+} // namespace rhi
ADD · src/backend/vulkan/utils.h +52 -0
--- a/src/backend/vulkan/utils.h
+++ b/src/backend/vulkan/utils.h
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <volk.h>
+
+#include <cstdint>
+#include <cstdlib>
+
+#include "core/globals.h"
+#include "core/logger.h"
+
+#define PNEXTCHAIN_DECLARE(next) const void **_pnxt = (const void **)&(next)
+
+#define PNEXTCHAIN_APPEND_STRUCT(desc)                                                                                 \
+    do {                                                                                                               \
+        *_pnxt = &(desc);                                                                                              \
+        _pnxt = (const void **)&(desc).pNext;                                                                          \
+    } while (0)
+
+namespace vk {
+
+const char *vk_result_to_string(VkResult res);
+
+static inline void chk(VkResult res, const char *what, const char *file, int line) {
+    if (res != VK_SUCCESS) {
+        const char *res_str = vk_result_to_string(res);
+        VEL_CRITICAL(
+            "\n--- VULKAN ERROR ---\n"
+            "Result: {} ({})\n"
+            "Call:   {}\n"
+            "At:     {}:{}\n"
+            "--------------------\n",
+            res_str,
+            static_cast<int>(res),
+            what,
+            file,
+            line
+        );
+        std::abort();
+    }
+}
+
+#define VK_CHECK(x) vk::chk((x), #x, __FILE__, __LINE__)
+
+static inline VkDeviceOrHostAddressKHR device_address_to_vk(u64 addr) {
+    return VkDeviceOrHostAddressKHR{.deviceAddress = addr};
+}
+
+static inline VkDeviceOrHostAddressConstKHR device_address_const_to_vk(u64 addr) {
+    return VkDeviceOrHostAddressConstKHR{.deviceAddress = addr};
+}
+
+} // namespace vk
ADD · src/backend/vulkan/vk_api.h +322 -0
--- a/src/backend/vulkan/vk_api.h
+++ b/src/backend/vulkan/vk_api.h
@@ -0,0 +1,322 @@
+#pragma once
+
+#include <slang-com-helper.h>
+#include <slang-com-ptr.h>
+#include <slang.h>
+
+#include <vk_mem_alloc.h>
+
+#include "backend/vulkan/vk_conversion.h"
+
+namespace vk {
+
+static constexpr u32 MAX_RESOURCES = 400'000;
+static constexpr u32 MAX_SAMPLERS = 64;
+
+struct SlotAllocator {
+    u32 maxSlots;
+    u32 nextSlot = 0;
+    std::vector<u32> freeSlots;
+
+    explicit SlotAllocator(u32 maxSlots) : maxSlots(maxSlots) {
+    }
+
+    u32 allocate() {
+        if (!freeSlots.empty()) {
+            u32 slot = freeSlots.back();
+            freeSlots.pop_back();
+            return slot;
+        }
+
+        if (nextSlot >= maxSlots) {
+            return UINT32_MAX;
+        }
+
+        return nextSlot++;
+    }
+
+    void free(u32 slot) {
+        freeSlots.push_back(slot);
+    }
+};
+
+static SlotAllocator SAMPLER_SLOTS = SlotAllocator{u64(MAX_SAMPLERS)};
+static SlotAllocator RESOURCE_SLOTS = SlotAllocator{u64(MAX_RESOURCES)};
+
+// no native view, sentinel marks valid
+inline const VkBufferView NON_TEXEL_BUFFER_VIEW_SENTINEL = (VkBufferView)(uintptr_t)1;
+
+void create_global_descriptors(Device &device);
+void destroy_global_descriptors(rhi::Device device);
+
+u64 write_sampler_descriptor(Device &device, Sampler sampler);
+u64 write_image_view(Device &device, VkImageView view, bool storage);
+u64 write_buffer_view(Device &device, rhi::Buffer *buffer, u64 offset, u64 size, bool writeable);
+void free_resource_slot(u64 slot);
+void free_sampler_slot(u64 slot);
+
+} // namespace vk
+
+struct Platform;
+
+namespace rhi {
+
+struct Memory {
+    VmaAllocator allocator;
+};
+
+struct Queue {
+    VkQueue handle = VK_NULL_HANDLE;
+    u32 family_index = UINT32_MAX;
+    u32 queue_index = 0;
+};
+
+struct Buffer {
+    rhi::BufferDesc desc{};
+    VkBuffer _handle{};
+    VmaAllocation _allocation{};
+    void *mapped = nullptr;
+    u64 address = 0;
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+    std::vector<std::pair<BufferViewDesc, VkBufferView>> view_cache;
+};
+
+struct Image {
+    rhi::ImageDesc desc;
+    VkImage _handle{};
+    VmaAllocation _alloc{};
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+    std::vector<std::pair<ImageViewDesc, VkImageView>> view_cache;
+};
+
+struct CmdPool {
+    VkCommandPool handle = VK_NULL_HANDLE;
+};
+
+struct CmdBuffer {
+    VkCommandBuffer handle = VK_NULL_HANDLE;
+    bool is_rendering = false;
+};
+
+struct Sync {
+    VkSemaphore timeline = VK_NULL_HANDLE;
+    VkDevice device = VK_NULL_HANDLE;
+};
+
+struct RenderPipeline {
+    Device *device = nullptr;
+    VkPipeline _handle = VK_NULL_HANDLE;
+};
+
+struct ComputePipeline {
+    Device *device = nullptr;
+    VkPipeline _handle = VK_NULL_HANDLE;
+};
+
+struct Sampler {
+    VkSampler _handle = VK_NULL_HANDLE;
+    u64 slot = UINT64_MAX;
+};
+
+struct ImageView {
+    ImageViewDesc desc{};
+    VkImageView _handle = nullptr;
+    u64 slot = UINT64_MAX;
+};
+
+struct BufferView {
+    Buffer *buffer = nullptr;
+    BufferViewDesc desc{};
+    VkBufferView _handle = nullptr;
+    u64 slot = UINT64_MAX;
+};
+
+struct QueryPool {
+    VkQueryPool _handle = VK_NULL_HANDLE;
+    u32 _type;
+    rhi::QueryPoolDesc desc;
+};
+
+struct AccelStruct {
+    VkAccelerationStructureKHR handle = VK_NULL_HANDLE;
+    Buffer *buffer = nullptr;
+};
+
+struct Swapchain {
+    VkSurfaceKHR surface = VK_NULL_HANDLE;
+    VkSwapchainKHR handle = VK_NULL_HANDLE;
+    rhi::ImageFormat format = rhi::ImageFormat::UNDEFINED;
+    rhi::ImageFormat depth_format = rhi::ImageFormat::UNDEFINED;
+    rhi::Extent2D extent = {};
+
+    bool recreate = false;
+
+    std::vector<Image> backbuffers;
+    std::vector<VkSemaphore> present;
+    VkFence acquire = VK_NULL_HANDLE;
+};
+
+struct Device {
+    VkInstance instance = VK_NULL_HANDLE;
+    VkPhysicalDevice physical = VK_NULL_HANDLE;
+    VkDevice logical = VK_NULL_HANDLE;
+
+    VkDescriptorPool descriptor_pool = VK_NULL_HANDLE;
+    VkDescriptorSetLayout descriptor_set_layout = VK_NULL_HANDLE;
+    VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
+    VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
+
+    Queue graphics;
+
+    Memory memory;
+
+    u32 max_sampled_textures = 1024;
+    u32 max_storage_buffers = 1024;
+    u32 max_storage_images = 1024;
+    u32 max_uniform_buffers = 128;
+    u32 max_samplers = 32;
+    u32 max_acceleration_structures = 1024;
+
+    u32 min_ubo_alignment = 16;
+    u64 timestamp_period = 1;
+
+    VkSurfaceKHR surface = VK_NULL_HANDLE;
+
+    VkPipelineCache pipeline_cache = VK_NULL_HANDLE;
+    VkDebugUtilsMessengerEXT debug_messenger = VK_NULL_HANDLE;
+};
+
+struct ShaderCompiler {
+    Slang::ComPtr<slang::IGlobalSession> global;
+    Slang::ComPtr<slang::ISession> session;
+
+    bool recreate_session();
+};
+
+struct ShaderModule {
+    VkShaderModule handle = VK_NULL_HANDLE;
+    rhi::ShaderStage stage;
+};
+
+ShaderModule
+load_shader(ShaderCompiler &sc, Device &device, const char *path, const char *entry_name, ShaderStage stage);
+
+struct SyncPoint {
+    Sync *sync = nullptr;
+    u64 value = 0;
+};
+
+struct QueueWait {
+    SyncPoint point;
+    rhi::PipelineStages stage_mask;
+};
+
+struct QueueSignal {
+    SyncPoint point;
+};
+
+struct QueueSubmitDesc {
+    u32 wait_count = 0;
+    const QueueWait *waits = nullptr;
+    u32 cmd_count = 0;
+    const CmdBuffer *cmds = nullptr;
+    u32 signal_count = 0;
+    const QueueSignal *signals = nullptr;
+};
+
+struct RenderPipelineDesc {
+    Device *device = nullptr;
+
+    std::string name;
+
+    std::vector<rhi::ImageFormat> color_attachment_formats;
+    rhi::ImageFormat depth_attachment_format = rhi::ImageFormat::UNDEFINED;
+
+    std::string shader_path;
+    std::string vs_entry, fs_entry;
+    std::vector<ShaderModule> shader_modules;
+
+    std::vector<VertexAttribute> vertex_attributes;
+    std::vector<VertexBinding> vertex_bindings;
+
+    rhi::PipelineTopology topology = rhi::PipelineTopology::TRIANGLES;
+    rhi::PipelineFillMode fill_mode = rhi::PipelineFillMode::SOLID;
+    rhi::PipelineCullMode cull_mode = rhi::PipelineCullMode::BACK;
+    rhi::PipelineTriangleWindingOrder winding = rhi::PipelineTriangleWindingOrder::CCW;
+
+    rhi::SampleCount samples = rhi::SampleCount::Sample1;
+
+    bool depth_test_enable = true;
+    bool depth_write_enable = true;
+    bool depth_bias_enable = false;
+    f32 depth_bias_constant = 0.0;
+    f32 depth_bias_clamp = 0.0;
+    f32 depth_bias_slope = 0.0;
+    bool depth_clamp_enable = false;
+    rhi::PipelineCompareOp depth_compare_op = rhi::PipelineCompareOp::LESS;
+    bool enable_dynamic_polygon_mode = false;
+    bool enable_dynamic_depth_write = false;
+
+    bool blend_enable = false;
+    rhi::PipelineBlendFactor src_color_blend_factor = rhi::PipelineBlendFactor::SRC_ALPHA;
+    rhi::PipelineBlendFactor dst_color_blend_factor = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA;
+    rhi::PipelineBlendOp color_blend_op = rhi::PipelineBlendOp::ADD;
+    rhi::PipelineBlendFactor src_alpha_blend_factor = rhi::PipelineBlendFactor::SRC_ALPHA;
+    rhi::PipelineBlendFactor dst_alpha_blend_factor = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA;
+    rhi::PipelineBlendOp alpha_blend_op = rhi::PipelineBlendOp::ADD;
+
+    RenderPipelineDesc() = default;
+    RenderPipelineDesc(const RenderPipelineDesc &) = default;
+    RenderPipelineDesc &operator=(const RenderPipelineDesc &) = default;
+
+    RenderPipelineDesc &set_shaders(ShaderCompiler &sc, const char *path, const char *vs, const char *fs);
+    RenderPipelineDesc &set_input_topology(rhi::PipelineTopology topology);
+    RenderPipelineDesc &add_vertex_binding(u32 binding, u32 stride = 0, bool is_instanced = false);
+    RenderPipelineDesc &add_vertex_attribute(u32 location, u32 binding, ImageFormat format, u32 offset = 0);
+    RenderPipelineDesc &set_polygon_mode(rhi::PipelineFillMode mode);
+    RenderPipelineDesc &set_color_format(rhi::ImageFormat format);
+    RenderPipelineDesc &set_depth_format(rhi::ImageFormat format);
+    RenderPipelineDesc &set_cull_mode(rhi::PipelineCullMode cull_mode, rhi::PipelineTriangleWindingOrder winding);
+    RenderPipelineDesc &set_multisampling(rhi::SampleCount count = rhi::SampleCount::Sample1);
+    RenderPipelineDesc &set_depth_testing(bool do_test, bool do_write, rhi::PipelineCompareOp op);
+    RenderPipelineDesc &set_depth_bias(bool enabled, f32 constant, f32 clamp, f32 slope);
+    RenderPipelineDesc &set_depth_clamp(bool enabled);
+    RenderPipelineDesc &set_dynamic_polygon_mode(bool enable = true) {
+        enable_dynamic_polygon_mode = enable;
+        return *this;
+    }
+    RenderPipelineDesc &set_dynamic_depth_write(bool enable = true) {
+        enable_dynamic_depth_write = enable;
+        return *this;
+    }
+    RenderPipelineDesc &set_blending(
+        rhi::PipelineBlendFactor src_color = rhi::PipelineBlendFactor::SRC_ALPHA,
+        rhi::PipelineBlendFactor dst_color = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA,
+        rhi::PipelineBlendOp color_op = rhi::PipelineBlendOp::ADD,
+        rhi::PipelineBlendFactor src_alpha = rhi::PipelineBlendFactor::SRC_ALPHA,
+        rhi::PipelineBlendFactor dst_alpha = rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA,
+        rhi::PipelineBlendOp alpha_op = rhi::PipelineBlendOp::ADD
+    );
+
+    RenderPipeline build();
+};
+
+struct ComputePipelineDesc {
+    Device *device = nullptr;
+
+    std::string name;
+
+    std::string shader_path;
+    std::string cs_entry;
+    std::vector<ShaderModule> shader_modules;
+
+    ComputePipelineDesc() = default;
+    ComputePipelineDesc(const ComputePipelineDesc &) = default;
+    ComputePipelineDesc &operator=(const ComputePipelineDesc &) = default;
+
+    ComputePipelineDesc &set_shader(ShaderCompiler &sc, const char *path, const char *cs);
+
+    ComputePipeline build();
+};
+
+} // namespace rhi
ADD · src/backend/vulkan/vk_conversion.cpp +649 -0
--- a/src/backend/vulkan/vk_conversion.cpp
+++ b/src/backend/vulkan/vk_conversion.cpp
@@ -0,0 +1,649 @@
+#include "vk_conversion.h"
+
+#include "backend/vulkan/vk_api.h"
+
+namespace vk {
+
+namespace {
+
+VkImageUsageFlags image_usage_bit_to_vk(ImageUsage flag) {
+    switch (flag) {
+    case ImageUsage::ColorAttachment:
+        return VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+    case ImageUsage::DepthAttachment:
+        return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
+    case ImageUsage::StencilAttachment:
+        return VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
+    case ImageUsage::Sampled:
+        return VK_IMAGE_USAGE_SAMPLED_BIT;
+    case ImageUsage::Storage:
+        return VK_IMAGE_USAGE_STORAGE_BIT;
+    case ImageUsage::TransferSrc:
+        return VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+    case ImageUsage::TransferDst:
+        return VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+    case ImageUsage::InputAttachment:
+        return VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT;
+    default:
+        return 0;
+    }
+}
+
+} // anonymous namespace
+
+VkImageAspectFlags image_aspect_bit_to_vk(ImageAspect flag) {
+    switch (flag) {
+    case ImageAspect::Color:
+        return VK_IMAGE_ASPECT_COLOR_BIT;
+    case ImageAspect::Depth:
+        return VK_IMAGE_ASPECT_DEPTH_BIT;
+    case ImageAspect::Stencil:
+        return VK_IMAGE_ASPECT_STENCIL_BIT;
+    default:
+        return 0;
+    }
+}
+
+VkFormat image_format_to_vk(ImageFormat format) {
+    switch (format) {
+    case ImageFormat::UNDEFINED:
+        return VK_FORMAT_UNDEFINED;
+    case ImageFormat::R8_UNORM:
+        return VK_FORMAT_R8_UNORM;
+    case ImageFormat::RGBA8_UNORM:
+        return VK_FORMAT_R8G8B8A8_UNORM;
+    case ImageFormat::RGBA8_SRGB:
+        return VK_FORMAT_R8G8B8A8_SRGB;
+    case ImageFormat::BGRA8_UNORM:
+        return VK_FORMAT_B8G8R8A8_UNORM;
+    case ImageFormat::ASTC6X6_SRGB:
+        return VK_FORMAT_ASTC_6x6_SRGB_BLOCK;
+    case ImageFormat::ASTC6X6_UNORM:
+        return VK_FORMAT_ASTC_6x6_UNORM_BLOCK;
+    case ImageFormat::BC7_SRGB:
+        return VK_FORMAT_BC7_SRGB_BLOCK;
+    case ImageFormat::BC7_UNORM:
+        return VK_FORMAT_BC7_UNORM_BLOCK;
+    case ImageFormat::D32_FLOAT:
+        return VK_FORMAT_D32_SFLOAT;
+    case ImageFormat::RGBA16_FLOAT:
+        return VK_FORMAT_R16G16B16A16_SFLOAT;
+    case ImageFormat::RGBA32_FLOAT:
+        return VK_FORMAT_R32G32B32A32_SFLOAT;
+    case ImageFormat::R32_FLOAT:
+        return VK_FORMAT_R32_SFLOAT;
+    case ImageFormat::R32_UINT:
+        return VK_FORMAT_R32_UINT;
+    case ImageFormat::R16_FLOAT:
+        return VK_FORMAT_R16_SFLOAT;
+    case ImageFormat::R10G10B10A2_UNORM:
+        return VK_FORMAT_A2B10G10R10_UNORM_PACK32;
+    case ImageFormat::RG16_FLOAT:
+        return VK_FORMAT_R16G16_SFLOAT;
+    case ImageFormat::RG32_FLOAT:
+        return VK_FORMAT_R32G32_SFLOAT;
+    case ImageFormat::RGB32_FLOAT:
+        return VK_FORMAT_R32G32B32_SFLOAT;
+    default:
+        return VK_FORMAT_UNDEFINED;
+    }
+}
+
+ImageFormat image_format_from_vk(VkFormat format) {
+    switch (format) {
+    case VK_FORMAT_UNDEFINED:
+        return ImageFormat::UNDEFINED;
+
+    case VK_FORMAT_R8_UNORM:
+        return ImageFormat::R8_UNORM;
+
+    case VK_FORMAT_R8G8B8A8_UNORM:
+        return ImageFormat::RGBA8_UNORM;
+
+    case VK_FORMAT_R8G8B8A8_SRGB:
+        return ImageFormat::RGBA8_SRGB;
+
+    case VK_FORMAT_B8G8R8A8_UNORM:
+        return ImageFormat::BGRA8_UNORM;
+
+    case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
+        return ImageFormat::ASTC6X6_SRGB;
+
+    case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
+        return ImageFormat::ASTC6X6_UNORM;
+
+    case VK_FORMAT_BC7_SRGB_BLOCK:
+        return ImageFormat::BC7_SRGB;
+
+    case VK_FORMAT_BC7_UNORM_BLOCK:
+        return ImageFormat::BC7_UNORM;
+
+    case VK_FORMAT_D32_SFLOAT:
+        return ImageFormat::D32_FLOAT;
+
+    case VK_FORMAT_R16G16B16A16_SFLOAT:
+        return ImageFormat::RGBA16_FLOAT;
+
+    case VK_FORMAT_R32G32B32A32_SFLOAT:
+        return ImageFormat::RGBA32_FLOAT;
+
+    case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
+        return ImageFormat::R10G10B10A2_UNORM;
+
+    case VK_FORMAT_R16G16_SFLOAT:
+        return ImageFormat::RG16_FLOAT;
+
+    case VK_FORMAT_R32_UINT:
+        return ImageFormat::R32_UINT;
+
+    default:
+        return ImageFormat::UNDEFINED;
+    }
+}
+
+VkImageViewType image_view_type_to_vk(TextureViewDimension type) {
+    switch (type) {
+    case TextureViewDimension::TEXTURE_2D:
+        return VK_IMAGE_VIEW_TYPE_2D;
+    case TextureViewDimension::TEXTURE_2D_ARRAY:
+        return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
+    case TextureViewDimension::TEXTURE_CUBE:
+        return VK_IMAGE_VIEW_TYPE_CUBE;
+    case TextureViewDimension::TEXTURE_3D:
+        return VK_IMAGE_VIEW_TYPE_3D;
+    }
+    return VK_IMAGE_VIEW_TYPE_2D;
+}
+
+VkComponentSwizzle component_swizzle_to_vk(ComponentSwizzle swizzle) {
+    switch (swizzle) {
+    case ComponentSwizzle::Identity:
+        return VK_COMPONENT_SWIZZLE_IDENTITY;
+    case ComponentSwizzle::R:
+        return VK_COMPONENT_SWIZZLE_R;
+    case ComponentSwizzle::G:
+        return VK_COMPONENT_SWIZZLE_G;
+    case ComponentSwizzle::B:
+        return VK_COMPONENT_SWIZZLE_B;
+    case ComponentSwizzle::A:
+        return VK_COMPONENT_SWIZZLE_A;
+    case ComponentSwizzle::Zero:
+        return VK_COMPONENT_SWIZZLE_ZERO;
+    case ComponentSwizzle::One:
+        return VK_COMPONENT_SWIZZLE_ONE;
+    }
+    return VK_COMPONENT_SWIZZLE_IDENTITY;
+}
+
+VkImageUsageFlags image_usage_to_vk(Device &device, ImageDesc const &desc) {
+    VkImageUsageFlags flags = 0;
+    u32 bits = static_cast<u32>(desc.usage);
+    for (int i = 0; i < 8; ++i) {
+        if (bits & (1u << i)) {
+            flags |= image_usage_bit_to_vk(static_cast<ImageUsage>(1u << i));
+        }
+    }
+    VkFormatProperties props{};
+    vkGetPhysicalDeviceFormatProperties(device.physical, image_format_to_vk(desc.format), &props);
+    if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) {
+        flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+    }
+    if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT) {
+        flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+    }
+    return flags;
+}
+
+VkImageAspectFlags image_aspect_to_vk(ImageAspect aspect) {
+    VkImageAspectFlags flags = 0;
+
+    u32 bits = static_cast<u32>(aspect);
+
+    if (bits & static_cast<u32>(ImageAspect::Color)) {
+        flags |= VK_IMAGE_ASPECT_COLOR_BIT;
+    }
+
+    if (bits & static_cast<u32>(ImageAspect::Depth)) {
+        flags |= VK_IMAGE_ASPECT_DEPTH_BIT;
+    }
+
+    if (bits & static_cast<u32>(ImageAspect::Stencil)) {
+        flags |= VK_IMAGE_ASPECT_STENCIL_BIT;
+    }
+
+    return flags;
+}
+
+VkSamplerAddressMode sampler_address_to_vk(SamplerAddressMode mode) {
+    switch (mode) {
+    case SamplerAddressMode::WRAP:
+        return VK_SAMPLER_ADDRESS_MODE_REPEAT;
+    case SamplerAddressMode::MIRROR:
+        return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
+    case SamplerAddressMode::CLAMP:
+        return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+    case SamplerAddressMode::BORDER:
+        return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
+    default:
+        return VK_SAMPLER_ADDRESS_MODE_REPEAT;
+    }
+}
+
+VkFilter sampler_filter_to_vk(SamplerFilter filter) {
+    switch (filter) {
+    case SamplerFilter::POINT:
+        return VK_FILTER_NEAREST;
+    case SamplerFilter::LINEAR:
+    case SamplerFilter::ANISOTROPIC:
+        return VK_FILTER_LINEAR;
+    default:
+        return VK_FILTER_NEAREST;
+    }
+}
+
+VkCompareOp sampler_comparison_to_vk(SamplerComparisonFunc func) {
+    switch (func) {
+    case SamplerComparisonFunc::NEVER:
+        return VK_COMPARE_OP_NEVER;
+    case SamplerComparisonFunc::LESS:
+        return VK_COMPARE_OP_LESS;
+    case SamplerComparisonFunc::EQUAL:
+        return VK_COMPARE_OP_EQUAL;
+    case SamplerComparisonFunc::LESS_EQUAL:
+        return VK_COMPARE_OP_LESS_OR_EQUAL;
+    case SamplerComparisonFunc::GREATER:
+        return VK_COMPARE_OP_GREATER;
+    case SamplerComparisonFunc::NOT_EQUAL:
+        return VK_COMPARE_OP_NOT_EQUAL;
+    case SamplerComparisonFunc::GREATER_EQUAL:
+        return VK_COMPARE_OP_GREATER_OR_EQUAL;
+    case SamplerComparisonFunc::ALWAYS:
+        return VK_COMPARE_OP_ALWAYS;
+    default:
+        return VK_COMPARE_OP_ALWAYS;
+    }
+}
+
+VkPrimitiveTopology pipeline_topology_to_vk(rhi::PipelineTopology topology) {
+    switch (topology) {
+    case rhi::PipelineTopology::TRIANGLES:
+        return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
+    case rhi::PipelineTopology::LINES:
+        return VK_PRIMITIVE_TOPOLOGY_LINE_LIST;
+    case rhi::PipelineTopology::POINTS:
+        return VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
+    default:
+        return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
+    }
+}
+
+VkPolygonMode pipeline_fill_mode_to_vk(rhi::PipelineFillMode fill_mode) {
+    switch (fill_mode) {
+    case rhi::PipelineFillMode::SOLID:
+        return VK_POLYGON_MODE_FILL;
+    case rhi::PipelineFillMode::WIREFRAME:
+        return VK_POLYGON_MODE_LINE;
+    default:
+        return VK_POLYGON_MODE_FILL;
+    }
+}
+
+VkCullModeFlags pipeline_cull_mode_to_vk(rhi::PipelineCullMode cull_mode) {
+    switch (cull_mode) {
+    case rhi::PipelineCullMode::NONE:
+        return VK_CULL_MODE_NONE;
+    case rhi::PipelineCullMode::FRONT:
+        return VK_CULL_MODE_FRONT_BIT;
+    case rhi::PipelineCullMode::BACK:
+        return VK_CULL_MODE_BACK_BIT;
+    default:
+        return VK_CULL_MODE_BACK_BIT;
+    }
+}
+
+VkFrontFace triangle_winding_to_vk(rhi::PipelineTriangleWindingOrder winding) {
+    switch (winding) {
+    case rhi::PipelineTriangleWindingOrder::CW:
+        return VK_FRONT_FACE_CLOCKWISE;
+    case rhi::PipelineTriangleWindingOrder::CCW:
+        return VK_FRONT_FACE_COUNTER_CLOCKWISE;
+    default:
+        return VK_FRONT_FACE_CLOCKWISE;
+    }
+}
+
+VkCompareOp pipeline_compare_op_to_vk(rhi::PipelineCompareOp compare_op) {
+    switch (compare_op) {
+    case rhi::PipelineCompareOp::NEVER:
+        return VK_COMPARE_OP_NEVER;
+    case rhi::PipelineCompareOp::LESS:
+        return VK_COMPARE_OP_LESS;
+    case rhi::PipelineCompareOp::EQUAL:
+        return VK_COMPARE_OP_EQUAL;
+    case rhi::PipelineCompareOp::LESS_EQUAL:
+        return VK_COMPARE_OP_LESS_OR_EQUAL;
+    case rhi::PipelineCompareOp::GREATER:
+        return VK_COMPARE_OP_GREATER;
+    case rhi::PipelineCompareOp::NOT_EQUAL:
+        return VK_COMPARE_OP_NOT_EQUAL;
+    case rhi::PipelineCompareOp::GREATER_EQUAL:
+        return VK_COMPARE_OP_GREATER_OR_EQUAL;
+    case rhi::PipelineCompareOp::ALWAYS:
+        return VK_COMPARE_OP_ALWAYS;
+    default:
+        return VK_COMPARE_OP_LESS;
+    }
+}
+
+VkShaderStageFlags shader_stage_to_vk(rhi::ShaderStage stages) {
+    if ((stages & rhi::ShaderStage::ALL) == rhi::ShaderStage::ALL) {
+        return VK_SHADER_STAGE_ALL;
+    }
+
+    VkShaderStageFlags flags = 0;
+
+    if ((stages & rhi::ShaderStage::VERTEX) == rhi::ShaderStage::VERTEX) {
+        flags |= VK_SHADER_STAGE_VERTEX_BIT;
+    }
+
+    if ((stages & rhi::ShaderStage::FRAGMENT) == rhi::ShaderStage::FRAGMENT) {
+        flags |= VK_SHADER_STAGE_FRAGMENT_BIT;
+    }
+
+    if ((stages & rhi::ShaderStage::COMPUTE) == rhi::ShaderStage::COMPUTE) {
+        flags |= VK_SHADER_STAGE_COMPUTE_BIT;
+    }
+
+    if ((stages & rhi::ShaderStage::MESH) == rhi::ShaderStage::MESH) {
+        flags |= VK_SHADER_STAGE_MESH_BIT_EXT;
+    }
+
+    if ((stages & rhi::ShaderStage::TASK) == rhi::ShaderStage::TASK) {
+        flags |= VK_SHADER_STAGE_TASK_BIT_EXT;
+    }
+
+    if ((stages & rhi::ShaderStage::GEOMETRY) == rhi::ShaderStage::GEOMETRY) {
+        flags |= VK_SHADER_STAGE_GEOMETRY_BIT;
+    }
+
+    if ((stages & rhi::ShaderStage::RAYGEN) == rhi::ShaderStage::RAYGEN) {
+        flags |= VK_SHADER_STAGE_RAYGEN_BIT_KHR;
+    }
+
+    if ((stages & rhi::ShaderStage::CLOSEST_HIT) == rhi::ShaderStage::CLOSEST_HIT) {
+        flags |= VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR;
+    }
+
+    if ((stages & rhi::ShaderStage::ANY_HIT) == rhi::ShaderStage::ANY_HIT) {
+        flags |= VK_SHADER_STAGE_ANY_HIT_BIT_KHR;
+    }
+
+    if ((stages & rhi::ShaderStage::MISS) == rhi::ShaderStage::MISS) {
+        flags |= VK_SHADER_STAGE_MISS_BIT_KHR;
+    }
+
+    if ((stages & rhi::ShaderStage::INTERSECTION) == rhi::ShaderStage::INTERSECTION) {
+        flags |= VK_SHADER_STAGE_INTERSECTION_BIT_KHR;
+    }
+
+    if ((stages & rhi::ShaderStage::CALLABLE) == rhi::ShaderStage::CALLABLE) {
+        flags |= VK_SHADER_STAGE_CALLABLE_BIT_KHR;
+    }
+
+    return flags;
+}
+
+enum VkBlendFactor pipeline_blend_factor_to_vk(rhi::PipelineBlendFactor factor) {
+    switch (factor) {
+    case rhi::PipelineBlendFactor::ZERO:
+        return VK_BLEND_FACTOR_ZERO;
+    case rhi::PipelineBlendFactor::ONE:
+        return VK_BLEND_FACTOR_ONE;
+    case rhi::PipelineBlendFactor::SRC_ALPHA:
+        return VK_BLEND_FACTOR_SRC_ALPHA;
+    case rhi::PipelineBlendFactor::ONE_MINUS_SRC_ALPHA:
+        return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+    case rhi::PipelineBlendFactor::DST_ALPHA:
+        return VK_BLEND_FACTOR_DST_ALPHA;
+    case rhi::PipelineBlendFactor::ONE_MINUS_DST_ALPHA:
+        return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
+    case rhi::PipelineBlendFactor::SRC_COLOR:
+        return VK_BLEND_FACTOR_SRC_COLOR;
+    case rhi::PipelineBlendFactor::ONE_MINUS_SRC_COLOR:
+        return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
+    case rhi::PipelineBlendFactor::DST_COLOR:
+        return VK_BLEND_FACTOR_DST_COLOR;
+    case rhi::PipelineBlendFactor::ONE_MINUS_DST_COLOR:
+        return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
+    case rhi::PipelineBlendFactor::SRC_ALPHA_SATURATE:
+        return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE;
+    default:
+        return VK_BLEND_FACTOR_ONE;
+    }
+}
+
+enum VkBlendOp pipeline_blend_op_to_vk(rhi::PipelineBlendOp op) {
+    switch (op) {
+    case rhi::PipelineBlendOp::ADD:
+        return VK_BLEND_OP_ADD;
+    case rhi::PipelineBlendOp::SUBTRACT:
+        return VK_BLEND_OP_SUBTRACT;
+    case rhi::PipelineBlendOp::REVERSE_SUBTRACT:
+        return VK_BLEND_OP_REVERSE_SUBTRACT;
+    case rhi::PipelineBlendOp::MIN:
+        return VK_BLEND_OP_MIN;
+    case rhi::PipelineBlendOp::MAX:
+        return VK_BLEND_OP_MAX;
+    default:
+        return VK_BLEND_OP_ADD;
+    }
+}
+
+VkSampleCountFlagBits sample_count_to_vk(rhi::SampleCount samples) {
+    switch (samples) {
+    case rhi::SampleCount::Sample1:
+        return VK_SAMPLE_COUNT_1_BIT;
+    case rhi::SampleCount::Sample2:
+        return VK_SAMPLE_COUNT_2_BIT;
+    case rhi::SampleCount::Sample4:
+        return VK_SAMPLE_COUNT_4_BIT;
+    case rhi::SampleCount::Sample8:
+        return VK_SAMPLE_COUNT_8_BIT;
+    case rhi::SampleCount::Sample16:
+        return VK_SAMPLE_COUNT_16_BIT;
+    case rhi::SampleCount::Sample32:
+        return VK_SAMPLE_COUNT_32_BIT;
+    case rhi::SampleCount::Sample64:
+        return VK_SAMPLE_COUNT_64_BIT;
+    }
+
+    return VK_SAMPLE_COUNT_1_BIT;
+}
+
+VkCommandPoolCreateFlags to_vk_cmd_pool_flags(CmdPoolUsage flags) {
+    VkCommandPoolCreateFlags vk_flags = 0;
+    if (Any(flags, CmdPoolUsage::Transient)) {
+        vk_flags |= VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
+    }
+    if (Any(flags, CmdPoolUsage::ResetCommandBuffer)) {
+        vk_flags |= VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+    }
+    if (Any(flags, CmdPoolUsage::Protected)) {
+        vk_flags |= VK_COMMAND_POOL_CREATE_PROTECTED_BIT;
+    }
+    return vk_flags;
+}
+
+VkCommandBufferLevel to_vk_cmd_buffer_level(CmdBufferLevel level) {
+    switch (level) {
+    case CmdBufferLevel::Primary:
+        return VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+    case CmdBufferLevel::Secondary:
+        return VK_COMMAND_BUFFER_LEVEL_SECONDARY;
+    default:
+        return VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+    }
+}
+
+VkCommandBufferUsageFlags to_vk_cmd_buffer_usage_flags(CmdBufferUsage flags) {
+    VkCommandBufferUsageFlags vk_flags = 0;
+    if (Any(flags, CmdBufferUsage::OneTimeSubmit)) {
+        vk_flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+    }
+    if (Any(flags, CmdBufferUsage::RenderPassContinue)) {
+        vk_flags |= VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
+    }
+    if (Any(flags, CmdBufferUsage::SimultaneousUse)) {
+        vk_flags |= VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
+    }
+    return vk_flags;
+}
+
+VkPipelineStageFlags2 pipeline_stage_flags_to_vk(PipelineStages stages) {
+    return static_cast<VkPipelineStageFlags2>(stages);
+}
+
+static bool is_depth_aspect(ImageAspect aspect) {
+    return Any(aspect, ImageAspect::Depth) || Any(aspect, ImageAspect::Stencil);
+}
+
+StateSync image_state_to_vk(ResourceState state, ImageAspect aspect) {
+    const bool depth = is_depth_aspect(aspect);
+    switch (state) {
+    case ResourceState::Idle:
+        return {};
+    case ResourceState::ColorDraw:
+        return {
+            VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT,
+            VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT,
+            VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
+        };
+    case ResourceState::ColorFetch:
+        return {
+            VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT,
+            VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT,
+            VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
+        };
+    case ResourceState::DepthDraw:
+        return {
+            VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT,
+            VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
+            VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
+        };
+    case ResourceState::DepthFetch:
+        return {
+            VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT,
+            VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
+            VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
+        };
+    case ResourceState::TextureSample:
+        return {
+            VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT,
+            VK_ACCESS_2_SHADER_READ_BIT,
+            depth ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
+        };
+    case ResourceState::TextureSampleNonFragment:
+        return {
+            VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_SHADER_READ_BIT,
+            depth ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
+        };
+    case ResourceState::StorageRead:
+        return {VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, VK_ACCESS_2_SHADER_STORAGE_READ_BIT, VK_IMAGE_LAYOUT_GENERAL};
+    case ResourceState::StorageReadWrite:
+        return {
+            VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_SHADER_READ_BIT | VK_ACCESS_2_SHADER_WRITE_BIT,
+            VK_IMAGE_LAYOUT_GENERAL
+        };
+    case ResourceState::TransferFrom:
+        return {VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL};
+    case ResourceState::TransferTo:
+        return {VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL};
+    case ResourceState::Display:
+        return {VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT, VK_ACCESS_2_NONE, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR};
+    case ResourceState::AccelBuild:
+        return {
+            VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
+            VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR,
+            VK_IMAGE_LAYOUT_GENERAL
+        };
+    case ResourceState::AccelTrace:
+        return {VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, VK_ACCESS_2_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL};
+    default:
+        return {VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, VK_ACCESS_2_SHADER_READ_BIT, VK_IMAGE_LAYOUT_GENERAL};
+    }
+}
+
+StateSync buffer_state_to_vk(ResourceState state) {
+    switch (state) {
+    case ResourceState::Idle:
+        return {};
+    case ResourceState::StorageRead:
+        return {
+            VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT |
+                VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_SHADER_STORAGE_READ_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::StorageReadWrite:
+        return {
+            VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_SHADER_READ_BIT | VK_ACCESS_2_SHADER_WRITE_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::VertexFetch:
+        return {
+            VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT,
+            VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::IndexFetch:
+        return {VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT, VK_ACCESS_2_INDEX_READ_BIT, VK_IMAGE_LAYOUT_UNDEFINED};
+    case ResourceState::IndirectFetch:
+        return {
+            VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT, VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT, VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::UniformRead:
+        return {
+            VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT |
+                VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_UNIFORM_READ_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::TransferFrom:
+        return {VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_READ_BIT, VK_IMAGE_LAYOUT_UNDEFINED};
+    case ResourceState::TransferTo:
+        return {
+            VK_PIPELINE_STAGE_2_TRANSFER_BIT | VK_PIPELINE_STAGE_2_CLEAR_BIT,
+            VK_ACCESS_2_TRANSFER_WRITE_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::TextureSample:
+    case ResourceState::TextureSampleNonFragment:
+        return {
+            VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT |
+                VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
+            VK_ACCESS_2_SHADER_READ_BIT,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::AccelBuild:
+        return {
+            VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
+            VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::AccelTrace:
+        return {
+            VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
+            VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR,
+            VK_IMAGE_LAYOUT_UNDEFINED
+        };
+    case ResourceState::HostRead:
+        return {VK_PIPELINE_STAGE_2_HOST_BIT, VK_ACCESS_2_HOST_READ_BIT, VK_IMAGE_LAYOUT_UNDEFINED};
+    default:
+        return {};
+    }
+}
+
+} // namespace vk
ADD · src/backend/vulkan/vk_conversion.h +56 -0
--- a/src/backend/vulkan/vk_conversion.h
+++ b/src/backend/vulkan/vk_conversion.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <volk.h>
+
+#include <array>
+#include <cassert>
+#include <cstdint>
+#include <type_traits>
+
+#include "backend/rhi_types.h"
+
+namespace rhi {
+struct Device;
+} // namespace rhi
+
+namespace vk {
+using namespace rhi;
+
+VkFormat image_format_to_vk(ImageFormat format);
+ImageFormat image_format_from_vk(VkFormat format);
+VkImageViewType image_view_type_to_vk(TextureViewDimension type);
+VkComponentSwizzle component_swizzle_to_vk(ComponentSwizzle swizzle);
+
+VkImageUsageFlags image_usage_to_vk(Device &device, ImageDesc const &desc);
+VkImageAspectFlags image_aspect_to_vk(ImageAspect aspect);
+VkImageAspectFlags image_aspect_bit_to_vk(ImageAspect flag);
+
+VkSamplerAddressMode sampler_address_to_vk(SamplerAddressMode mode);
+VkFilter sampler_filter_to_vk(SamplerFilter filter);
+VkCompareOp sampler_comparison_to_vk(SamplerComparisonFunc func);
+
+VkPrimitiveTopology pipeline_topology_to_vk(rhi::PipelineTopology topology);
+VkPolygonMode pipeline_fill_mode_to_vk(rhi::PipelineFillMode fill_mode);
+VkCullModeFlags pipeline_cull_mode_to_vk(rhi::PipelineCullMode cull_mode);
+VkFrontFace triangle_winding_to_vk(rhi::PipelineTriangleWindingOrder winding);
+VkCompareOp pipeline_compare_op_to_vk(rhi::PipelineCompareOp compare_op);
+VkShaderStageFlags shader_stage_to_vk(rhi::ShaderStage stages);
+VkBlendFactor pipeline_blend_factor_to_vk(rhi::PipelineBlendFactor factor);
+VkBlendOp pipeline_blend_op_to_vk(rhi::PipelineBlendOp op);
+VkSampleCountFlagBits sample_count_to_vk(rhi::SampleCount samples);
+
+VkCommandPoolCreateFlags to_vk_cmd_pool_flags(CmdPoolUsage flags);
+VkCommandBufferLevel to_vk_cmd_buffer_level(CmdBufferLevel level);
+VkCommandBufferUsageFlags to_vk_cmd_buffer_usage_flags(CmdBufferUsage flags);
+
+VkPipelineStageFlags2 pipeline_stage_flags_to_vk(PipelineStages stages);
+
+struct StateSync {
+    VkPipelineStageFlags2 stages = 0;
+    VkAccessFlags2 access = 0;
+    VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
+};
+StateSync image_state_to_vk(ResourceState state, ImageAspect aspect);
+StateSync buffer_state_to_vk(ResourceState state);
+
+} // namespace vk
ADD · src/core/arena.cpp +52 -0
--- a/src/core/arena.cpp
+++ b/src/core/arena.cpp
@@ -0,0 +1,52 @@
+#include "arena.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
+
+ArenaC::ArenaC(usize requested_capacity) {
+    base = static_cast<u8 *>(malloc(requested_capacity));
+    capacity = requested_capacity;
+    position = 0;
+}
+
+void *ArenaC::push(u64 push_size, u64 push_alignment, bool zero_init) {
+    u64 aligned_pos = align_up_pow_2(position, push_alignment);
+    u64 final_pos = aligned_pos + push_size;
+
+    if (final_pos > capacity) {
+        assert(false && "ARENA CAPPED OUT");
+        return nullptr;
+    }
+
+    position = final_pos;
+
+    u8 *out = base + aligned_pos;
+
+    if (zero_init) {
+        memset(out, 0, push_size);
+    }
+
+    return out;
+}
+
+void ArenaC::pop(u64 pop_size) {
+    assert(pop_size <= position && "ARENA POP UNDERFLOW");
+    position -= pop_size;
+}
+
+void ArenaC::reset() {
+    position = 0;
+}
+
+u64 ArenaC::used() const {
+    return position;
+}
+
+u64 ArenaC::remaining() const {
+    return capacity - position;
+}
+
+ArenaC::~ArenaC() {
+    free(base);
+}
ADD · src/core/arena.h +32 -0
--- a/src/core/arena.h
+++ b/src/core/arena.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "globals.h"
+
+constexpr usize DEFAULT_ALIGNMENT = sizeof(void *);
+
+constexpr usize align_up_pow_2(usize x, usize b) {
+    return (x + b - 1) & ~(b - 1);
+}
+
+constexpr usize align_down_pow_2(usize x, usize b) {
+    return x & ~(b - 1);
+}
+
+struct ArenaC {
+    u8 *base;
+    usize capacity;
+    usize position;
+
+    void *push(u64 push_size, u64 push_alignment = DEFAULT_ALIGNMENT, bool zero_init = true);
+    void pop(u64 size);
+    void reset();
+
+    u64 used() const;
+    u64 remaining() const;
+
+    ArenaC(usize requested_capacity);
+    ~ArenaC();
+
+    ArenaC(const ArenaC &) = delete;
+    ArenaC &operator=(const ArenaC &) = delete;
+};
ADD · src/core/array.h +34 -0
--- a/src/core/array.h
+++ b/src/core/array.h
@@ -0,0 +1,34 @@
+#pragma once
+#include "arena.h"
+#include "globals.h"
+
+template <typename T> struct Array {
+    ArenaC *arena;
+    T *data;
+    u64 count;
+
+    Array(ArenaC *a) : arena(a), data(nullptr), count(0) {
+    }
+
+    T *push(const T &value) {
+        T *slot = static_cast<T *>(arena->push(sizeof(T), alignof(T)));
+        if (!data) {
+            data = slot;
+        }
+        *slot = value;
+        count++;
+        return slot;
+    }
+    T &operator[](u64 i) {
+        return data[i];
+    }
+    const T &operator[](u64 i) const {
+        return data[i];
+    }
+    u64 size() const {
+        return count;
+    }
+    void clear() {
+        count = 0;
+    }
+};
ADD · src/core/frame_stats.h +44 -0
--- a/src/core/frame_stats.h
+++ b/src/core/frame_stats.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "globals.h"
+
+struct FrameStats {
+    static constexpr u32 HISTORY_SIZE = 120;
+
+    // per-frame ms
+    f32 history[HISTORY_SIZE] = {};
+    u32 write = 0;
+    u32 frames = 0;
+
+    f32 last_ms = 0.0f;
+    f32 avg_ms = 0.0f;
+    f32 min_ms = 0.0f;
+    f32 max_ms = 0.0f;
+
+    void record(f32 ms) {
+        last_ms = ms;
+        history[write] = ms;
+        write = (write + 1) % HISTORY_SIZE;
+        frames++;
+
+        u32 n = (frames < HISTORY_SIZE) ? frames : HISTORY_SIZE;
+        f32 sum = 0.0f;
+        min_ms = ms;
+        max_ms = ms;
+        for (u32 i = 0; i < n; ++i) {
+            f32 v = history[(write + HISTORY_SIZE - n + i) % HISTORY_SIZE];
+            sum += v;
+            if (v < min_ms) {
+                min_ms = v;
+            }
+            if (v > max_ms) {
+                max_ms = v;
+            }
+        }
+        avg_ms = sum / (f32)n;
+    }
+
+    f32 fps() const {
+        return avg_ms > 0.0f ? 1000.0f / avg_ms : 0.0f;
+    }
+};
ADD · src/core/globals.h +89 -0
--- a/src/core/globals.h
+++ b/src/core/globals.h
@@ -0,0 +1,89 @@
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+
+typedef int8_t i8;
+typedef int16_t i16;
+typedef int32_t i32;
+typedef int64_t i64;
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef float f32;
+typedef double f64;
+typedef size_t usize;
+
+#define static_global   static
+#define static_local    static
+#define static_internal static
+
+// RHI STUFF, TODO: move
+constexpr u32 REMAINING_MIPS = 0xFFFFFFFF;
+constexpr u32 REMAINING_LAYERS = 0xFFFFFFFF;
+constexpr u64 WHOLE_SIZE = ~0ull;
+
+#define BIT(x) (1u << (x))
+#define ENUM_BIT_OPS(EnumType)                                                                                         \
+    constexpr inline EnumType operator|(EnumType a, EnumType b) noexcept {                                             \
+        return (EnumType)((u32)a | (u32)b);                                                                            \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType operator&(EnumType a, EnumType b) noexcept {                                             \
+        return (EnumType)((u32)a & (u32)b);                                                                            \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType operator~(EnumType a) noexcept {                                                         \
+        return (EnumType)(~(u32)a);                                                                                    \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType &operator|=(EnumType &a, EnumType b) noexcept {                                          \
+        a = a | b;                                                                                                     \
+        return a;                                                                                                      \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType &operator&=(EnumType &a, EnumType b) noexcept {                                          \
+        a = a & b;                                                                                                     \
+        return a;                                                                                                      \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline bool Any(EnumType value, EnumType flags) noexcept {                                               \
+        return ((u32)value & (u32)flags) != 0;                                                                         \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType EnumNot(EnumType a) noexcept {                                                           \
+        return (EnumType)(~(u32)a);                                                                                    \
+    }
+
+// 64‑bit version of ENUM_BIT_OPS for enums whose values exceed 32 bits.
+#define ENUM_BIT_OPS_64(EnumType)                                                                                      \
+    constexpr inline EnumType operator|(EnumType a, EnumType b) noexcept {                                             \
+        return (EnumType)((u64)a | (u64)b);                                                                            \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType operator&(EnumType a, EnumType b) noexcept {                                             \
+        return (EnumType)((u64)a & (u64)b);                                                                            \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType operator~(EnumType a) noexcept {                                                         \
+        return (EnumType)(~(u64)a);                                                                                    \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType &operator|=(EnumType &a, EnumType b) noexcept {                                          \
+        a = a | b;                                                                                                     \
+        return a;                                                                                                      \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType &operator&=(EnumType &a, EnumType b) noexcept {                                          \
+        a = a & b;                                                                                                     \
+        return a;                                                                                                      \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline bool Any(EnumType value, EnumType flags) noexcept {                                               \
+        return ((u64)value & (u64)flags) != 0;                                                                         \
+    }                                                                                                                  \
+                                                                                                                       \
+    constexpr inline EnumType EnumNot(EnumType a) noexcept {                                                           \
+        return (EnumType)(~(u64)a);                                                                                    \
+    }
ADD · src/core/gpu_arena.h +49 -0
--- a/src/core/gpu_arena.h
+++ b/src/core/gpu_arena.h
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include <cassert>
+#include <cstring>
+
+struct Arena {
+    rhi::Buffer buffer;
+    u64 cursor = 0;
+};
+
+inline u64 alloc_from_arena(Arena &a, u64 size, u64 alignment) {
+    auto align_up = [](u64 v, u64 a) { return (v + a - 1) & ~(a - 1); };
+    u64 offset = align_up(a.cursor, alignment ? alignment : 1);
+    // TODO: replace with a growing arena. For now overflow is a hard error.
+    assert(offset + size <= a.buffer.desc.size && "Arena overflow");
+    if (offset + size > a.buffer.desc.size) {
+        return UINT64_MAX;
+    }
+    a.cursor = offset + size;
+    return offset;
+}
+
+inline void reset_arena(Arena &a) {
+    a.cursor = 0;
+}
+
+static bool create_arena(rhi::Device &dev, Arena &out, rhi::BufferDesc desc, rhi::BufferViewDesc view_desc) {
+    (void)view_desc;
+    if (!rhi::create_buffer(dev, desc, out.buffer)) {
+        return false;
+    }
+    out.cursor = 0;
+    return true;
+}
+
+static void destroy_arena(rhi::Device &dev, Arena &arena) {
+    rhi::destroy_buffer(dev, arena.buffer);
+    arena = {};
+}
+
+inline u64 stage_to_arena(Arena &arena, const void *src, u64 size) {
+    u64 offset = alloc_from_arena(arena, size, 16);
+    if (offset == UINT64_MAX) {
+        return UINT64_MAX;
+    }
+    memcpy(static_cast<u8 *>(arena.buffer.mapped) + offset, src, size);
+    return offset;
+}
ADD · src/core/logger.cpp +67 -0
--- a/src/core/logger.cpp
+++ b/src/core/logger.cpp
@@ -0,0 +1,67 @@
+#include "logger.h"
+
+#include <plog/Appenders/ColorConsoleAppender.h>
+#include <plog/Appenders/DynamicAppender.h>
+#include <plog/Appenders/RollingFileAppender.h>
+#include <plog/Formatters/TxtFormatter.h>
+#include <plog/Init.h>
+#include <plog/Record.h>
+
+namespace vel {
+
+namespace {
+
+plog::ColorConsoleAppender<plog::TxtFormatter> CONSOLE_APPENDER;
+plog::RollingFileAppender<plog::TxtFormatter> FILE_APPENDER("logs/vel-renderer.log", 1024 * 1024 * 5, 3);
+plog::DynamicAppender APPENDERS;
+bool INITIALIZED = false;
+
+plog::Severity to_plog_severity(VelLogLevel level) {
+    switch (level) {
+    case VelLogLevel::Trace:
+        return plog::verbose;
+    case VelLogLevel::Debug:
+        return plog::debug;
+    case VelLogLevel::Info:
+        return plog::info;
+    case VelLogLevel::Warn:
+        return plog::warning;
+    case VelLogLevel::Error:
+        return plog::error;
+    case VelLogLevel::Critical:
+        return plog::fatal;
+    }
+
+    return plog::none;
+}
+
+} // namespace
+
+void Logger::init() {
+    if (INITIALIZED) {
+        return;
+    }
+
+    APPENDERS.addAppender(&FILE_APPENDER);
+    APPENDERS.addAppender(&CONSOLE_APPENDER);
+    plog::init(plog::verbose, &APPENDERS);
+    INITIALIZED = true;
+}
+
+void Logger::shutdown() {
+    if (plog::Logger<PLOG_DEFAULT_INSTANCE_ID> *logger = plog::get()) {
+        logger->setMaxSeverity(plog::none);
+    }
+
+    INITIALIZED = false;
+}
+
+void Logger::log(VelLogLevel level, const char *file, std::size_t line, const std::string &message) {
+    if (plog::Logger<PLOG_DEFAULT_INSTANCE_ID> *logger = plog::get()) {
+        plog::Record record(to_plog_severity(level), "", line, file, nullptr, PLOG_DEFAULT_INSTANCE_ID);
+        record << message;
+        logger->write(record);
+    }
+}
+
+} // namespace vel
ADD · src/core/logger.h +46 -0
--- a/src/core/logger.h
+++ b/src/core/logger.h
@@ -0,0 +1,46 @@
+#pragma once
+#include <cstddef>
+#include <format>
+#include <string>
+
+namespace vel {
+
+enum class VelLogLevel {
+    Trace,
+    Debug,
+    Info,
+    Warn,
+    Error,
+    Critical
+};
+
+class Logger {
+  public:
+    static void init();
+    static void shutdown();
+
+    static void log(VelLogLevel level, const char *file, std::size_t line, const std::string &message);
+
+    template <typename... Args>
+    static void
+    log(VelLogLevel level, const char *file, std::size_t line, std::format_string<Args...> fmt, Args &&...args) {
+        log(level, file, line, std::format(fmt, std::forward<Args>(args)...));
+    }
+};
+
+} // namespace vel
+
+#define VEL_TRACE(...)    ::vel::Logger::log(::vel::VelLogLevel::Trace, __FILE__, __LINE__, __VA_ARGS__)
+#define VEL_DEBUG(...)    ::vel::Logger::log(::vel::VelLogLevel::Debug, __FILE__, __LINE__, __VA_ARGS__)
+#define VEL_INFO(...)     ::vel::Logger::log(::vel::VelLogLevel::Info, __FILE__, __LINE__, __VA_ARGS__)
+#define VEL_WARN(...)     ::vel::Logger::log(::vel::VelLogLevel::Warn, __FILE__, __LINE__, __VA_ARGS__)
+#define VEL_ERROR(...)    ::vel::Logger::log(::vel::VelLogLevel::Error, __FILE__, __LINE__, __VA_ARGS__)
+#define VEL_CRITICAL(...) ::vel::Logger::log(::vel::VelLogLevel::Critical, __FILE__, __LINE__, __VA_ARGS__)
+
+// Release-safe handle validity check
+#define VEL_ASSERT_HANDLE(h, msg)                                                                                      \
+    do {                                                                                                               \
+        if ((h) == 0) {                                                                                                \
+            VEL_CRITICAL(msg);                                                                                         \
+        }                                                                                                              \
+    } while (false)
ADD · src/core/math_rtm.cpp +206 -0
--- a/src/core/math_rtm.cpp
+++ b/src/core/math_rtm.cpp
@@ -0,0 +1,206 @@
+#include "math_rtm.h"
+
+#include <algorithm>
+#include <cmath>
+
+// reverse-z layout, inf far plane
+mat4 perspective(f32 fovy, f32 aspect, f32 world_near_plane, f32 world_far_plane, f32 clip_near_z, f32 clip_far_z) {
+    f32 f = 1.0f / tanf(fovy * 0.5f);
+    mat4 r = {};
+
+    r.m[0] = f / aspect; // x scale
+    r.m[5] = f;          // y scale
+
+    r.m[11] = 1.0f; // z into .w for perspective divice
+
+    // finite reverse Z
+    if (world_far_plane > 0.0f) {
+        f32 depth_range = world_far_plane - world_near_plane;
+        r.m[10] = (world_far_plane * clip_far_z - world_near_plane * clip_near_z) / depth_range;
+        r.m[14] = (world_near_plane * world_far_plane * (clip_near_z - clip_far_z)) / depth_range;
+    }
+    // default infinite reverse Z
+    else {
+        r.m[10] = clip_far_z;
+        r.m[11] = 1.0f;
+        r.m[14] = world_near_plane * (clip_near_z - clip_far_z);
+    }
+
+    return r;
+}
+
+// left-handed view mat for  (v * M)
+// left handed to really just match the convention,
+// geom at higher world depth == positive, increasing view space Z
+// maps directly into depth buffers without me doing a negative Z negation step
+// and generally, it just keeps me sane doing all the view space culling stuff
+// world space -> view Space (+X: Right, +Y: Up, +Z: Forward)
+mat4 look_at(vec3 eye, vec3 center, vec3 up) {
+    vec3 f = vec3({center.x - eye.x, center.y - eye.y, center.z - eye.z}).normalized();
+    vec3 r = cross(f, up).normalized();
+    vec3 u = cross(r, f).normalized();
+
+    mat4 m = {};
+
+    // each row: camera basis vectors (r, -u, f)
+    // clang-format off
+    m.m[0] = r.x; m.m[1] = -u.x; m.m[2] = f.x;  m.m[3] = 0.0f;  // x (rgt)
+    m.m[4] = r.y; m.m[5] = -u.y; m.m[6] = f.y;  m.m[7] = 0.0f;  // y (up)
+    m.m[8] = r.z; m.m[9] = -u.z; m.m[10] = f.z; m.m[11] = 0.0f; // z (fwd)
+    // camera ws translation projected onto it's local axes
+    m.m[12] = -r.dot(eye); m.m[13] = u.dot(eye); m.m[14] = -f.dot(eye); m.m[15] = 1.0f;
+    // clang-format on
+
+    return m;
+}
+
+mat4 ortho(f32 width, f32 height, f32 near_plane, f32 far_plane) {
+    mat4 r = {};
+
+    // row 0, x: [-width/2, width/2] -> [-1.0f, 1.0f]
+    r.m[0] = 2.0f / width;
+    r.m[1] = 0.0f;
+    r.m[2] = 0.0f;
+    r.m[3] = 0.0f;
+
+    // row 1, y: [-height/2, height/2] -> [-1.0, 1.0]
+    r.m[4] = 0.0f;
+    r.m[5] = 2.0f / height;
+    r.m[6] = 0.0f;
+    r.m[7] = 0.0f;
+
+    // row 2, Z slope (reverse-Z: near -> 1.0f, far -> 0.0f)
+    // same as look_at, left handed +Z forward
+    r.m[8] = 0.0f;
+    r.m[9] = 0.0f;
+    r.m[10] = 1.0f / (near_plane - far_plane);
+    r.m[11] = 0.0f;
+
+    // row 3, translation (Z offset)
+    // z_ndc = z * (1/(near-far) + (far / (far- near)))
+    r.m[12] = 0.0f;
+    r.m[13] = 0.0f;
+    r.m[14] = far_plane / (far_plane - near_plane);
+    r.m[15] = 1.0f;
+
+    return r;
+}
+
+mat4 ortho_offcenter(f32 left, f32 right, f32 bottom, f32 top, f32 near_plane, f32 far_plane) {
+    mat4 r = {};
+
+    f32 inv_w = 1.0f / (right - left);
+    f32 inv_h = 1.0f / (top - bottom);
+
+    // row 0, x
+    r.m[0] = 2.0f * inv_w;
+    r.m[1] = 0.0f;
+    r.m[2] = 0.0f;
+    r.m[3] = 0.0f;
+
+    // row 1, y
+    r.m[4] = 0.0f;
+    r.m[5] = 2.0f * inv_h;
+    r.m[6] = 0.0f;
+    r.m[7] = 0.0f;
+
+    // row 2, reverse z
+    r.m[8] = 0.0f;
+    r.m[9] = 0.0f;
+    r.m[10] = 1.0f / (near_plane - far_plane);
+    r.m[11] = 0.0f;
+
+    // row 3 translations
+    r.m[12] = -(right + left) * inv_w;
+    r.m[13] = -(top + bottom) * inv_h;
+    r.m[14] = far_plane / (far_plane - near_plane);
+    r.m[15] = 1.0f;
+
+    return r;
+}
+
+mat4 rotate(vec3 axis, f32 angle_rad) {
+    vec_work axis_v = rtm::vector_normalize3(rtm::vector_set(axis.x, axis.y, axis.z));
+    rtm::quatf q = rtm::quat_from_axis_angle(axis_v, angle_rad);
+    rtm::matrix3x4f rot = rtm::matrix_from_rotation(q);
+    return mat4::from_matrix(rtm::matrix_cast(rot));
+}
+
+mat4 inverse(mat4 m) {
+    rtm::matrix4x4f inv = rtm::matrix_inverse(m.to_matrix());
+    mat4 r;
+    rtm::vector_store(inv.x_axis, &r.m[0]);
+    rtm::vector_store(inv.y_axis, &r.m[4]);
+    rtm::vector_store(inv.z_axis, &r.m[8]);
+    rtm::vector_store(inv.w_axis, &r.m[12]);
+    return r;
+}
+
+// w 1.0
+vec4 transform_point(const vec3 &v, const mat4 &m) {
+    vec_work vv = rtm::vector_set(v.x, v.y, v.z, 1.0f);
+    return vec4::from_vec4(rtm::matrix_mul_vector(vv, m.to_matrix()));
+}
+
+vec3 transform_direction(const vec3 &v, const mat4 &m) {
+    vec_work vv = rtm::vector_set(v.x, v.y, v.z, 0.0f);
+    return vec3::from_vec4(rtm::matrix_mul_vector(vv, m.to_matrix()));
+}
+
+mat4 trs_to_mat4(const TRS &trs) {
+    rtm::matrix3x4f t =
+        rtm::matrix_from_translation(rtm::vector_set(trs.translation.x, trs.translation.y, trs.translation.z));
+    rtm::matrix3x4f r = rtm::matrix_from_rotation(trs.rotation);
+    rtm::matrix3x4f s = rtm::matrix_from_scale(rtm::vector_set(trs.scale.x, trs.scale.y, trs.scale.z));
+    // s * r * t
+    rtm::matrix3x4f sr = rtm::matrix_mul(s, r);
+    rtm::matrix3x4f trs_m = rtm::matrix_mul(sr, t);
+    return mat4::from_matrix(rtm::matrix_cast(trs_m));
+}
+
+TRS mat4_to_trs(const mat4 &m) {
+    rtm::matrix4x4f m4 = m.to_matrix();
+    rtm::matrix3x4f m34;
+    m34.x_axis = m4.x_axis;
+    m34.y_axis = m4.y_axis;
+    m34.z_axis = m4.z_axis;
+    m34.w_axis = m4.w_axis;
+
+    // translation is column 3
+    vec3 t = vec3::from_vec4(m34.w_axis);
+
+    // rot from 3x3 part
+    quat r;
+    r.q = rtm::quat_from_matrix(m34);
+    r.q = rtm::quat_normalize(r.q);
+
+    // scale = length of each column vector of the 3x3 part
+    vec3 s(
+        rtm::scalar_cast(rtm::vector_length3_as_scalar(m34.x_axis)),
+        rtm::scalar_cast(rtm::vector_length3_as_scalar(m34.y_axis)),
+        rtm::scalar_cast(rtm::vector_length3_as_scalar(m34.z_axis))
+    );
+
+    return {t, r, s};
+}
+
+vec3 quat_to_euler(const quat &q) {
+    // rot matrix for q (row-vector convention), via the T*R*S path with identity T/S.
+    const mat4 m = trs_to_mat4(TRS{vec3(0.0f), q, vec3(1.0f)});
+    // RTM stores each mat row as vector type: element [row][col] = m.m[row*4 + col].
+    const f32 m00 = m.m[0];
+    const f32 m01 = m.m[1];
+    const f32 m02 = m.m[2];
+    const f32 m12 = m.m[6];
+    const f32 m22 = m.m[10];
+
+    f32 pitch = std::asin(std::min(1.0f, std::max(-1.0f, m02)));
+    f32 yaw = std::atan2(m01, m00);
+    f32 roll = std::atan2(-m12, m22);
+
+    return {degrees(pitch), degrees(yaw), degrees(roll)};
+}
+
+quat euler_to_quat(const vec3 &euler) {
+    return rtm::quat_from_euler(radians(euler.x), radians(euler.y), radians(euler.z));
+}
ADD · src/core/math_rtm.h +538 -0
--- a/src/core/math_rtm.h
+++ b/src/core/math_rtm.h
@@ -0,0 +1,538 @@
+#pragma once
+
+#include <rtm/math.h>
+#include <rtm/matrix3x4f.h>
+#include <rtm/matrix4x4f.h>
+#include <rtm/quatf.h>
+#include <rtm/vector4f.h>
+
+#include "core/globals.h"
+
+using vec_work = rtm::vector4f;
+
+inline f32 radians(f32 deg) {
+    return deg * 0.01745329251994329577f; // π / 180
+}
+
+inline f32 degrees(f32 rad) {
+    return rad * 57.295779513082320876f; // 180 / π
+}
+
+struct vec2 {
+    f32 x, y;
+
+    //
+    // constructors
+    //
+
+    constexpr vec2() : x(0), y(0) {
+    }
+
+    constexpr explicit vec2(f32 s) : x(s), y(s) {
+    }
+
+    constexpr vec2(f32 x_, f32 y_) : x(x_), y(y_) {
+    }
+
+    //
+    // SIMD bridge
+    //
+
+    static inline vec2 from_vec4(const vec_work &v) {
+        vec2 result;
+        rtm::vector_store2(v, &result.x);
+        return result;
+    }
+
+    inline vec_work to_vec4() const {
+        return rtm::vector_load2(&x);
+    }
+
+    //
+    // operators
+    //
+
+    inline vec2 operator+(const vec2 &rhs) const {
+        return from_vec4(rtm::vector_add(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec2 operator-(const vec2 &rhs) const {
+        return from_vec4(rtm::vector_sub(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec2 operator-() const {
+        return from_vec4(rtm::vector_neg(to_vec4()));
+    }
+
+    inline vec2 operator*(f32 s) const {
+        return from_vec4(rtm::vector_mul(to_vec4(), s));
+    }
+
+    inline vec2 operator/(f32 s) const {
+        return from_vec4(rtm::vector_div(to_vec4(), rtm::vector_set(s)));
+    }
+
+    inline vec2 &operator+=(const vec2 &rhs) {
+        *this = *this + rhs;
+        return *this;
+    }
+
+    inline vec2 &operator-=(const vec2 &rhs) {
+        *this = *this - rhs;
+        return *this;
+    }
+
+    inline vec2 &operator*=(f32 s) {
+        *this = *this * s;
+        return *this;
+    }
+
+    inline vec2 &operator/=(f32 s) {
+        *this = *this / s;
+        return *this;
+    }
+
+    //
+    // methods
+    //
+
+    inline f32 dot(const vec2 &rhs) const {
+        return rtm::scalar_cast(rtm::vector_dot2_as_scalar(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline f32 length() const {
+        vec_work vv = to_vec4();
+
+        rtm::scalarf len_sq = rtm::vector_dot2_as_scalar(vv, vv);
+
+        return rtm::scalar_cast(rtm::scalar_sqrt(len_sq));
+    }
+
+    inline f32 length_squared() const {
+        return rtm::scalar_cast(rtm::vector_dot2_as_scalar(to_vec4(), to_vec4()));
+    }
+
+    inline vec2 normalized() const {
+        return from_vec4(rtm::vector_normalize2(to_vec4()));
+    }
+};
+
+inline vec2 operator*(f32 s, const vec2 &v) {
+    return v * s;
+}
+
+struct vec3 {
+    f32 x, y, z;
+
+    //
+    // constructors
+    //
+
+    constexpr vec3() : x(0), y(0), z(0) {
+    }
+
+    constexpr explicit vec3(f32 s) : x(s), y(s), z(s) {
+    }
+
+    constexpr vec3(f32 x_, f32 y_, f32 z_) : x(x_), y(y_), z(z_) {
+    }
+
+    //
+    // SIMD bridge
+    //
+
+    static inline vec3 from_vec4(const vec_work &v) {
+        vec3 result;
+        rtm::vector_store3(v, &result.x);
+        return result;
+    }
+
+    inline vec_work to_vec4() const {
+        return rtm::vector_load3(&x);
+    }
+
+    //
+    // operators
+    //
+
+    inline vec3 operator+(const vec3 &rhs) const {
+        return from_vec4(rtm::vector_add(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec3 operator-(const vec3 &rhs) const {
+        return from_vec4(rtm::vector_sub(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec3 operator-() const {
+        return from_vec4(rtm::vector_neg(to_vec4()));
+    }
+
+    inline vec3 operator*(f32 s) const {
+        return from_vec4(rtm::vector_mul(to_vec4(), s));
+    }
+
+    inline vec3 operator-(f32 s) const {
+        return from_vec4(rtm::vector_sub(to_vec4(), rtm::vector_set(s)));
+    }
+
+    inline vec3 operator/(f32 s) const {
+        return from_vec4(rtm::vector_div(to_vec4(), rtm::vector_set(s)));
+    }
+
+    inline vec3 &operator+=(const vec3 &rhs) {
+        *this = *this + rhs;
+        return *this;
+    }
+
+    inline vec3 &operator-=(const vec3 &rhs) {
+        *this = *this - rhs;
+        return *this;
+    }
+
+    inline vec3 &operator*=(f32 s) {
+        *this = *this * s;
+        return *this;
+    }
+
+    inline vec3 &operator/=(f32 s) {
+        *this = *this / s;
+        return *this;
+    }
+
+    //
+    // methods
+    //
+
+    inline f32 dot(const vec3 &rhs) const {
+        return rtm::scalar_cast(rtm::vector_dot3_as_scalar(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline f32 length() const {
+        vec_work vv = to_vec4();
+
+        rtm::scalarf len_sq = rtm::vector_dot3_as_scalar(vv, vv);
+
+        return rtm::scalar_cast(rtm::scalar_sqrt(len_sq));
+    }
+
+    inline f32 length_squared() const {
+        return rtm::scalar_cast(rtm::vector_dot3_as_scalar(to_vec4(), to_vec4()));
+    }
+
+    inline vec3 normalized() const {
+        return from_vec4(rtm::vector_normalize3(to_vec4()));
+    }
+};
+
+inline vec3 operator*(f32 s, const vec3 &v) {
+    return v * s;
+}
+
+inline vec3 cross(const vec3 &a, const vec3 &b) {
+    return vec3::from_vec4(rtm::vector_cross3(a.to_vec4(), b.to_vec4()));
+}
+
+struct vec4 {
+    f32 x, y, z, w;
+
+    //
+    // constructors
+    //
+
+    constexpr vec4() : x(0), y(0), z(0), w(0) {
+    }
+
+    constexpr explicit vec4(f32 s) : x(s), y(s), z(s), w(s) {
+    }
+
+    constexpr vec4(f32 x_, f32 y_, f32 z_, f32 w_) : x(x_), y(y_), z(z_), w(w_) {
+    }
+
+    //
+    // SIMD bridge
+    //
+
+    static inline vec4 from_vec4(const vec_work &v) {
+        vec4 result;
+        rtm::vector_store(v, &result.x);
+        return result;
+    }
+
+    inline vec_work to_vec4() const {
+        return rtm::vector_load(&x);
+    }
+
+    //
+    // operators
+    //
+
+    inline vec4 operator+(const vec4 &rhs) const {
+        return from_vec4(rtm::vector_add(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec4 operator-(const vec4 &rhs) const {
+        return from_vec4(rtm::vector_sub(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline vec4 operator-() const {
+        return from_vec4(rtm::vector_neg(to_vec4()));
+    }
+
+    inline vec4 operator*(f32 s) const {
+        return from_vec4(rtm::vector_mul(to_vec4(), s));
+    }
+
+    inline vec4 operator/(f32 s) const {
+        return from_vec4(rtm::vector_div(to_vec4(), rtm::vector_set(s)));
+    }
+
+    inline vec4 &operator+=(const vec4 &rhs) {
+        *this = *this + rhs;
+        return *this;
+    }
+
+    inline vec4 &operator-=(const vec4 &rhs) {
+        *this = *this - rhs;
+        return *this;
+    }
+
+    inline vec4 &operator*=(f32 s) {
+        *this = *this * s;
+        return *this;
+    }
+
+    inline vec4 &operator/=(f32 s) {
+        *this = *this / s;
+        return *this;
+    }
+
+    //
+    // methods
+    //
+
+    inline f32 dot(const vec4 &rhs) const {
+        return rtm::scalar_cast(rtm::vector_dot_as_scalar(to_vec4(), rhs.to_vec4()));
+    }
+
+    inline f32 length() const {
+        vec_work vv = to_vec4();
+
+        rtm::scalarf len_sq = rtm::vector_dot_as_scalar(vv, vv);
+
+        return rtm::scalar_cast(rtm::scalar_sqrt(len_sq));
+    }
+
+    inline f32 length_squared() const {
+        return rtm::scalar_cast(rtm::vector_dot_as_scalar(to_vec4(), to_vec4()));
+    }
+
+    inline vec4 normalized() const {
+        return from_vec4(rtm::vector_normalize(to_vec4()));
+    }
+};
+
+inline vec4 operator*(f32 s, const vec4 &v) {
+    return v * s;
+}
+
+struct mat3 {
+    f32 m[9]; // column-major: col * 3 + row
+
+    mat3() = default;
+
+    explicit mat3(f32 diag) {
+        m[0] = diag;
+        m[3] = 0;
+        m[6] = 0;
+        m[1] = 0;
+        m[4] = diag;
+        m[7] = 0;
+        m[2] = 0;
+        m[5] = 0;
+        m[8] = diag;
+    }
+};
+
+struct mat4 {
+    f32 m[16];
+
+    //
+    // column access
+    //
+
+    inline f32 *operator[](int col) {
+        return &m[col * 4];
+    }
+
+    inline const f32 *operator[](int col) const {
+        return &m[col * 4];
+    }
+
+    //
+    // SIMD bridge
+    //
+
+    static inline mat4 from_matrix(const rtm::matrix4x4f &mat) {
+        mat4 result;
+        rtm::vector_store(mat.x_axis, &result.m[0]);
+        rtm::vector_store(mat.y_axis, &result.m[4]);
+        rtm::vector_store(mat.z_axis, &result.m[8]);
+        rtm::vector_store(mat.w_axis, &result.m[12]);
+        return result;
+    }
+
+    inline rtm::matrix4x4f to_matrix() const {
+        return rtm::matrix4x4f{
+            rtm::vector_load(&m[0]), rtm::vector_load(&m[4]), rtm::vector_load(&m[8]), rtm::vector_load(&m[12])
+        };
+    }
+};
+
+inline mat4 identity() {
+    return mat4::from_matrix(rtm::matrix_identity());
+}
+
+inline mat4 translate(vec3 t) {
+    rtm::matrix3x4f m34 = rtm::matrix_from_translation(rtm::vector_set(t.x, t.y, t.z));
+    return mat4::from_matrix(rtm::matrix_cast(m34));
+}
+
+inline mat4 scale(vec3 s) {
+    rtm::matrix3x4f m34 = rtm::matrix_from_scale(rtm::vector_set(s.x, s.y, s.z));
+    return mat4::from_matrix(rtm::matrix_cast(m34));
+}
+
+mat4 rotate(vec3 axis, f32 angle_rad);
+mat4 inverse(mat4 m);
+
+// w 1.0
+vec4 transform_point(const vec3 &v, const mat4 &m);
+
+// w 0.0
+vec3 transform_direction(const vec3 &v, const mat4 &m);
+
+inline vec4 operator*(const mat4 &m, const vec4 &v) {
+    return vec4::from_vec4(rtm::matrix_mul_vector(v.to_vec4(), m.to_matrix()));
+}
+
+inline mat4 operator*(const mat4 &a, const mat4 &b) {
+    return mat4::from_matrix(rtm::matrix_mul(a.to_matrix(), b.to_matrix()));
+}
+
+inline mat4 transpose(const mat4 &m) {
+    return mat4::from_matrix(rtm::matrix_transpose(m.to_matrix()));
+}
+
+inline mat3 m3_from_mat4(const mat4 &m) {
+    mat3 r;
+
+    // column 0
+    r.m[0] = m.m[0];
+    r.m[1] = m.m[1];
+    r.m[2] = m.m[2];
+
+    // column 1
+    r.m[3] = m.m[4];
+    r.m[4] = m.m[5];
+    r.m[5] = m.m[6];
+
+    // column 2
+    r.m[6] = m.m[8];
+    r.m[7] = m.m[9];
+    r.m[8] = m.m[10];
+
+    return r;
+}
+
+inline vec3 operator*(const mat3 &m, const vec3 &v) {
+    return {
+        m.m[0] * v.x + m.m[3] * v.y + m.m[6] * v.z,
+        m.m[1] * v.x + m.m[4] * v.y + m.m[7] * v.z,
+        m.m[2] * v.x + m.m[5] * v.y + m.m[8] * v.z
+    };
+}
+
+mat4 ortho(f32 width, f32 height, f32 near_plane, f32 far_plane);
+mat4 look_at(vec3 eye, vec3 center, vec3 up);
+mat4 perspective(
+    f32 fovy,
+    f32 aspect,
+    f32 world_near_plane,
+    f32 world_far_plane = 0.0f,
+    f32 clip_near_z = 1.0f,
+    f32 clip_far_z = 0.0f
+);
+// [0, 1] helper
+static inline mat4 perspective_standard_z(f32 fovy, f32 aspect, f32 near_plane, f32 far_plane) {
+    return perspective(fovy, aspect, near_plane, far_plane, 0.0f, 1.0f);
+}
+mat4 ortho_offcenter(f32 left, f32 right, f32 bottom, f32 top, f32 near_plane, f32 far_plane);
+
+static_assert(sizeof(vec2) == 8, "vec2 must be 8 bytes");
+static_assert(sizeof(vec3) == 12, "vec3 must be 12 bytes");
+static_assert(sizeof(vec4) == 16, "vec4 must be 16 bytes");
+static_assert(sizeof(mat3) == 36, "mat3 must be 36 bytes");
+static_assert(sizeof(mat4) == 64, "mat4 must be 64 bytes");
+
+static_assert(std::is_trivially_copyable_v<vec2>);
+static_assert(std::is_trivially_copyable_v<vec3>);
+static_assert(std::is_trivially_copyable_v<vec4>);
+static_assert(std::is_trivially_copyable_v<mat3>);
+static_assert(std::is_trivially_copyable_v<mat4>);
+
+static_assert(std::is_standard_layout_v<vec2>);
+static_assert(std::is_standard_layout_v<vec3>);
+static_assert(std::is_standard_layout_v<vec4>);
+static_assert(std::is_standard_layout_v<mat3>);
+static_assert(std::is_standard_layout_v<mat4>);
+
+// =========================================================================
+// Quaternion (WIP)
+// =========================================================================
+
+struct quat {
+    rtm::quatf q;
+
+    quat() : q(rtm::quat_identity()) {
+    }
+
+    quat(const rtm::quatf &q_) : q(q_) {
+    }
+
+    static quat from_axis_angle(const vec3 &axis, f32 angle_rad) {
+        return rtm::quat_from_axis_angle(rtm::vector_normalize3(rtm::vector_set(axis.x, axis.y, axis.z)), angle_rad);
+    }
+
+    quat operator*(const quat &rhs) const {
+        return rtm::quat_mul(q, rhs.q);
+    }
+
+    quat normalized() const {
+        return rtm::quat_normalize(q);
+    }
+
+    operator rtm::quatf() const {
+        return q;
+    }
+};
+
+static_assert(sizeof(quat) == 16, "quat must be 16 bytes");
+static_assert(std::is_trivially_copyable_v<quat>);
+
+// =========================================================================
+// TRS decomposition
+// =========================================================================
+
+struct TRS {
+    vec3 translation = vec3(0.0f);
+    quat rotation;
+    vec3 scale = vec3(1.0f);
+};
+
+mat4 trs_to_mat4(const TRS &trs);
+TRS mat4_to_trs(const mat4 &m);
+
+// euler angles in degrees, (pitch, yaw, roll) = (x, y, z).
+// matches rtm::quat_from_euler's convention (pitch about Y, yaw about Z, roll about X).
+vec3 quat_to_euler(const quat &q);
+quat euler_to_quat(const vec3 &euler);
ADD · src/core/platform.cpp +338 -0
--- a/src/core/platform.cpp
+++ b/src/core/platform.cpp
@@ -0,0 +1,338 @@
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define GLFW_EXPOSE_NATIVE_WIN32
+#include <dwmapi.h>
+#include <windows.h>
+#endif
+
+#include "platform.h"
+
+#include <GLFW/glfw3.h>
+#include <cassert>
+#include <cstdlib>
+
+#ifdef _WIN32
+#include <GLFW/glfw3native.h>
+#endif
+
+#include "core/logger.h"
+
+static GLFWwindow *as_glfw(PlatformWindow *w) {
+    return reinterpret_cast<GLFWwindow *>(w);
+}
+static PlatformWindow *as_platform(GLFWwindow *w) {
+    return reinterpret_cast<PlatformWindow *>(w);
+}
+
+#ifdef _WIN32
+static void apply_dark_titlebar(GLFWwindow *window) {
+    HWND hwnd = glfwGetWin32Window(window);
+    BOOL dark = TRUE;
+    if (FAILED(DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &dark, sizeof(dark)))) {
+        DwmSetWindowAttribute(hwnd, 19, &dark, sizeof(dark));
+    }
+}
+#endif
+
+void toggle_capture(Platform &platform) {
+    platform.captured = !platform.captured;
+
+    platform.pending_mouse_dx = 0.0f;
+    platform.pending_mouse_dy = 0.0f;
+    platform.first_mouse_sample = true;
+
+    if (platform.captured) {
+        glfwGetCursorPos(as_glfw(platform.window), &platform.last_mouse_x, &platform.last_mouse_y);
+        glfwSetInputMode(as_glfw(platform.window), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
+
+        // raw input, TODO: actually validate?
+        if (glfwRawMouseMotionSupported()) {
+            glfwSetInputMode(as_glfw(platform.window), GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
+        }
+    } else {
+        glfwSetInputMode(as_glfw(platform.window), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
+        glfwSetInputMode(as_glfw(platform.window), GLFW_RAW_MOUSE_MOTION, GLFW_FALSE);
+        platform.input = {};
+    }
+}
+
+void cursor_position_callback(GLFWwindow *window, f64 xpos, f64 ypos) {
+    Platform *platform = static_cast<Platform *>(glfwGetWindowUserPointer(window));
+    if (!platform || !platform->captured) {
+        return;
+    }
+
+    if (platform->first_mouse_sample) {
+        platform->last_mouse_x = xpos;
+        platform->last_mouse_y = ypos;
+        platform->first_mouse_sample = false;
+        return;
+    }
+
+    // accumulate ALL sub-frame mouse events from high-polling mice (1000Hz+)
+    platform->pending_mouse_dx += static_cast<f32>(xpos - platform->last_mouse_x);
+    platform->pending_mouse_dy += static_cast<f32>(ypos - platform->last_mouse_y);
+
+    platform->last_mouse_x = xpos;
+    platform->last_mouse_y = ypos;
+}
+
+void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) {
+    Platform *platform = static_cast<Platform *>(glfwGetWindowUserPointer(window));
+    if (!platform) {
+        return;
+    }
+
+    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
+        glfwSetWindowShouldClose(window, GLFW_TRUE);
+        return;
+    }
+
+    if (key == GLFW_KEY_L && action == GLFW_PRESS) {
+        toggle_capture(*platform);
+        return;
+    }
+
+    if (!platform->captured) {
+        return;
+    }
+
+    // ignore key repeat events sent by the OS
+    if (action == GLFW_REPEAT) {
+        return;
+    }
+
+    const bool pressed = (action == GLFW_PRESS);
+    switch (key) {
+    case GLFW_KEY_W:
+        platform->input.move_forward = pressed;
+        break;
+    case GLFW_KEY_S:
+        platform->input.move_backward = pressed;
+        break;
+    case GLFW_KEY_A:
+        platform->input.move_left = pressed;
+        break;
+    case GLFW_KEY_D:
+        platform->input.move_right = pressed;
+        break;
+    case GLFW_KEY_E:
+        platform->input.move_up = pressed;
+        break;
+    case GLFW_KEY_Q:
+        platform->input.move_down = pressed;
+        break;
+    case GLFW_KEY_LEFT_SHIFT:
+    case GLFW_KEY_RIGHT_SHIFT:
+        platform->input.fast = pressed;
+        break;
+    default:
+        break;
+    }
+}
+
+void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) {
+    Platform *platform = static_cast<Platform *>(glfwGetWindowUserPointer(window));
+    if (!platform) {
+        return;
+    }
+
+    if (button == GLFW_MOUSE_BUTTON_5 && action == GLFW_PRESS) {
+        toggle_capture(*platform);
+    }
+}
+
+void window_focus_callback(GLFWwindow *window, int focused) {
+    Platform *platform = static_cast<Platform *>(glfwGetWindowUserPointer(window));
+    if (!platform) {
+        return;
+    }
+
+    if (!focused) {
+        // clear inputs immediately on Alt-Tab so keys don't get stuck down
+        platform->input = {};
+        platform->pending_mouse_dx = 0.0f;
+        platform->pending_mouse_dy = 0.0f;
+        platform->first_mouse_sample = true;
+    } else if (platform->captured) {
+        platform->first_mouse_sample = true;
+    }
+}
+
+void framebuffer_resize_callback(GLFWwindow *window, int width, int height) {
+    Platform *platform = static_cast<Platform *>(glfwGetWindowUserPointer(window));
+    if (platform) {
+        platform->framebuffer_resized = true;
+        platform->width = static_cast<u32>(width);
+        platform->height = static_cast<u32>(height);
+    }
+}
+
+void init_platform(std::vector<const char *> &extensions) {
+    VEL_INFO("[GLFW] Initializing");
+    glfwInit();
+#ifndef RHI_BACKEND_METAL
+    // Vulkan needs GLFW's required instance extensions; Metal needs none.
+    if (!glfwVulkanSupported()) {
+        std::abort();
+    }
+    u32 extension_count = 0;
+    const char **glfw_extensions = glfwGetRequiredInstanceExtensions(&extension_count);
+    for (u32 i = 0; i < extension_count; ++i) {
+        extensions.push_back(glfw_extensions[i]);
+    }
+#endif
+}
+
+void create_window(rhi::Device &device, Platform &platform, const char *windowTitle, WindowMode mode, bool resizable) {
+    VEL_INFO("[GLFW] Initializing window");
+    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+    glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
+
+    GLFWmonitor *monitor = glfwGetPrimaryMonitor();
+    const GLFWvidmode *video = glfwGetVideoMode(monitor);
+    GLFWmonitor *target_monitor = nullptr;
+
+    int w = platform.width;
+    int h = platform.height;
+    switch (mode) {
+    case WindowMode::Fullscreen: {
+        target_monitor = monitor;
+        w = video->width;
+        h = video->height;
+        glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
+        glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
+    } break;
+
+    case WindowMode::Maximized: {
+        w = video->width;
+        h = video->height;
+        glfwWindowHint(GLFW_DECORATED, GLFW_TRUE);
+        glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
+    } break;
+
+    case WindowMode::Windowed:
+    default: {
+        assert(platform.width > 0 && platform.height > 0);
+        glfwWindowHint(GLFW_DECORATED, GLFW_TRUE);
+        glfwWindowHint(GLFW_RESIZABLE, resizable ? GLFW_TRUE : GLFW_FALSE);
+    } break;
+    }
+
+    platform.window = as_platform(glfwCreateWindow(w, h, windowTitle, target_monitor, nullptr));
+    if (!platform.window) {
+        VEL_CRITICAL("[GLFW] Failed to create window");
+        std::abort();
+    }
+
+#ifdef _WIN32
+    apply_dark_titlebar(as_glfw(platform.window));
+#endif
+
+    if (mode == WindowMode::Maximized) {
+        glfwMaximizeWindow(as_glfw(platform.window));
+    } else if (mode == WindowMode::Windowed) {
+        int mx, my;
+        glfwGetMonitorPos(monitor, &mx, &my);
+        glfwSetWindowPos(as_glfw(platform.window), mx + (video->width - w) / 2, my + (video->height - h) / 2);
+    }
+
+    glfwSetWindowUserPointer(as_glfw(platform.window), &platform);
+
+    glfwSetFramebufferSizeCallback(as_glfw(platform.window), framebuffer_resize_callback);
+    glfwSetKeyCallback(as_glfw(platform.window), key_callback);
+    glfwSetMouseButtonCallback(as_glfw(platform.window), mouse_button_callback);
+    glfwSetCursorPosCallback(as_glfw(platform.window), cursor_position_callback);
+    glfwSetWindowFocusCallback(as_glfw(platform.window), window_focus_callback);
+
+    if (platform.captured) {
+        glfwSetInputMode(as_glfw(platform.window), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
+        if (glfwRawMouseMotionSupported()) {
+            glfwSetInputMode(as_glfw(platform.window), GLFW_RAW_MOUSE_MOTION, GLFW_TRUE);
+        }
+    }
+
+    glfwGetCursorPos(as_glfw(platform.window), &platform.last_mouse_x, &platform.last_mouse_y);
+    platform.first_mouse_sample = true;
+
+    glfwShowWindow(as_glfw(platform.window));
+}
+
+void destroy_window(rhi::Device &device, Platform &platform) {
+    VEL_INFO("Destroying GLFW window...");
+    glfwDestroyWindow(as_glfw(platform.window));
+    platform.window = nullptr;
+}
+
+bool platform_update(Platform &platform) {
+    if (glfwWindowShouldClose(as_glfw(platform.window))) {
+        return false;
+    }
+
+    const f64 now = glfwGetTime();
+    static f64 last_time = now;
+    const f64 raw_dt = now - last_time;
+    last_time = now;
+
+    // unclamped delta for profiling:
+    // hitches >50ms are preserved here so the
+    // stats overlay shows real frame-time spikes.
+    platform.raw_dt = raw_dt;
+
+    // clamp (50ms)
+    // to prevent camera jumps on hitching/pipeline reload
+    platform.dt = (raw_dt > 0.05) ? 0.016667 : raw_dt;
+    platform.input.dt = static_cast<f32>(platform.dt);
+
+    // clear previous frame pending mouse deltas
+    // pull this shit into a helper or something ffs
+    platform.pending_mouse_dx = 0.0f;
+    platform.pending_mouse_dy = 0.0f;
+
+    glfwPollEvents();
+
+    platform.input.mouse_dx = platform.pending_mouse_dx;
+    platform.input.mouse_dy = platform.pending_mouse_dy;
+
+    return true;
+}
+
+bool platform_should_close(Platform &platform) {
+    return glfwWindowShouldClose(as_glfw(platform.window)) != 0;
+}
+
+void platform_request_close(Platform &platform) {
+    glfwSetWindowShouldClose(as_glfw(platform.window), GLFW_TRUE);
+}
+
+void platform_framebuffer_size(Platform &platform, u32 &out_w, u32 &out_h) {
+    int w = 0, h = 0;
+    glfwGetFramebufferSize(as_glfw(platform.window), &w, &h);
+    out_w = static_cast<u32>(w);
+    out_h = static_cast<u32>(h);
+}
+
+f32 platform_content_scale(Platform &platform) {
+    f32 scale = 1.0f;
+    glfwGetWindowContentScale(as_glfw(platform.window), &scale, nullptr);
+    return scale;
+}
+
+bool platform_wait_for_valid_framebuffer(Platform &platform) {
+    int w = 0, h = 0;
+    glfwGetFramebufferSize(as_glfw(platform.window), &w, &h);
+    while ((w == 0 || h == 0) && !glfwWindowShouldClose(as_glfw(platform.window))) {
+        glfwWaitEvents();
+        glfwGetFramebufferSize(as_glfw(platform.window), &w, &h);
+    }
+    if (glfwWindowShouldClose(as_glfw(platform.window))) {
+        return false;
+    }
+    platform.width = static_cast<u32>(w);
+    platform.height = static_cast<u32>(h);
+    return true;
+}
+
+void *platform_native_window(Platform &platform) {
+    return as_glfw(platform.window);
+}
ADD · src/core/platform.h +67 -0
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -0,0 +1,67 @@
+#pragma once
+#include <vector>
+
+#include "backend/rhi.h"
+#include "globals.h"
+
+struct PlatformWindow;
+
+enum class WindowMode {
+    Windowed,
+    Maximized,
+    Fullscreen
+    // exclusive?, I haven't looked into glfw hints to see if this is somehow truly exclusive exclusive
+    // I have validated indepedent flip for windowed/bordless though, so it doens't matter too much ig
+};
+
+// TODO: decouple from cam
+struct PlatformInput {
+    f32 dt;
+
+    f32 mouse_dx = 0.0f;
+    f32 mouse_dy = 0.0f;
+
+    bool move_forward = false;  // W
+    bool move_backward = false; // S
+    bool move_left = false;     // A
+    bool move_right = false;    // D
+    bool move_up = false;       // E
+    bool move_down = false;     // Q
+    bool fast = false;          // Shift
+};
+
+struct Platform {
+    PlatformWindow *window = nullptr;
+    bool framebuffer_resized = false;
+    bool captured = false;
+    u32 width;
+    u32 height;
+    f32 pending_mouse_dx = 0.0f;
+    f32 pending_mouse_dy = 0.0f;
+
+    int should_close;
+    f64 dt;     // max delta hitch limit baked
+    f64 raw_dt; // unclamped frame delta
+
+    f64 last_mouse_x = 0.0;
+    f64 last_mouse_y = 0.0;
+    bool first_mouse_sample = true;
+    PlatformInput input;
+};
+
+void init_platform(std::vector<const char *> &extensions);
+void create_window(rhi::Device &device, Platform &platform, const char *windowTitle, WindowMode mode, bool resizable);
+
+void destroy_window(rhi::Device &device, Platform &platform);
+bool platform_update(Platform &platform);
+
+// Window queries. Implemented in platform.cpp; keeps GLFW out of callers.
+bool platform_should_close(Platform &platform);
+void platform_request_close(Platform &platform);
+void platform_framebuffer_size(Platform &platform, u32 &out_w, u32 &out_h);
+f32 platform_content_scale(Platform &platform);
+// Blocks with wait-events until the framebuffer is non-zero (un-minimized).
+// Returns false if close was requested. Syncs platform.width/height.
+bool platform_wait_for_valid_framebuffer(Platform &platform);
+// Opaque native handle for rhi::SwapchainDesc / imgui backend (they cast it).
+void *platform_native_window(Platform &platform);
ADD · src/core/profile.h +12 -0
--- a/src/core/profile.h
+++ b/src/core/profile.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#ifdef ENABLE_TRACY
+#include <tracy/Tracy.hpp>
+#define VEL_PROFILE_ZONE()        ZoneScoped
+#define VEL_PROFILE_FRAME()       FrameMark
+#define VEL_PROFILE_PLOT(name, v) TracyPlot(name, v)
+#else
+#define VEL_PROFILE_ZONE()        ((void)0)
+#define VEL_PROFILE_FRAME()       ((void)0)
+#define VEL_PROFILE_PLOT(name, v) ((void)0)
+#endif
ADD · src/core/random.h +25 -0
--- a/src/core/random.h
+++ b/src/core/random.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <random>
+#include <type_traits>
+
+struct Random {
+    std::mt19937 engine;
+    // std::uniform_real_distribution<f32> dist{0.0f, 1.0f}; // easier to generate a unit vector
+
+    Random() : engine(std::random_device{}()) {
+    }
+
+    explicit Random(u32 seed) : engine(seed) {
+    }
+
+    template <typename T> T Range(T min, T max) {
+        if constexpr (std::is_integral_v<T>) {
+            std::uniform_int_distribution<T> dist(min, max);
+            return dist(engine);
+        } else {
+            std::uniform_real_distribution<T> dist(min, max);
+            return dist(engine);
+        }
+    }
+};
ADD · src/editor/debug_draw.cpp +104 -0
--- a/src/editor/debug_draw.cpp
+++ b/src/editor/debug_draw.cpp
@@ -0,0 +1,104 @@
+#ifdef ENABLE_EDITOR
+#include "editor.h"
+
+#include "core/math_rtm.h"
+#include "passes/debug/debug_draw.h"
+#include "renderer.h"
+#include "scene/scene.h"
+#include "shaders/renderer_types.h"
+
+namespace editor {
+
+void apply_debug_settings(const Editor &e, DebugDraw &draw) {
+    draw.force_xray = e.force_xray;
+    u32 mask = 0;
+    if (e.show_cat_default) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_DEFAULT);
+    }
+    if (e.show_cat_grid) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_GRID);
+    }
+    if (e.show_cat_proxy) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_PROXY);
+    }
+    if (e.show_cat_selection) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_SELECTION);
+    }
+    if (e.show_cat_light) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_LIGHT);
+    }
+    if (e.show_cat_ddgi) {
+        mask |= DebugDraw::category_bit(DEBUG_CAT_DDGI);
+    }
+    draw.category_mask = mask;
+}
+
+void debug_draw_selection(DebugDraw &draw, const Scene &scene, const RenderData &rd, int selected_node) {
+    if (selected_node < 0 || (u32)selected_node >= scene.scene_graph.node_count) {
+        return;
+    }
+    if (!scene.scene_graph.is_node_alive((u32)selected_node)) {
+        return;
+    }
+    u32 node = (u32)selected_node;
+    const SceneGraph &sg = scene.scene_graph;
+    const mat4 base_world = sg.worlds[node];
+    const u32 inst_count = sg.instance_count[node];
+    const u32 inst_base = sg.instance_base[node];
+    bool drew = false;
+    for (const RenderItemGPU &item : rd.render_items) {
+        // entity_id is node+1 (see create_render_data); match selection.
+        if (item.entity_id != node + 1) {
+            continue;
+        }
+        if (item.submesh_index >= rd.submeshes.size()) {
+            continue;
+        }
+        // Per-instance world (Scene::instance_world, same composition as
+        // upload_transforms); node base when not instanced.
+        mat4 world = base_world;
+        if (inst_count > 0) {
+            if (item.instance_id < inst_base) {
+                continue;
+            }
+            u32 k = item.instance_id - inst_base;
+            if (k >= inst_count) {
+                continue;
+            }
+            world = scene.instance_world(node, k);
+        }
+        const SubmeshGPU &sm = rd.submeshes[item.submesh_index];
+        vec3 mn = sm.local_aabb_min;
+        vec3 mx = sm.local_aabb_max;
+        auto xform = [](vec3 p, const mat4 &m) {
+            vec4 h = transform_point(p, m);
+            return vec3(h.x, h.y, h.z);
+        };
+        // 8 corners of the local AABB into world -> world AABB (conservative).
+        vec3 wmn = vec3(1e30f);
+        vec3 wmx = vec3(-1e30f);
+        for (u32 c = 0; c < 8; ++c) {
+            vec3 corner = vec3((c & 1) ? mx.x : mn.x, (c & 2) ? mx.y : mn.y, (c & 4) ? mx.z : mn.z);
+            vec3 w = xform(corner, world);
+            wmn.x = wmn.x < w.x ? wmn.x : w.x;
+            wmn.y = wmn.y < w.y ? wmn.y : w.y;
+            wmn.z = wmn.z < w.z ? wmn.z : w.z;
+            wmx.x = wmx.x > w.x ? wmx.x : w.x;
+            wmx.y = wmx.y > w.y ? wmx.y : w.y;
+            wmx.z = wmx.z > w.z ? wmx.z : w.z;
+        }
+        draw.aabb(wmn, wmx, vec4(4.0f, 1.4f, 0.4f, 1.0f), DEBUG_CAT_SELECTION, DEBUG_DEPTH_TEST, 3.0f);
+        drew = true;
+    }
+    if (!drew) {
+        // Node without mesh (light/camera/empty): small cross at its origin.
+        vec4 h = transform_point(vec3(0.0f), base_world);
+        draw.sphere(
+            vec3(h.x, h.y, h.z), 0.3f, vec4(4.0f, 1.4f, 0.4f, 1.0f), DEBUG_CAT_SELECTION, DEBUG_DEPTH_TEST, 3.0f
+        );
+    }
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/editor.cpp +314 -0
--- a/src/editor/editor.cpp
+++ b/src/editor/editor.cpp
@@ -0,0 +1,314 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+#include <imgui_internal.h>
+
+#include "backend/imgui_backend.h"
+#include "core/logger.h"
+#include "core/platform.h"
+#include "renderer.h"
+#include "scene/scene.h"
+
+namespace editor {
+
+struct DebugItem {
+    DebugViewMode mode;
+    const char *name;
+};
+
+const DebugItem DEBUG_ITEMS[] = {
+    {NONE, "NONE"},
+    {DEPTH_grayscale, "DEPTH_grayscale"},
+    {DEPTH_color, "DEPTH_color"},
+    {UV, "UV"},
+    {NORMAL_TEX, "NORMAL_TEX"},
+    {NORMAL_GEO, "NORMAL_GEO"},
+    {TANGENT_GEO, "TANGENT_GEO"},
+    {BITANGENT_GEO, "BITANGENT_GEO"},
+    {TANGENT_GEO_W, "TANGENT_GEO_W"},
+    {SHADING_NORMAL, "SHADING_NORMAL"},
+    {ALPHA, "ALPHA"},
+    {EMISSIVE, "EMISSIVE"},
+    {ALBEDO, "ALBEDO"},
+    {METALLIC, "METALLIC"},
+    {ROUGHNESS, "ROUGHNESS"},
+    {OCCLUSION, "OCCLUSION"},
+    {SHADOW_CASCADE, "SHADOW_CASCADE"},
+    {LIGHTING_ONLY, "LIGHTING_ONLY"},
+    {CLUSTER_HEATMAP, "CLUSTER_HEATMAP"},
+    {CLUSTER_BOUNDS, "CLUSTER_BOUNDS"},
+    {WIREFRAME, "WIREFRAME"},
+    {PROBES_RAY_SAMPLES, "PROBES_RAY_SAMPLES"},
+    {PROBES_IRRADIANCE, "PROBES_IRRADIANCE"},
+    {PROBES_DISTANCE, "PROBES_DISTANCE"},
+    {PROBES_CLASSIFICATION, "PROBES_CLASSIFICATION"}
+};
+
+void build_layout_0(Editor &e, ImGuiID dockspace_id, ImVec2 size) {
+    ImGui::DockBuilderRemoveNode(dockspace_id);
+    ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace | ImGuiDockNodeFlags_PassthruCentralNode);
+    ImGui::DockBuilderSetNodeSize(dockspace_id, size);
+
+    ImGuiID root = dockspace_id;
+
+    // split 0: root → left (20%) + remaining (80%)
+    ImGuiID left;
+    ImGuiID remaining;
+    ImGui::DockBuilderSplitNode(root, ImGuiDir_Left, 0.20f, &left, &remaining);
+
+    // split 1: remaining → right (25%) + center (75%)
+    ImGuiID right;
+    ImGuiID center;
+    ImGui::DockBuilderSplitNode(remaining, ImGuiDir_Right, 0.25f, &right, &center);
+
+    // split 2: left → left_bottom (50%) + left (50%)
+    ImGuiID left_bottom;
+    ImGui::DockBuilderSplitNode(left, ImGuiDir_Down, 0.5f, &left_bottom, &left);
+
+    // split 3: center → center_bottom (35%) + center (65%)
+    ImGuiID center_bottom;
+    ImGui::DockBuilderSplitNode(center, ImGuiDir_Down, 0.35f, &center_bottom, &center);
+
+    // split 4: right → right_bottom (50%) + right (50%)
+    ImGuiID right_bottom;
+    ImGui::DockBuilderSplitNode(right, ImGuiDir_Down, 0.5f, &right_bottom, &right);
+
+    ImGui::DockBuilderDockWindow("Hierarchy", left);
+    ImGui::DockBuilderDockWindow("Viewport", center);
+    ImGui::DockBuilderDockWindow("Timings", center_bottom);
+    ImGui::DockBuilderDockWindow("Log", center_bottom);
+    ImGui::DockBuilderDockWindow("Inspector", right);
+    ImGui::DockBuilderDockWindow("Texture Viewer", right_bottom);
+
+    ImGui::DockBuilderFinish(dockspace_id);
+    e.dock_layout_built = true;
+}
+
+void draw_menu_bar(Editor &editor, RenderData &rd) {
+    if (ImGui::BeginMenuBar()) {
+
+        ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 8.0f));
+        if (ImGui::BeginMenu("File")) {
+            if (ImGui::MenuItem("Exit")) {
+                platform_request_close(*editor.platform);
+            }
+            ImGui::EndMenu();
+        }
+        if (ImGui::BeginMenu("View")) {
+            ImGui::MenuItem("Viewport", nullptr, &editor.show_viewport);
+            ImGui::MenuItem("Hierarchy", nullptr, &editor.show_hierarchy);
+            ImGui::MenuItem("Inspector", nullptr, &editor.show_inspector);
+            ImGui::MenuItem("Texture Viewer", nullptr, &editor.show_texture_viewer);
+            ImGui::MenuItem("Timings", nullptr, &editor.show_timings);
+            ImGui::MenuItem("Log", nullptr, &editor.show_log);
+            if (ImGui::BeginMenu("Render Mode")) {
+                for (int i = 0; i < IM_ARRAYSIZE(DEBUG_ITEMS); i++) {
+                    if (ImGui::MenuItem(DEBUG_ITEMS[i].name, nullptr, rd.debug == DEBUG_ITEMS[i].mode)) {
+                        rd.debug = DEBUG_ITEMS[i].mode;
+                    }
+                }
+                ImGui::EndMenu();
+            }
+            if (ImGui::BeginMenu("Debug Draw")) {
+                ImGui::MenuItem("Lines enabled", nullptr, &editor.show_debug_lines);
+                ImGui::MenuItem("Force X-ray (ignore depth)", nullptr, &editor.force_xray);
+                ImGui::Separator();
+                ImGui::MenuItem("Category: default", nullptr, &editor.show_cat_default);
+                ImGui::MenuItem("Category: grid", nullptr, &editor.show_cat_grid);
+                ImGui::MenuItem("Category: proxy", nullptr, &editor.show_cat_proxy);
+                ImGui::MenuItem("Category: selection", nullptr, &editor.show_cat_selection);
+                ImGui::MenuItem("Category: light", nullptr, &editor.show_cat_light);
+                ImGui::MenuItem("Category: DDGI", nullptr, &editor.show_cat_ddgi);
+                ImGui::EndMenu();
+            }
+            ImGui::EndMenu();
+        }
+        ImGui::PopStyleVar();
+
+        const char *button_text = "Reload Shaders";
+        f32 button_width = ImGui::CalcTextSize(button_text).x + ImGui::GetStyle().FramePadding.x * 2.0f;
+        f32 right_padding = ImGui::GetStyle().FramePadding.x;
+        f32 target_x = ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - button_width - right_padding;
+        ImGui::SetCursorPosX(target_x);
+        if (ImGui::Button(button_text)) {
+            request_reload(editor);
+        }
+
+        ImGui::EndMenuBar();
+    }
+}
+
+void draw_status_bar(Editor &editor, RenderData &rd) {
+    const ImGuiViewport *viewport = ImGui::GetMainViewport();
+    f32 frame_height = ImGui::GetFrameHeight();
+    ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + viewport->Size.y - frame_height));
+    ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, frame_height));
+    ImGui::SetNextWindowViewport(viewport->ID);
+
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(6.0f, 2.0f));
+
+    ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove |
+                             ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoSavedSettings |
+                             ImGuiWindowFlags_NoDocking;
+
+    ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyleColorVec4(ImGuiCol_MenuBarBg));
+
+    if (ImGui::Begin("##StatusBarWindow", nullptr, flags)) {
+        const FrameStats &st = rd.frame_stats;
+
+        auto sep = []() {
+            ImGui::SameLine();
+            ImGui::TextUnformatted("|");
+            ImGui::SameLine();
+        };
+
+        ImGui::PushFont(editor.font_mono);
+        ImGui::Text("FPS: %.1f", st.fps());
+        sep();
+        ImGui::Text("Viewport: %ux%u", editor.viewport_width, editor.viewport_height);
+        ImGui::PopFont();
+        sep();
+
+        if (rd.debug >= 0 && rd.debug < IM_ARRAYSIZE(DEBUG_ITEMS)) {
+            ImGui::Text("Mode: %s", DEBUG_ITEMS[rd.debug].name);
+        } else {
+            ImGui::Text("Mode: %d", rd.debug);
+        }
+
+        ImGui::End();
+    }
+
+    ImGui::PopStyleColor();
+    ImGui::PopStyleVar(3);
+}
+
+void init(
+    Editor &e,
+    rhi::Device &device,
+    Platform &platform,
+    QuickSubmit &qs,
+    Arena &staging,
+    FrameGraph &fg,
+    AssetManager &assets
+) {
+    e.device = &device;
+    e.platform = &platform;
+    e.assets = &assets;
+    e.qs = &qs;
+    VEL_INFO("Initializing ImGui...");
+
+    IMGUI_CHECKVERSION();
+    ImGui::CreateContext();
+    ImGuiIO &io = ImGui::GetIO();
+    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
+    io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
+
+    static const ImWchar ranges[] = {0x0020, 0x007E, 0};
+
+    ImGuiStyle &style = ImGui::GetStyle();
+    f32 scale_factor = platform_content_scale(platform);
+    style.ScaleAllSizes(scale_factor);
+
+    apply_style(scale_factor, style);
+
+    ImFontConfig cfg{};
+    e.font_ui = io.Fonts->AddFontFromFileTTF("assets/fonts/Inter-Regular.otf", 16.0f, &cfg, ranges);
+    e.font_mono = io.Fonts->AddFontFromFileTTF("assets/fonts/MonaspaceNeon-Regular.otf", 14.0f, &cfg, ranges);
+
+    io.ConfigDpiScaleFonts = true;
+    io.ConfigDpiScaleViewports = true;
+    io.ConfigViewportsNoDecoration = true;
+    io.ConfigViewportsNoDefaultParent = true;
+    io.ConfigNavCaptureKeyboard = true;
+    io.ConfigInputTextCursorBlink = true;
+    io.ConfigWindowsResizeFromEdges = true;
+    cfg.PixelSnapH = true;
+    cfg.PixelSnapV = true;
+
+    imgui_backend::init(device, platform_native_window(platform), qs, staging);
+
+    rhi::SamplerDesc vp_sampler_desc;
+    vp_sampler_desc.filter = rhi::SamplerFilter::LINEAR;
+    vp_sampler_desc.address = rhi::SamplerAddressMode::CLAMP;
+    vp_sampler_desc.name = "samp/viewport";
+    rhi::create_sampler(device, vp_sampler_desc, e.viewport_sampler);
+
+    init_log_viewer();
+}
+
+void shutdown(Editor &e, rhi::Device &device) {
+    VEL_INFO("Shutting down ImGui...");
+    shutdown_texture_inspectors(device);
+    imgui_backend::shutdown(device);
+    ImGui::DestroyContext();
+    rhi::destroy_sampler(device, e.viewport_sampler);
+}
+
+void begin_frame(Editor &e, RenderData &rd) {
+    imgui_backend::begin_frame();
+
+    ImGuiViewport *viewport = ImGui::GetMainViewport();
+    ImGui::SetNextWindowPos(viewport->WorkPos);
+    ImGui::SetNextWindowSize(viewport->WorkSize);
+    ImGui::SetNextWindowViewport(viewport->ID);
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
+
+    ImGui::Begin(
+        "##DockSpaceHost",
+        nullptr,
+        ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoTitleBar |
+            ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
+            ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus
+    );
+
+    draw_menu_bar(e, rd);
+
+    ImVec2 host_size = ImGui::GetContentRegionAvail();
+    ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
+
+    // status bar substract
+    f32 status_h = ImGui::GetFrameHeight();
+    ImVec2 subtracted_dock_size = ImVec2(host_size.x, ImMax(host_size.y - status_h, 0.0f));
+    ImGui::DockSpace(dockspace_id, subtracted_dock_size, ImGuiDockNodeFlags_None);
+
+    if (!e.dock_layout_built) {
+        build_layout_0(e, dockspace_id, subtracted_dock_size);
+    }
+
+    draw_status_bar(e, rd);
+
+    ImGui::End();
+    ImGui::PopStyleVar(3);
+}
+
+void end_frame(Editor &e, Scene &scene, RenderData &rd, const PassInspectorEntry *passes, u32 pass_count) {
+    // ImGui::ShowStyleEditor();
+    if (e.show_timings) {
+        draw_timings_window(scene, rd, passes, pass_count, e, e.font_mono);
+    }
+    // if (e.show_texture_viewer) {
+    //     draw_texture_viewer_window(*e.device, e, rd);
+    // }
+    if (e.show_log) {
+        draw_log_window(e.font_mono);
+    }
+    if (e.show_hierarchy && e.assets) {
+        draw_scene_graph_window(scene, *e.assets, e.selected_node);
+    }
+    if (e.show_inspector && e.assets) {
+        draw_inspector_window(scene, *e.assets, e.font_mono, e.selected_node);
+    }
+    if (e.show_viewport) {
+        draw_viewport_central(e, rd);
+    }
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/editor.h +190 -0
--- a/src/editor/editor.h
+++ b/src/editor/editor.h
@@ -0,0 +1,190 @@
+#pragma once
+#include "backend/rhi.h"
+#include "imgui.h"
+#include "passes/fg.h"
+#include "scene/camera.h"
+#include "scene/light.h"
+
+struct Scene;
+struct SceneGraph;
+struct RenderData;
+struct DebugDraw;
+struct Pipelines;
+struct PassInspectorEntry;
+struct PassContext;
+struct QuickSubmit;
+struct Arena;
+struct Platform;
+class AssetManager;
+class PassTimings;
+
+namespace rhi {
+struct ShaderCompiler;
+struct Swapchain;
+} // namespace rhi
+
+namespace editor {
+
+constexpr ImGuiWindowFlags PANEL_FLAGS = ImGuiWindowFlags_NoCollapse;
+
+struct TextureViewerDesc {
+    rhi::Image *image = nullptr;
+    rhi::Sampler *sampler = nullptr;
+    const char *name = nullptr;
+    const char *format_name = nullptr;
+};
+
+bool draw_texture_inspector(rhi::Device &device, QuickSubmit &qs, const char *id, const TextureViewerDesc &desc);
+void shutdown_texture_inspectors(rhi::Device &device);
+
+// single-texel GPU readback (staging copy + timeline sync wait) into `out`.
+// image TransferSrc usage and sample_count 1.
+bool readback_texel_raw(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    rhi::ImageView &view,
+    u32 mip,
+    u32 layer,
+    i64 tx,
+    i64 ty,
+    void *out,
+    usize out_size
+);
+
+void init_log_viewer();
+
+void apply_style(f32 scale, ImGuiStyle &style);
+
+struct Editor {
+    bool dock_layout_built = false;
+    ImFont *font_ui = nullptr;
+    ImFont *font_mono = nullptr;
+    rhi::Sampler viewport_sampler = {};
+    rhi::RenderPipeline *imgui_pipeline = nullptr;
+    u32 viewport_width = 0;
+    u32 viewport_height = 0;
+    bool viewport_resized = false;
+
+    rhi::Device *device = nullptr;
+    AssetManager *assets = nullptr;
+    QuickSubmit *qs = nullptr; // retained for one-off GPU work (readbacks); set in init.
+
+    bool visible = false;
+    bool enabled = true;
+
+    bool show_viewport = true;
+    bool show_hierarchy = true;
+    bool show_inspector = true;
+    bool show_texture_viewer = true;
+    bool show_timings = true;
+    bool show_log = true;
+
+    Platform *platform = nullptr;
+
+    // DdgiConfig ddgi_config;
+    u32 ddgi_frame_counter = 0;
+    int selected_node = -1;
+
+    // debug draw
+    bool show_debug_lines = true;
+    bool force_xray = false;
+    bool show_cat_default = true;
+    bool show_cat_grid = false;
+    bool show_cat_proxy = true;
+    bool show_cat_selection = true;
+    bool show_cat_light = false;
+    bool show_cat_ddgi = false;
+
+    // shader reload
+    bool reload_requested_ = false;
+
+    bool show_translate_gizmo = true;
+    bool gizmo_snap = false;
+    f32 gizmo_snap_step = 0.1f;
+    // drag runtime (owned by update_translate_gizmo; handles only)
+    bool gizmo_dragging = false;
+    int gizmo_grab_node = -1;           // node the active drag belongs to
+    u8 gizmo_drag_axis = 0;             // 0/1/2 = X/Y/Z axis, 3 = center free-move (handle resolved at grab)
+    int gizmo_hover_axis = -1;          // screen-space handle hover (-1 = none, 0..2 = axis, 3 = center)
+    vec3 gizmo_grab_point = vec3(0.0f); // world-space ref point at grab
+    vec3 gizmo_base_local = vec3(0.0f); // node local translation at grab
+    vec3 gizmo_base_world = vec3(0.0f); // node world origin at grab
+    vec3 gizmo_plane_n = vec3(0.0f);    // view-plane normal captured at center grab
+    // viewport rect cache (written by end_frame UI, read pre-execute next frame)
+    ImVec2 gizmo_view_min = ImVec2(0, 0);
+    ImVec2 gizmo_view_size = ImVec2(0, 0);
+};
+
+inline bool reload_requested(Editor &e) {
+    if (e.reload_requested_) {
+        e.reload_requested_ = false;
+        return true;
+    }
+    return false;
+}
+inline void request_reload(Editor &e) {
+    e.reload_requested_ = true;
+}
+
+void init(
+    Editor &e,
+    rhi::Device &device,
+    Platform &platform,
+    QuickSubmit &qs,
+    Arena &staging,
+    FrameGraph &fg,
+    AssetManager &assets
+);
+void shutdown(Editor &e, rhi::Device &device);
+void begin_frame(Editor &e, RenderData &rd);
+void end_frame(Editor &e, Scene &scene, RenderData &rd, const PassInspectorEntry *passes, u32 pass_count);
+
+void draw_viewport_central(Editor &e, RenderData &rd);
+void draw_log_window(ImFont *mono_font);
+void draw_timings_window(
+    Scene &scene, RenderData &rd, const PassInspectorEntry *passes, u32 pass_count, Editor &e, ImFont *mono_font
+);
+void draw_texture_viewer_window(rhi::Device &device, Editor &editor, RenderData &rd);
+void draw_scene_graph_window(Scene &scene, const AssetManager &mgr, int &selected_node);
+void draw_inspector_window(Scene &scene, const AssetManager &mgr, ImFont *mono_font, int &selected_node);
+
+void update_translate_gizmo(Editor &e, Scene &scene, DebugDraw &draw);
+
+void handle_frame_begin(
+    Editor &e,
+    RenderData &rd,
+    rhi::Device &device,
+    rhi::Swapchain &swapchain,
+    FrameGraph &fg,
+    ImageHandle swapchain_target,
+    rhi::Extent2D &render_size,
+    Scene &scene,
+    Pipelines &pipelines,
+    PassTimings &timings,
+    u32 frame_slot
+);
+
+void eval_render_size(u32 viewport_w, u32 viewport_h, rhi::Swapchain &swapchain, rhi::Extent2D &extent);
+
+struct PresentTargets {
+    ImageHandle display;
+    ImageHandle id_blit;
+    ImageHandle irradiance;
+    ImageHandle distance;
+    ImageHandle cascade[Light::CASCADE_COUNT];
+    ImageHandle swapchain;
+};
+void record_present(
+    Editor &e,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    rhi::Swapchain &swapchain,
+    const PresentTargets &targets,
+    PassTimings &timings
+);
+
+void apply_debug_settings(const Editor &e, DebugDraw &draw);
+void debug_draw_selection(DebugDraw &draw, const Scene &scene, const RenderData &rd, int selected_node);
+
+} // namespace editor
ADD · src/editor/frame.cpp +133 -0
--- a/src/editor/frame.cpp
+++ b/src/editor/frame.cpp
@@ -0,0 +1,133 @@
+#ifdef ENABLE_EDITOR
+#include "editor.h"
+
+#include <algorithm>
+
+#include "backend/imgui_backend.h"
+#include "passes/fg_utils.h"
+#include "passes/imgui/imgui.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "scene/scene.h"
+
+namespace editor {
+
+void eval_render_size(u32 viewport_w, u32 viewport_h, rhi::Swapchain &swapchain, rhi::Extent2D &extent) {
+    rhi::Extent2D sc_extent = rhi::swapchain_extent(swapchain);
+    u32 w = (viewport_w > 0) ? viewport_w : sc_extent.width;
+    u32 h = (viewport_h > 0) ? viewport_h : sc_extent.height;
+
+    extent.width = std::max(w, 1u);
+    extent.height = std::max(h, 1u);
+}
+
+void handle_frame_begin(
+    Editor &e,
+    RenderData &rd,
+    rhi::Device &device,
+    rhi::Swapchain &swapchain,
+    FrameGraph &fg,
+    ImageHandle swapchain_target,
+    rhi::Extent2D &render_size,
+    Scene &scene,
+    Pipelines &pipelines,
+    PassTimings &timings,
+    u32 frame_slot
+) {
+    begin_frame(e, rd);
+
+    if (e.viewport_resized && e.viewport_width > 0 && e.viewport_height > 0) {
+        rhi::queue_wait_idle(device);
+
+        eval_render_size(e.viewport_width, e.viewport_height, swapchain, render_size);
+
+        fg.overwrite_imported_image(swapchain_target, rhi::swapchain_image(swapchain, 0));
+        fg.compile(device, render_size);
+
+        Camera &cam = scene.cameras[scene.active_camera];
+        cam.aspect = static_cast<f32>(render_size.width) / static_cast<f32>(render_size.height);
+
+        e.viewport_resized = false;
+    }
+
+    if (reload_requested(e)) {
+        pipelines.reload();
+    }
+
+    timings.readback(device, frame_slot);
+}
+
+void record_present(
+    Editor &e,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    rhi::Swapchain &swapchain,
+    const PresentTargets &targets,
+    PassTimings &timings
+) {
+    imgui_pass::record(*fg.device, pipelines, sc, fg, rhi::swapchain_format(swapchain));
+    e.imgui_pipeline = &pipelines.get_render("ImGui");
+
+    Editor *ed = &e;
+    PassTimings *tm = &timings;
+    rhi::Swapchain *sw = &swapchain;
+    PresentTargets tg = targets;
+
+    auto &builder = fg.add_pass("Editor Present");
+    builder.read(tg.display, rhi::ResourceState::TextureSample);
+    builder.read(tg.irradiance, rhi::ResourceState::TextureSample);
+    builder.read(tg.distance, rhi::ResourceState::TextureSample);
+    builder.read(tg.id_blit, rhi::ResourceState::TextureSample);
+
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        builder.read(tg.cascade[i], rhi::ResourceState::TextureSample);
+    }
+
+    builder.write(tg.swapchain, rhi::ResourceState::ColorDraw).execute([ed, tm, sw, tg](PassContext &ctx) {
+        ctx.render_data->display = ctx.get_image(tg.display);
+        ctx.render_data->irr_atlas = ctx.get_image(tg.irradiance);
+        ctx.render_data->dis_atlas = ctx.get_image(tg.distance);
+        ctx.render_data->id_blit = ctx.get_image(tg.id_blit);
+
+        for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+            ctx.render_data->cascade[i] = ctx.get_image(tg.cascade[i]);
+        };
+
+        auto vs = ctx.image_view(tg.swapchain, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &vs;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.0f;
+        color_att.clearValue.color.float32[1] = 0.0f;
+        color_att.clearValue.color.float32[2] = 0.0f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+
+        u32 pass_count;
+        const PassInspectorEntry *passes = tm->entries(pass_count);
+        editor::end_frame(*ed, *ctx.scene, *ctx.render_data, passes, pass_count);
+
+        bool draw_ui = false;
+        if (ed->imgui_pipeline != nullptr) {
+            draw_ui = imgui_backend::prepare(ctx);
+        }
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = (u32)rhi::swapchain_extent(*sw).width;
+        ri.height = (u32)rhi::swapchain_extent(*sw).height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+        if (draw_ui) {
+            imgui_backend::draw(ctx, *ed->imgui_pipeline, ri.width, ri.height);
+        }
+        rhi::end_rendering(ctx.cmd);
+    });
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/gizmo.cpp +99 -0
--- a/src/editor/gizmo.cpp
+++ b/src/editor/gizmo.cpp
@@ -0,0 +1,99 @@
+#ifdef ENABLE_EDITOR
+#include "editor.h"
+#include "gizmo_common.h"
+
+#include "imgui.h"
+#include "passes/debug/debug_draw.h"
+#include "passes/debug/debug_ray.h"
+#include "scene/camera.h"
+#include "scene/scene.h"
+
+namespace editor {
+
+void update_translate_gizmo(Editor &e, Scene &scene, DebugDraw &draw) {
+    GizmoFrame f;
+    if (!gizmo_begin_frame(e, scene, f)) {
+        return;
+    }
+    SceneGraph &sg = *f.sg;
+    const Camera &cam = *f.cam;
+
+    // screen-space handle hit test
+    int hover_axis = -1;
+    if (f.o_visible && f.hover_view && !e.gizmo_dragging) {
+        if (gizmo_hit_center(f.mouse, f.o_px)) {
+            hover_axis = GIZMO_FREE_AXIS;
+        } else {
+            hover_axis = gizmo_hit_axis(f.mouse, f.o_px, f, e);
+        }
+    }
+    e.gizmo_hover_axis = hover_axis;
+
+    // rebase, if selected node updated
+    if (e.gizmo_dragging && e.selected_node != e.gizmo_grab_node) {
+        gizmo_rebase_drag(e, scene, f);
+    }
+
+    bool mouse_down = ImGui::IsMouseDown(0);
+    bool clicked = ImGui::IsMouseClicked(0);
+
+    if (!e.gizmo_dragging) {
+        if (clicked && f.hover_view && hover_axis >= 0 && debug_finite_vec3(f.ray.dir) &&
+            debug_finite_vec3(f.ray.origin)) {
+            // gizmo handle grab, axis = 0/1/2, center = 3
+            e.gizmo_dragging = true;
+            e.gizmo_grab_node = e.selected_node;
+            e.gizmo_drag_axis = (u8)hover_axis;
+            e.gizmo_base_local = sg.translations[f.node];
+            e.gizmo_base_world = f.origin;
+            if (e.gizmo_drag_axis == GIZMO_FREE_AXIS) {
+                e.gizmo_plane_n = cam.forward().normalized();
+                e.gizmo_grab_point = ray_plane_point(f.origin, e.gizmo_plane_n, f.ray.origin, f.ray.dir, f.origin);
+            } else {
+                vec3 axis = gizmo_axis_dir(e.gizmo_drag_axis);
+                e.gizmo_grab_point = closest_point_on_axis(f.origin, axis, f.ray.origin, f.ray.dir);
+            }
+        }
+    } else if (!mouse_down) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+    } else {
+        // drag: current ref point -> world delta -> parent-space local write.
+        vec3 cur = e.gizmo_grab_point;
+        if (e.gizmo_drag_axis == GIZMO_FREE_AXIS) {
+            cur = ray_plane_point(e.gizmo_base_world, e.gizmo_plane_n, f.ray.origin, f.ray.dir, cur);
+        } else {
+            vec3 axis = gizmo_axis_dir(e.gizmo_drag_axis);
+            cur = closest_point_on_axis(e.gizmo_base_world, axis, f.ray.origin, f.ray.dir);
+        }
+        vec3 new_world = e.gizmo_base_world + (cur - e.gizmo_grab_point);
+        if (e.gizmo_snap && e.gizmo_snap_step > 0.0f) {
+            new_world.x = roundf(new_world.x / e.gizmo_snap_step) * e.gizmo_snap_step;
+            new_world.y = roundf(new_world.y / e.gizmo_snap_step) * e.gizmo_snap_step;
+            new_world.z = roundf(new_world.z / e.gizmo_snap_step) * e.gizmo_snap_step;
+        }
+        gizmo_write_translation(sg, f.node, e.gizmo_base_local, e.gizmo_base_world, new_world);
+    }
+
+    // handles (always drawn while a valid selection exists).
+    if (!f.o_visible) {
+        return;
+    }
+    GizmoDrawScope tool_draw(draw);
+    for (u8 a = 0; a < 3; ++a) {
+        bool active = (e.gizmo_dragging && a == e.gizmo_drag_axis) || (!e.gizmo_dragging && (int)a == hover_axis);
+        vec4 col = active ? vec4(5.0f, 5.0f, 5.0f, 1.0f) : gizmo_axis_color(a);
+        f32 w = active ? 4.0f : 3.0f;
+        vec3 tip = f.origin + gizmo_axis_dir(a) * f.len;
+        draw.line(f.origin, tip, col, DEBUG_CAT_DEFAULT, DEBUG_DEPTH_XRAY, w);
+        draw.cross(tip, f.len * 0.14f, col, DEBUG_CAT_DEFAULT, DEBUG_DEPTH_XRAY, w);
+    }
+
+    bool center_active = (e.gizmo_dragging && e.gizmo_drag_axis == GIZMO_FREE_AXIS) ||
+                         (!e.gizmo_dragging && hover_axis == GIZMO_FREE_AXIS);
+    gizmo_draw_center_ring(draw, f, e, center_active);
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/gizmo_common.h +291 -0
--- a/src/editor/gizmo_common.h
+++ b/src/editor/gizmo_common.h
@@ -0,0 +1,291 @@
+#pragma once
+
+#ifdef ENABLE_EDITOR
+
+#include <cmath>
+
+#include "core/math_rtm.h"
+#include "imgui.h"
+#include "passes/debug/debug_draw.h"
+#include "passes/debug/debug_ray.h"
+#include "scene/camera.h"
+#include "scene/scene.h"
+
+#include "editor.h"
+
+namespace editor {
+
+// 0/1/2 = X/Y/Z axis handles, 3 = center free-move handle.
+constexpr u8 GIZMO_FREE_AXIS = 3;
+constexpr f32 GIZMO_AXIS_HIT_PX = 10.0f;
+constexpr f32 GIZMO_CENTER_RADIUS_PX = 10.0f;
+constexpr f32 GIZMO_CENTER_HIT_PX = 12.0f;
+constexpr f32 GIZMO_HANDLE_LEN_PX = 90.0f;
+constexpr u32 GIZMO_RING_SEGS = 24;
+constexpr f32 GIZMO_PI = 3.14159265358979323846f;
+
+// world-space axis directions (engine space: X fwd, Y right, Z up)
+inline vec3 gizmo_axis_dir(u8 a) {
+    if (a == 0) {
+        return vec3(1.0f, 0.0f, 0.0f);
+    }
+    if (a == 1) {
+        return vec3(0.0f, 1.0f, 0.0f);
+    }
+    return vec3(0.0f, 0.0f, 1.0f);
+}
+
+// HDR-bright axis colors (grid convention: X red, Y green, Z blue).
+inline vec4 gizmo_axis_color(u8 a) {
+    if (a == 0) {
+        return vec4(4.0f, 0.6f, 0.6f, 1.0f);
+    }
+    if (a == 1) {
+        return vec4(0.6f, 4.0f, 0.6f, 1.0f);
+    }
+    return vec4(0.6f, 0.8f, 4.0f, 1.0f);
+}
+
+inline vec3 selection_origin(const Scene &scene, u32 node) {
+    const SceneGraph &sg = scene.scene_graph;
+    mat4 base = (sg.instance_count[node] > 0) ? scene.instance_world(node, 0) : sg.worlds[node];
+    vec4 h = transform_point(vec3(0.0f, 0.0f, 0.0f), base);
+    return vec3(h.x, h.y, h.z);
+}
+
+inline bool project_to_view(vec3 p, const mat4 &view_proj, ImVec2 min, ImVec2 size, ImVec2 &out) {
+    vec4 c = transform_point(p, view_proj);
+    if (c.w <= 0.0f) { // behind camera
+        return false;
+    }
+    f32 nx = c.x / c.w;
+    f32 ny = c.y / c.w;
+    out = ImVec2(min.x + (nx * 0.5f + 0.5f) * size.x, min.y + (ny * 0.5f + 0.5f) * size.y);
+    return true;
+}
+
+inline f32 dist_point_seg(ImVec2 p, ImVec2 a, ImVec2 b) {
+    f32 dx = b.x - a.x;
+    f32 dy = b.y - a.y;
+    f32 len2 = dx * dx + dy * dy;
+    f32 t = (len2 > 1e-8f) ? ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2 : 0.0f;
+    if (t < 0.0f) {
+        t = 0.0f;
+    } else if (t > 1.0f) {
+        t = 1.0f;
+    }
+    f32 ex = a.x + dx * t - p.x;
+    f32 ey = a.y + dy * t - p.y;
+    return sqrtf(ex * ex + ey * ey);
+}
+
+// closest point on axis (origin + s*axis, |axis|==1) to ray (ray_o + t*ray_d).
+inline vec3 closest_point_on_axis(vec3 origin, vec3 axis, vec3 ray_o, vec3 ray_d) {
+    vec3 w0 = origin - ray_o;
+    f32 b = axis.dot(ray_d);
+    f32 d = axis.dot(w0);
+    f32 f = ray_d.dot(w0);
+    f32 denom = 1.0f - b * b;
+    f32 s = (fabsf(denom) < 1e-6f) ? 0.0f : (b * f - d) / denom;
+    return origin + axis * s;
+}
+
+// ray plane intersection (point + t*n, |n|==1). Falls back to `fallback` when the ray
+// runs parallel to the plane or points away.
+inline vec3 ray_plane_point(vec3 point, vec3 n, vec3 ray_o, vec3 ray_d, vec3 fallback) {
+    f32 denom = ray_d.dot(n);
+    if (fabsf(denom) < 1e-6f) {
+        return fallback;
+    }
+    f32 t = (point - ray_o).dot(n) / denom;
+    if (!(t > 0.0f) || !std::isfinite(t)) {
+        return fallback;
+    }
+    return ray_o + ray_d * t;
+}
+
+// per-frame gizmo context, computed once per tool update.
+struct GizmoFrame {
+    u32 node = 0;
+    SceneGraph *sg = nullptr;
+    const Camera *cam = nullptr;
+    vec3 origin = vec3(0.0f);
+    f32 dist = 0.0f;
+    f32 len = 0.0f; // screen-constant handle length (world units)
+    ImVec2 mouse = ImVec2(0, 0);
+    bool hover_view = false;
+    ImVec2 o_px = ImVec2(0, 0);
+    bool o_visible = false;
+    DebugRay ray = {};
+};
+
+inline bool gizmo_begin_frame(Editor &e, Scene &scene, GizmoFrame &f) {
+    if (!e.show_translate_gizmo || e.selected_node < 0 || (u32)e.selected_node >= scene.scene_graph.node_count) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        e.gizmo_hover_axis = -1;
+        return false;
+    }
+    SceneGraph &sg = scene.scene_graph;
+    u32 node = (u32)e.selected_node;
+    if (!sg.is_node_alive(node)) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        e.gizmo_hover_axis = -1;
+        return false;
+    }
+    if (scene.active_camera >= scene.cameras.size()) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        e.gizmo_hover_axis = -1;
+        return false;
+    }
+    if (e.gizmo_view_size.x <= 0.0f || e.gizmo_view_size.y <= 0.0f) {
+        return false; // no viewport rect cached yet (first frame)
+    }
+    const Camera &cam = scene.cameras[scene.active_camera];
+
+    vec3 origin = selection_origin(scene, node);
+    vec3 to_cam = cam.position - origin;
+    f32 dist = to_cam.length();
+    if (!(dist > 0.0f) || !std::isfinite(dist)) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        e.gizmo_hover_axis = -1;
+        return false;
+    }
+    // screen-constant handle size (see pixels_to_world).
+    f32 len = DebugDraw::pixels_to_world(dist, GIZMO_HANDLE_LEN_PX, cam.fov_y_deg, e.gizmo_view_size.y);
+    if (!(len > 0.0f) || !std::isfinite(len)) {
+        return false;
+    }
+
+    ImVec2 mouse = ImGui::GetMousePos();
+    bool hover_view = mouse.x >= e.gizmo_view_min.x && mouse.x <= e.gizmo_view_min.x + e.gizmo_view_size.x &&
+                      mouse.y >= e.gizmo_view_min.y && mouse.y <= e.gizmo_view_min.y + e.gizmo_view_size.y;
+
+    ImVec2 o_px{};
+    bool o_visible = project_to_view(origin, cam.view_proj, e.gizmo_view_min, e.gizmo_view_size, o_px);
+
+    // mouse ray in world space (for grab + drag).
+    // NDC: up is y=-1.
+    // imgui pixels map straight through, no y-flip
+    f32 nx = ((mouse.x - e.gizmo_view_min.x) / e.gizmo_view_size.x) * 2.0f - 1.0f;
+    f32 ny = ((mouse.y - e.gizmo_view_min.y) / e.gizmo_view_size.y) * 2.0f - 1.0f;
+    DebugRay ray = debug_unproject(nx, ny, cam.position, cam.inv_view_proj);
+
+    f.node = node;
+    f.sg = &sg;
+    f.cam = &cam;
+    f.origin = origin;
+    f.dist = dist;
+    f.len = len;
+    f.mouse = mouse;
+    f.hover_view = hover_view;
+    f.o_px = o_px;
+    f.o_visible = o_visible;
+    f.ray = ray;
+    return true;
+}
+
+inline void gizmo_rebase_drag(Editor &e, Scene &scene, GizmoFrame &f) {
+    SceneGraph &sg = *f.sg;
+    bool alive = e.selected_node >= 0 && (u32)e.selected_node < sg.node_count && sg.is_node_alive((u32)e.selected_node);
+    if (!alive || !debug_finite_vec3(f.ray.dir) || !debug_finite_vec3(f.ray.origin)) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        return;
+    }
+    u32 node = (u32)e.selected_node;
+    vec3 origin = selection_origin(scene, node);
+    const Camera &cam = *f.cam;
+    vec3 to_cam = cam.position - origin;
+    f32 dist = to_cam.length();
+    f32 len = DebugDraw::pixels_to_world(dist, GIZMO_HANDLE_LEN_PX, cam.fov_y_deg, e.gizmo_view_size.y);
+    if (!(dist > 0.0f) || !std::isfinite(dist) || !(len > 0.0f) || !std::isfinite(len)) {
+        e.gizmo_dragging = false;
+        e.gizmo_grab_node = -1;
+        return;
+    }
+    f.node = node;
+    f.origin = origin;
+    f.dist = dist;
+    f.len = len;
+    e.gizmo_grab_node = e.selected_node;
+    e.gizmo_base_local = sg.translations[node];
+    e.gizmo_base_world = origin;
+    if (e.gizmo_drag_axis == GIZMO_FREE_AXIS) {
+        e.gizmo_grab_point = ray_plane_point(origin, e.gizmo_plane_n, f.ray.origin, f.ray.dir, origin);
+    } else {
+        vec3 rebase_axis = gizmo_axis_dir(e.gizmo_drag_axis);
+        e.gizmo_grab_point = closest_point_on_axis(origin, rebase_axis, f.ray.origin, f.ray.dir);
+    }
+}
+
+inline void gizmo_write_translation(SceneGraph &sg, u32 node, vec3 base_local, vec3 base_world, vec3 new_world) {
+    int p = sg.parent[node];
+    mat4 parent_world = (p >= 0) ? sg.worlds[p] : identity();
+    vec3 local_delta = transform_direction(new_world - base_world, inverse(parent_world));
+    vec3 new_local = base_local + local_delta;
+    if (debug_finite_vec3(new_local)) {
+        sg.set_translation(node, new_local);
+    }
+}
+
+struct GizmoDrawScope {
+    DebugDraw &draw;
+    u32 saved_mask;
+    explicit GizmoDrawScope(DebugDraw &d) : draw(d), saved_mask(d.category_mask) {
+        draw.category_mask = 0xFFFFFFFFu;
+    }
+    ~GizmoDrawScope() {
+        draw.category_mask = saved_mask;
+    }
+};
+
+inline bool gizmo_hit_center(ImVec2 mouse, ImVec2 o_px) {
+    f32 dx = mouse.x - o_px.x;
+    f32 dy = mouse.y - o_px.y;
+    return sqrtf(dx * dx + dy * dy) < GIZMO_CENTER_HIT_PX;
+}
+
+inline int gizmo_hit_axis(ImVec2 mouse, ImVec2 o_px, const GizmoFrame &f, const Editor &e) {
+    f32 best = GIZMO_AXIS_HIT_PX;
+    int hit = -1;
+    for (u8 a = 0; a < 3; ++a) {
+        ImVec2 t_px{};
+        if (!project_to_view(
+                f.origin + gizmo_axis_dir(a) * f.len, f.cam->view_proj, e.gizmo_view_min, e.gizmo_view_size, t_px
+            )) {
+            continue;
+        }
+        f32 d = dist_point_seg(mouse, o_px, t_px);
+        if (d < best) {
+            best = d;
+            hit = (int)a;
+        }
+    }
+    return hit;
+}
+
+inline void gizmo_draw_center_ring(DebugDraw &draw, const GizmoFrame &f, const Editor &e, bool active) {
+    vec4 col = active ? vec4(5.0f, 5.0f, 5.0f, 1.0f) : vec4(3.0f, 3.0f, 3.0f, 1.0f);
+    f32 w = active ? 4.0f : 3.0f;
+    f32 r = DebugDraw::pixels_to_world(f.dist, GIZMO_CENTER_RADIUS_PX, f.cam->fov_y_deg, e.gizmo_view_size.y);
+    if (!(r > 0.0f) || !std::isfinite(r)) {
+        return;
+    }
+    vec3 right = f.cam->right();
+    vec3 up = f.cam->up();
+    vec3 prev = f.origin + right * r;
+    for (u32 i = 1; i <= GIZMO_RING_SEGS; ++i) {
+        f32 t = (f32)i / (f32)GIZMO_RING_SEGS * 2.0f * GIZMO_PI;
+        vec3 p = f.origin + (right * cosf(t) + up * sinf(t)) * r;
+        draw.line(prev, p, col, DEBUG_CAT_DEFAULT, DEBUG_DEPTH_XRAY, w);
+        prev = p;
+    }
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/hierarchy.cpp +103 -0
--- a/src/editor/hierarchy.cpp
+++ b/src/editor/hierarchy.cpp
@@ -0,0 +1,103 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#include <cstdio>
+
+#include "scene/scene.h"
+
+namespace editor {
+
+void draw_node_tree(const Scene &scene, const AssetManager &mgr, u32 node, int depth, int &selected_node) {
+    const SceneGraph &sc = scene.scene_graph;
+    if (!sc.is_node_alive(node)) {
+        return;
+    }
+    ImGui::PushID((int)node);
+
+    bool is_leaf = sc.first_child[node] == SCENE_INVALID;
+    u32 flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth;
+    if (is_leaf) {
+        flags |= ImGuiTreeNodeFlags_Leaf;
+    }
+    if ((int)node == selected_node) {
+        flags |= ImGuiTreeNodeFlags_Selected;
+    }
+
+    char type_prefix[16] = "";
+    int tp_len = 0;
+    for (u32 mn : scene.mesh_nodes) {
+        if (mn == node) {
+            tp_len += snprintf(type_prefix + tp_len, sizeof(type_prefix) - tp_len, "[M]");
+            break;
+        }
+    }
+    for (auto &cam : scene.cameras) {
+        if (cam.node == node) {
+            tp_len += snprintf(type_prefix + tp_len, sizeof(type_prefix) - tp_len, "[C]");
+            break;
+        }
+    }
+    for (auto &dl : scene.directional_lights) {
+        if (dl.node == node) {
+            tp_len += snprintf(type_prefix + tp_len, sizeof(type_prefix) - tp_len, "[D]");
+            break;
+        }
+    }
+    for (auto &pl : scene.point_lights) {
+        if (pl.node == node) {
+            tp_len += snprintf(type_prefix + tp_len, sizeof(type_prefix) - tp_len, "[L]");
+            break;
+        }
+    }
+
+    char label[128];
+    const char *name = scene.node_name(mgr, node);
+    if (name) {
+        if (tp_len > 0) {
+            (void)snprintf(label, sizeof(label), "%s %s", type_prefix, name);
+        } else {
+            (void)snprintf(label, sizeof(label), "%s", name);
+        }
+    } else if (tp_len > 0) {
+        (void)snprintf(label, sizeof(label), "%s Node %u", type_prefix, node);
+    } else {
+        (void)snprintf(label, sizeof(label), "[N] Node %u", node);
+    }
+
+    bool open = ImGui::TreeNodeEx(label, flags);
+    if (ImGui::IsItemClicked() && !ImGui::IsItemToggledOpen()) {
+        selected_node = (int)node;
+    }
+    if (open) {
+        for (u32 child = sc.first_child[node]; child != SCENE_INVALID; child = sc.next_sibling[child]) {
+            draw_node_tree(scene, mgr, child, depth + 1, selected_node);
+        }
+        ImGui::TreePop();
+    }
+    ImGui::PopID();
+}
+
+void draw_scene_graph_window(Scene &scene, const AssetManager &mgr, int &selected_node) {
+    if (ImGui::Begin("Hierarchy", nullptr, PANEL_FLAGS)) {
+        SceneGraph *sc = &scene.scene_graph;
+        if (!sc || sc->node_count == 0) {
+            ImGui::TextUnformatted("No scene graph loaded");
+            ImGui::End();
+            return;
+        }
+        ImGui::Text("Nodes: %u  Roots: %zu", sc->node_count, sc->roots.size());
+        ImGui::BeginChild("TreePanel", ImVec2(0, 0), 0);
+        for (u32 root : sc->roots) {
+            draw_node_tree(scene, mgr, root, 0, selected_node);
+        }
+        ImGui::EndChild();
+    }
+    ImGui::End();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/inspector.cpp +243 -0
--- a/src/editor/inspector.cpp
+++ b/src/editor/inspector.cpp
@@ -0,0 +1,243 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#include <cmath>
+#include <cstdio>
+
+#include "core/math_rtm.h"
+#include "scene/camera.h"
+#include "scene/scene.h"
+
+namespace editor {
+
+namespace {
+
+void draw_transform_panel(SceneGraph &sg, u32 node) {
+    ImGui::Text("Index: %u", node);
+    ImGui::Text("Parent: %d", sg.parent[node]);
+    ImGui::Text("Children: %s", sg.first_child[node] == SCENE_INVALID ? "none" : "yes");
+    ImGui::Separator();
+
+    vec3 t = sg.translations[node];
+    if (ImGui::DragFloat3("Translation", &t.x, 0.05f)) {
+        sg.set_translation(node, t);
+    }
+
+    vec3 euler = quat_to_euler(quat(sg.rotations[node]));
+    if (ImGui::DragFloat3("Rotation (pitch, yaw, roll) deg", &euler.x, 0.5f)) {
+        sg.set_rotation(node, rtm::quat_normalize((rtm::quatf)euler_to_quat(euler)));
+    }
+
+    vec3 s = sg.scales[node];
+    if (ImGui::DragFloat3("Scale", &s.x, 0.01f)) {
+        sg.set_scale(node, s);
+    }
+
+    vec4 wh = transform_point(vec3(0.0f, 0.0f, 0.0f), sg.worlds[node]);
+    ImGui::Text("World pos: %.3f %.3f %.3f", wh.x, wh.y, wh.z);
+}
+
+void draw_mesh_inspector(Scene &scene, const AssetManager &mgr, u32 node) {
+    SceneGraph &sg = scene.scene_graph;
+
+    bool is_mesh = false;
+    for (u32 mn : scene.mesh_nodes) {
+        if (mn == node) {
+            is_mesh = true;
+            break;
+        }
+    }
+    if (!is_mesh) {
+        return;
+    }
+
+    ImGui::SeparatorText("Mesh");
+    ImGui::Text("Asset: %u  Node: %u", sg.asset[node].id, sg.asset_index[node]);
+
+    const AssetScene *src = scene.node_source(mgr, node);
+    if (src) {
+        u32 mesh_idx = src->nodes[sg.asset_index[node]].mesh;
+        if (mesh_idx != ASSET_INVALID && mesh_idx < src->meshes.size()) {
+            const char *mesh_name = mesh_idx < src->mesh_names.size() && !src->mesh_names[mesh_idx].empty()
+                                        ? src->mesh_names[mesh_idx].c_str()
+                                        : "unnamed";
+            ImGui::Text("Mesh: %s", mesh_name);
+
+            const AssetMesh &am = src->meshes[mesh_idx];
+            for (u32 k = 0; k < am.submesh_count; ++k) {
+                u32 sub = am.first_submesh + k;
+                if (sub >= src->submeshes.size()) {
+                    break;
+                }
+                const char *mat_name = nullptr;
+                u32 mat = src->submeshes[sub].material;
+                if (mat != ASSET_INVALID && mat < src->materials.size() && !src->materials[mat].name.empty()) {
+                    mat_name = src->materials[mat].name.c_str();
+                } else if (sub < src->submesh_names.size() && !src->submesh_names[sub].empty()) {
+                    mat_name = src->submesh_names[sub].c_str();
+                }
+                ImGui::Text("  [%u] %s", k, mat_name ? mat_name : "unnamed");
+            }
+        }
+    }
+    u32 ic = sg.instance_count[node];
+    u32 base = sg.instance_base[node];
+    if (ic > 0) {
+        char buf[32];
+        (void)snprintf(buf, sizeof(buf), "Instances (%u)", ic);
+        if (ImGui::TreeNode(buf)) {
+            for (u32 k = 0; k < ic; ++k) {
+                ImGui::PushID((int)(base + k));
+                // node's instance TRS is the source of truth; edits apply directly.
+                TRS &trs = scene.instance_locals[base + k];
+                char lb[32];
+                (void)snprintf(lb, sizeof(lb), "Instance %u", k);
+                if (ImGui::TreeNode(lb)) {
+                    ImGui::DragFloat3("Translation (local)", &trs.translation.x, 0.05f);
+
+                    vec3 euler = quat_to_euler(trs.rotation);
+                    if (ImGui::DragFloat3("Rotation (pitch, yaw, roll) deg", &euler.x, 0.5f)) {
+                        trs.rotation = euler_to_quat(euler);
+                    }
+
+                    if (ImGui::DragFloat3("Scale", &trs.scale.x, 0.01f)) {
+                        auto clamp_axis = [](f32 &axis) {
+                            f32 a = std::fabs(axis);
+                            if (a < 1e-4f) {
+                                a = 1e-4f;
+                            }
+                            axis = a * (axis < 0.0f ? -1.0f : 1.0f);
+                        };
+                        clamp_axis(trs.scale.x);
+                        clamp_axis(trs.scale.y);
+                        clamp_axis(trs.scale.z);
+                    }
+
+                    // world-space position of this copy (Scene::instance_world,
+                    // same composition as upload_transforms).
+                    mat4 world = scene.instance_world(node, k);
+                    ImGui::Text("World pos: %.2f, %.2f, %.2f", world.m[12], world.m[13], world.m[14]);
+                    ImGui::TreePop();
+                }
+                ImGui::PopID();
+            }
+            ImGui::TreePop();
+        }
+    }
+}
+
+void draw_camera_inspector(Scene &scene, u32 node) {
+    Camera *cam = nullptr;
+    for (auto &c : scene.cameras) {
+        if (c.node == node) {
+            cam = &c;
+            break;
+        }
+    }
+    if (!cam) {
+        return;
+    }
+    ImGui::SeparatorText("Camera");
+    ImGui::DragFloat("FOV", &cam->fov_y_deg, 0.5f, 1.0f, 179.0f);
+    ImGui::DragFloat("Near", &cam->near_plane, 0.001f, 0.0001f, 10.0f);
+    ImGui::DragFloat("Far", &cam->far_plane, 10.0f, 10.0f, 10000.0f);
+    ImGui::DragFloat("Move Speed", &cam->move_speed, 0.1f, 0.1f, 100.0f);
+    ImGui::DragFloat("Look Sensitivity", &cam->look_sensitivity, 0.01f, 0.01f, 5.0f);
+    bool is_active = (scene.active_camera != NODE_INVALID) && (&scene.cameras[scene.active_camera] == cam);
+    if (ImGui::Checkbox("Active", &is_active)) {
+        if (is_active) {
+            for (u32 i = 0; i < (u32)scene.cameras.size(); ++i) {
+                if (&scene.cameras[i] == cam) {
+                    scene.active_camera = i;
+                    break;
+                }
+            }
+        }
+    }
+}
+
+void draw_directional_light_inspector(Scene &scene, u32 node) {
+    SceneGraph &sg = scene.scene_graph;
+    Light *dl = nullptr;
+    for (auto &l : scene.directional_lights) {
+        if (l.node == node) {
+            dl = &l;
+            break;
+        }
+    }
+    if (!dl) {
+        return;
+    }
+    ImGui::SeparatorText("Directional Light");
+    vec3 dir = dl->direction;
+    if (ImGui::DragFloat3("Direction", &dir.x, 0.01f, -1.0f, 1.0f)) {
+        dir = dir.normalized();
+        dl->direction = dir;
+        vec3 fwd = vec3(1.0f, 0.0f, 0.0f);
+        vec3 axis = cross(fwd, dir).normalized();
+        f32 angle = std::acos(std::clamp(fwd.dot(dir), -1.0f, 1.0f));
+        sg.set_rotation(node, quat::from_axis_angle(axis, angle));
+    }
+    ImGui::DragFloat3("Color", &dl->color.x, 1.0f);
+    ImGui::DragFloat("Intensity", &dl->intensity, 1.0f, 0.0f, 100.0f);
+    ImGui::DragFloat("Distance", &dl->distance, 1.0f);
+    ImGui::DragFloat("Max Shadow", &dl->max_shadow_distance, 10.0f, 10.0f, 1000.0f);
+}
+
+void draw_point_light_inspector(Scene &scene, u32 node) {
+    SceneGraph &sg = scene.scene_graph;
+    PointLight *pl = nullptr;
+    for (auto &p : scene.point_lights) {
+        if (p.node == node) {
+            pl = &p;
+            break;
+        }
+    }
+    if (!pl) {
+        return;
+    }
+    ImGui::SeparatorText("Point Light");
+    vec3 pos = sg.translations[node];
+    if (ImGui::DragFloat3("Position", &pos.x, 0.05f)) {
+        sg.set_translation(node, pos);
+    }
+    ImGui::DragFloat3("Color", &pl->color.x, 0.01f);
+    ImGui::DragFloat("Intensity", &pl->intensity, 0.1f, 0.0f, 100.0f);
+    ImGui::DragFloat("Range", &pl->range, 0.1f, 0.1f, 100.0f);
+}
+
+} // anonymous namespace
+
+void draw_inspector_window(Scene &scene, const AssetManager &mgr, ImFont *mono_font, int &selected_node) {
+    if (ImGui::Begin("Inspector", nullptr, PANEL_FLAGS)) {
+        SceneGraph *sc = &scene.scene_graph;
+        if (!sc || sc->node_count == 0) {
+            ImGui::TextUnformatted("No scene graph loaded");
+            ImGui::End();
+            return;
+        }
+        if (selected_node >= 0 && selected_node < (int)sc->node_count) {
+            u32 node = (u32)selected_node;
+            if (!sc->is_node_alive(node)) {
+                ImGui::TextUnformatted("Node not alive");
+                ImGui::End();
+                return;
+            }
+            draw_transform_panel(*sc, node);
+            draw_mesh_inspector(scene, mgr, node);
+            draw_camera_inspector(scene, node);
+            draw_directional_light_inspector(scene, node);
+            draw_point_light_inspector(scene, node);
+        } else {
+            ImGui::TextUnformatted("Select a node from the Scene Graph");
+        }
+    }
+    ImGui::End();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/log_viewer.cpp +226 -0
--- a/src/editor/log_viewer.cpp
+++ b/src/editor/log_viewer.cpp
@@ -0,0 +1,226 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#include <plog/Appenders/IAppender.h>
+#include <plog/Log.h>
+#include <plog/Record.h>
+#include <plog/Util.h>
+
+#include <mutex>
+#include <string>
+
+namespace editor {
+
+namespace {
+
+#ifdef _WIN32
+std::string log_message_to_utf8(const std::wstring &wstr) {
+    if (wstr.empty()) {
+        return {};
+    }
+    int len = plog::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), nullptr, 0, nullptr, nullptr);
+    std::string result(len, '\0');
+    plog::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), result.data(), len, nullptr, nullptr);
+    return result;
+}
+#else
+std::string log_message_to_utf8(const std::string &str) {
+    return str;
+}
+#endif
+
+constexpr int MAX_LOG_ENTRIES = 1000;
+
+struct LogEntry {
+    plog::Severity severity;
+    std::string text;
+    int repeat_count;
+};
+
+struct LogBuffer : plog::IAppender {
+    LogEntry entries[MAX_LOG_ENTRIES];
+    int head = 0;
+    int count = 0;
+    std::mutex mtx;
+    void write(const plog::Record &record) override {
+        std::lock_guard<std::mutex> lock(mtx);
+        std::string msg = log_message_to_utf8(record.getMessage());
+        if (count > 0) {
+            LogEntry &last = entries[(head - 1 + MAX_LOG_ENTRIES) % MAX_LOG_ENTRIES];
+            if (last.severity == record.getSeverity() && last.text == msg) {
+                ++last.repeat_count;
+                return;
+            }
+        }
+        LogEntry &e = entries[head];
+        e.severity = record.getSeverity();
+        e.text = std::move(msg);
+        e.repeat_count = 0;
+        head = (head + 1) % MAX_LOG_ENTRIES;
+        if (count < MAX_LOG_ENTRIES) {
+            ++count;
+        }
+    }
+};
+
+LogBuffer &log_buffer() {
+    static LogBuffer buf;
+    return buf;
+}
+
+struct LogViewerUIState {
+    bool show_trace = false, show_debug = true, show_info = true, show_warn = true, show_error = true,
+         show_critical = true;
+    bool auto_scroll = true, initialized = false;
+    char filter[256] = "";
+};
+
+LogViewerUIState &ui_state() {
+    static LogViewerUIState s;
+    return s;
+}
+
+bool severity_visible(plog::Severity severity) {
+    const LogViewerUIState &s = ui_state();
+    switch (severity) {
+    case plog::verbose:
+        return s.show_trace;
+    case plog::debug:
+        return s.show_debug;
+    case plog::info:
+        return s.show_info;
+    case plog::warning:
+        return s.show_warn;
+    case plog::error:
+        return s.show_error;
+    case plog::fatal:
+        return s.show_critical;
+    default:
+        return true;
+    }
+}
+
+ImU32 severity_color(plog::Severity severity) {
+    switch (severity) {
+    case plog::verbose:
+        return IM_COL32(130, 130, 130, 255);
+    case plog::debug:
+        return IM_COL32(180, 180, 180, 255);
+    case plog::info:
+        return IM_COL32(200, 220, 255, 255);
+    case plog::warning:
+        return IM_COL32(255, 200, 80, 255);
+    case plog::error:
+        return IM_COL32(255, 80, 80, 255);
+    case plog::fatal:
+        return IM_COL32(255, 40, 40, 255);
+    default:
+        return IM_COL32(255, 255, 255, 255);
+    }
+}
+
+const char *severity_label(plog::Severity severity) {
+    switch (severity) {
+    case plog::verbose:
+        return "TRACE";
+    case plog::debug:
+        return "DEBUG";
+    case plog::info:
+        return "INFO";
+    case plog::warning:
+        return "WARN";
+    case plog::error:
+        return "ERROR";
+    case plog::fatal:
+        return "CRITICAL";
+    default:
+        return "?";
+    }
+}
+
+} // anonymous namespace
+
+void init_log_viewer() {
+    LogViewerUIState &s = ui_state();
+    if (s.initialized) {
+        return;
+    }
+    plog::get()->addAppender(&log_buffer());
+    s.initialized = true;
+}
+
+void draw_log_window(ImFont *mono_font) {
+    LogViewerUIState &s = ui_state();
+    if (ImGui::Begin("Log", nullptr)) {
+        if (ImGui::Button("Clear")) {
+            std::lock_guard<std::mutex> lock(log_buffer().mtx);
+            log_buffer().head = 0;
+            log_buffer().count = 0;
+        }
+        ImGui::SameLine();
+        ImGui::Checkbox("Trace", &s.show_trace);
+        ImGui::SameLine();
+        ImGui::Checkbox("Debug", &s.show_debug);
+        ImGui::SameLine();
+        ImGui::Checkbox("Info", &s.show_info);
+        ImGui::SameLine();
+        ImGui::Checkbox("Warn", &s.show_warn);
+        ImGui::SameLine();
+        ImGui::Checkbox("Error", &s.show_error);
+        ImGui::SameLine();
+        ImGui::Checkbox("Fatal", &s.show_critical);
+        ImGui::SameLine();
+        ImGui::Checkbox("Auto-scroll", &s.auto_scroll);
+        ImGui::SameLine();
+        ImGui::SetNextItemWidth(180);
+        ImGui::InputText("##filter", s.filter, sizeof(s.filter));
+        ImGui::Separator();
+        ImGui::BeginChild("LogMessages", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar);
+        bool filter_active = s.filter[0] != '\0';
+        int visible = 0;
+        {
+            std::lock_guard<std::mutex> lock(log_buffer().mtx);
+            LogBuffer &buf = log_buffer();
+            int start = buf.count < MAX_LOG_ENTRIES ? 0 : buf.head;
+            int end = start + buf.count;
+            for (int i = start; i < end; ++i) {
+                const LogEntry &e = buf.entries[i % MAX_LOG_ENTRIES];
+                if (!severity_visible(e.severity)) {
+                    continue;
+                }
+                if (filter_active && e.text.find(s.filter) == std::string::npos) {
+                    continue;
+                }
+                ++visible;
+                ImGui::PushFont(mono_font);
+                ImGui::PushStyleColor(ImGuiCol_Text, severity_color(e.severity));
+                if (e.repeat_count > 0) {
+                    ImGui::Text("[%s] %s (x%d)", severity_label(e.severity), e.text.c_str(), e.repeat_count + 1);
+                } else {
+                    ImGui::Text("[%s] %s", severity_label(e.severity), e.text.c_str());
+                }
+                ImGui::PopStyleColor();
+                ImGui::PopFont();
+            }
+        }
+        if (visible == 0) {
+            ImGui::TextUnformatted("(no messages)");
+        }
+        if (s.auto_scroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY() - 6.0f) {
+            ImGui::SetScrollHereY(1.0f);
+        }
+        ImGui::EndChild();
+    }
+    ImGui::End();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/style.cpp +112 -0
--- a/src/editor/style.cpp
+++ b/src/editor/style.cpp
@@ -0,0 +1,112 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+namespace editor {
+
+constexpr ImVec4 ACCENT{0.26f, 0.59f, 0.98f, 1.00f};
+constexpr ImVec4 ACCENT_DIM{0.26f, 0.59f, 0.98f, 0.45f};
+constexpr ImVec4 WARNING{0.95f, 0.75f, 0.30f, 1.00f};
+constexpr ImVec4 DANGER{0.90f, 0.42f, 0.40f, 1.00f};
+constexpr ImVec4 MUTED{0.55f, 0.57f, 0.60f, 1.00f};
+constexpr ImVec4 PLAYING{0.35f, 0.82f, 0.45f, 1.00f};
+constexpr ImVec4 IDLE{0.78f, 0.80f, 0.84f, 1.00f};
+
+ImVec4 grey(f32 v, f32 a = 1.f) {
+    return {v, v, v, a};
+}
+
+void apply_style(f32 scale, ImGuiStyle &style) {
+    style.WindowMenuButtonPosition = ImGuiDir_None;
+
+    style.FramePadding.y = 7.0f;
+    style.DockingSeparatorSize = 1.0f;
+    style.SeparatorTextBorderSize = 1.0f;
+    style.GrabRounding = 4.0f;
+
+    style.WindowBorderSize = 1.0f;
+    style.WindowRounding = 6.0f;
+
+    style.ChildBorderSize = 1.0f;
+    style.ChildRounding = 6.0f;
+
+    style.PopupBorderSize = 1.0f;
+    style.PopupRounding = 6.0f;
+
+    style.FrameBorderSize = 0.0f;
+    style.FrameRounding = 4.0f;
+
+    style.MenuItemRounding = 4.0f;
+    style.ScrollbarPadding = 0.0f;
+    style.ScrollbarSize = 14.0f;
+
+    ImVec4 *c = style.Colors;
+
+    c[ImGuiCol_Text] = grey(0.88f);
+    c[ImGuiCol_TextDisabled] = MUTED;
+
+    c[ImGuiCol_WindowBg] = grey(0.125f);
+    c[ImGuiCol_ChildBg] = grey(0.125f);
+    c[ImGuiCol_PopupBg] = grey(0.15f, 0.98f);
+    c[ImGuiCol_MenuBarBg] = grey(0.125f);
+
+    c[ImGuiCol_Border] = grey(0.24f);
+    c[ImGuiCol_BorderShadow] = grey(0.f, 0.f);
+
+    c[ImGuiCol_FrameBg] = grey(0.20f);
+    c[ImGuiCol_FrameBgHovered] = grey(0.26f);
+    c[ImGuiCol_FrameBgActive] = grey(0.30f);
+
+    c[ImGuiCol_TitleBg] = grey(0.10f);
+    c[ImGuiCol_TitleBgActive] = grey(0.16f);
+    c[ImGuiCol_TitleBgCollapsed] = grey(0.10f);
+
+    c[ImGuiCol_ScrollbarBg] = grey(0.11f);
+    c[ImGuiCol_ScrollbarGrab] = grey(0.28f);
+    c[ImGuiCol_ScrollbarGrabHovered] = grey(0.35f);
+    c[ImGuiCol_ScrollbarGrabActive] = grey(0.42f);
+
+    c[ImGuiCol_CheckMark] = ACCENT;
+    c[ImGuiCol_SliderGrab] = {0.35f, 0.55f, 0.80f, 1.00f};
+    c[ImGuiCol_SliderGrabActive] = ACCENT;
+
+    c[ImGuiCol_Button] = grey(0.22f);
+    c[ImGuiCol_ButtonHovered] = grey(0.30f);
+    c[ImGuiCol_ButtonActive] = ACCENT_DIM;
+
+    c[ImGuiCol_Header] = grey(0.24f);
+    c[ImGuiCol_HeaderHovered] = grey(0.30f);
+    c[ImGuiCol_HeaderActive] = ACCENT_DIM;
+
+    c[ImGuiCol_Separator] = grey(0.24f);
+    c[ImGuiCol_SeparatorHovered] = ACCENT_DIM;
+    c[ImGuiCol_SeparatorActive] = ACCENT;
+
+    c[ImGuiCol_ResizeGrip] = grey(0.f, 0.f);
+    c[ImGuiCol_ResizeGripHovered] = ACCENT_DIM;
+    c[ImGuiCol_ResizeGripActive] = ACCENT;
+
+    c[ImGuiCol_Tab] = grey(0.16f);
+    c[ImGuiCol_TabHovered] = grey(0.28f);
+    c[ImGuiCol_TabSelected] = grey(0.24f);
+    c[ImGuiCol_TabSelectedOverline] = grey(0.0f, 0.0f);
+    c[ImGuiCol_TabDimmed] = grey(0.13f);
+    c[ImGuiCol_TabDimmedSelected] = grey(0.20f);
+
+    c[ImGuiCol_TableHeaderBg] = grey(0.18f);
+    c[ImGuiCol_TableBorderStrong] = grey(0.26f);
+    c[ImGuiCol_TableBorderLight] = grey(0.20f);
+    c[ImGuiCol_TableRowBg] = grey(0.f, 0.f);
+    c[ImGuiCol_TableRowBgAlt] = grey(1.f, 0.03f);
+
+    c[ImGuiCol_TextSelectedBg] = ACCENT_DIM;
+    c[ImGuiCol_DragDropTarget] = WARNING;
+    c[ImGuiCol_NavCursor] = ACCENT;
+    c[ImGuiCol_ModalWindowDimBg] = grey(0.05f, 0.65f);
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/targets.cpp +179 -0
--- a/src/editor/targets.cpp
+++ b/src/editor/targets.cpp
@@ -0,0 +1,179 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#include <cstring>
+#include <string>
+#include <vector>
+
+#include "quick_submit.h"
+#include "renderer.h"
+
+namespace editor {
+
+const char *format_name(rhi::ImageFormat fmt) {
+    switch (fmt) {
+    case rhi::ImageFormat::R8_UNORM:
+        return "R8_UNORM";
+    case rhi::ImageFormat::RGBA8_UNORM:
+        return "RGBA8_UNORM";
+    case rhi::ImageFormat::RGBA8_SRGB:
+        return "RGBA8_SRGB";
+    case rhi::ImageFormat::BGRA8_UNORM:
+        return "BGRA8_UNORM";
+    case rhi::ImageFormat::D32_FLOAT:
+        return "D32_FLOAT";
+    case rhi::ImageFormat::RGBA16_FLOAT:
+        return "RGBA16_FLOAT";
+    case rhi::ImageFormat::RGBA32_FLOAT:
+        return "RGBA32_FLOAT";
+    case rhi::ImageFormat::BC7_UNORM:
+        return "BC7_UNORM";
+    case rhi::ImageFormat::BC7_SRGB:
+        return "BC7_SRGB";
+    case rhi::ImageFormat::ASTC6X6_UNORM:
+        return "ASTC6X6_UNORM";
+    case rhi::ImageFormat::ASTC6X6_SRGB:
+        return "ASTC6X6_SRGB";
+    case rhi::ImageFormat::R16_FLOAT:
+        return "R16_FLOAT";
+    case rhi::ImageFormat::R32_FLOAT:
+        return "R32_FLOAT";
+    case rhi::ImageFormat::R10G10B10A2_UNORM:
+        return "R10G10B10A2_UNORM";
+    case rhi::ImageFormat::RG16_FLOAT:
+        return "RG16_FLOAT";
+    default:
+        return "Other";
+    }
+}
+
+struct SourceEntry {
+    std::string name;
+    std::string format_name;
+    rhi::Image *img = nullptr;
+    // false = render target (display / ddgi / cascades), true = scene texture.
+    bool is_texture = false;
+};
+
+// persists across frames; re-resolved against the catalog each frame so
+// pointers stay valid across scene reloads.
+std::vector<SourceEntry> PINNED;
+bool AUTO_PINNED = false;
+
+bool is_pinned(const std::string &name) {
+    for (const auto &p : PINNED) {
+        if (p.name == name) {
+            return true;
+        }
+    }
+    return false;
+}
+
+void build_catalog(RenderData &rd, std::vector<SourceEntry> &out) {
+    out.clear();
+    out.push_back({"Main Color", format_name(rd.display.desc.format), &rd.display, false});
+    out.push_back({"DDGI Irradiance", format_name(rd.irr_atlas.desc.format), &rd.irr_atlas, false});
+    out.push_back({"DDGI Distance", format_name(rd.dis_atlas.desc.format), &rd.dis_atlas, false});
+
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        std::string name = "Shadow Cascade " + std::to_string(i);
+        out.push_back({name, format_name(rd.cascade[i].desc.format), &rd.cascade[i], false});
+    }
+
+    // Scene textures (deduped by GPU handle; multiple materials may share a load).
+    u32 tex_idx = 0;
+    for (auto &[img, view] : rd.loaded_textures) {
+        (void)view;
+        if (!rhi::valid(img)) {
+            continue;
+        }
+        out.push_back({"Tex " + std::to_string(tex_idx), format_name(img.desc.format), &img, true});
+        ++tex_idx;
+    }
+}
+
+void draw_texture_viewer_window(rhi::Device &device, Editor &editor, RenderData &rd) {
+    if (!ImGui::Begin("Texture Viewer", nullptr, PANEL_FLAGS)) {
+        ImGui::End();
+        return;
+    }
+
+    std::vector<SourceEntry> sources;
+    build_catalog(rd, sources);
+
+    if (!AUTO_PINNED && !sources.empty()) {
+        AUTO_PINNED = true;
+        PINNED.push_back(sources[0]);
+    }
+
+    for (auto &p : PINNED) {
+        const SourceEntry *match = nullptr;
+        for (const auto &e : sources) {
+            if (e.name == p.name) {
+                match = &e;
+                break;
+            }
+        }
+        p.img = match ? match->img : nullptr;
+        p.format_name = match ? match->format_name : std::string();
+    }
+
+    ImGui::TextUnformatted("Sources:");
+    ImGui::SameLine();
+    ImGui::SetNextItemWidth(150);
+    if (ImGui::BeginCombo("##add_source", "Add...")) {
+        const char *last_section = nullptr;
+        for (const auto &e : sources) {
+            if (is_pinned(e.name)) {
+                continue;
+            }
+            const char *section = e.is_texture ? "Scene Textures" : "Render Targets";
+            if (last_section == nullptr || strcmp(last_section, section) != 0) {
+                last_section = section;
+                ImGui::TextUnformatted(section);
+            }
+            if (ImGui::Selectable(e.name.c_str())) {
+                PINNED.push_back(e);
+            }
+        }
+        ImGui::EndCombo();
+    }
+
+    std::vector<usize> to_remove;
+    if (ImGui::BeginTabBar("##tv_tabs", ImGuiTabBarFlags_None)) {
+        for (usize i = 0; i < PINNED.size(); ++i) {
+            SourceEntry &pin = PINNED[i];
+            bool open_tab = true;
+            if (ImGui::BeginTabItem(pin.name.c_str(), &open_tab)) {
+                if (pin.img && rhi::valid(*pin.img)) {
+                    TextureViewerDesc tv{};
+                    tv.image = pin.img;
+                    tv.sampler = &editor.viewport_sampler;
+                    tv.name = pin.name.c_str();
+                    tv.format_name = pin.format_name.c_str();
+                    draw_texture_inspector(device, *editor.qs, pin.name.c_str(), tv);
+                } else {
+                    ImGui::TextUnformatted("Source unavailable");
+                }
+                ImGui::EndTabItem();
+            }
+            if (!open_tab) {
+                to_remove.push_back(i);
+            }
+        }
+        ImGui::EndTabBar();
+    }
+
+    for (usize i = to_remove.size(); i-- > 0;) {
+        PINNED.erase(PINNED.begin() + (i32)to_remove[i]);
+    }
+
+    ImGui::End();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/texture_viewer.cpp +718 -0
--- a/src/editor/texture_viewer.cpp
+++ b/src/editor/texture_viewer.cpp
@@ -0,0 +1,718 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+#include <imgui_internal.h>
+
+#include <cmath>
+#include <cstdio>
+#include <cstring>
+#include <vector>
+
+#include "backend/imgui_backend.h"
+#include "quick_submit.h"
+
+namespace editor {
+
+enum class Channel : u8 {
+    RGB,
+    R,
+    G,
+    B,
+    A,
+};
+
+constexpr const char *CHANNEL_NAMES[] = {"RGB", "R", "G", "B", "A"};
+
+struct InspectorState {
+    ImGuiID id;
+    const rhi::Image *image = nullptr;
+    f32 scale = 1.0f;
+    u64 desc = UINT64_MAX;
+    bool y_flip = false;
+    u32 mip_level = 0;
+    u32 array_layer = 0;
+
+    rhi::ImageView custom_view;
+    bool owns_view = false;
+    const rhi::Image *view_image = nullptr;
+    u32 view_mip = 0;
+    u32 view_layer = 0;
+    Channel view_channel = Channel::RGB;
+
+    Channel channel = Channel::RGB;
+    bool show_checker = false;
+    bool show_grid = false;
+    bool reset_scroll = false;
+
+    // Hover readback cache
+    const rhi::Image *read_image = nullptr;
+    i64 read_tx = -1;
+    i64 read_ty = -1;
+    u32 read_mip = 0;
+    u32 read_layer = 0;
+    f32 read_uv_x = 0.0f;
+    f32 read_uv_y = 0.0f;
+    bool read_valid = false;
+    char hover_text[256];
+};
+
+std::vector<InspectorState> INSPECTORS;
+
+InspectorState *find_or_create(ImGuiID id) {
+    for (auto &insp : INSPECTORS) {
+        if (insp.id == id) {
+            return &insp;
+        }
+    }
+    INSPECTORS.push_back({});
+    INSPECTORS.back().id = id;
+    return &INSPECTORS.back();
+}
+
+struct ReadbackScratch {
+    rhi::Device *device = nullptr;
+    rhi::Buffer stage{};
+};
+
+ReadbackScratch RB;
+
+void ensure_scratch(rhi::Device &device) {
+    if (RB.device == &device) {
+        return;
+    }
+    RB.device = &device;
+
+    rhi::BufferDesc bd{};
+    bd.size = 256;
+    bd.usage = rhi::BufferUsage::CopyDst;
+    bd.memory = rhi::BufferMemType::Readback;
+    bd.name = "rb/stage";
+    rhi::create_buffer(device, bd, RB.stage);
+}
+
+void destroy_scratch(rhi::Device &device) {
+    if (RB.device == nullptr) {
+        return;
+    }
+    rhi::destroy_buffer(device, RB.stage);
+    RB = {};
+}
+
+rhi::Image CHECKER_IMG;
+rhi::ImageView CHECKER_VIEW;
+u64 CHECKER_DESC = UINT64_MAX;
+
+bool create_checkerboard(rhi::Device &device, QuickSubmit &qs, const rhi::Sampler *sampler) {
+    if (CHECKER_DESC != UINT64_MAX || sampler == nullptr) {
+        return CHECKER_DESC != UINT64_MAX;
+    }
+    ensure_scratch(device);
+
+    constexpr u32 checker_size = 16;
+    constexpr u32 checker_cell = 8;
+    std::vector<u8> px(checker_size * checker_size * 4);
+    for (u32 y = 0; y < checker_size; ++y) {
+        for (u32 x = 0; x < checker_size; ++x) {
+            bool light = (((x / checker_cell) + (y / checker_cell)) & 1) == 0;
+            u8 c = light ? 130 : 85;
+            u32 i = (y * checker_size + x) * 4;
+            px[i + 0] = c;
+            px[i + 1] = c;
+            px[i + 2] = c;
+            px[i + 3] = 255;
+        }
+    }
+
+    rhi::ImageDesc img_desc{};
+    img_desc.width = checker_size;
+    img_desc.height = checker_size;
+    img_desc.format = rhi::ImageFormat::RGBA8_UNORM;
+    img_desc.usage = rhi::ImageUsage::Sampled | rhi::ImageUsage::TransferDst;
+    img_desc.name = "tex/checker";
+    if (!rhi::create_image(device, img_desc, CHECKER_IMG)) {
+        return false;
+    }
+    rhi::ImageViewDesc view_desc{};
+    view_desc.image = &CHECKER_IMG;
+    if (!rhi::create_image_view(device, view_desc, CHECKER_VIEW)) {
+        rhi::destroy_image(device, CHECKER_IMG);
+        return false;
+    }
+
+    rhi::BufferDesc bd{};
+    bd.size = px.size();
+    bd.usage = rhi::BufferUsage::CopySrc;
+    bd.memory = rhi::BufferMemType::Upload;
+    bd.name = "rb/checker-stage";
+    rhi::Buffer stage{};
+    if (!rhi::create_buffer(device, bd, stage)) {
+        rhi::destroy_image_view(device, CHECKER_VIEW);
+        rhi::destroy_image(device, CHECKER_IMG);
+        return false;
+    }
+    std::memcpy(stage.mapped, px.data(), px.size());
+    rhi::buffer_flush(device, stage, 0, px.size());
+
+    QsCmd *qcmd = qs_acquire(qs);
+    {
+        rhi::ImageRange range{};
+        rhi::barrier(qcmd->cmd, CHECKER_IMG, range, CHECKER_IMG.state, rhi::ResourceState::TransferTo);
+    }
+    rhi::BufferTextureCopyRegion region{};
+    region.buffer_offset = 0;
+    region.texture_extent_width = checker_size;
+    region.texture_extent_height = checker_size;
+    region.texture_extent_depth = 1;
+    region.base_array_layer = 0;
+    region.mip_level = 0;
+    region.layer_count = 1;
+    rhi::copy_buffer_to_texture(qcmd->cmd, stage, CHECKER_VIEW, region);
+    {
+        rhi::ImageRange range{};
+        rhi::barrier(qcmd->cmd, CHECKER_IMG, range, rhi::ResourceState::TransferTo, rhi::ResourceState::TextureSample);
+    }
+
+    qs_submit_and_wait(qs, *qcmd);
+
+    rhi::destroy_buffer(device, stage);
+    CHECKER_DESC = imgui_backend::texture(CHECKER_VIEW);
+    return CHECKER_DESC != UINT64_MAX;
+}
+
+void destroy_checkerboard(rhi::Device &device) {
+    CHECKER_DESC = UINT64_MAX;
+    if (rhi::valid(CHECKER_VIEW)) {
+        rhi::destroy_image_view(device, CHECKER_VIEW);
+    }
+    if (rhi::valid(CHECKER_IMG)) {
+        rhi::destroy_image(device, CHECKER_IMG);
+    }
+}
+
+bool format_readback_supported(rhi::ImageFormat fmt) {
+    switch (fmt) {
+    case rhi::ImageFormat::R8_UNORM:
+    case rhi::ImageFormat::RGBA8_UNORM:
+    case rhi::ImageFormat::RGBA8_SRGB:
+    case rhi::ImageFormat::BGRA8_UNORM:
+    case rhi::ImageFormat::R10G10B10A2_UNORM:
+    case rhi::ImageFormat::RGBA16_FLOAT:
+    case rhi::ImageFormat::RG16_FLOAT:
+    case rhi::ImageFormat::R16_FLOAT:
+    case rhi::ImageFormat::R32_FLOAT:
+    case rhi::ImageFormat::R32_UINT:
+    case rhi::ImageFormat::RGBA32_FLOAT:
+    case rhi::ImageFormat::D32_FLOAT:
+        return true;
+    default:
+        return false;
+    }
+}
+
+static f32 half_to_float(u16 h) {
+    u32 sign = (u32)((h >> 15) & 1);
+    u32 exp = (u32)((h >> 10) & 0x1f);
+    u32 man = (u32)(h & 0x3ff);
+    u32 f;
+    if (exp == 0) {
+        if (man == 0) {
+            f = sign << 31;
+        } else {
+            exp = 127 - 15 + 1;
+            while ((man & 0x400) == 0) {
+                man <<= 1;
+                exp--;
+            }
+            man &= 0x3ff;
+            f = (sign << 31) | (exp << 23) | (man << 13);
+        }
+    } else if (exp == 31) {
+        f = (sign << 31) | 0x7f800000u | (man << 13);
+    } else {
+        f = (sign << 31) | ((exp - 15 + 127) << 23) | (man << 13);
+    }
+    f32 out;
+    std::memcpy(&out, &f, sizeof(f32));
+    return out;
+}
+
+void decode_texel(rhi::ImageFormat fmt, const void *data, char *out, usize out_size) {
+    switch (fmt) {
+    case rhi::ImageFormat::R8_UNORM: {
+        u8 v = ((const u8 *)data)[0];
+        (void)std::snprintf(out, out_size, "R: %u (%.3f)", v, v / 255.0f);
+        break;
+    }
+    case rhi::ImageFormat::RGBA8_UNORM:
+    case rhi::ImageFormat::RGBA8_SRGB: {
+        const u8 *p = (const u8 *)data;
+        (void)std::snprintf(out, out_size, "R: %u  G: %u  B: %u  A: %u", p[0], p[1], p[2], p[3]);
+        break;
+    }
+    case rhi::ImageFormat::BGRA8_UNORM: {
+        const u8 *p = (const u8 *)data;
+        (void)std::snprintf(out, out_size, "B: %u  G: %u  R: %u  A: %u", p[0], p[1], p[2], p[3]);
+        break;
+    }
+    case rhi::ImageFormat::R10G10B10A2_UNORM: {
+        u32 p = *(const u32 *)data;
+        (void)std::snprintf(
+            out,
+            out_size,
+            "R: %.3f  G: %.3f  B: %.3f  A: %.3f",
+            (f32)(p & 0x3ff) / 1023.0f,
+            (f32)((p >> 10) & 0x3ff) / 1023.0f,
+            (f32)((p >> 20) & 0x3ff) / 1023.0f,
+            (f32)((p >> 30) & 0x3) / 3.0f
+        );
+        break;
+    }
+    case rhi::ImageFormat::RGBA16_FLOAT: {
+        const u16 *p = (const u16 *)data;
+        (void)std::snprintf(
+            out,
+            out_size,
+            "R: %.4g  G: %.4g  B: %.4g  A: %.4g",
+            half_to_float(p[0]),
+            half_to_float(p[1]),
+            half_to_float(p[2]),
+            half_to_float(p[3])
+        );
+        break;
+    }
+    case rhi::ImageFormat::RG16_FLOAT: {
+        const u16 *p = (const u16 *)data;
+        (void)std::snprintf(out, out_size, "R: %.4g  G: %.4g", half_to_float(p[0]), half_to_float(p[1]));
+        break;
+    }
+    case rhi::ImageFormat::R16_FLOAT: {
+        (void)std::snprintf(out, out_size, "R: %.4g", half_to_float(*(const u16 *)data));
+        break;
+    }
+    case rhi::ImageFormat::R32_FLOAT:
+    case rhi::ImageFormat::D32_FLOAT: {
+        (void)std::snprintf(out, out_size, "V: %.6g", *(const f32 *)data);
+        break;
+    }
+    case rhi::ImageFormat::R32_UINT: {
+        (void)std::snprintf(out, out_size, "ID: %u", *(const u32 *)data);
+        break;
+    }
+    case rhi::ImageFormat::RGBA32_FLOAT: {
+        const f32 *p = (const f32 *)data;
+        (void)std::snprintf(out, out_size, "R: %.4g  G: %.4g  B: %.4g  A: %.4g", p[0], p[1], p[2], p[3]);
+        break;
+    }
+    default:
+        (void)std::snprintf(out, out_size, "readback unsupported");
+        break;
+    }
+}
+
+bool readback_texel_raw(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    rhi::ImageView &view,
+    u32 mip,
+    u32 layer,
+    i64 tx,
+    i64 ty,
+    void *out,
+    usize out_size
+) {
+    if (out == nullptr || out_size == 0) {
+        return false;
+    }
+    rhi::Image &img = *view.desc.image;
+    // multisampling, cannot be copied directly
+    if (img.desc.sample_count != rhi::SampleCount::Sample1) {
+        return false;
+    }
+
+    ensure_scratch(device);
+    rhi::ResourceState saved = img.state;
+    rhi::ImageRange vr{};
+    vr.mip = view.desc.mip_start;
+    vr.mip_count = view.desc.mip_count;
+    vr.layer = view.desc.layer_start;
+    vr.layer_count = view.desc.layer_count;
+    vr.aspect = view.desc.aspect;
+
+    QsCmd *qcmd = qs_acquire(qs);
+
+    rhi::barrier(qcmd->cmd, img, vr, saved, rhi::ResourceState::TransferFrom);
+
+    rhi::BufferTextureCopyRegion region{};
+    region.buffer_offset = 0;
+    region.mip_level = mip;
+    region.base_array_layer = layer;
+    region.layer_count = 1;
+    region.texture_offset_x = (u32)tx;
+    region.texture_offset_y = (u32)ty;
+    region.texture_offset_z = 0;
+    region.texture_extent_width = 1;
+    region.texture_extent_height = 1;
+    region.texture_extent_depth = 1;
+    rhi::copy_image_to_buffer(qcmd->cmd, view, RB.stage, region);
+
+    // restore the subrange to its exact prior state so the framegraph's
+    // tracked state stays consistent with the GPU. img.state was untouched
+    // (sub-range barriers never write it), so this is TransferFrom -> saved.
+    rhi::barrier(qcmd->cmd, img, vr, rhi::ResourceState::TransferFrom, saved);
+
+    qs_submit_and_wait(qs, *qcmd);
+
+    if (RB.stage.mapped == nullptr) {
+        return false;
+    }
+    rhi::buffer_invalidate(device, RB.stage, 0, out_size);
+    std::memcpy(out, RB.stage.mapped, out_size);
+    return true;
+}
+
+bool readback_texel(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    rhi::ImageView &view,
+    u32 mip,
+    u32 layer,
+    i64 tx,
+    i64 ty,
+    char *out,
+    usize out_size
+) {
+    if (!format_readback_supported(view.desc.image->desc.format)) {
+        (void)std::snprintf(out, out_size, "readback unsupported for this format");
+        return false;
+    }
+    u8 raw[16];
+    if (!readback_texel_raw(device, qs, view, mip, layer, tx, ty, raw, sizeof(raw))) {
+        (void)std::snprintf(out, out_size, "readback failed");
+        return false;
+    }
+    decode_texel(view.desc.image->desc.format, raw, out, out_size);
+    return true;
+}
+
+void build_swizzle(
+    Channel channel,
+    rhi::ImageFormat fmt,
+    rhi::ComponentSwizzle &sr,
+    rhi::ComponentSwizzle &sg,
+    rhi::ComponentSwizzle &sb,
+    rhi::ComponentSwizzle &sa
+) {
+    sr = rhi::ComponentSwizzle::Identity;
+    sg = rhi::ComponentSwizzle::Identity;
+    sb = rhi::ComponentSwizzle::Identity;
+    sa = rhi::ComponentSwizzle::Identity;
+
+    if (fmt == rhi::ImageFormat::D32_FLOAT) {
+        // depth views restrict swizzle: G/B/A may only be R/IDENTITY/ZERO.
+        // Grayscale display: depth -> RGB, alpha stays Identity (sampled as 1).
+        if (channel == Channel::R) {
+            sr = sg = sb = rhi::ComponentSwizzle::R;
+            sa = rhi::ComponentSwizzle::Identity;
+        }
+        return;
+    }
+
+    switch (channel) {
+    case Channel::R:
+        sr = sg = sb = rhi::ComponentSwizzle::R;
+        sa = rhi::ComponentSwizzle::One;
+        break;
+    case Channel::G:
+        sr = sg = sb = rhi::ComponentSwizzle::G;
+        sa = rhi::ComponentSwizzle::One;
+        break;
+    case Channel::B:
+        sr = sg = sb = rhi::ComponentSwizzle::B;
+        sa = rhi::ComponentSwizzle::One;
+        break;
+    case Channel::A:
+        sr = sg = sb = rhi::ComponentSwizzle::A;
+        sa = rhi::ComponentSwizzle::One;
+        break;
+    default:
+        break;
+    }
+}
+
+bool draw_texture_inspector(rhi::Device &device, QuickSubmit &qs, const char *id, const TextureViewerDesc &desc) {
+    ImGuiID imgui_id = ImGui::GetID(id);
+    const ImGuiIO &io = ImGui::GetIO();
+    InspectorState *state = find_or_create(imgui_id);
+
+    if (!desc.image || !rhi::valid(*desc.image)) {
+        if (state->owns_view) {
+            rhi::destroy_image_view(device, state->custom_view);
+            state->owns_view = false;
+        }
+        ImGui::TextUnformatted("No texture");
+        return false;
+    }
+
+    if (desc.image != state->image) {
+        state->image = desc.image;
+        state->scale = 1.0f;
+        state->y_flip = false;
+        state->mip_level = 0;
+        state->array_layer = 0;
+        state->channel = Channel::RGB;
+
+        // Auto-fit the newly opened texture.
+        f32 w = (f32)ImMax(desc.image->desc.width, 1u);
+        f32 h = (f32)ImMax(desc.image->desc.height, 1u);
+        ImVec2 a = ImGui::GetContentRegionAvail();
+        a.y -= 60;
+        state->scale = ImMax(ImMin(a.x / w, a.y / h), 0.0625f);
+        state->read_valid = false;
+    }
+
+    // Depth sources display as grayscale; the channel selector is disabled.
+    bool is_depth = desc.image->desc.format == rhi::ImageFormat::D32_FLOAT;
+    if (is_depth) {
+        state->channel = Channel::R;
+    }
+
+    u32 max_mip = (desc.image->desc.mip_levels > 1) ? desc.image->desc.mip_levels - 1 : 0;
+    u32 max_layer = (desc.image->desc.layers > 1) ? desc.image->desc.layers - 1 : 0;
+    if (state->mip_level > max_mip) {
+        state->mip_level = max_mip;
+    }
+    if (state->array_layer > max_layer) {
+        state->array_layer = max_layer;
+    }
+
+    // Rebuild the owned view only when its parameters actually change.
+    const bool want_custom =
+        is_depth || state->mip_level > 0 || state->array_layer > 0 || state->channel != Channel::RGB;
+    const bool view_changed = state->view_image != desc.image || state->view_mip != state->mip_level ||
+                              state->view_layer != state->array_layer || state->view_channel != state->channel;
+    if (state->owns_view && view_changed) {
+        rhi::destroy_image_view(device, state->custom_view);
+        state->owns_view = false;
+    }
+
+    if (!state->owns_view) {
+        rhi::ImageAspect aspect =
+            desc.image->desc.format == rhi::ImageFormat::D32_FLOAT ? rhi::ImageAspect::Depth : rhi::ImageAspect::Color;
+        rhi::ImageViewDesc vd{};
+        vd.image = desc.image;
+        vd.aspect = aspect;
+        vd.dimension = rhi::TextureViewDimension::TEXTURE_2D;
+        vd.mip_start = want_custom ? state->mip_level : 0;
+        vd.mip_count = 1;
+        vd.layer_start = want_custom ? state->array_layer : 0;
+        vd.layer_count = 1;
+        if (want_custom) {
+            build_swizzle(
+                state->channel, desc.image->desc.format, vd.swizzle_r, vd.swizzle_g, vd.swizzle_b, vd.swizzle_a
+            );
+        }
+        state->owns_view = rhi::create_image_view(device, vd, state->custom_view);
+        if (!state->owns_view) {
+            return false;
+        }
+    }
+    rhi::ImageView &view = state->custom_view;
+    state->view_image = desc.image;
+    state->view_mip = state->mip_level;
+    state->view_layer = state->array_layer;
+    state->view_channel = state->channel;
+
+    state->desc = imgui_backend::texture(view);
+    if (state->desc == UINT64_MAX) {
+        return false;
+    }
+
+    f32 &scale = state->scale;
+    f32 tex_w = (f32)ImMax(desc.image->desc.width >> state->mip_level, 1u);
+    f32 tex_h = (f32)ImMax(desc.image->desc.height >> state->mip_level, 1u);
+    ImVec2 tex_size = ImVec2(tex_w, tex_h);
+
+    if (desc.name) {
+        ImGui::Text("%s", desc.name);
+        if (desc.format_name) {
+            ImGui::SameLine();
+            ImGui::Text("  %s", desc.format_name);
+        }
+        ImGui::SameLine();
+        ImGui::Text("  %ux%u", desc.image->desc.width, desc.image->desc.height);
+    }
+
+    // Row 1: view controls
+    if (ImGui::Button("1:1")) {
+        scale = 1.0f;
+        state->reset_scroll = true;
+    }
+    ImGui::SameLine();
+    if (ImGui::Button("Fit")) {
+        ImVec2 a = ImGui::GetContentRegionAvail();
+        a.y -= 60;
+        scale = ImMax(ImMin(a.x / tex_size.x, a.y / tex_size.y), 0.0625f);
+        state->reset_scroll = true;
+    }
+    ImGui::SameLine();
+    ImGui::SetNextItemWidth(100);
+    ImGui::SliderFloat("##zoom", &scale, 0.0625f, 64.0f, "%.2fx");
+    if (max_mip > 0) {
+        ImGui::SameLine();
+        ImGui::SetNextItemWidth(80);
+        int m = (int)state->mip_level;
+        if (ImGui::SliderInt("##mip", &m, 0, (int)max_mip, "Mip %d")) {
+            state->mip_level = (u32)m;
+        }
+    }
+    if (max_layer > 0) {
+        ImGui::SameLine();
+        ImGui::SetNextItemWidth(80);
+        int l = (int)state->array_layer;
+        if (ImGui::SliderInt("##layer", &l, 0, (int)max_layer, "Lyr %d")) {
+            state->array_layer = (u32)l;
+        }
+    }
+    ImGui::SameLine();
+    if (ImGui::Button(state->y_flip ? "Y-Flip ON" : "Y-Flip OFF")) {
+        state->y_flip = !state->y_flip;
+    }
+
+    // Row 2: display controls
+    if (is_depth) {
+        ImGui::TextUnformatted("Depth");
+    } else {
+        ImGui::SetNextItemWidth(70);
+        int ch = (int)state->channel;
+        if (ImGui::Combo("##channel", &ch, CHANNEL_NAMES, IM_ARRAYSIZE(CHANNEL_NAMES))) {
+            state->channel = (Channel)ch;
+        }
+    }
+    ImGui::SameLine();
+    ImGui::Checkbox("Checker", &state->show_checker);
+    ImGui::SameLine();
+    ImGui::Checkbox("Grid", &state->show_grid);
+
+    ImGui::BeginChild("##img", ImVec2(0, 0), 0, ImGuiWindowFlags_HorizontalScrollbar);
+    if (state->reset_scroll) {
+        ImGui::SetScrollX(0.0f);
+        ImGui::SetScrollY(0.0f);
+        state->reset_scroll = false;
+    }
+    ImVec2 img_size = tex_size * scale;
+    ImVec2 cursor_tl = ImGui::GetCursorScreenPos();
+    ImVec2 uv0(0, state->y_flip ? 1 : 0), uv1(1, state->y_flip ? 0 : 1);
+
+    ImDrawList *dl = ImGui::GetWindowDrawList();
+    if (state->show_checker) {
+        if (create_checkerboard(device, qs, desc.sampler)) {
+            dl->AddImage((ImTextureID)(u64)CHECKER_DESC, cursor_tl, cursor_tl + img_size, uv0, uv1);
+        }
+    }
+
+    ImGui::Image((ImTextureID)(u64)state->desc, img_size, uv0, uv1);
+    bool hovered = ImGui::IsItemHovered();
+
+    if (state->show_grid && scale > 4.0f) {
+        f32 a = ImClamp((scale - 4.0f) / 20.0f, 0.0f, 1.0f);
+        ImU32 col = IM_COL32(255, 255, 255, (int)(255.0f * (0.2f + 0.4f * a)));
+        ImVec2 br = cursor_tl + img_size;
+        for (int x = 1; x < (int)tex_w; ++x) {
+            float sx = ImFloor(cursor_tl.x + x * scale) + 0.5f;
+            dl->AddLine(ImVec2(sx, cursor_tl.y), ImVec2(sx, br.y), col);
+        }
+        for (int y = 1; y < (int)tex_h; ++y) {
+            float sy = ImFloor(cursor_tl.y + y * scale) + 0.5f;
+            dl->AddLine(ImVec2(cursor_tl.x, sy), ImVec2(br.x, sy), col);
+        }
+        dl->AddRect(cursor_tl, br, col);
+    }
+
+    if (hovered && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
+        ImVec2 a = ImGui::GetContentRegionAvail();
+        a.y -= 60;
+        scale = ImMax(ImMin(a.x / tex_size.x, a.y / tex_size.y), 0.0625f);
+        state->reset_scroll = true;
+    }
+    if (hovered && io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_0)) {
+        scale = 1.0f;
+        state->reset_scroll = true;
+    }
+
+    if (hovered && io.MouseWheel != 0.0f) {
+        f32 os = scale;
+        f32 f = (io.MouseWheel > 0) ? 1.3f : (1 / 1.3f);
+        f32 ns = ImClamp(os * f, 0.0625f, 64.0f);
+        if (ns != os) {
+            ImVec2 mu = (io.MousePos - cursor_tl) / (tex_size * os);
+            scale = ns;
+            ImVec2 nm = mu * tex_size * scale;
+            ImGui::SetScrollX(ImGui::GetScrollX() + nm.x - (io.MousePos.x - cursor_tl.x));
+            ImGui::SetScrollY(ImGui::GetScrollY() + nm.y - (io.MousePos.y - cursor_tl.y));
+        }
+    }
+    if (hovered) {
+        ImVec2 mf = (io.MousePos - cursor_tl) / img_size;
+        f32 vf = state->y_flip ? 1.0f - mf.y : mf.y;
+        i64 tx = (i64)ImClamp(ImFloor(mf.x * tex_w), 0.0f, tex_w - 1.0f);
+        i64 ty = (i64)ImClamp(ImFloor(vf * tex_h), 0.0f, tex_h - 1.0f);
+
+        state->read_uv_x = mf.x;
+        state->read_uv_y = vf;
+        state->read_valid = true;
+
+        if (state->read_image != desc.image || state->read_tx != tx || state->read_ty != ty ||
+            state->read_mip != state->mip_level || state->read_layer != state->array_layer) {
+            state->read_image = desc.image;
+            state->read_tx = tx;
+            state->read_ty = ty;
+            state->read_mip = state->mip_level;
+            state->read_layer = state->array_layer;
+            readback_texel(
+                device,
+                qs,
+                view,
+                state->mip_level,
+                state->array_layer,
+                tx,
+                ty,
+                state->hover_text,
+                sizeof(state->hover_text)
+            );
+        }
+
+        ImGui::BeginTooltip();
+        ImGui::Text(
+            "UV: (%.4f, %.4f)  Texel: (%lld, %lld)  Mip: %u  Layer: %u",
+            mf.x,
+            vf,
+            tx,
+            ty,
+            state->mip_level,
+            state->array_layer
+        );
+        ImGui::TextUnformatted(state->hover_text);
+        ImGui::EndTooltip();
+    }
+    ImGui::EndChild();
+
+    return true;
+}
+
+void shutdown_texture_inspectors(rhi::Device &device) {
+    for (auto &insp : INSPECTORS) {
+        if (insp.owns_view) {
+            rhi::destroy_image_view(device, insp.custom_view);
+        }
+        insp.desc = UINT64_MAX;
+    }
+    INSPECTORS.clear();
+    destroy_checkerboard(device);
+    destroy_scratch(device);
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/timings.cpp +70 -0
--- a/src/editor/timings.cpp
+++ b/src/editor/timings.cpp
@@ -0,0 +1,70 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#include "passes/fg_utils.h"
+#include "renderer.h"
+#include "scene/scene.h"
+
+namespace editor {
+
+void draw_timings_window(
+    Scene &scene, RenderData &rd, const PassInspectorEntry *passes, u32 pass_count, Editor &editor, ImFont *mono_font
+) {
+    if (ImGui::Begin("Timings", nullptr, PANEL_FLAGS)) {
+        ImGui::PushFont(mono_font);
+
+        const FrameStats &st = rd.frame_stats;
+        f32 gpu_ms = 0.0f;
+        for (u32 i = 0; i < pass_count; ++i) {
+            if (passes[i].timing_valid) {
+                gpu_ms += passes[i].gpu_ms;
+            }
+        }
+
+        ImGui::Text("FPS: %.1f", st.fps());
+        ImGui::Text("CPU: last %.3f | avg %.3f | min %.3f | max %.3f ms", st.last_ms, st.avg_ms, st.min_ms, st.max_ms);
+        ImGui::Text("GPU: %.3f ms total", gpu_ms);
+
+        ImGui::Separator();
+
+        if (ImGui::BeginTable("PassInspector", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
+            ImGui::TableSetupColumn("Pass");
+            ImGui::TableSetupColumn("GPU ms", ImGuiTableColumnFlags_WidthFixed, 80.0f);
+            ImGui::TableHeadersRow();
+
+            f32 total_gpu_ms = 0.0f;
+            for (u32 i = 0; i < pass_count; ++i) {
+                const PassInspectorEntry &pass = passes[i];
+                ImGui::TableNextRow();
+                ImGui::TableSetColumnIndex(0);
+                ImGui::TextUnformatted(pass.name ? pass.name : "Unnamed Pass");
+                ImGui::TableSetColumnIndex(1);
+                if (pass.timing_valid) {
+                    ImGui::Text("%.3f", pass.gpu_ms);
+                    total_gpu_ms += pass.gpu_ms;
+                } else {
+                    ImGui::TextUnformatted("pending");
+                }
+            }
+
+            if (pass_count > 0) {
+                ImGui::TableNextRow();
+                ImGui::TableSetColumnIndex(0);
+                ImGui::TextUnformatted("Total GPU");
+                ImGui::TableSetColumnIndex(1);
+                ImGui::Text("%.3f", total_gpu_ms);
+            }
+            ImGui::EndTable();
+        }
+
+        ImGui::PopFont();
+    }
+    ImGui::End();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/editor/viewport.cpp +109 -0
--- a/src/editor/viewport.cpp
+++ b/src/editor/viewport.cpp
@@ -0,0 +1,109 @@
+#ifdef ENABLE_EDITOR
+#define IMGUI_DEFINE_MATH_OPERATORS
+#include "editor.h"
+
+#include <imgui.h>
+
+#include <algorithm>
+
+#include "backend/imgui_backend.h"
+#include "quick_submit.h"
+#include "renderer.h"
+
+namespace editor {
+
+void draw_viewport_central(Editor &e, RenderData &rd) {
+    if (!rhi::valid(rd.display)) {
+        return;
+    }
+    rhi::Image &img = rd.display;
+    if (!rhi::valid(img)) {
+        return;
+    }
+
+    static rhi::ImageView live{};
+    if (rhi::valid(live)) {
+        rhi::destroy_image_view(*e.device, live);
+        live = {};
+    }
+    rhi::ImageView view{};
+    if (!rhi::create_image_view(*e.device, {.image = &img, .aspect = rhi::ImageAspect::Color, .mip_count = 1}, view)) {
+        return;
+    }
+    u64 slot = imgui_backend::texture(view);
+    if (slot == UINT64_MAX) {
+        rhi::destroy_image_view(*e.device, view);
+        return;
+    }
+    live = view;
+
+    ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
+
+    ImGui::Begin("Viewport", nullptr);
+
+    // translate-gizmo toolbar (widget state; drag math runs pre-execute in update_translate_gizmo)
+    {
+        bool move_on = e.show_translate_gizmo;
+        if (ImGui::Button(move_on ? "Move: ON" : "Move")) {
+            e.show_translate_gizmo = !e.show_translate_gizmo;
+        }
+        ImGui::SameLine();
+        ImGui::Checkbox("Snap", &e.gizmo_snap);
+        ImGui::SameLine();
+        ImGui::SetNextItemWidth(64.0f);
+        ImGui::DragFloat("##snapstep", &e.gizmo_snap_step, 0.01f, 0.01f, 10.0f, "%.2f");
+    }
+
+    ImVec2 viewport_size = ImGui::GetContentRegionAvail();
+    if (viewport_size.x > 0.0f && viewport_size.y > 0.0f) {
+        ImGui::Image((ImTextureID)(u64)slot, viewport_size);
+
+        // rect cache for next frame's pre-execute gizmo update
+        e.gizmo_view_min = ImGui::GetItemRectMin();
+        e.gizmo_view_size = viewport_size;
+
+        // a grab in progress owns the mouse, and handle presses are consumed
+        // by the gizmo: never (de)select underneath a drag or a handle grab
+        // (hover is 1 frame stale, same as the gizmo rect cache)
+        if (ImGui::IsItemHovered() && ImGui::IsItemClicked(ImGuiMouseButton_Left) && !e.gizmo_dragging &&
+            e.gizmo_hover_axis < 0 && rhi::valid(rd.id_blit)) {
+            rhi::Image &id_img = rd.id_blit;
+            ImVec2 rel = {
+                ImGui::GetMousePos().x - ImGui::GetItemRectMin().x, ImGui::GetMousePos().y - ImGui::GetItemRectMin().y
+            };
+            i64 tx = (i64)(rel.x * (f32)id_img.desc.width / viewport_size.x);
+            i64 ty = (i64)(rel.y * (f32)id_img.desc.height / (viewport_size.y));
+            ty = id_img.desc.height - 1 - ty; // I flip the vk viewport
+
+            rhi::ImageView id_view{};
+            if (rhi::create_image_view(
+                    *e.device, {.image = &id_img, .aspect = rhi::ImageAspect::Color, .mip_count = 1}, id_view
+                )) {
+                u32 raw = 0;
+                if (e.qs != nullptr && readback_texel_raw(*e.device, *e.qs, id_view, 0, 0, tx, ty, &raw, sizeof(raw)) &&
+                    raw > 0) {
+                    e.selected_node = (int)raw - 1;
+                } else {
+                    e.selected_node = -1;
+                }
+                rhi::destroy_image_view(*e.device, id_view);
+            } else {
+                e.selected_node = -1;
+            }
+        }
+    }
+
+    u32 nw = (u32)(viewport_size.x + 0.5f), nh = (u32)(viewport_size.y + 0.5f);
+    if (nw > 0 && nh > 0 && (nw != e.viewport_width || nh != e.viewport_height)) {
+        e.viewport_width = nw;
+        e.viewport_height = nh;
+        e.viewport_resized = true;
+    }
+
+    ImGui::End();
+    ImGui::PopStyleVar();
+}
+
+} // namespace editor
+
+#endif // ENABLE_EDITOR
ADD · src/passes/cluster/cluster_bounds.cpp +79 -0
--- a/src/passes/cluster/cluster_bounds.cpp
+++ b/src/passes/cluster/cluster_bounds.cpp
@@ -0,0 +1,79 @@
+#include "cluster_bounds.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace cluster_bounds {
+
+static u64 cluster_total(u32 w, u32 h) {
+    return (u64)((w + TILE_SIZE_X - 1) / TILE_SIZE_X) * ((h + TILE_SIZE_Y - 1) / TILE_SIZE_Y) * CLUSTER_COUNT_Z;
+}
+static u64 cluster_bounds_size(u32 w, u32 h) {
+    return cluster_total(w, h) * sizeof(ClusterBounds);
+}
+static u64 cluster_records_size(u32 w, u32 h) {
+    return cluster_total(w, h) * sizeof(ClusterRecord);
+}
+
+Resources
+record(rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, u32 width, u32 height) {
+
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/cluster/cluster_bounds.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("ClusterBounds", pd);
+
+    Resources out;
+    out.cluster_bounds = fg.add_buffer({
+        .desc = {.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr},
+        .name = "fg/cluster/bounds",
+        .size_fn = cluster_bounds_size,
+    });
+    out.cluster_records = fg.add_buffer({
+        .desc = {.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr},
+        .name = "fg/cluster/records",
+        .size_fn = cluster_records_size,
+    });
+
+    auto &builder = fg.add_pass("ClusterBounds");
+    builder.write(out.cluster_bounds, rhi::ResourceState::StorageReadWrite);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        auto &frame = ctx.frame_data[ctx.frame_index];
+
+        u32 cx = (ctx.render_width + TILE_SIZE_X - 1) / TILE_SIZE_X;
+        u32 cy = (ctx.render_height + TILE_SIZE_Y - 1) / TILE_SIZE_Y;
+        u32 cz = CLUSTER_COUNT_Z;
+        u32 total_clusters = cx * cy * cz;
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        ClusterGrid cb{
+            .cluster_count_x = cx,
+            .cluster_count_y = cy,
+            .cluster_count_z = cz,
+            .cluster_total = total_clusters,
+            .clusters_bounds = rhi::buffer_device_address(ctx.device, ctx.get_buffer(out.cluster_bounds)),
+        };
+        memcpy((u8 *)frame.frame_ubo.mapped + offsetof(FrameUBO, cluster), &cb, sizeof(ClusterGrid));
+
+        ClusterBoundsPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        u32 total = cx * cy * cz;
+        u32 groups = (total + 63u) / 64u;
+        if (groups > 0) {
+            rhi::dispatch(ctx.cmd, groups);
+        }
+    });
+    return out;
+}
+
+} // namespace cluster_bounds<
\ No newline at end of file
ADD · src/passes/cluster/cluster_bounds.h +20 -0
--- a/src/passes/cluster/cluster_bounds.h
+++ b/src/passes/cluster/cluster_bounds.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct RenderData;
+struct Scene;
+struct Pipelines;
+
+namespace cluster_bounds {
+
+struct Resources {
+    BufferHandle cluster_bounds;
+    BufferHandle cluster_records;
+};
+
+Resources
+record(rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, u32 width, u32 height);
+
+} // namespace cluster_bounds
ADD · src/passes/cluster/cluster_bounds.slang +86 -0
--- a/src/passes/cluster/cluster_bounds.slang
+++ b/src/passes/cluster/cluster_bounds.slang
@@ -0,0 +1,86 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+ClusterBoundsPushConstants pc;
+
+f32 slice_far_depth(u32 slice, f32 near, f32 far, u32 num_slices) {
+    f32 t = (f32(slice) + 1.0) / f32(num_slices);
+    return near * pow(far / near, t);
+}
+
+vec3 make_view_ray(f32 sx, f32 sy, mat4 invProj, f32 screenW, f32 screenH) {
+    f32 ndcX = sx / screenW * 2.0 - 1.0;
+    f32 ndcY = 1.0 - sy / screenH * 2.0;
+    // f32 ndcY = sy / screenH * 2.0 - 1.0;
+
+    vec4 p = vec4(ndcX, ndcY, 1.0, 1.0) * invProj;
+
+    vec3 ray = p.xyz / p.w;
+
+    // Make z = 1
+    return ray / ray.z;
+}
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 dispatchThreadID: SV_DispatchThreadID) {
+    u32 clusterIndex = dispatchThreadID.x;
+    FrameUBO frame = *pc.frame;
+    ClusterGrid data = frame.cluster;
+
+    u32 totalClusters = data.cluster_count_x * data.cluster_count_y * data.cluster_count_z;
+    if (clusterIndex >= totalClusters) {
+        return;
+    }
+
+    // create a flat index to (tx, ty, tz)
+    u32 tz = clusterIndex / (data.cluster_count_x * data.cluster_count_y);
+    u32 xy = clusterIndex % (data.cluster_count_x * data.cluster_count_y);
+    u32 ty = xy / data.cluster_count_x;
+    u32 tx = xy % data.cluster_count_x;
+
+    // screen-space tile bounds
+    f32 left = f32(tx) * f32(TILE_SIZE_X);
+    f32 top = f32(ty) * f32(TILE_SIZE_Y);
+    f32 right = f32(tx + 1) * f32(TILE_SIZE_X);
+    f32 bottom = f32(ty + 1) * f32(TILE_SIZE_Y);
+
+    // depth bounds for this slice (view-space Z, positive away from camera)
+    f32 nearZ =
+        tz == 0 ? frame.near_plane : slice_far_depth(tz - 1, frame.near_plane, frame.far_plane, data.cluster_count_z);
+    f32 farZ = slice_far_depth(tz, frame.near_plane, frame.far_plane, data.cluster_count_z);
+
+    // sample 4 tile corners at both near and far depth → 8 points
+    vec3 corners[8];
+    mat4 invProj = frame.inv_proj;
+
+    vec3 rayTL = make_view_ray(left, top, invProj, f32(frame.screen_w), f32(frame.screen_h));
+    vec3 rayTR = make_view_ray(right, top, invProj, f32(frame.screen_w), f32(frame.screen_h));
+    vec3 rayBL = make_view_ray(left, bottom, invProj, f32(frame.screen_w), f32(frame.screen_h));
+    vec3 rayBR = make_view_ray(right, bottom, invProj, f32(frame.screen_w), f32(frame.screen_h));
+
+    corners[0] = rayTL * nearZ;
+    corners[1] = rayTL * farZ;
+
+    corners[2] = rayTR * nearZ;
+    corners[3] = rayTR * farZ;
+
+    corners[4] = rayBL * nearZ;
+    corners[5] = rayBL * farZ;
+
+    corners[6] = rayBR * nearZ;
+    corners[7] = rayBR * farZ;
+
+    // view space bounding box
+    vec3 minP = corners[0];
+    vec3 maxP = corners[0];
+    [unroll]
+    for (u32 i = 1; i < 8; ++i) {
+        minP = min(minP, corners[i]);
+        maxP = max(maxP, corners[i]);
+    }
+
+    data.clusters_bounds[clusterIndex].minPoint = vec4(minP, 0.0);
+    data.clusters_bounds[clusterIndex].maxPoint = vec4(maxP, 0.0);
+}
ADD · src/passes/cluster/light_cull.cpp +94 -0
--- a/src/passes/cluster/light_cull.cpp
+++ b/src/passes/cluster/light_cull.cpp
@@ -0,0 +1,94 @@
+#include "light_cull.h"
+
+#include "backend/rhi.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace light_cull {
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle cluster_bounds,
+    BufferHandle cluster_records
+) {
+
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/cluster/light_cull.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("LightCull", pd);
+
+    Resources out;
+    out.light_index_list = fg.add_buffer({
+        .desc =
+            {
+                .size = MAX_LIGHT_INDICES * sizeof(u32),
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+            },
+        .name = "fg/light-cull/index-list",
+    });
+    out.light_index_counter = fg.add_buffer({
+        .desc =
+            {
+                .size = sizeof(u32),
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+
+            },
+        .name = "fg/light-cull/counter",
+    });
+
+    auto &builder = fg.add_pass("LightCull");
+    builder.read(cluster_bounds, rhi::ResourceState::StorageRead);
+    builder.write(cluster_records, rhi::ResourceState::StorageReadWrite);
+    builder.write(out.light_index_list, rhi::ResourceState::StorageReadWrite);
+    builder.write(out.light_index_counter, rhi::ResourceState::StorageReadWrite);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        auto &frame = ctx.frame_data[ctx.frame_index];
+
+        u32 cx = (ctx.render_width + TILE_SIZE_X - 1) / TILE_SIZE_X;
+        u32 cy = (ctx.render_height + TILE_SIZE_Y - 1) / TILE_SIZE_Y;
+        u32 cz = CLUSTER_COUNT_Z;
+        u32 total_clusters = cx * cy * cz;
+
+        u32 group_count_x = (total_clusters + 63u) / 64u;
+        if (group_count_x == 0) {
+            return;
+        }
+
+        rhi::BufferView counter_view = ctx.buffer_view(out.light_index_counter, {.type = rhi::BufferViewType::Storage});
+        rhi::Buffer &counter_buf = *counter_view.buffer;
+        rhi::barrier(ctx.cmd, counter_buf, counter_buf.state, rhi::ResourceState::TransferTo);
+        rhi::fill_buffer(ctx.cmd, counter_buf, 0, sizeof(u32), 0);
+        rhi::barrier(ctx.cmd, counter_buf, rhi::ResourceState::TransferTo, rhi::ResourceState::StorageReadWrite);
+
+        LightCull lc{};
+        lc.clusters_records = rhi::buffer_device_address(ctx.device, ctx.get_buffer(cluster_records));
+        lc.light_index_list = rhi::buffer_device_address(ctx.device, ctx.get_buffer(out.light_index_list));
+
+        memcpy((u8 *)frame.frame_ubo.mapped + offsetof(FrameUBO, light_cull), &lc, sizeof(LightCull));
+
+        LightCullPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.light_index_counter = rhi::buffer_device_address(ctx.device, ctx.get_buffer(out.light_index_counter));
+
+        pc.light_count = 0;
+        pc.phase = 0;
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+        rhi::dispatch(ctx.cmd, group_count_x);
+    });
+    return out;
+}
+
+} // namespace light_cull<
\ No newline at end of file
ADD · src/passes/cluster/light_cull.h +24 -0
--- a/src/passes/cluster/light_cull.h
+++ b/src/passes/cluster/light_cull.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct Device;
+struct FrameData;
+struct Pipelines;
+
+namespace light_cull {
+
+struct Resources {
+    BufferHandle light_index_list;
+    BufferHandle light_index_counter; // not read by forward; tracks lights culled per cluster
+};
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle cluster_bounds,
+    BufferHandle cluster_records
+);
+
+} // namespace light_cull
ADD · src/passes/cluster/light_cull.slang +85 -0
--- a/src/passes/cluster/light_cull.slang
+++ b/src/passes/cluster/light_cull.slang
@@ -0,0 +1,85 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/frustum_culling.slang"
+
+[[vk::push_constant]]
+LightCullPushConstants pc;
+
+// single-phase light culling: each thread counts, allocates, and fills
+// for its cluster in one go
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 dispatchThreadID: SV_DispatchThreadID) {
+    u32 clusterIndex = dispatchThreadID.x;
+
+    FrameUBO frame = *pc.frame;
+    ClusterGrid data = frame.cluster;
+    LightCull lc_data = frame.light_cull;
+
+    if (clusterIndex >= data.cluster_total) {
+        return;
+    }
+
+    // aabb of each cluster (cluster_bounds.sla)
+    ClusterBounds bounds = data.clusters_bounds[clusterIndex];
+    vec4 bmin = bounds.minPoint;
+    vec4 bmax = bounds.maxPoint;
+
+    mat4 view = frame.view;
+    mat4 view_proj = frame.view_proj;
+    Frustum frustum = extract_frustum(view_proj);
+    u32 pl_count = frame.point_light_count;
+
+    // lights intersection w the cluster
+    u32 count = 0;
+    for (u32 i = 0; i < pl_count; ++i) {
+        PointLightGPU pl = frame.point_lights[i];
+        vec3 posWS = pl.position;
+        f32 range = pl.range;
+
+        if (!sphere_visible_in_frustum(posWS, range, frustum))
+            continue;
+
+        vec4 posVS4 = vec4(posWS, 1.0) * view;
+        vec3 posVS = posVS4.xyz / posVS4.w;
+
+        if (sphere_intersects_aabb(posVS, range, bmin.xyz, bmax.xyz)) {
+            count++;
+        }
+    }
+
+    if (count == 0) {
+        lc_data.clusters_records[clusterIndex].lightOffset = 0;
+        lc_data.clusters_records[clusterIndex].lightCount = 0;
+        return;
+    }
+
+    // alloc slot range from global atomic counter
+    u32 offset;
+    InterlockedAdd(pc.light_index_counter[0], count, offset);
+
+    u32 writeCount = (offset < MAX_LIGHT_INDICES) ? min(count, MAX_LIGHT_INDICES - offset) : 0;
+
+    lc_data.clusters_records[clusterIndex].lightOffset = offset;
+    lc_data.clusters_records[clusterIndex].lightCount = writeCount;
+
+    u32 localIdx = 0;
+    for (u32 i = 0; i < pl_count && localIdx < writeCount; ++i) {
+        PointLightGPU pl = frame.point_lights[i];
+        vec3 posWS = pl.position;
+        f32 range = pl.range;
+
+        if (!sphere_visible_in_frustum(posWS, range, frustum)) {
+            continue;
+        }
+
+        vec4 posVS4 = vec4(posWS, 1.0) * view;
+        vec3 posVS = posVS4.xyz / posVS4.w;
+
+        if (sphere_intersects_aabb(posVS, range, bmin.xyz, bmax.xyz)) {
+            lc_data.light_index_list[offset + localIdx] = i;
+            localIdx++;
+        }
+    }
+}
ADD · src/passes/ddgi/ddgi_classify.cpp +46 -0
--- a/src/passes/ddgi/ddgi_classify.cpp
+++ b/src/passes/ddgi/ddgi_classify.cpp
@@ -0,0 +1,46 @@
+#include "ddgi_classify.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ddgi_classify {
+
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, ddgi_trace::Resources &res
+) {
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/ddgi/ddgi_classify.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("DdgiClassify", pd);
+
+    auto &builder = fg.add_pass("DDGI Classify");
+    builder.read(res.ray_samples, rhi::ResourceState::StorageRead);
+    builder.read_write(res.probe_state, rhi::ResourceState::StorageReadWrite);
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        u32 groups = (res.grid.probe_count + 63) / 64;
+        if (groups == 0) {
+            return;
+        }
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        DdgiClassifyPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.frame_counter = ctx.frame_count;
+        pc.samples_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.ray_samples));
+        pc.probe_state = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.probe_state));
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+        rhi::dispatch(ctx.cmd, groups, 1, 1);
+    });
+}
+
+} // namespace ddgi_classify<
\ No newline at end of file
ADD · src/passes/ddgi/ddgi_classify.h +13 -0
--- a/src/passes/ddgi/ddgi_classify.h
+++ b/src/passes/ddgi/ddgi_classify.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "ddgi_trace.h"
+#include "passes/fg.h"
+
+struct FrameData;
+struct RenderData;
+
+namespace ddgi_classify {
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, ddgi_trace::Resources &res
+);
+}
ADD · src/passes/ddgi/ddgi_classify.slang +46 -0
--- a/src/passes/ddgi/ddgi_classify.slang
+++ b/src/passes/ddgi/ddgi_classify.slang
@@ -0,0 +1,46 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/ddgi_common.slang"
+
+[[vk::push_constant]]
+DdgiClassifyPushConstants pc;
+
+static const f32 DDGI_MISS_DISTANCE = 1e27f;
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 dtid: SV_DispatchThreadID) {
+    uint probe_idx = dtid.x;
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+    DdgiConfig cfg = frame.ddgi_cfg;
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    if (probe_idx >= dims.x * dims.y * dims.z) {
+        return;
+    }
+
+    // if probe is inside geometry, count backface hits
+    uint backface_count = 0;
+    f32 closest_frontface = 1e27f;
+
+    for (uint r = 0; r < FIXED_RAY_COUNT; r++) {
+        vec4 rad = pc.samples_buffer[probe_idx * RAYS_PER_PROBE + r].radiance_distance;
+
+        if (rad.w < 0.0f) {
+            backface_count++;
+        } else {
+            closest_frontface = min(closest_frontface, rad.w);
+        }
+    }
+
+    // snap state, 0 active 1 inactive (TODO: REVERSE IT!)
+    vec3 geometry_bounds = grid.spacing.xyz * 2.0f * 1.45f;
+    f32 backface_ratio = f32(backface_count) / f32(FIXED_RAY_COUNT);
+    f32 target = (all(vec3(closest_frontface) <= geometry_bounds) && backface_ratio < cfg.fixed_ray_backface_threshold)
+                     ? DDGI_STATE_PROBE_ACTIVE
+                     : DDGI_STATE_PROBE_INACTIVE;
+    ProbeState ps = pc.probe_state[probe_idx];
+    ps.offset_active.w = target;
+    pc.probe_state[probe_idx] = ps;
+}
ADD · src/passes/ddgi/ddgi_probe.slang +117 -0
--- a/src/passes/ddgi/ddgi_probe.slang
+++ b/src/passes/ddgi/ddgi_probe.slang
@@ -0,0 +1,117 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "../../shaders/lib/ddgi_common.slang"
+#include "../../shaders/lib/octahedral.slang"
+
+[[vk::push_constant]]
+ProbeSpherePushConstants pc;
+
+struct vtxout {
+    vec4 position : SV_Position;
+    vec3 world_pos : TEXCOORD0;
+    uint probe_index : TEXCOORD1;
+};
+
+[shader("vertex")]
+vtxout vsMain(uint vid: SV_VertexID, uint iid: SV_InstanceID) {
+    vec4 pos_packed = pc.sphere_mesh[vid];
+
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    vec3 probe_pos = ProbePosition(iid, grid.origin.xyz, grid.spacing.xyz, dims) +
+                     ProbeOffset(pc.probe_state, iid, grid.spacing.xyz);
+
+    f32 scale = 0.1;
+    vec3 world_pos = pos_packed.xyz * scale + probe_pos;
+
+    vtxout o;
+    o.position = vec4(world_pos, 1.0) * frame.view_proj;
+    o.world_pos = world_pos;
+    o.probe_index = iid;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(vtxout in) : SV_Target {
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+
+    if (pc.debug_flag == DebugViewMode::PROBES_CLASSIFICATION) {
+        // stored state, 0 active 1 inactive
+        f32 state = LoadProbeState(pc.probe_state, in.probe_index);
+        return state == DDGI_STATE_PROBE_INACTIVE ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);
+    }
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    vec3 probe_pos = ProbePosition(in.probe_index, grid.origin.xyz, grid.spacing.xyz, dims) +
+                     ProbeOffset(pc.probe_state, in.probe_index, grid.spacing.xyz);
+    vec3 frag_dir = normalize(in.world_pos - probe_pos);
+
+    uint base = in.probe_index * pc.rays_per_probe;
+    uint closest = 0;
+    f32 best_dot = -1.0;
+
+    for (uint i = 0; i < pc.rays_per_probe; i++) {
+        vec3 ray_dir = pc.samples_buffer[base + i].direction.xyz;
+        f32 d = dot(frag_dir, ray_dir);
+        if (d > best_dot) {
+            best_dot = d;
+            closest = i;
+        }
+    }
+
+    vec4 sample = pc.samples_buffer[base + closest].radiance_distance;
+
+    return vec4(sample.rgb, 1.0);
+}
+
+[shader("fragment")]
+vec4 fsAtlasMain(vtxout in) : SV_Target {
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    vec3 probe_pos = ProbePosition(in.probe_index, grid.origin.xyz, grid.spacing.xyz, dims) +
+                     ProbeOffset(pc.probe_state, in.probe_index, grid.spacing.xyz);
+
+    vec3 dir = normalize(in.world_pos - probe_pos);
+    vec2 uv = OctEncode(dir) * 0.5 + 0.5;
+
+    u32 w, h;
+    pc.atlas_sampled.GetDimensions(w, h);
+    u32 tpr = w / IRRADIANCE_TILE_STRIDE;
+
+    uvec2 tile_origin = ProbeTileOrigin(in.probe_index, tpr, IRRADIANCE_TILE_STRIDE);
+    vec2 atlas_uv = OctUVtoAtlasUV(uv, tile_origin, vec2(w, h), IRRADIANCE_SIZE);
+
+    vec4 irradiance = pc.atlas_sampled.SampleLevel(frame.linear_clamp, atlas_uv, 0);
+    return vec4(irradiance.rgb, 1.0);
+}
+
+[shader("fragment")]
+vec4 fsDistMain(vtxout in) : SV_Target {
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    vec3 probe_pos = ProbePosition(in.probe_index, grid.origin.xyz, grid.spacing.xyz, dims) +
+                     ProbeOffset(pc.probe_state, in.probe_index, grid.spacing.xyz);
+    vec3 dir = normalize(in.world_pos - probe_pos);
+    vec2 uv = OctEncode(dir) * 0.5 + 0.5;
+
+    u32 w, h;
+    pc.atlas_sampled.GetDimensions(w, h);
+    u32 tpr = w / DISTANCE_TILE_STRIDE;
+
+    uvec2 tile_origin = ProbeTileOrigin(in.probe_index, tpr, DISTANCE_TILE_STRIDE);
+    vec2 atlas_uv = OctUVtoAtlasUV(uv, tile_origin, vec2(w, h), ATLAS_SIZE);
+
+    // dist2 lives in green
+    f32 dist = pc.atlas_sampled.SampleLevel(frame.linear_clamp, atlas_uv, 0).r;
+
+    f32 t = clamp(dist / 2.0, 0.0, 1.0);
+    vec3 color = t < 0.5 ? vec3(0.0, t * 2.0, 1.0 - t * 2.0) : vec3((t - 0.5) * 2.0, 1.0 - (t - 0.5) * 2.0, 0.0);
+    return vec4(color, 1.0);
+}
ADD · src/passes/ddgi/ddgi_probes_dbg.cpp +180 -0
--- a/src/passes/ddgi/ddgi_probes_dbg.cpp
+++ b/src/passes/ddgi/ddgi_probes_dbg.cpp
@@ -0,0 +1,180 @@
+#include "ddgi_probes_dbg.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ddgi_probes {
+static const f32 PI = 3.14159265358979323846f;
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main,
+    ImageHandle depth,
+    ddgi_trace::Resources &res,
+    DebugViewMode *debug_mode
+) {
+
+    rhi::RenderPipelineDesc ddgi_probe_p;
+    ddgi_probe_p.device = &device;
+    ddgi_probe_p.set_shaders(sc, "src/passes/ddgi/ddgi_probe.slang", "vsMain", "fsMain");
+    ddgi_probe_p.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    ddgi_probe_p.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    ddgi_probe_p.set_blending();
+    ddgi_probe_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    ddgi_probe_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &raw_pipeline = pipelines.add_render("DdgiProbe", ddgi_probe_p);
+
+    rhi::RenderPipelineDesc ddgi_probe_atlas_p;
+    ddgi_probe_atlas_p.device = &device;
+    ddgi_probe_atlas_p.set_shaders(sc, "src/passes/ddgi/ddgi_probe.slang", "vsMain", "fsAtlasMain");
+    ddgi_probe_atlas_p.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    ddgi_probe_atlas_p.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    ddgi_probe_atlas_p.set_blending();
+    ddgi_probe_atlas_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    ddgi_probe_atlas_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &atlas_pipeline = pipelines.add_render("DdgiProbeAtlas", ddgi_probe_atlas_p);
+
+    rhi::RenderPipelineDesc ddgi_probe_dist_p;
+    ddgi_probe_dist_p.device = &device;
+    ddgi_probe_dist_p.set_shaders(sc, "src/passes/ddgi/ddgi_probe.slang", "vsMain", "fsDistMain");
+    ddgi_probe_dist_p.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    ddgi_probe_dist_p.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    ddgi_probe_dist_p.set_blending();
+    ddgi_probe_dist_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    ddgi_probe_dist_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &distance_pipeline = pipelines.add_render("DdgiProbeDistance", ddgi_probe_dist_p);
+
+    static const auto sphere_verts = []() {
+        const u32 num_sides = 32;
+        const u32 num_rings = 16;
+        std::vector<vec4> v;
+        v.reserve(num_sides * num_rings * 6);
+        for (u32 r = 0; r < num_rings; r++) {
+            f32 phi0 = (f32)(r) / (f32)num_rings * PI;
+            f32 phi1 = (f32)(r + 1) / (f32)num_rings * PI;
+            for (u32 s = 0; s < num_sides; s++) {
+                f32 theta0 = (f32)(s) / (f32)num_sides * 2.0f * PI;
+                f32 theta1 = (f32)(s + 1) / (f32)num_sides * 2.0f * PI;
+                auto vert = [](f32 theta, f32 phi) {
+                    return vec4(sinf(phi) * cosf(theta), cosf(phi), sinf(phi) * sinf(theta), 0.0f);
+                };
+                v.push_back(vert(theta0, phi0));
+                v.push_back(vert(theta1, phi0));
+                v.push_back(vert(theta0, phi1));
+                v.push_back(vert(theta1, phi0));
+                v.push_back(vert(theta1, phi1));
+                v.push_back(vert(theta0, phi1));
+            }
+        }
+        return v;
+    }();
+
+    u32 sphere_index_count = (u32)sphere_verts.size();
+    u64 sphere_size = (u64)sphere_verts.size() * sizeof(vec4);
+
+    auto sphere_vb = fg.add_buffer({
+        .desc =
+            {
+                .size = sphere_size,
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+                .memory = rhi::BufferMemType::Upload,
+            },
+        .name = "fg/ddgi/probe-spheres",
+    });
+
+    fg.add_pass("DDGI Probes")
+        .read(res.ray_samples, rhi::ResourceState::StorageRead)
+        .read(res.probe_state, rhi::ResourceState::StorageRead)
+        .read(res.irradiance_img, rhi::ResourceState::TextureSample)
+        .read(res.distance_img, rhi::ResourceState::TextureSample)
+        .write(main, rhi::ResourceState::ColorDraw)
+        .write(depth, rhi::ResourceState::DepthDraw)
+        .execute([=, &raw_pipeline, &atlas_pipeline, &distance_pipeline](PassContext &ctx) {
+            // one-time upload of static sphere mesh
+            {
+                auto &buf = ctx.get_buffer(sphere_vb);
+                if (buf.mapped) {
+                    memcpy(buf.mapped, sphere_verts.data(), sphere_size);
+                }
+            }
+
+            u64 sample_idx;
+            rhi::RenderPipeline *p = nullptr;
+            if (*debug_mode == DebugViewMode::PROBES_RAY_SAMPLES ||
+                *debug_mode == DebugViewMode::PROBES_CLASSIFICATION) {
+                p = &raw_pipeline;
+                sample_idx = 0; // raw view reads rays via bda, no atlas sample
+            } else if (*debug_mode == DebugViewMode::PROBES_IRRADIANCE) {
+                p = &atlas_pipeline;
+                sample_idx = (u64)ctx.view(res.irradiance_img);
+            } else if (*debug_mode == DebugViewMode::PROBES_DISTANCE) {
+                p = &distance_pipeline;
+                sample_idx = (u64)ctx.view(res.distance_img);
+            } else {
+                return;
+            }
+
+            auto main_view = ctx.image_view(main, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+            auto depth_view = ctx.image_view(depth, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+
+            rhi::AttachmentDesc color_att{};
+            color_att.img = &main_view;
+            color_att.loadOp = rhi::LoadOp::LOAD;
+            color_att.storeOp = rhi::StoreOp::STORE;
+            rhi::AttachmentDesc depth_att{};
+            depth_att.img = &depth_view;
+            depth_att.loadOp = rhi::LoadOp::LOAD;
+            depth_att.storeOp = rhi::StoreOp::STORE;
+
+            rhi::RenderingInfo ri{};
+            ri.colorAttachments[0] = color_att;
+            ri.colorAttachmentCount = 1;
+            ri.depthAttachment = depth_att;
+            ri.width = ctx.render_width;
+            ri.height = ctx.render_height;
+
+            rhi::begin_rendering(ctx.cmd, ri);
+            rhi::set_pipeline(ctx.cmd, *p);
+
+            rhi::Viewport vp{};
+            vp.width = (f32)ctx.render_width;
+            vp.height = (f32)ctx.render_height;
+            rhi::set_viewports(ctx.cmd, &vp);
+            rhi::Rect scissor{};
+            scissor.width = (i32)ctx.render_width;
+            scissor.height = (i32)ctx.render_height;
+            rhi::set_scissors(ctx.cmd, &scissor);
+
+            u32 probe_count = res.grid.probe_count;
+
+            ProbeSpherePushConstants pc{};
+            pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+            pc.sphere_mesh = rhi::buffer_device_address(ctx.device, ctx.get_buffer(sphere_vb));
+            pc.sphere_vertex_count = sphere_index_count;
+            if (*debug_mode == DebugViewMode::PROBES_RAY_SAMPLES ||
+                *debug_mode == DebugViewMode::PROBES_CLASSIFICATION) {
+                pc.samples_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.ray_samples));
+            } else {
+                pc.samples_buffer = 0;
+            }
+            pc.atlas_sampled = (u32)sample_idx;
+            pc.probe_state = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.probe_state));
+            pc.debug_flag = *debug_mode;
+            pc.rays_per_probe = RAYS_PER_PROBE;
+
+            {
+                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                char pc128[128] = {};
+                std::memcpy(pc128, &pc, sizeof(pc));
+                rhi::set_constants(ctx.cmd, *p, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+            }
+            rhi::draw(ctx.cmd, sphere_index_count, probe_count, 0, 0);
+            rhi::end_rendering(ctx.cmd);
+        });
+}
+
+} // namespace ddgi_probes<
\ No newline at end of file
ADD · src/passes/ddgi/ddgi_probes_dbg.h +24 -0
--- a/src/passes/ddgi/ddgi_probes_dbg.h
+++ b/src/passes/ddgi/ddgi_probes_dbg.h
@@ -0,0 +1,24 @@
+#pragma once
+#include "ddgi_trace.h"
+
+#include "passes/fg.h"
+#include "shaders/renderer_types.h"
+
+struct FrameData;
+struct RenderData;
+struct Pipelines;
+
+namespace ddgi_probes {
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main,
+    ImageHandle depth,
+    ddgi_trace::Resources &res,
+    DebugViewMode *debug_mode
+);
+
+} // namespace ddgi_probes
ADD · src/passes/ddgi/ddgi_relocate.cpp +45 -0
--- a/src/passes/ddgi/ddgi_relocate.cpp
+++ b/src/passes/ddgi/ddgi_relocate.cpp
@@ -0,0 +1,45 @@
+#include "ddgi_relocate.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ddgi_relocate {
+
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, ddgi_trace::Resources &res
+) {
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/ddgi/ddgi_relocate.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("DdgiRelocate", pd);
+
+    auto &builder = fg.add_pass("DDGI Relocate");
+    builder.read(res.ray_samples, rhi::ResourceState::StorageRead);
+    builder.read_write(res.probe_state, rhi::ResourceState::StorageReadWrite);
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        u32 groups = (res.grid.probe_count + 63) / 64;
+        if (groups == 0) {
+            return;
+        }
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        DdgiRelocatePushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.samples_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.ray_samples));
+        pc.probe_state = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.probe_state));
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+        rhi::dispatch(ctx.cmd, groups, 1, 1);
+    });
+}
+
+} // namespace ddgi_relocate<
\ No newline at end of file
ADD · src/passes/ddgi/ddgi_relocate.h +12 -0
--- a/src/passes/ddgi/ddgi_relocate.h
+++ b/src/passes/ddgi/ddgi_relocate.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "ddgi_trace.h"
+#include "passes/fg.h"
+
+struct FrameData;
+
+namespace ddgi_relocate {
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, ddgi_trace::Resources &res
+);
+}
ADD · src/passes/ddgi/ddgi_relocate.slang +97 -0
--- a/src/passes/ddgi/ddgi_relocate.slang
+++ b/src/passes/ddgi/ddgi_relocate.slang
@@ -0,0 +1,97 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+DdgiRelocatePushConstants pc;
+
+static const f32 DDGI_MISS_DISTANCE = 1e27f;
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 dtid: SV_DispatchThreadID) {
+    uint probe_idx = dtid.x;
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+    DdgiConfig cfg = frame.ddgi_cfg;
+
+    uvec3 dims = uvec3(grid.dims.xyz);
+    if (probe_idx >= dims.x * dims.y * dims.z)
+        return;
+
+    // load current offset (denormalize to world) and state
+    vec4 ps = pc.probe_state[probe_idx].offset_active;
+    vec3 off = ps.xyz * grid.spacing.xyz; // denormalize to world-space
+    f32 state = ps.w;
+
+    // scan fixed rays for closest/farthest frontface and closest backface
+    uint backface_hits = 0;
+    int closest_backface_idx = -1;
+    int closest_frontface_idx = -1;
+    int farthest_frontface_idx = -1;
+    f32 closest_backface_dist = 1e27f;
+    f32 closest_frontface_dist = 1e27f;
+    f32 farthest_frontface_dist = 0.0f;
+
+    uint numRays = FIXED_RAY_COUNT;
+    for (uint r = 0; r < numRays; r++) {
+        vec4 rad_dist = pc.samples_buffer[probe_idx * RAYS_PER_PROBE + r].radiance_distance;
+
+        if (abs(rad_dist.w) >= DDGI_MISS_DISTANCE)
+            continue;
+
+        if (rad_dist.w < 0.0f) {
+            // backface hit
+            backface_hits++;
+
+            // backfaces store -dist * 0.2, restore with * -5
+            f32 hitDist = rad_dist.w * -5.0f;
+            if (hitDist < closest_backface_dist) {
+                closest_backface_dist = hitDist;
+                closest_backface_idx = (int)r;
+            }
+        } else {
+            // frontface hit
+            if (rad_dist.w < closest_frontface_dist) {
+                closest_frontface_dist = rad_dist.w;
+                closest_frontface_idx = (int)r;
+            }
+            if (rad_dist.w > farthest_frontface_dist) {
+                farthest_frontface_dist = rad_dist.w;
+                farthest_frontface_idx = (int)r;
+            }
+        }
+    }
+
+    vec3 fullOff = vec3(1e27f, 1e27f, 1e27f);
+
+    // probe inside geometry, push out along closest backface dir
+    if (closest_backface_idx != -1 && (f32(backface_hits) / f32(numRays)) > cfg.fixed_ray_backface_threshold) {
+        vec3 closestBackfaceDir = pc.samples_buffer[probe_idx * RAYS_PER_PROBE + closest_backface_idx].direction.xyz;
+        fullOff = off + normalize(closestBackfaceDir) * closest_backface_dist * (cfg.probe_distance_scale + 1.0f);
+    }
+    // probe too close to surface, nudge away
+    else if (closest_frontface_dist < cfg.probe_min_frontface_distance) {
+        vec3 closestDir = pc.samples_buffer[probe_idx * RAYS_PER_PROBE + closest_frontface_idx].direction.xyz;
+        vec3 farthestDir = pc.samples_buffer[probe_idx * RAYS_PER_PROBE + farthest_frontface_idx].direction.xyz;
+
+        // move if closest and farthest directions disagree, ensures we don't push through geometry
+        if (dot(closestDir, farthestDir) <= 0.0f) {
+            fullOff = off + normalize(farthestDir) * cfg.probe_distance_scale;
+        }
+    }
+    // probe far from everything, drift back to zero offset
+    else if (closest_frontface_dist > cfg.probe_min_frontface_distance + cfg.probe_distance_scale) {
+        f32 moveBackMargin = min(closest_frontface_dist - cfg.probe_min_frontface_distance, length(off));
+        vec3 moveBackDirection = normalize(-off);
+        fullOff = off + moveBackMargin * moveBackDirection;
+    }
+
+    // keep probe within 45% of its grid cell
+    vec3 normalizedOff = fullOff / grid.spacing.xyz;
+    if (dot(normalizedOff, normalizedOff) < 0.2025f) {
+        off = fullOff;
+    }
+
+    // store normalized offset, state (.w) written by classify
+    pc.probe_state[probe_idx].offset_active = vec4(off / grid.spacing.xyz, state);
+}
ADD · src/passes/ddgi/ddgi_trace.cpp +195 -0
--- a/src/passes/ddgi/ddgi_trace.cpp
+++ b/src/passes/ddgi/ddgi_trace.cpp
@@ -0,0 +1,195 @@
+#include "ddgi_trace.h"
+
+#include <cmath>
+#include <cstring>
+
+#include "backend/rhi.h"
+#include "core/random.h"
+#include "passes/debug/debug_draw.h"
+#include "passes/fg.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ddgi_trace {
+
+static vec3 debug_probe_position(u32 probe_idx, vec3 origin, vec3 spacing, vec3 dims_f) {
+    u32 dx = (u32)dims_f.x;
+    u32 dy = (u32)dims_f.y;
+    dx = dx == 0 ? 1 : dx;
+    dy = dy == 0 ? 1 : dy;
+    u32 cx = probe_idx % dx;
+    u32 cy = (probe_idx / dx) % dy;
+    u32 cz = probe_idx / (dx * dy);
+    vec3 coord = vec3((f32)cx, (f32)cy, (f32)cz);
+    vec3 center = (vec3(dims_f.x, dims_f.y, dims_f.z) - vec3(1.0f)) * 0.5f;
+    return vec3(
+        origin.x + (coord.x - center.x) * spacing.x,
+        origin.y + (coord.y - center.y) * spacing.y,
+        origin.z + (coord.z - center.z) * spacing.z
+    );
+}
+
+void debug_draw(DebugDraw &draw, const RenderData &rd) {
+    const DdgiGridParams &grid = rd.ddgi_grid;
+    if (grid.probe_count == 0) {
+        return;
+    }
+    vec3 origin = vec3(grid.origin.x, grid.origin.y, grid.origin.z);
+    vec3 spacing = vec3(grid.spacing.x, grid.spacing.y, grid.spacing.z);
+    vec3 dims_f = vec3(grid.dims.x, grid.dims.y, grid.dims.z);
+    if (spacing.x <= 0.0f || spacing.y <= 0.0f || spacing.z <= 0.0f) {
+        return;
+    }
+    vec3 half_extent = vec3(
+        (dims_f.x - 1.0f) * 0.5f * spacing.x, (dims_f.y - 1.0f) * 0.5f * spacing.y, (dims_f.z - 1.0f) * 0.5f * spacing.z
+    );
+
+    vec4 grid_color = vec4(0.4f, 1.6f, 2.0f, 1.0f);
+    draw.aabb(origin - half_extent, origin + half_extent, grid_color, DEBUG_CAT_DDGI, DEBUG_DEPTH_TEST, 2.0f);
+
+    vec4 probe_color = vec4(3.0f, 2.7f, 0.6f, 1.0f);
+    f32 cross_size = (spacing.x + spacing.y + spacing.z) / 3.0f * 0.25f;
+    if (cross_size <= 0.0f) {
+        cross_size = 0.1f;
+    }
+    for (u32 i = 0; i < grid.probe_count; ++i) {
+        vec3 p = debug_probe_position(i, origin, spacing, dims_f);
+        draw.cross(p, cross_size, probe_color, DEBUG_CAT_DDGI, DEBUG_DEPTH_TEST, 2.0f);
+    }
+}
+
+Resources create(FrameGraph &fg) {
+    Resources out;
+
+    out.grid.origin = {0.0f, 0.0f, 6.0f, 0.0};
+    out.grid.dims = {16, 24, 12, 0};
+    out.grid.spacing = {2.0, 2.0, 2.0, 0.0};
+    out.grid.spacing.w = fmax(fmax(out.grid.spacing.x, out.grid.spacing.y), out.grid.spacing.z);
+    out.grid.probe_count = out.grid.dims.x * out.grid.dims.y * out.grid.dims.z;
+
+    u64 buf_size = (u64)out.grid.probe_count * RAYS_PER_PROBE * sizeof(ProbeRaySample);
+    out.ray_samples = fg.add_buffer({
+        .desc =
+            {
+                .size = buf_size,
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+            },
+        .name = "fg/ddgi/ray-samples",
+    });
+    out.probe_state = fg.add_buffer({
+        .desc =
+            {
+                .size = (u64)out.grid.probe_count * sizeof(ProbeState),
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+                .memory = rhi::BufferMemType::Upload,
+            },
+        .name = "fg/ddgi/probe-state",
+        .lifetime = Lifetime::Persistent,
+    });
+
+    u32 irr_tiles_per_row = (u32)ceilf(sqrtf((f32)out.grid.probe_count));
+    u32 irr_row_count = (out.grid.probe_count + irr_tiles_per_row - 1) / irr_tiles_per_row;
+    u32 irr_width = irr_tiles_per_row * IRRADIANCE_TILE_STRIDE;
+    u32 irr_height = irr_row_count * IRRADIANCE_TILE_STRIDE;
+    out.irradiance_img = fg.add_image({
+        .desc = {.width = irr_width, .height = irr_height, .format = rhi::ImageFormat::RGBA16_FLOAT},
+        .name = "fg/ddgi/irradiance",
+        .lifetime = Lifetime::History,
+        .size_class = SizeOp::Absolute,
+        .view = {.type = rhi::ImageViewType::Sampled},
+    });
+
+    u32 dist_tiles_per_row = (u32)ceilf(sqrtf((f32)out.grid.probe_count));
+    u32 dist_row_count = (out.grid.probe_count + dist_tiles_per_row - 1) / dist_tiles_per_row;
+    u32 dist_width = dist_tiles_per_row * DISTANCE_TILE_STRIDE;
+    u32 dist_height = dist_row_count * DISTANCE_TILE_STRIDE;
+    out.distance_img = fg.add_image({
+        .desc{
+            .width = dist_width,
+            .height = dist_height,
+            .format = rhi::ImageFormat::RG16_FLOAT,
+        },
+        .name = "fg/ddgi/distance",
+        .lifetime = Lifetime::History,
+        .size_class = SizeOp::Absolute,
+        .view = {.type = rhi::ImageViewType::Sampled},
+    });
+
+    return out;
+}
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &out,
+    ImageHandle env,
+    BufferHandle tlas_buf
+) {
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/ddgi/ddgi_trace.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("DdgiTrace", pd);
+
+    auto &builder = fg.add_pass("DDGI Trace");
+    builder.read(tlas_buf, rhi::ResourceState::AccelTrace);
+    builder.read(out.probe_state, rhi::ResourceState::StorageRead);
+    builder.write(out.ray_samples, rhi::ResourceState::StorageReadWrite);
+    builder.read(out.irradiance_img, rhi::ResourceState::TextureSampleNonFragment);
+    builder.read(out.distance_img, rhi::ResourceState::TextureSampleNonFragment);
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        u32 probe_count = out.grid.probe_count;
+        u32 total_rays = probe_count * RAYS_PER_PROBE;
+        u32 groups = (total_rays + 63) / 64;
+        if (groups == 0) {
+            return;
+        }
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        DdgiTracePushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.framecount_idx = ctx.frame_count;
+
+        pc.tlas_idx = 0; // unused, tlas comes from frame tlas address
+        pc.samples_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(out.ray_samples));
+        pc.instance_data = rhi::buffer_device_address(ctx.device, ctx.render_data->rt_scene.instance_data_buffer);
+
+        pc.cascade_count = Light::CASCADE_COUNT;
+        pc.probe_state = rhi::buffer_device_address(ctx.device, ctx.get_buffer(out.probe_state));
+        pc.irradiance = (u32)ctx.view(out.irradiance_img);
+        pc.distance = (u32)ctx.view(out.distance_img);
+
+        pc.vertex = (u64)ctx.render_data->vertex_view.slot;
+        pc.index_bda = ctx.render_data->index_bda;
+
+        static Random rng;
+        vec3 axis = vec3(rng.Range(-1.0f, 1.0f), rng.Range(-1.0f, 1.0f), rng.Range(-1.0f, 1.0f)).normalized();
+        f32 angle = rng.Range(0.0f, 2.0f * 3.14159265f);
+        pc.random_rotation = vec4(axis.x, axis.y, axis.z, angle);
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        static bool probe_state_initialized = false;
+        if (!probe_state_initialized) {
+            auto &ps = ctx.get_buffer(out.probe_state);
+            if (ps.mapped) {
+                memset(ps.mapped, 0, (u64)out.grid.probe_count * sizeof(ProbeState));
+                probe_state_initialized = true;
+            }
+        }
+
+        rhi::dispatch(ctx.cmd, groups, 1, 1);
+    });
+}
+
+} // namespace ddgi_trace
ADD · src/passes/ddgi/ddgi_trace.h +35 -0
--- a/src/passes/ddgi/ddgi_trace.h
+++ b/src/passes/ddgi/ddgi_trace.h
@@ -0,0 +1,35 @@
+#pragma once
+#include "passes/fg.h"
+#include "shaders/renderer_types.h"
+
+struct FrameData;
+struct RenderData;
+struct Scene;
+struct Pipelines;
+struct DebugDraw;
+
+namespace ddgi_trace {
+
+struct Resources {
+    BufferHandle ray_samples;
+    BufferHandle probe_state;
+    ImageHandle irradiance_img;
+    ImageHandle distance_img;
+    DdgiConfig cfg;
+    DdgiGridParams grid;
+};
+
+Resources create(FrameGraph &fg);
+
+void debug_draw(DebugDraw &draw, const RenderData &rd);
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &out,
+    ImageHandle env,
+    BufferHandle tlas_buf
+);
+
+} // namespace ddgi_trace
ADD · src/passes/ddgi/ddgi_trace.slang +153 -0
--- a/src/passes/ddgi/ddgi_trace.slang
+++ b/src/passes/ddgi/ddgi_trace.slang
@@ -0,0 +1,153 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/ddgi_common.slang"
+#include "lib/octahedral.slang"
+#include "lib/shadow_sample.slang"
+
+[vk::push_constant]
+DdgiTracePushConstants pc;
+
+static const f32 DDGI_BOUNCE_CONTRIBUTION_MULTIPLIER = 0.9f;
+static const f32 DDGI_MISS_DISTANCE = 1e27f;
+
+static const f32 PI = 3.1415926535f;
+static const f32 M_PI_INV = 0.318309886f;
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 dtid: SV_DispatchThreadID) {
+    uint ray_index = dtid.x;
+    FrameUBO frame = *pc.frame;
+    DdgiGridParams grid = frame.ddgi_grid;
+    uvec3 dims = uvec3(grid.dims.xyz);
+    uint total_rays = dims.x * dims.y * dims.z * RAYS_PER_PROBE;
+    if (ray_index >= total_rays)
+        return;
+
+    uint probe_idx = ray_index / RAYS_PER_PROBE;
+    uint ray_slot = ray_index % RAYS_PER_PROBE;
+    // probe world position includes relocation offset
+    vec3 probe_pos = ProbePosition(probe_idx, grid.origin.xyz, grid.spacing.xyz, dims) +
+                     ProbeOffset(pc.probe_state, probe_idx, grid.spacing.xyz);
+
+    vec3 dir;
+    if (ray_slot < FIXED_RAY_COUNT) {
+        // fixed rays, same dirs every frame for stable relocate/classify
+        dir = SphericalFibonacci(ray_slot, FIXED_RAY_COUNT);
+    } else {
+        // stochastic rays, rotated each frame
+        uint sampleIndex = ray_slot - FIXED_RAY_COUNT;
+        uint numSamples = RAYS_PER_PROBE - FIXED_RAY_COUNT;
+        vec3 raw_dir = SphericalFibonacci(sampleIndex, numSamples);
+        vec3 axis = normalize(pc.random_rotation.xyz);
+        f32 angle = pc.random_rotation.w;
+        f32 s, c;
+        sincos(angle, s, c);
+        dir = raw_dir * c + cross(axis, raw_dir) * s + axis * dot(axis, raw_dir) * (1.0f - c);
+        dir = normalize(dir);
+    }
+
+    // skip stochastic rays on dead probes, fixed rays still trace for classify.
+    // zero the slot so readers never see stale data
+    f32 state = LoadProbeState(pc.probe_state, probe_idx);
+    if (state >= DDGI_STATE_PROBE_INACTIVE && ray_slot >= FIXED_RAY_COUNT) {
+        pc.samples_buffer[ray_index].radiance_distance = vec4(0.0f);
+        pc.samples_buffer[ray_index].direction = vec4(dir, 0.0f);
+        return;
+    }
+
+    RayQuery<0> q;
+    RayDesc ray;
+    ray.Origin = probe_pos;
+    ray.Direction = dir;
+    ray.TMin = 0.0f;
+    f32 grid_extent = max(max(grid.dims.x, grid.dims.y), grid.dims.z) * grid.spacing.w;
+    ray.TMax = grid_extent * 2.0;
+    q.TraceRayInline(RaytracingAccelerationStructure(frame.tlas_address), 0, 0xFF, ray);
+    q.Proceed();
+
+    ProbeRaySample sample;
+    sample.direction = vec4(dir, 0.0);
+    sample.radiance_distance = vec4(0.0);
+
+    if (q.CommittedStatus() == COMMITTED_TRIANGLE_HIT) {
+        f32 dist = q.CommittedRayT();
+
+        if (!q.CommittedTriangleFrontFace()) {
+            // backface, probe is inside geometry. no light here, flag with negative dist
+            sample.radiance_distance = vec4(vec3(0.0f, 0.0f, 0.0f), -dist * 0.2f);
+        } else {
+            // fixed rays store dist only, no lighting, must not bias irradiance
+            if (ray_slot < FIXED_RAY_COUNT) {
+                sample.radiance_distance = vec4(vec3(0.0f, 0.0f, 0.0f), dist);
+            } else {
+                u32 inst_idx = q.CommittedInstanceID();
+                u32 item_idx = pc.instance_data[inst_idx].render_item_idx;
+                u32 prim_idx = q.CommittedPrimitiveIndex();
+                vec2 bc = q.CommittedTriangleBarycentrics();
+
+                f32 bary_u = 1.0 - bc.x - bc.y;
+                f32 bary_v = bc.x;
+                f32 bary_w = bc.y;
+
+                RenderItemGPU item = frame.render_items[item_idx];
+                SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+
+                u32 i0 = pc.index_bda[submesh.first_index + prim_idx * 3 + 0];
+                u32 i1 = pc.index_bda[submesh.first_index + prim_idx * 3 + 1];
+                u32 i2 = pc.index_bda[submesh.first_index + prim_idx * 3 + 2];
+
+                StructuredBuffer<Vertex> verts = pc.vertex;
+                Vertex v0 = verts[i0 + submesh.base_vertex];
+                Vertex v1 = verts[i1 + submesh.base_vertex];
+                Vertex v2 = verts[i2 + submesh.base_vertex];
+
+                vec2 uv = v0.uv * bary_u + v1.uv * bary_v + v2.uv * bary_w;
+
+                MaterialGPU mat = frame.materials[item.material_index];
+                vec4 albedo = mat.albedo.SampleLevel(frame.aniso_wrap_mips, uv, 0) * mat.base_color;
+
+                vec3 objN = normalize(v0.normal * bary_u + v1.normal * bary_v + v2.normal * bary_w);
+                TransformGPU xform = frame.transforms[item.instance_id];
+                vec3 N = normalize(objN * (mat3)transpose(xform.normal_world));
+
+                vec3 hit_ws = ray.Origin + ray.Direction * dist;
+
+                vec3 L = normalize(frame.light_dir);
+                f32 NdotL = saturate(dot(N, L));
+                f32 intensity = f32(frame.light_intensity);
+                vec3 light_color = frame.light_color;
+
+                f32 vis = 1.0;
+                {
+                    RayDesc shadow_ray;
+                    shadow_ray.Origin = hit_ws + N * 0.01f;
+                    shadow_ray.Direction = L;
+                    shadow_ray.TMin = 0.0f;
+                    shadow_ray.TMax = 1e6f;
+                    RayQuery<0> sq;
+                    sq.TraceRayInline(
+                        RaytracingAccelerationStructure(frame.tlas_address),
+                        RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER,
+                        0xFF,
+                        shadow_ray
+                    );
+                    sq.Proceed();
+                    if (sq.CommittedStatus() == COMMITTED_TRIANGLE_HIT)
+                        vis = 0.0f;
+                }
+                vec3 direct = light_color * intensity * NdotL * vis;
+                vec3 indirect =
+                    sample_ddgi_irradiance(hit_ws, N, grid, frame, pc.irradiance, pc.distance, pc.probe_state, false);
+                vec3 radiance = (direct + indirect) * (min(albedo.rgb, 0.9) / PI);
+                sample.radiance_distance = vec4(radiance, dist);
+            }
+        }
+    } else {
+        vec3 sky = frame.env.SampleLevel(frame.linear_clamp, dir, 0.0f).rgb;
+        sample.radiance_distance = vec4(sky, DDGI_MISS_DISTANCE);
+    }
+
+    pc.samples_buffer[ray_index] = sample;
+}
+
ADD · src/passes/ddgi/ddgi_update.cpp +47 -0
--- a/src/passes/ddgi/ddgi_update.cpp
+++ b/src/passes/ddgi/ddgi_update.cpp
@@ -0,0 +1,47 @@
+#include "ddgi_update.h"
+
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ddgi_update {
+
+void record(
+    FrameGraph &fg,
+    ddgi_trace::Resources &res,
+    ImageHandle &target_image,
+    rhi::ComputePipeline &pipeline,
+    const char *pass_name
+) {
+    auto &builder = fg.add_pass(pass_name);
+    builder.read(res.ray_samples, rhi::ResourceState::StorageRead);
+    builder.read(res.probe_state, rhi::ResourceState::StorageRead);
+    builder.read(target_image, rhi::ResourceState::TextureSampleNonFragment);
+    builder.write(target_image, rhi::ResourceState::StorageReadWrite);
+
+    // storage view resolved at compile, execute only reads
+    u32 storage_view = fg.request_extra_view(target_image, false);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        DdgiUpdatePushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.frame_counter = (u32)ctx.frame_count;
+
+        pc.atlas_sample = (u32)ctx.view(target_image);
+        pc.atlas_storage = (u32)ctx.view_extra(storage_view);
+        pc.samples_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.ray_samples));
+        pc.probe_state = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.probe_state));
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+        rhi::dispatch(ctx.cmd, res.grid.dims.x, res.grid.dims.y, res.grid.dims.z);
+    });
+}
+} // namespace ddgi_update<
\ No newline at end of file
ADD · src/passes/ddgi/ddgi_update.h +16 -0
--- a/src/passes/ddgi/ddgi_update.h
+++ b/src/passes/ddgi/ddgi_update.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "ddgi_trace.h"
+#include "passes/fg.h"
+
+struct FrameData;
+struct RenderData;
+
+namespace ddgi_update {
+void record(
+    FrameGraph &fg,
+    ddgi_trace::Resources &res,
+    ImageHandle &target_image,
+    rhi::ComputePipeline &pipeline,
+    const char *pass_name
+);
+} // namespace ddgi_update
ADD · src/passes/ddgi/ddgi_update.slang +161 -0
--- a/src/passes/ddgi/ddgi_update.slang
+++ b/src/passes/ddgi/ddgi_update.slang
@@ -0,0 +1,161 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/ddgi_common.slang"
+#include "lib/octahedral.slang"
+
+[[vk::push_constant]]
+DdgiUpdatePushConstants pc;
+
+#ifndef TILE_SIZE
+#error "TILE_SIZE must be defined before including ddgi_update_common.slang"
+#endif
+
+static const f32 SHARPNESS = 50.0f;
+
+groupshared vec4 gs_tile[TILE_STRIDE][TILE_STRIDE];
+
+[shader("compute")]
+[numthreads(TILE_STRIDE, TILE_STRIDE, 1)]
+void csMain(
+    uvec3 dtid: SV_DispatchThreadID, uvec3 gtid: SV_GroupThreadID, uvec3 gid: SV_GroupID, uint gidx: SV_GroupIndex
+) {
+    FrameUBO frame = *pc.frame;
+    DdgiConfig cfg = frame.ddgi_cfg;
+    DdgiGridParams grid = frame.ddgi_grid;
+    uvec4 dims = uvec4(grid.dims);
+
+    uint probe_idx = gid.z * dims.y * dims.x + gid.y * dims.x + gid.x;
+    if (probe_idx >= dims.x * dims.y * dims.z)
+        return;
+
+    uint texel_x = gtid.x;
+    uint texel_y = gtid.y;
+
+    RWTexture2D<float4> atlas = pc.atlas_storage;
+    u32 atlas_w;
+    u32 atlas_h;
+    atlas.GetDimensions(atlas_w, atlas_h);
+
+    uint tiles_per_row = atlas_w / TILE_STRIDE;
+    uint tile_grid_x = probe_idx % tiles_per_row;
+    uint tile_grid_y = probe_idx / tiles_per_row;
+
+    uvec2 atlas_pixel;
+    atlas_pixel.x = tile_grid_x * TILE_STRIDE + texel_x;
+    atlas_pixel.y = tile_grid_y * TILE_STRIDE + texel_y;
+
+    f32 state = pc.probe_state[probe_idx].offset_active.w;
+
+    f32 probeMaxDistance = length(grid.spacing.w) * 1.5f;
+
+    vec4 prev = pc.atlas_sample.Load(ivec3(atlas_pixel, 0));
+    gs_tile[texel_x][texel_y] = prev;
+
+    // dead probes keep old data, fading ones still blend so they stay fresh
+    if (state >= DDGI_STATE_PROBE_INACTIVE) {
+        atlas[atlas_pixel] = prev;
+        return;
+    }
+
+    // step 1: load, prev frame value already in groupshared for border mirror
+    GroupMemoryBarrierWithGroupSync();
+
+    // step 2: compute, interior texels only
+    bool is_interior = texel_x >= 1 && texel_x <= TILE_SIZE && texel_y >= 1 && texel_y <= TILE_SIZE;
+
+    if (is_interior) {
+        vec2 uv = (vec2(texel_x - 1, texel_y - 1) + 0.5) / f32(TILE_SIZE);
+        vec3 texel_dir = OctDecode(uv * 2.0 - 1.0);
+
+        vec4 accumulated_result = 0.0;
+        f32 accumulated_weight = 0.0;
+
+        uint startRay = RAYS_PER_PROBE > FIXED_RAY_COUNT ? FIXED_RAY_COUNT : 0;
+        uint backfaces = 0;
+        bool skip_texel = false;
+
+        for (uint i = startRay; i < RAYS_PER_PROBE; i++) {
+            uint base = probe_idx * RAYS_PER_PROBE;
+            vec4 rad_dist = pc.samples_buffer[base + i].radiance_distance;
+            vec4 ray_dir = pc.samples_buffer[base + i].direction;
+
+            vec3 ray_radiance = rad_dist.xyz;
+            f32 ray_distance = rad_dist.w;
+            bool is_backface = (rad_dist.w < 0.0f);
+
+            f32 w = dot(texel_dir, ray_dir.xyz);
+            if (w <= 0.0f)
+                continue;
+
+#if defined(MODE_IRRADIANCE)
+            if (is_backface) {
+                backfaces++;
+                if (backfaces > uint((RAYS_PER_PROBE - FIXED_RAY_COUNT) * cfg.random_ray_backface_threshold)) {
+                    // too many backfaces, skip texel but keep threads converged
+                    skip_texel = true;
+                    break;
+                }
+                continue;
+            }
+            accumulated_result.rgb += ray_radiance * w;
+#elif defined(MODE_DISTANCE)
+            if (is_backface) {
+                ray_distance = abs(ray_distance);
+            }
+
+            w += pow(w, SHARPNESS);
+
+            ray_distance = min(ray_distance, probeMaxDistance);
+
+            accumulated_result.x += abs(ray_distance) * w;
+            accumulated_result.y += abs(ray_distance) * abs(ray_distance) * w;
+#endif
+            accumulated_weight += w;
+        }
+
+        f32 hw = pc.frame_counter > 0 ? (1.0 - cfg.history_alpha) : 1.0;
+
+#if defined(MODE_IRRADIANCE)
+        vec3 irr = accumulated_weight > 0.0 ? accumulated_result.rgb / (2.0 * accumulated_weight) : 0.0;
+        irr = pow(irr, 1.0f / cfg.irradiance_encoding_gamma);
+        irr = lerp(prev.rgb, irr, hw);
+        gs_tile[texel_x][texel_y] = skip_texel ? prev : vec4(irr, 1.0);
+#elif defined(MODE_DISTANCE)
+        f32 mean_dist = accumulated_weight > 0.0 ? accumulated_result.x / (2.0 * accumulated_weight) : 0.0;
+        f32 mean_dist2 = accumulated_weight > 0.0 ? accumulated_result.y / (2.0 * accumulated_weight) : 0.0;
+        mean_dist = lerp(prev.x, mean_dist, hw);
+        mean_dist2 = lerp(prev.y, mean_dist2, hw);
+        gs_tile[texel_x][texel_y] = vec4(mean_dist, mean_dist2, 1.0, 1.0);
+#endif
+    }
+
+    GroupMemoryBarrierWithGroupSync();
+
+    // step 3: mirror, border texels copy interior
+    if (!is_interior) {
+        uint src_x = texel_x;
+        uint src_y = texel_y;
+
+        if (texel_x == 0)
+            src_x = TILE_SIZE;
+        else if (texel_x == TILE_STRIDE - 1)
+            src_x = 1;
+
+        if (texel_y == 0)
+            src_y = TILE_SIZE;
+        else if (texel_y == TILE_STRIDE - 1)
+            src_y = 1;
+
+        src_x = TILE_SIZE + 1 - src_x;
+        src_y = TILE_SIZE + 1 - src_y;
+
+        gs_tile[texel_x][texel_y] = gs_tile[src_x][src_y];
+    }
+
+    GroupMemoryBarrierWithGroupSync();
+
+    // step 4: store, all threads write atlas
+    atlas[atlas_pixel] = gs_tile[texel_x][texel_y];
+    return;
+}
+
ADD · src/passes/ddgi/ddgi_update_distance.slang +4 -0
--- a/src/passes/ddgi/ddgi_update_distance.slang
+++ b/src/passes/ddgi/ddgi_update_distance.slang
@@ -0,0 +1,4 @@
+#define TILE_SIZE   ATLAS_SIZE
+#define TILE_STRIDE DISTANCE_TILE_STRIDE
+#define MODE_DISTANCE
+#include "ddgi_update.slang"
ADD · src/passes/ddgi/ddgi_update_irradiance.slang +4 -0
--- a/src/passes/ddgi/ddgi_update_irradiance.slang
+++ b/src/passes/ddgi/ddgi_update_irradiance.slang
@@ -0,0 +1,4 @@
+#define TILE_SIZE   IRRADIANCE_SIZE
+#define TILE_STRIDE IRRADIANCE_TILE_STRIDE
+#define MODE_IRRADIANCE
+#include "ddgi_update.slang"
ADD · src/passes/debug/debug_draw.h +215 -0
--- a/src/passes/debug/debug_draw.h
+++ b/src/passes/debug/debug_draw.h
@@ -0,0 +1,215 @@
+#pragma once
+
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <vector>
+
+#include "core/globals.h"
+#include "core/math_rtm.h"
+
+enum DebugCategory : u8 {
+    DEBUG_CAT_DEFAULT = 0,
+    DEBUG_CAT_GRID = 1,
+    DEBUG_CAT_PROXY = 2,
+    DEBUG_CAT_SELECTION = 3,
+    DEBUG_CAT_LIGHT = 4,
+    DEBUG_CAT_DDGI = 5,
+    DEBUG_CAT_GIZMO_X = 6, // reserved
+    DEBUG_CAT_GIZMO_Y = 7, // reserved
+    DEBUG_CAT_GIZMO_Z = 8, // reserved
+};
+
+enum DebugDepthMode : u8 {
+    DEBUG_DEPTH_TEST = 0,
+    DEBUG_DEPTH_XRAY = 1,
+};
+
+struct DebugLineVertex {
+    vec3 pos = vec3(0.0f);
+    u32 packed = 0; // [category:8][depth:8][reserved:16]
+    vec4 color = vec4(1.0f);
+    u32 width_bits = 0; // f32 screen-space width in px (thick quad expansion)
+    u32 _pad1 = 0;      // reserved: gizmo id
+
+    static u32 pack(u8 category, u8 depth) {
+        return (u32)category | ((u32)depth << 8u);
+    }
+    static u32 width_to_bits(f32 w) {
+        u32 b = 0;
+        memcpy(&b, &w, sizeof(b));
+        return b;
+    }
+    f32 width() const {
+        f32 w = 2.0f;
+        memcpy(&w, &width_bits, sizeof(w));
+        return w;
+    }
+    u8 category() const {
+        return (u8)(packed & 0xFFu);
+    }
+    u8 depth_mode() const {
+        return (u8)((packed >> 8u) & 0xFFu);
+    }
+};
+#ifndef __SLANG__
+static_assert(sizeof(DebugLineVertex) == 40, "DebugLineVertex must be 40B");
+static_assert(offsetof(DebugLineVertex, color) == 16, "DebugLineVertex color offset drift");
+#endif
+
+constexpr u32 MAX_DEBUG_LINES = 65536; // verts; 64k * 40B ~= 2.6MB upload
+
+inline bool debug_finite_vec3(vec3 v) {
+    return std::isfinite(v.x) && std::isfinite(v.y) && std::isfinite(v.z);
+}
+
+struct DebugDraw {
+    std::vector<DebugLineVertex> test_lines; // depth-tested
+    std::vector<DebugLineVertex> xray_lines; // depth-ALWAYS overlay
+    bool overflow_warned = false;
+    bool force_xray = false;
+
+    // category bitmask
+    u32 category_mask = 0xFFFFFFFFu; // not reset by clear()
+    static u32 category_bit(u8 category) {
+        return (category < 32u) ? (1u << category) : 0u;
+    }
+
+    void clear() {
+        test_lines.clear();
+        xray_lines.clear();
+        overflow_warned = false;
+        // NOTE: force_xray/category_mask are set by the frame loop after clear(), not reset here
+    }
+
+    usize total_count() const {
+        return test_lines.size() + xray_lines.size();
+    }
+
+    void line(
+        vec3 a, vec3 b, vec4 color, u8 category = DEBUG_CAT_DEFAULT, u8 depth = DEBUG_DEPTH_TEST, f32 width_px = 1.5f
+    ) {
+        if (!debug_finite_vec3(a) || !debug_finite_vec3(b)) {
+            return;
+        }
+        if (!(category_mask & category_bit(category))) {
+            return;
+        }
+        if (force_xray && depth == DEBUG_DEPTH_TEST) {
+            depth = DEBUG_DEPTH_XRAY;
+        }
+        if (!(width_px > 0.0f) || !std::isfinite(width_px)) {
+            width_px = 1.5f;
+        }
+        if (width_px > 16.0f) {
+            width_px = 16.0f;
+        }
+        std::vector<DebugLineVertex> &dst = (depth == DEBUG_DEPTH_XRAY) ? xray_lines : test_lines;
+        if (dst.size() + 2 > MAX_DEBUG_LINES) {
+            return; // truncated; pass logs once per frame (has frame context)
+        }
+        u32 packed = DebugLineVertex::pack(category, depth);
+        u32 wb = DebugLineVertex::width_to_bits(width_px);
+        dst.push_back({a, packed, color, wb, 0});
+        dst.push_back({b, packed, color, wb, 0});
+    }
+
+    void cross(
+        vec3 p, f32 size, vec4 color, u8 category = DEBUG_CAT_DEFAULT, u8 depth = DEBUG_DEPTH_TEST, f32 width_px = 2.0f
+    ) {
+        f32 h = size * 0.5f;
+        line(vec3(p.x - h, p.y, p.z), vec3(p.x + h, p.y, p.z), color, category, depth, width_px);
+        line(vec3(p.x, p.y - h, p.z), vec3(p.x, p.y + h, p.z), color, category, depth, width_px);
+        line(vec3(p.x, p.y, p.z - h), vec3(p.x, p.y, p.z + h), color, category, depth, width_px);
+    }
+
+    // 8 corners -> 12 edges. The proxy primitive: AABB/OBB/cascade/cluster
+    // boxes all lower to this. `world` maps unit-box corners into place.
+    void box_mat(
+        mat4 world, vec4 color, u8 category = DEBUG_CAT_PROXY, u8 depth = DEBUG_DEPTH_TEST, f32 width_px = 2.0f
+    ) {
+        auto xform = [](vec3 p, const mat4 &m) {
+            vec4 h = transform_point(p, m);
+            return vec3(h.x, h.y, h.z);
+        };
+        vec3 c[8] = {
+            xform(vec3(-0.5f, -0.5f, -0.5f), world),
+            xform(vec3(0.5f, -0.5f, -0.5f), world),
+            xform(vec3(0.5f, 0.5f, -0.5f), world),
+            xform(vec3(-0.5f, 0.5f, -0.5f), world),
+            xform(vec3(-0.5f, -0.5f, 0.5f), world),
+            xform(vec3(0.5f, -0.5f, 0.5f), world),
+            xform(vec3(0.5f, 0.5f, 0.5f), world),
+            xform(vec3(-0.5f, 0.5f, 0.5f), world),
+        };
+        static const u8 edges[12][2] = {
+            {0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 5}, {5, 6}, {6, 7}, {7, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7}
+        };
+        for (u32 i = 0; i < 12; ++i) {
+            line(c[edges[i][0]], c[edges[i][1]], color, category, depth, width_px);
+        }
+    }
+
+    void aabb(
+        vec3 mn, vec3 mx, vec4 color, u8 category = DEBUG_CAT_PROXY, u8 depth = DEBUG_DEPTH_TEST, f32 width_px = 2.0f
+    ) {
+        if (!debug_finite_vec3(mn) || !debug_finite_vec3(mx)) {
+            return;
+        }
+        vec3 center = (mn + mx) * 0.5f;
+        vec3 extent = vec3(mx.x - mn.x, mx.y - mn.y, mx.z - mn.z);
+        if (extent.x <= 0.0f || extent.y <= 0.0f || extent.z <= 0.0f) {
+            return;
+        }
+        mat4 world = scale(extent) * translate(center);
+        box_mat(world, color, category, depth, width_px);
+    }
+
+    // 3 great circles, CPU-tessellated. `segments` is per-circle.
+    void sphere(
+        vec3 center,
+        f32 radius,
+        vec4 color,
+        u32 segments = 24,
+        u8 category = DEBUG_CAT_PROXY,
+        u8 depth = DEBUG_DEPTH_TEST,
+        f32 width_px = 2.0f
+    ) {
+        if (!debug_finite_vec3(center) || !std::isfinite(radius) || radius <= 0.0f) {
+            return;
+        }
+        segments = segments < 8 ? 8 : (segments > 64 ? 64 : segments);
+        const f32 PI = 3.14159265358979323846f;
+        for (u32 axis = 0; axis < 3; ++axis) {
+            vec3 prev{};
+            for (u32 i = 0; i <= segments; ++i) {
+                f32 t = (f32)i / (f32)segments * 2.0f * PI;
+                vec3 p{};
+                if (axis == 0) {
+                    p = vec3(center.x, center.y + cosf(t) * radius, center.z + sinf(t) * radius);
+                } else if (axis == 1) {
+                    p = vec3(center.x + cosf(t) * radius, center.y, center.z + sinf(t) * radius);
+                } else {
+                    p = vec3(center.x + cosf(t) * radius, center.y + sinf(t) * radius, center.z);
+                }
+                if (i > 0) {
+                    line(prev, p, color, category, depth, width_px);
+                }
+                prev = p;
+            }
+        }
+    }
+
+    // screen-constant-size helper for future gizmo handles: world size for
+    // `pixels` at `dist` given vertical fov. Gizmo handles should call this
+    // so they don't shrink with distance (unlike fixed world sizes)
+    static f32 pixels_to_world(f32 dist, f32 pixels, f32 fov_y_deg, f32 viewport_h) {
+        if (viewport_h <= 0.0f || dist <= 0.0f) {
+            return 0.0f;
+        }
+        const f32 PI = 3.14159265358979323846f;
+        f32 fov_rad = fov_y_deg * PI / 180.0f;
+        return 2.0f * dist * tanf(fov_rad * 0.5f) * (pixels / viewport_h);
+    }
+};
ADD · src/passes/debug/debug_lines.cpp +183 -0
--- a/src/passes/debug/debug_lines.cpp
+++ b/src/passes/debug/debug_lines.cpp
@@ -0,0 +1,183 @@
+#include "debug_lines.h"
+
+#include "core/logger.h"
+#include "debug_draw.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace debug_lines {
+
+static rhi::RenderPipeline &make_pipeline(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    const char *name,
+    rhi::PipelineCompareOp depth_op
+) {
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/debug/debug_lines.slang", "vsThickMain", "fsMain");
+    pd.set_input_topology(rhi::PipelineTopology::TRIANGLES);
+    pd.set_depth_testing(true, false, depth_op);
+    pd.set_blending();
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    return pipelines.add_render(name, pd);
+}
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image,
+    const Settings &settings
+) {
+    rhi::RenderPipeline &test_pipeline =
+        make_pipeline(device, pipelines, sc, "DebugLinesTest", rhi::PipelineCompareOp::GREATER_EQUAL);
+    rhi::RenderPipeline &xray_pipeline =
+        make_pipeline(device, pipelines, sc, "DebugLinesXray", rhi::PipelineCompareOp::ALWAYS);
+
+    const u64 max_bytes = (u64)MAX_DEBUG_LINES * sizeof(DebugLineVertex);
+    auto vb = fg.add_buffer({
+        .desc =
+            {
+                .size = max_bytes,
+                .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr,
+                .memory = rhi::BufferMemType::Upload,
+            },
+        .name = "fg/debug-lines/verts",
+    });
+
+    fg.add_pass("DebugLines")
+        .write(main_image, rhi::ResourceState::ColorDraw)
+        .read_write(depth_image, rhi::ResourceState::DepthDraw)
+        .execute([=, &test_pipeline, &xray_pipeline](PassContext &ctx) {
+            const DebugDraw *draw = settings.draw;
+            if (draw == nullptr) {
+                return;
+            }
+            usize test_count = settings.enable_test ? draw->test_lines.size() : 0;
+            usize xray_count = settings.enable_xray ? draw->xray_lines.size() : 0;
+            if (test_count == 0 && xray_count == 0) {
+                return;
+            }
+
+            auto &buf = ctx.get_buffer(vb);
+            u64 test_bytes = (u64)test_count * sizeof(DebugLineVertex);
+            u64 xray_bytes = (u64)xray_count * sizeof(DebugLineVertex);
+            if (test_bytes + xray_bytes > max_bytes) {
+                VEL_WARN("DebugLines truncated: need {}B, have {}B", (test_bytes + xray_bytes), max_bytes);
+                // Prefer keeping the overlay: clamp test list, keep xray whole if it fits.
+                if (xray_bytes >= max_bytes) {
+                    xray_count = MAX_DEBUG_LINES;
+                    xray_bytes = max_bytes;
+                    test_count = 0;
+                    test_bytes = 0;
+                } else {
+                    test_count = (usize)((max_bytes - xray_bytes) / sizeof(DebugLineVertex));
+                    test_count &= ~1u; // keep line pairs whole
+                    test_bytes = (u64)test_count * sizeof(DebugLineVertex);
+                }
+            }
+            if (buf.mapped) {
+                u8 *dst = (u8 *)buf.mapped;
+                if (test_count > 0) {
+                    memcpy(dst, draw->test_lines.data(), (usize)test_bytes);
+                    dst += test_bytes;
+                }
+                if (xray_count > 0) {
+                    memcpy(dst, draw->xray_lines.data(), (usize)xray_bytes);
+                }
+            }
+            u64 bda = rhi::buffer_device_address(ctx.device, buf);
+
+            auto main_view = ctx.image_view(
+                main_image,
+                {
+                    .aspect = rhi::ImageAspect::Color,
+                    .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+                    .mip_start = 0,
+                    .mip_count = 1,
+                    .layer_start = 0,
+                    .layer_count = 1,
+                }
+            );
+            auto depth_view = ctx.image_view(
+                depth_image,
+                {
+                    .aspect = rhi::ImageAspect::Depth,
+                    .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+                    .mip_start = 0,
+                    .mip_count = 1,
+                    .layer_start = 0,
+                    .layer_count = 1,
+                }
+            );
+
+            rhi::AttachmentDesc color_att{};
+            color_att.img = &main_view;
+            color_att.loadOp = rhi::LoadOp::LOAD;
+            color_att.storeOp = rhi::StoreOp::STORE;
+            rhi::AttachmentDesc depth_att{};
+            depth_att.img = &depth_view;
+            depth_att.loadOp = rhi::LoadOp::LOAD;
+            depth_att.storeOp = rhi::StoreOp::STORE;
+
+            rhi::RenderingInfo ri{};
+            ri.colorAttachments[0] = color_att;
+            ri.colorAttachmentCount = 1;
+            ri.depthAttachment = depth_att;
+            ri.width = ctx.render_width;
+            ri.height = ctx.render_height;
+
+            rhi::begin_rendering(ctx.cmd, ri);
+
+            rhi::Viewport viewport{};
+            viewport.width = (f32)ctx.render_width;
+            viewport.height = (f32)ctx.render_height;
+            rhi::set_viewports(ctx.cmd, &viewport);
+            rhi::Rect scissor{};
+            scissor.width = (i32)ctx.render_width;
+            scissor.height = (i32)ctx.render_height;
+            rhi::set_scissors(ctx.cmd, &scissor);
+
+            u64 base_verts = 0;
+            for (u32 pass = 0; pass < 2; ++pass) {
+                usize count = (pass == 0) ? test_count : xray_count;
+                if (count == 0) {
+                    continue;
+                }
+                // Odd counts can't happen via DebugDraw::line() but guard anyway.
+                count &= ~1u;
+                if (count == 0) {
+                    continue;
+                }
+                rhi::RenderPipeline &pl = (pass == 0) ? test_pipeline : xray_pipeline;
+                rhi::set_pipeline(ctx.cmd, pl);
+
+                DebugLinesPushConstants pc{};
+                pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+                pc.lines = bda + base_verts * sizeof(DebugLineVertex);
+                pc.viewport_w = (f32)ctx.render_width;
+                pc.viewport_h = (f32)ctx.render_height;
+                {
+                    static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                    char pc128[128] = {};
+                    std::memcpy(pc128, &pc, sizeof(pc));
+                    rhi::set_constants(ctx.cmd, pl, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+                }
+                // Thick quads: 6 verts per input line (count is input verts).
+                u32 line_count = (u32)count / 2;
+                rhi::draw(ctx.cmd, line_count * 6, 1, 0, 0);
+                base_verts += count;
+            }
+
+            rhi::end_rendering(ctx.cmd);
+        });
+}
+
+} // namespace debug_lines
ADD · src/passes/debug/debug_lines.h +27 -0
--- a/src/passes/debug/debug_lines.h
+++ b/src/passes/debug/debug_lines.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct Pipelines;
+struct DebugDraw;
+
+namespace debug_lines {
+
+struct Settings {
+    const DebugDraw *draw = nullptr;
+    bool enable_test = true;
+    bool enable_xray = true;
+};
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image,
+    const Settings &settings
+);
+
+} // namespace debug_lines
ADD · src/passes/debug/debug_lines.slang +94 -0
--- a/src/passes/debug/debug_lines.slang
+++ b/src/passes/debug/debug_lines.slang
@@ -0,0 +1,94 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[vk::push_constant]
+DebugLinesPushConstants pc;
+
+struct DebugLineOut {
+    vec4 position : SV_Position;
+    vec4 color : TEXCOORD0;
+};
+
+// thick lines: each input (2 verts) protrudes to a camera-facing quad
+// (6 verts / 2 triangles), widht is per-vertex px, averaged over endpoints
+[shader("vertex")]
+DebugLineOut vsThickMain(u32 vertexID: SV_VertexID) {
+    DebugLineOut o;
+
+    u32 line_idx = vertexID / 6;
+    u32 corner = vertexID % 6;
+
+    DebugLineVertexGPU va = pc.lines[line_idx * 2 + 0];
+    DebugLineVertexGPU vb = pc.lines[line_idx * 2 + 1];
+    FrameUBO frame = *pc.frame;
+
+    vec4 ca = vec4(va.pos, 1.0) * frame.view_proj;
+    vec4 cb = vec4(vb.pos, 1.0) * frame.view_proj;
+
+    f32 wa = asfloat(va.width_bits);
+    f32 wb = asfloat(vb.width_bits);
+    f32 half_px = (wa + wb) * 0.25f;
+
+    // degen: behind camera
+    if (ca.w <= 0.0f || cb.w <= 0.0f || half_px <= 0.0f) {
+        o.position = vec4(0.0, 0.0, 2.0, 1.0); // w=1, z beyond far -> clipped
+        o.color = va.color;
+        return o;
+    }
+
+    vec2 na = ca.xy / ca.w;
+    vec2 nb = cb.xy / cb.w;
+
+    // screen space direction (aspect-correct) for a stable perpendicular.
+    vec2 pa = vec2(na.x * pc.viewport_w, na.y * pc.viewport_h);
+    vec2 pb = vec2(nb.x * pc.viewport_w, nb.y * pc.viewport_h);
+    vec2 d = pb - pa;
+    f32 len = length(d);
+    if (len < 1e-4) {
+        o.position = vec4(0.0, 0.0, 2.0, 1.0);
+        o.color = va.color;
+        return o;
+    }
+    vec2 n = vec2(-d.y, d.x) / len;
+
+    // grab endpoint + side for this corner.
+    // tri 1: a+n, a-n, b+n | Tri 2: b+n, a-n, b-n
+    vec4 c;
+    vec2 off;
+    f32 pick_w;
+    if (corner == 0) {
+        c = ca;
+        off = n;
+        pick_w = ca.w;
+    } else if (corner == 1) {
+        c = ca;
+        off = -n;
+        pick_w = ca.w;
+    } else if (corner == 2) {
+        c = cb;
+        off = n;
+        pick_w = cb.w;
+    } else if (corner == 3) {
+        c = cb;
+        off = n;
+        pick_w = cb.w;
+    } else if (corner == 4) {
+        c = ca;
+        off = -n;
+        pick_w = ca.w;
+    } else {
+        c = cb;
+        off = -n;
+        pick_w = cb.w;
+    }
+
+    vec2 off_clip = vec2(off.x * half_px / (pc.viewport_w * 0.5), off.y * half_px / (pc.viewport_h * 0.5)) * pick_w;
+    o.position = vec4(c.xy + off_clip, c.zw);
+    o.color = (corner == 2 || corner == 3 || corner == 5) ? vb.color : va.color;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(DebugLineOut input) : SV_Target {
+    return input.color;
+}
ADD · src/passes/debug/debug_ray.h +66 -0
--- a/src/passes/debug/debug_ray.h
+++ b/src/passes/debug/debug_ray.h
@@ -0,0 +1,66 @@
+#pragma once
+
+#include "core/math_rtm.h"
+
+struct DebugRay {
+    vec3 origin = vec3(0.0f);
+    vec3 dir = vec3(0.0f, 0.0f, 1.0f); // normalized
+};
+
+inline DebugRay debug_unproject(f32 ndc_x, f32 ndc_y, vec3 eye_pos, const mat4 &inv_view_proj) {
+    vec4 near_p = transform_point(vec3(ndc_x, ndc_y, 1.0f), inv_view_proj);
+    vec3 n = vec3(near_p.x / near_p.w, near_p.y / near_p.w, near_p.z / near_p.w);
+    DebugRay r;
+    r.origin = eye_pos;
+    r.dir = (n - eye_pos).normalized();
+    return r;
+}
+
+// returns true + nearest positive t on hit
+inline bool debug_ray_vs_aabb(const DebugRay &ray, vec3 mn, vec3 mx, f32 &t_out) {
+    f32 tmin = 0.0f;
+    f32 tmax = 1e30f;
+    const f32 o[3] = {ray.origin.x, ray.origin.y, ray.origin.z};
+    const f32 d[3] = {ray.dir.x, ray.dir.y, ray.dir.z};
+    const f32 bmin[3] = {mn.x, mn.y, mn.z};
+    const f32 bmax[3] = {mx.x, mx.y, mx.z};
+    for (int i = 0; i < 3; ++i) {
+        if (d[i] == 0.0f) {
+            if (o[i] < bmin[i] || o[i] > bmax[i]) {
+                return false;
+            }
+        } else {
+            f32 inv = 1.0f / d[i];
+            f32 t0 = (bmin[i] - o[i]) * inv;
+            f32 t1 = (bmax[i] - o[i]) * inv;
+            if (t0 > t1) {
+                f32 tmp = t0;
+                t0 = t1;
+                t1 = tmp;
+            }
+            tmin = t0 > tmin ? t0 : tmin;
+            tmax = t1 < tmax ? t1 : tmax;
+            if (tmax < tmin) {
+                return false;
+            }
+        }
+    }
+    t_out = tmin;
+    return true;
+}
+
+inline bool debug_ray_vs_sphere(const DebugRay &ray, vec3 center, f32 radius, f32 &t_out) {
+    vec3 oc = ray.origin - center;
+    f32 b = oc.dot(ray.dir);
+    f32 c = oc.dot(oc) - radius * radius;
+    f32 disc = b * b - c;
+    if (disc < 0.0f) {
+        return false;
+    }
+    f32 t = -b - sqrtf(disc);
+    if (t < 0.0f) {
+        return false;
+    }
+    t_out = t;
+    return true;
+}
ADD · src/passes/debug/pass_frustum_debug.cpp +54 -0
--- a/src/passes/debug/pass_frustum_debug.cpp
+++ b/src/passes/debug/pass_frustum_debug.cpp
@@ -0,0 +1,54 @@
+#include "pass_frustum_debug.h"
+
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+void FrustumDebugPass::render() {
+    FrameData &frame = ctx_->frame_data[ctx_->frame_index];
+
+    rhi::AttachmentDesc colorAttachment{};
+    colorAttachment.img = &ctx_->render_data->targets.main.default_view;
+    colorAttachment.loadOp = rhi::LoadOp::LOAD;
+    colorAttachment.storeOp = rhi::StoreOp::STORE;
+
+    rhi::AttachmentDesc depthAttachment{};
+    depthAttachment.img = &ctx_->render_data->targets.depth.default_view;
+    depthAttachment.loadOp = rhi::LoadOp::LOAD;
+    depthAttachment.storeOp = rhi::StoreOp::STORE;
+
+    rhi::RenderingInfo ri{};
+    ri.colorAttachments[0] = colorAttachment;
+    ri.colorAttachmentCount = 1;
+    ri.depthAttachment = depthAttachment;
+    ri.width = ctx_->width;
+    ri.height = ctx_->height;
+
+    rhi::begin_rendering(ctx_->cmdbuf, ri);
+    rhi::set_pipeline(ctx_->cmdbuf, pipeline);
+    rhi::set_descriptor_set(ctx_->cmdbuf, pipeline, *ctx_->descriptor_set);
+
+    rhi::Viewport viewport{};
+    viewport.width = (f32)ctx_->width;
+    viewport.height = (f32)ctx_->height;
+    rhi::set_viewports(ctx_->cmdbuf, &viewport);
+
+    rhi::Rect scissor{};
+    scissor.width = ctx_->width;
+    scissor.height = ctx_->height;
+    rhi::set_scissors(ctx_->cmdbuf, &scissor);
+
+    FrustumDebugPushConstants pc{};
+    pc.frame_ubo_idx = frame.camera_view.shader_handle;
+    pc.debug_view_proj = ctx_->scene->cameras.debug_camera()->view_proj;
+    pc.debug_inv_view_proj = ctx_->scene->cameras.debug_camera()->inv_view_proj;
+    rhi::set_constants(ctx_->cmdbuf, pipeline, rhi::ShaderStage::VERTEX, sizeof(pc), &pc);
+
+    rhi::draw(ctx_->cmdbuf, 24, 1, 0, 0);
+    rhi::end_rendering(ctx_->cmdbuf);
+}
+
+void FrustumDebugPass::resize() {
+}
+
+FrustumDebugPass::~FrustumDebugPass() {
+}
ADD · src/passes/debug/pass_frustum_debug.h +20 -0
--- a/src/passes/debug/pass_frustum_debug.h
+++ b/src/passes/debug/pass_frustum_debug.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include "renderpass.h"
+
+class FrustumDebugPass : public RenderPass {
+  public:
+    FrustumDebugPass(RenderPassDesc *ctx, rhi::RenderPipeline &pipeline);
+    ~FrustumDebugPass() override;
+
+    void render() override;
+    void resize() override;
+
+    const char *name() const override {
+        return "FrustumDebug";
+    }
+
+  private:
+    rhi::RenderPipeline &pipeline;
+};
ADD · src/passes/depth_pre/depth_normal.cpp +113 -0
--- a/src/passes/depth_pre/depth_normal.cpp
+++ b/src/passes/depth_pre/depth_normal.cpp
@@ -0,0 +1,113 @@
+#include "depth_normal.h"
+
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace depth_normal {
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible
+) {
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/depth_pre/depth_normal.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    pd.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CW);
+    pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    pipelines.add_render("DepthNormal", pd);
+
+    Resources res;
+    res.normal = fg.add_image({
+        .desc = {.format = rhi::ImageFormat::RGBA16_FLOAT},
+        .name = "fg/depth/normal",
+        .size_class = SizeOp::Swapchain,
+        .view = {.type = rhi::ImageViewType::Sampled},
+    });
+    res.depth = fg.add_image({
+        .desc = {.format = rhi::ImageFormat::D32_FLOAT},
+        .name = "fg/depth/depth",
+        .size_class = SizeOp::Swapchain,
+        .view = {.aspect = rhi::ImageAspect::Depth, .type = rhi::ImageViewType::Sampled, .mip_count = 1},
+    });
+
+    auto &builder = fg.add_pass("DepthNormal");
+    builder.read(indirect, rhi::ResourceState::IndirectFetch);
+    builder.read(draw_count, rhi::ResourceState::IndirectFetch);
+    builder.read(visible, rhi::ResourceState::StorageRead);
+    builder.write(res.normal, rhi::ResourceState::ColorDraw);
+    builder.write(res.depth, rhi::ResourceState::DepthDraw);
+
+    rhi::RenderPipeline &pipeline = pipelines.get_render("DepthNormal");
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        auto &frame = ctx.frame_data[ctx.frame_index];
+
+        auto normal_view = ctx.image_view(res.normal, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+        auto depth_view = ctx.image_view(res.depth, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachmentCount = 1;
+        ri.colorAttachments[0].img = &normal_view;
+        ri.colorAttachments[0].loadOp = rhi::LoadOp::CLEAR;
+        ri.colorAttachments[0].storeOp = rhi::StoreOp::STORE;
+        ri.colorAttachments[0].clearValue.color.float32[0] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[1] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[2] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[3] = 0.0f;
+
+        ri.depthAttachment.img = &depth_view;
+        ri.depthAttachment.loadOp = rhi::LoadOp::CLEAR;
+        ri.depthAttachment.storeOp = rhi::StoreOp::STORE;
+        ri.depthAttachment.clearValue.depthStencil = {0.0f, 0};
+        ri.width = ctx.render_width;
+        ri.height = ctx.render_height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)ctx.render_width;
+        vp.height = (f32)ctx.render_height;
+        rhi::set_viewports(ctx.cmd, &vp);
+        rhi::Rect scissor{};
+        scissor.width = (i32)ctx.render_width;
+        scissor.height = (i32)ctx.render_height;
+        rhi::set_scissors(ctx.cmd, &scissor);
+
+        FwdDrawPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.vertex = (u64)ctx.render_data->vertex_view.slot;
+        pc.visible_items = rhi::buffer_device_address(ctx.device, ctx.get_buffer(visible));
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        rhi::set_index_buffer(ctx.cmd, ctx.render_data->index_buffer);
+        rhi::draw_indexed_indirect(
+            ctx.cmd,
+            ctx.get_buffer(indirect),
+            &ctx.get_buffer(draw_count),
+            ctx.render_data->render_item_count,
+            rhi::DRAW_INDEXED_INDIRECT_STRIDE,
+            0,
+            0
+        );
+
+        rhi::end_rendering(ctx.cmd);
+    });
+
+    return res;
+}
+} // namespace depth_normal<
\ No newline at end of file
ADD · src/passes/depth_pre/depth_normal.h +23 -0
--- a/src/passes/depth_pre/depth_normal.h
+++ b/src/passes/depth_pre/depth_normal.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "passes/fg.h"
+#include "pipelines.h"
+
+namespace depth_normal {
+
+struct Resources {
+    ImageHandle normal;
+    ImageHandle depth;
+};
+
+// Resources create(FrameGraph &fg, u32 width, u32 height);
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible
+);
+} // namespace depth_normal
ADD · src/passes/depth_pre/depth_normal.slang +63 -0
--- a/src/passes/depth_pre/depth_normal.slang
+++ b/src/passes/depth_pre/depth_normal.slang
@@ -0,0 +1,63 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+FwdDrawPushConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID, u32 drawID: SV_DrawIndex, u32 instanceID: SV_InstanceID) {
+    VtxOut o;
+
+    FrameUBO frame = *pc.frame;
+
+    u32 item_idx = pc.visible_items[drawID].id;
+    RenderItemGPU item = frame.render_items[item_idx];
+    SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+    TransformGPU xform = frame.transforms[item.instance_id];
+
+    Vertex v = pc.vertex[vertexID + submesh.base_vertex];
+    mat3 world3x3 = (mat3)xform.world;
+    mat3 normalMat = (mat3)transpose(xform.normal_world);
+
+    vec3 N = v.normal * normalMat;
+    vec3 T = v.tangent.xyz * world3x3;
+    vec4 worldPos = vec4(v.pos, 1.0) * xform.world;
+
+    o.view_pos = worldPos * frame.view;
+    o.clip_pos = o.view_pos * frame.proj;
+    o.world_pos = worldPos.xyz;
+    o.clip_debug = o.clip_pos;
+    o.normal = N;
+    o.tangent = vec4(T, v.tangent.w);
+    o.uv = v.uv;
+    o.material_index = item.material_index;
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target {
+    FrameUBO frame = *pc.frame;
+
+    MaterialGPU material = frame.materials[input.material_index];
+    Texture2D albedoTex = material.albedo;
+    Texture2D normalTex = material.normal;
+    SamplerState sampler = frame.aniso_wrap_mips;
+
+    vec4 albedo = albedoTex.Sample(sampler, input.uv) * material.base_color;
+    f32 alpha = albedo.a;
+
+    if (alpha < 0.5) {
+        discard;
+    }
+
+    vec3 N = normalize(input.normal);
+    vec3 T = normalize(input.tangent.xyz);
+    T = normalize(T - N * dot(N, T));
+    vec3 B = cross(N, T) * input.tangent.w;
+    mat3 TBN = mat3(T, B, N);
+    vec3 normalTS = normalTex.Sample(sampler, input.uv).xyz * 2.0 - 1.0;
+    vec3 normalWS = normalize(normalTS * TBN);
+
+    return vec4(normalWS, 1.0);
+}
ADD · src/passes/dispatch_mdi/build_indirect.cpp +120 -0
--- a/src/passes/dispatch_mdi/build_indirect.cpp
+++ b/src/passes/dispatch_mdi/build_indirect.cpp
@@ -0,0 +1,120 @@
+#include "build_indirect.h"
+
+#include <cstdio>
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace build_indirect {
+
+Resources create(FrameGraph &fg, u32 render_item_count, const char *tag) {
+    char indirect_name[128];
+    char visible_name[128];
+    char count_name[128];
+    (void)snprintf(indirect_name, sizeof(indirect_name), "fg/build-indirect/%s/indirect", tag);
+    (void)snprintf(visible_name, sizeof(visible_name), "fg/build-indirect/%s/visible", tag);
+    (void)snprintf(count_name, sizeof(count_name), "fg/build-indirect/%s/draw-count", tag);
+
+    Resources res;
+    const u64 indirect_size = render_item_count * rhi::DRAW_INDEXED_INDIRECT_STRIDE;
+    const u64 visible_size = render_item_count * sizeof(u32) * 2;
+
+    res.indirect = fg.add_buffer({
+        .desc = {.size = indirect_size, .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr},
+        .name = indirect_name,
+    });
+    res.visible = fg.add_buffer({
+        .desc = {.size = visible_size, .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr},
+        .name = visible_name,
+    });
+    res.draw_count = fg.add_buffer({
+        .desc = {.size = sizeof(u32), .usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr},
+        .name = count_name,
+    });
+    return res;
+};
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle render_items,
+    BufferHandle submeshes,
+    Resources &res,
+    ImageHandle hiz_image,
+    bool enable_culling,
+    const char *pass_name
+) {
+
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/dispatch_mdi/build_indirect.slang", "csMain");
+    pipelines.add_compute("BuildIndirect", pd);
+
+    rhi::ComputePipeline &pipeline = pipelines.get_compute("BuildIndirect");
+
+    auto &clear = fg.add_pass("Clear Draw Count");
+    clear.write(res.draw_count, rhi::ResourceState::TransferTo);
+    clear.execute([=](PassContext &ctx) {
+        auto &count_buf = ctx.get_buffer(res.draw_count);
+        rhi::fill_buffer(ctx.cmd, count_buf, 0, sizeof(u32), 0);
+    });
+
+    auto &builder = fg.add_pass(pass_name);
+    builder.read(render_items, rhi::ResourceState::StorageRead);
+    builder.read(submeshes, rhi::ResourceState::StorageRead);
+    if (enable_culling && hiz_image.id != UINT32_MAX) {
+        builder.read(hiz_image, rhi::ResourceState::TextureSampleNonFragment);
+    }
+    builder.write(res.indirect, rhi::ResourceState::StorageReadWrite);
+    builder.write(res.visible, rhi::ResourceState::StorageReadWrite);
+    builder.write(res.draw_count, rhi::ResourceState::StorageReadWrite);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        // render-item buffer is the candidate list: one thread per item.
+        u32 item_count = (u32)ctx.render_data->render_items.size();
+
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        BuildIndirectPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+
+        // (BDA path: render-item/submesh buffers travel by device address.)
+
+        pc.indirect_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.indirect));
+        pc.visible_items = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.visible));
+        pc.draw_count_buffer = rhi::buffer_device_address(ctx.device, ctx.get_buffer(res.draw_count));
+
+        pc.item_count = item_count;
+
+        if (enable_culling) {
+            auto hiz_img = ctx.get_image(hiz_image);
+            pc.hiz = (u32)ctx.view(hiz_image);
+            pc.hiz_width = hiz_img.desc.width;
+            pc.hiz_height = hiz_img.desc.height;
+            pc.hiz_mip_count = hiz_img.desc.mip_levels;
+        } else {
+            pc.hiz = UINT64_MAX; // canonical null handle: skips occlusion test
+            pc.hiz_width = 0;
+            pc.hiz_height = 0;
+            pc.hiz_mip_count = 0;
+        }
+
+        pc.enable_culling = enable_culling ? 1 : 0;
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        u32 group_count_x = (item_count + 63u) / 64u;
+        if (group_count_x > 0) {
+            rhi::dispatch(ctx.cmd, group_count_x);
+        }
+    });
+}
+
+} // namespace build_indirect
ADD · src/passes/dispatch_mdi/build_indirect.h +30 -0
--- a/src/passes/dispatch_mdi/build_indirect.h
+++ b/src/passes/dispatch_mdi/build_indirect.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct RenderData;
+struct FrameData;
+struct Pipelines;
+
+namespace build_indirect {
+struct Resources {
+    BufferHandle indirect;
+    BufferHandle visible;
+    BufferHandle draw_count;
+};
+
+Resources create(FrameGraph &fg, u32 render_item_count, const char *tag);
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle render_items,
+    BufferHandle submeshes,
+    Resources &res,
+    ImageHandle hiz_image,
+    bool enable_culling,
+    const char *pass_name
+);
+} // namespace build_indirect
ADD · src/passes/dispatch_mdi/build_indirect.slang +101 -0
--- a/src/passes/dispatch_mdi/build_indirect.slang
+++ b/src/passes/dispatch_mdi/build_indirect.slang
@@ -0,0 +1,101 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/frustum_culling.slang"
+
+[[vk::push_constant]]
+BuildIndirectPushConstants pc;
+
+// VkDrawIndexedIndirectCommand is 5 x 4-byte fields:
+//   uint32 indexCount
+//   uint32 instanceCount
+//   uint32 firstIndex
+//   int32  vertexOffset
+//   uint32 firstInstance
+// Total = 20 bytes.
+// TODO: size this via a push constant to whatever gfx API
+
+static const u32 DrawIndexedIndirectCommandStride = 20;
+static const u32 WG = 64;
+
+groupshared u32 s_vis[WG];
+groupshared u32 s_group_base;
+
+[shader("compute")]
+[numthreads(64, 1, 1)]
+void csMain(uvec3 id: SV_DispatchThreadID, uint gt: SV_GroupIndex) {
+    u32 visible = 0;
+
+    FrameUBO frame = *pc.frame;
+    Frustum frustum = extract_frustum(frame.view_proj);
+    set_far_plane(frustum, frame.position_ws.xyz, frame.forward_ws, 1000.0f);
+
+    if (id.x < pc.item_count) {
+        RenderItemGPU item = frame.render_items[id.x];
+        SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+        TransformGPU xform = frame.transforms[item.instance_id];
+        visible = 1;
+
+        if (xform.active != 0) {
+            if (pc.enable_culling == 1) {
+                if (is_object_visible(submesh, xform, frustum)) {
+                    bool occluded = false;
+                    // UINT64_MAX is the canonical null handle (host-normalized).
+                    Texture2D.Handle hiz_null = reinterpret<Texture2D.Handle>(uint2(0xFFFFFFFFu, 0xFFFFFFFFu));
+                    if (pc.hiz != hiz_null) {
+                        occluded = is_object_occluded(
+                            submesh.local_aabb_min,
+                            submesh.local_aabb_max,
+                            xform,
+                            frame.view_proj,
+                            pc.hiz,
+                            pc.hiz_width,
+                            pc.hiz_height,
+                            pc.hiz_mip_count
+                        );
+                    }
+                    visible = !occluded;
+                }
+            } else {
+                visible = 1;
+            }
+        }
+    }
+
+    s_vis[gt] = visible;
+
+    GroupMemoryBarrierWithGroupSync();
+    if (gt == 0) {
+        u32 total = 0;
+        [unroll]
+        for (u32 i = 0; i < WG; ++i) {
+            u32 c = s_vis[i];
+            s_vis[i] = total;
+            total += c;
+        }
+        if (total > 0)
+            InterlockedAdd(pc.draw_count_buffer[0], total, s_group_base);
+        else
+            s_group_base = 0;
+    }
+    GroupMemoryBarrierWithGroupSync();
+
+    if (visible == 0)
+        return;
+
+    if (id.x >= pc.item_count) {
+        return;
+    }
+
+    RenderItemGPU item = frame.render_items[id.x];
+    SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+
+    u32 slot = s_group_base + s_vis[gt];
+
+    pc.indirect_buffer[slot].indexCount = submesh.index_count;
+    pc.indirect_buffer[slot].instanceCount = 1;
+    pc.indirect_buffer[slot].firstIndex = submesh.first_index;
+    pc.indirect_buffer[slot].vertexOffset = submesh.base_vertex;
+    pc.indirect_buffer[slot].firstInstance = item.instance_id;
+    pc.visible_items[slot].id = id.x;
+    pc.visible_items[slot].instance_id = item.instance_id;
+}
ADD · src/passes/fg.cpp +935 -0
--- a/src/passes/fg.cpp
+++ b/src/passes/fg.cpp
@@ -0,0 +1,935 @@
+#include "fg.h"
+
+#include "core/logger.h"
+#include "fg_utils.h"
+#include <array>
+
+// each recorder declares rhi::ResourceState, each backend lowers to
+// native stages/access/layouts. ideally compatible states ought to  merge (no barrier),
+// currently only readonly stuff does
+// all writes in the pair force a transition, Idle is the fresh-resource state (not sure if Idle will be ketp)
+
+static bool state_is_read_only(rhi::ResourceState s) {
+    using S = rhi::ResourceState;
+    switch (s) {
+    case S::Idle:
+    case S::ColorFetch:
+    case S::DepthFetch:
+    case S::TextureSample:
+    case S::TextureSampleNonFragment:
+    case S::StorageRead:
+    case S::VertexFetch:
+    case S::IndexFetch:
+    case S::IndirectFetch:
+    case S::UniformRead:
+    case S::TransferFrom:
+    case S::HostRead:
+    case S::AccelTrace:
+    case S::Display:
+        return true;
+    default:
+        return false;
+    }
+}
+
+static rhi::ImageUsage image_state_creation_usage(rhi::ResourceState s) {
+    using S = rhi::ResourceState;
+    switch (s) {
+    case S::ColorDraw:
+    case S::ColorFetch:
+        return rhi::ImageUsage::ColorAttachment;
+    case S::DepthDraw:
+    case S::DepthFetch:
+        return rhi::ImageUsage::DepthAttachment;
+    case S::TextureSample:
+    case S::TextureSampleNonFragment:
+        return rhi::ImageUsage::Sampled;
+    case S::StorageRead:
+    case S::StorageReadWrite:
+        return rhi::ImageUsage::Storage;
+    case S::TransferFrom:
+        return rhi::ImageUsage::TransferSrc;
+    case S::TransferTo:
+        return rhi::ImageUsage::TransferDst;
+    case S::Display:
+        return rhi::ImageUsage::TransferSrc;
+    default:
+        return rhi::ImageUsage::None;
+    }
+}
+
+static rhi::BufferUsage buffer_state_creation_usage(rhi::ResourceState s) {
+    using S = rhi::ResourceState;
+    using U = rhi::BufferUsage;
+    switch (s) {
+    case S::StorageRead:
+    case S::StorageReadWrite:
+        return U::StorageBuffer;
+    case S::UniformRead:
+        return rhi::BufferUsage::UniformBuffer;
+    case S::VertexFetch:
+        return rhi::BufferUsage::VertexBuffer;
+    case S::IndexFetch:
+        return rhi::BufferUsage::IndexBuffer;
+    case S::IndirectFetch:
+        return rhi::BufferUsage::IndirectBuffer;
+    case S::TransferFrom:
+    case S::HostRead:
+        return rhi::BufferUsage::CopySrc;
+    case S::TransferTo:
+        return rhi::BufferUsage::CopyDst;
+    case S::AccelBuild:
+    case S::AccelTrace:
+        return rhi::BufferUsage::AccelStructStorage;
+    default:
+        return rhi::BufferUsage::None;
+    }
+}
+
+// same-state merge policy for a repeated handle in one pass: keep the
+// writable state (conservative union), read-only pairs keep the latest
+static rhi::ResourceState merge_image_state(rhi::ResourceState a, rhi::ResourceState b) {
+    if (a == b) {
+        return a;
+    }
+    const bool wa = !state_is_read_only(a);
+    const bool wb = !state_is_read_only(b);
+    if (wa != wb) {
+        return wa ? a : b;
+    }
+    return b;
+}
+
+static rhi::ImageAspect aspect_from_format(rhi::ImageFormat fmt) {
+    switch (fmt) {
+    case rhi::ImageFormat::D32_FLOAT:
+        return rhi::ImageAspect::Depth;
+    // TODO: stencil?
+    default:
+        return rhi::ImageAspect::Color;
+    }
+}
+
+//==========================================================================================
+
+static Operation merge_access(Operation a, Operation b) {
+    if (a == Operation::ReadWrite || b == Operation::ReadWrite) {
+        return Operation::ReadWrite;
+    }
+    if (a == Operation::Write || b == Operation::Write) {
+        return Operation::Write;
+    }
+    return Operation::Read;
+}
+
+ImageHandle FrameGraph::add_image(ImageResource img) {
+    assert(
+        (img.lifetime != Lifetime::Imported) ||
+        (img.external != nullptr) && "Imported resources must carry an external object (use import_image)"
+    );
+    u32 id = logical_images.size();
+    logical_images.push_back(img);
+    return {id};
+}
+
+BufferHandle FrameGraph::add_buffer(BufferResource buf) {
+    assert(
+        (buf.lifetime != Lifetime::Imported) ||
+        (buf.external != nullptr) && "Imported resources must carry an external object (use import_buffer)"
+    );
+    u32 id = logical_buffers.size();
+    logical_buffers.push_back(buf);
+    return {id};
+}
+
+PassBuilder &FrameGraph::add_pass(const char *name) {
+    passes.emplace_back();
+    passes.back().name = name;
+    passes.back().graph_ = this;
+    return passes.back();
+}
+
+PassBuilder &
+PassBuilder::add_image_ref(FrameGraph &g, ImageHandle img, rhi::ResourceState state, Operation op, i32 version_offset) {
+    assert(img.is_valid() && img.id < g.logical_images.size() && "invalid image handle in PassBuilder::read");
+    if (image_ref_count == 0) {
+        image_ref_start = static_cast<u32>(g.image_refs.size());
+    }
+    for (u32 i = image_ref_start; i < image_ref_start + image_ref_count; ++i) {
+        ImageResourceRef &ref = g.image_refs[i];
+        if (ref.img.id == img.id && ref.version_offset == version_offset) {
+            ref.operation = merge_access(ref.operation, op);
+            ref.state = merge_image_state(ref.state, state);
+            return *this;
+        }
+    }
+    g.image_refs.push_back({.img = img, .operation = op, .state = state, .version_offset = version_offset});
+    image_ref_count++;
+    return *this;
+}
+
+PassBuilder &PassBuilder::add_buffer_ref(
+    FrameGraph &g, BufferHandle buf, rhi::ResourceState state, Operation op, i32 version_offset
+) {
+    assert(buf.is_valid() && buf.id < g.logical_buffers.size() && "invalid buffer handle in PassBuilder::read");
+    if (buffer_ref_count == 0) {
+        buffer_ref_start = static_cast<u32>(g.buffer_refs.size());
+    }
+    for (u32 i = buffer_ref_start; i < buffer_ref_start + buffer_ref_count; ++i) {
+        BufferResourceRef &ref = g.buffer_refs[i];
+        if (ref.buf.id == buf.id && ref.version_offset == version_offset) {
+            ref.operation = merge_access(ref.operation, op);
+            ref.state = merge_image_state(ref.state, state);
+            return *this;
+        }
+    }
+    g.buffer_refs.push_back({.buf = buf, .operation = op, .state = state, .version_offset = version_offset});
+    buffer_ref_count++;
+    return *this;
+}
+
+PassBuilder &PassBuilder::read(FrameGraph &g, ImageHandle img, rhi::ResourceState state) {
+    return add_image_ref(g, img, state, Operation::Read, 0);
+}
+PassBuilder &PassBuilder::write(FrameGraph &g, ImageHandle image, rhi::ResourceState state) {
+    return add_image_ref(g, image, state, Operation::Write, 0);
+}
+PassBuilder &PassBuilder::read_write(FrameGraph &g, ImageHandle image, rhi::ResourceState state) {
+    return add_image_ref(g, image, state, Operation::ReadWrite, 0);
+}
+PassBuilder &PassBuilder::read(FrameGraph &g, BufferHandle buf, rhi::ResourceState state) {
+    return add_buffer_ref(g, buf, state, Operation::Read, 0);
+}
+PassBuilder &PassBuilder::write(FrameGraph &g, BufferHandle buffer, rhi::ResourceState state) {
+    return add_buffer_ref(g, buffer, state, Operation::Write, 0);
+}
+PassBuilder &PassBuilder::read_write(FrameGraph &g, BufferHandle buffer, rhi::ResourceState state) {
+    return add_buffer_ref(g, buffer, state, Operation::ReadWrite, 0);
+}
+
+// ---------------------------------------------------------------------------
+// Owner-aware forms: forward to the graph this pass was recorded on.
+
+PassBuilder &PassBuilder::read(ImageHandle img, rhi::ResourceState state) {
+    return read(*graph_, img, state);
+}
+PassBuilder &PassBuilder::write(ImageHandle image, rhi::ResourceState state) {
+    return write(*graph_, image, state);
+}
+PassBuilder &PassBuilder::read_write(ImageHandle image, rhi::ResourceState state) {
+    return read_write(*graph_, image, state);
+}
+PassBuilder &PassBuilder::read(BufferHandle buf, rhi::ResourceState state) {
+    return read(*graph_, buf, state);
+}
+PassBuilder &PassBuilder::write(BufferHandle buffer, rhi::ResourceState state) {
+    return write(*graph_, buffer, state);
+}
+PassBuilder &PassBuilder::read_write(BufferHandle buffer, rhi::ResourceState state) {
+    return read_write(*graph_, buffer, state);
+}
+
+// ---------------------------------------------------------------------------
+// History resource versioning forms.
+
+PassBuilder &PassBuilder::write_current(FrameGraph &g, ImageHandle img, rhi::ResourceState state) {
+    return add_image_ref(g, img, state, Operation::Write, 0);
+}
+PassBuilder &PassBuilder::read_previous(FrameGraph &g, ImageHandle img, rhi::ResourceState state) {
+    return add_image_ref(g, img, state, Operation::Read, -1);
+}
+PassBuilder &PassBuilder::write_current(FrameGraph &g, BufferHandle buf, rhi::ResourceState state) {
+    return add_buffer_ref(g, buf, state, Operation::Write, 0);
+}
+PassBuilder &PassBuilder::read_previous(FrameGraph &g, BufferHandle buf, rhi::ResourceState state) {
+    return add_buffer_ref(g, buf, state, Operation::Read, -1);
+}
+PassBuilder &PassBuilder::write_current(ImageHandle img, rhi::ResourceState state) {
+    return write_current(*graph_, img, state);
+}
+PassBuilder &PassBuilder::read_previous(ImageHandle img, rhi::ResourceState state) {
+    return read_previous(*graph_, img, state);
+}
+PassBuilder &PassBuilder::write_current(BufferHandle buf, rhi::ResourceState state) {
+    return write_current(*graph_, buf, state);
+}
+PassBuilder &PassBuilder::read_previous(BufferHandle buf, rhi::ResourceState state) {
+    return read_previous(*graph_, buf, state);
+}
+
+void FrameGraph::init() {
+    assert(
+        physical.images.empty() && physical.buffers.empty() &&
+        "call destroy() or reset() before init() to release GPU storage"
+    );
+    logical_images.clear();
+    logical_buffers.clear();
+    image_refs.clear();
+    buffer_refs.clear();
+    passes.clear();
+    image_barriers.clear();
+    buffer_barriers.clear();
+    extra_views.clear();
+    is_compiled = false;
+}
+
+static void destroy_transient_views(FrameGraph &g) {
+    if (g.device == nullptr) {
+        g.physical.transient_views.clear();
+        return;
+    }
+    for (rhi::ImageView &v : g.physical.transient_views) {
+        rhi::destroy_image_view(*g.device, v);
+    }
+    g.physical.transient_views.clear();
+}
+
+static u32 mint_transient_view(FrameGraph &g, rhi::Image *img, const rhi::ImageViewDesc &desc) {
+    assert(g.device != nullptr);
+    assert(img != nullptr);
+    rhi::ImageViewDesc full = desc;
+    full.image = img;
+    rhi::ImageView v{};
+    if (!rhi::create_image_view(*g.device, full, v)) {
+        VEL_CRITICAL("FrameGraph::compile: failed transient view mint");
+        return INVALID_VIEW_INDEX;
+    }
+    assert(v.slot <= UINT32_MAX && "bindless slot exceeds u32 shader index");
+    g.physical.transient_views.push_back(std::move(v));
+    return (u32)g.physical.transient_views.back().slot;
+}
+
+u32 FrameGraph::request_extra_view(ImageHandle img, bool all_mips) {
+    u32 idx = (u32)extra_views.size();
+    extra_views.push_back({img, all_mips, {}, 0});
+    return idx;
+}
+
+rhi::ImageView PassContext::image_view(ImageHandle handle, const rhi::ImageViewDesc &desc) const {
+    return rhi::get_cached_image_view(device, get_image(handle), desc);
+}
+
+u32 PassContext::view_extra(u32 extra_idx, i32 version_offset, u32 mip) const {
+    assert(extra_views != nullptr && extra_idx < (u32)extra_views->size());
+    const ExtraImageView &ev = (*extra_views)[extra_idx];
+    u32 vc = storage.image_version_count[ev.img.id];
+    i32 v = ((i32)frame_index + version_offset) % (i32)vc;
+    if (v < 0) {
+        v += (i32)vc;
+    }
+    if (ev.all_mips) {
+        assert(mip < ev.mips_per_version);
+        return ev.slots[(u32)v * ev.mips_per_version + mip];
+    }
+    assert(ev.slots.size() > (u32)v);
+    return ev.slots[(u32)v];
+}
+
+static void release_image(FrameGraph &g, rhi::Image &img) {
+    (void)g;
+    rhi::destroy_image_views(*g.device, img);
+}
+
+static void release_buffer(FrameGraph &g, rhi::Buffer &buf) {
+    (void)g;
+    rhi::destroy_buffer_views(*g.device, buf);
+}
+
+static void destroy_physicals(FrameGraph &g, bool include_persistent) {
+    if (g.device == nullptr) {
+        return;
+    }
+    destroy_transient_views(g);
+    for (u32 i = 0; i < g.logical_images.size(); ++i) {
+        if (i >= g.physical.image_base.size()) {
+            continue;
+        }
+        if (g.logical_images[i].lifetime == Lifetime::Imported) {
+            continue;
+        }
+        if (!include_persistent && (g.logical_images[i].lifetime == Lifetime::Persistent ||
+                                    g.logical_images[i].lifetime == Lifetime::History)) {
+            continue;
+        }
+        const u32 vc = g.physical.image_version_count[i];
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Image &img = g.physical.owned_images[g.physical.image_base[i] + v];
+            if (!rhi::valid(img)) {
+                continue;
+            }
+            // views are cached on the image; release them BEFORE destroying it
+            release_image(g, img);
+            rhi::destroy_image(*g.device, img);
+        }
+    }
+    for (u32 i = 0; i < g.logical_buffers.size(); ++i) {
+        if (i >= g.physical.buffer_base.size()) {
+            continue;
+        }
+        if (g.logical_buffers[i].lifetime == Lifetime::Imported) {
+            continue;
+        }
+        if (!include_persistent && (g.logical_buffers[i].lifetime == Lifetime::Persistent ||
+                                    g.logical_buffers[i].lifetime == Lifetime::History)) {
+            continue;
+        }
+        const u32 vc = g.physical.buffer_version_count[i];
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Buffer &buf = g.physical.owned_buffers[g.physical.buffer_base[i] + v];
+            if (!rhi::valid(buf)) {
+                continue;
+            }
+
+            release_buffer(g, buf);
+            rhi::destroy_buffer(*g.device, buf);
+        }
+    }
+    if (include_persistent) {
+        g.physical.owned_images.clear();
+        g.physical.owned_buffers.clear();
+        g.physical.image_base.clear();
+        g.physical.image_version_count.clear();
+        g.physical.buffer_base.clear();
+        g.physical.buffer_version_count.clear();
+    }
+    g.physical.images.clear();
+    g.physical.buffers.clear();
+    g.physical.image_view_index.clear();
+}
+
+static rhi::Extent2D resolve_image_extent(ImageResource &img, u32 swap_width, u32 swap_height) {
+    switch (img.size_class) {
+    case SizeOp::Absolute: {
+        return {img.desc.width, img.desc.height};
+    }
+    case SizeOp::Relative:
+    case SizeOp::Swapchain: {
+        u32 w = std::max(1u, static_cast<u32>(static_cast<f32>(swap_width) * img.scale.x));
+        u32 h = std::max(1u, static_cast<u32>(static_cast<f32>(swap_height) * img.scale.y));
+        return {w, h};
+    }
+    }
+    return {img.desc.width, img.desc.height};
+}
+
+static u32 full_mip_chain_levels(u32 w, u32 h) {
+    u32 levels = 1;
+    while ((w > 1 || h > 1) && levels < 32) {
+        w >>= 1;
+        h >>= 1;
+        ++levels;
+    }
+    return levels;
+}
+
+static rhi::ImageDesc resolve_image_desc(ImageResource &img, rhi::ImageUsage agg_usage, u32 w, u32 h, bool readback) {
+    rhi::Extent2D extent = resolve_image_extent(img, w, h);
+    rhi::ImageDesc desc = img.desc;
+    desc.width = extent.width;
+    desc.height = extent.height;
+    desc.usage |= agg_usage;
+    if (readback) {
+        desc.usage |= rhi::ImageUsage::TransferSrc;
+    }
+    desc.mip_levels = desc.mip_levels == 0 ? full_mip_chain_levels(extent.width, extent.height) : desc.mip_levels;
+    return desc;
+}
+
+static rhi::BufferDesc resolve_buffer_desc(BufferResource &buf, rhi::BufferUsage agg_usage, u32 w, u32 h) {
+    rhi::BufferDesc desc = buf.desc;
+    if (buf.size_fn) {
+        desc.size = buf.size_fn(w, h);
+    }
+    desc.usage |= agg_usage;
+    return desc;
+}
+
+static bool same_image_desc(const rhi::ImageDesc &a, const rhi::ImageDesc &b) {
+    return a.width == b.width && a.height == b.height && a.depth == b.depth && a.mip_levels == b.mip_levels &&
+           a.layers == b.layers && a.is_cubemap == b.is_cubemap && a.sample_count == b.sample_count &&
+           a.format == b.format && a.usage == b.usage;
+}
+
+static bool same_buffer_desc(const rhi::BufferDesc &a, const rhi::BufferDesc &b) {
+    return a.size == b.size && a.usage == b.usage && a.memory == b.memory && a.dedicated == b.dedicated;
+}
+
+bool FrameGraph::compile(rhi::Device &in_device, rhi::Extent2D swapchain_extent) {
+    width = swapchain_extent.width;
+    height = swapchain_extent.height;
+    device = &in_device;
+
+    // clear the previous baked plan up front so a failure below leaves a clean,
+    // uncompiled state rather than stale barriers paired with new storage.
+    is_compiled = false;
+    pending_state_fixup = false;
+    image_barriers.clear();
+    buffer_barriers.clear();
+    for (PassBuilder &p : passes) {
+        p.image_barrier_count = 0;
+        p.buffer_barrier_count = 0;
+    }
+
+    destroy_physicals(*this, false);
+
+    // Rebuild flat-with-stride layout: base offsets + version strides.
+    physical.image_base.assign(logical_images.size(), 0);
+    physical.image_version_count.assign(logical_images.size(), 1);
+    u32 img_total = 0;
+    for (u32 i = 0; i < logical_images.size(); ++i) {
+        physical.image_version_count[i] = get_version_count(logical_images[i].lifetime);
+        physical.image_base[i] = img_total;
+        img_total += physical.image_version_count[i];
+    }
+    physical.buffer_base.assign(logical_buffers.size(), 0);
+    physical.buffer_version_count.assign(logical_buffers.size(), 1);
+    u32 buf_total = 0;
+    for (u32 i = 0; i < logical_buffers.size(); ++i) {
+        physical.buffer_version_count[i] = get_version_count(logical_buffers[i].lifetime);
+        physical.buffer_base[i] = buf_total;
+        buf_total += physical.buffer_version_count[i];
+    }
+
+    if (physical.owned_images.size() < img_total) {
+        physical.owned_images.resize(img_total);
+    } else if (physical.owned_images.size() > img_total) {
+        for (u32 i = img_total; i < physical.owned_images.size(); ++i) {
+            rhi::Image &img = physical.owned_images[i];
+            if (rhi::valid(img)) {
+                release_image(*this, img);
+                rhi::destroy_image(*device, img);
+            }
+        }
+        physical.owned_images.resize(img_total);
+    }
+    if (physical.owned_buffers.size() < buf_total) {
+        physical.owned_buffers.resize(buf_total);
+    } else if (physical.owned_buffers.size() > buf_total) {
+        for (u32 i = buf_total; i < physical.owned_buffers.size(); ++i) {
+            rhi::Buffer &buf = physical.owned_buffers[i];
+            if (rhi::valid(buf)) {
+                release_buffer(*this, buf);
+                rhi::destroy_buffer(*device, buf);
+            }
+        }
+        physical.owned_buffers.resize(buf_total);
+    }
+
+    std::vector<rhi::ImageUsage> img_usage(logical_images.size(), rhi::ImageUsage::None);
+    std::vector<rhi::BufferUsage> buffer_usage(logical_buffers.size(), rhi::BufferUsage::None);
+
+    // aggregate resource usages across all passes
+    for (const auto &curr_pass : passes) {
+        for (u32 j = 0; j < curr_pass.image_ref_count; ++j) {
+            const auto &r = image_refs[curr_pass.image_ref_start + j];
+            if (logical_images[r.img.id].lifetime != Lifetime::Imported) {
+                img_usage[r.img.id] |= image_state_creation_usage(r.state);
+            }
+        }
+        for (u32 ri = 0; ri < curr_pass.buffer_ref_count; ++ri) {
+            const auto &r = buffer_refs[curr_pass.buffer_ref_start + ri];
+            if (logical_buffers[r.buf.id].lifetime != Lifetime::Imported) {
+                buffer_usage[r.buf.id] |= buffer_state_creation_usage(r.state);
+            }
+        }
+    }
+
+    // alloc Physical Images (imports borrow survivors are reused)
+    physical.images.resize(img_total);
+    physical.image_view_index.assign(img_total, INVALID_VIEW_INDEX);
+    for (u32 i = 0; i < logical_images.size(); ++i) {
+        ImageResource &img_res = logical_images[i];
+        const u32 base = physical.image_base[i];
+        if (img_res.lifetime == Lifetime::Imported) {
+            if (img_res.external == nullptr) {
+                VEL_CRITICAL("FrameGraph::compile: imported image {} has no external image; aborting compile", i);
+                return false;
+            }
+            physical.images[base] = img_res.external;
+            continue;
+        }
+
+        const u32 vc = physical.image_version_count[i];
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Image &img = physical.owned_images[base + v];
+            if (rhi::valid(img)) {
+                // persistent/history survivor: reuse if its descriptor still
+                // matches the resolved target, otherwise recreate (e.g. resize)
+                rhi::ImageDesc want = resolve_image_desc(img_res, img_usage[i], width, height, image_readback);
+                if (same_image_desc(img.desc, want)) {
+                    physical.images[base + v] = &img;
+                    continue;
+                }
+                release_image(*this, img);
+                rhi::destroy_image(*device, img);
+            }
+
+            rhi::ImageDesc desc = resolve_image_desc(img_res, img_usage[i], width, height, image_readback);
+            if (!img_res.name.empty()) {
+                desc.name = img_res.name;
+                if (vc > 1) {
+                    desc.name += "#v" + std::to_string(v);
+                }
+            }
+            if (!rhi::create_image(*device, desc, img)) {
+                VEL_CRITICAL("FrameGraph::compile: failed physical image allocation at index {} v{}", i, v);
+                physical.images[base + v] = nullptr;
+                continue;
+            }
+            physical.images[base + v] = &img;
+        }
+    }
+
+    for (u32 i = 0; i < logical_images.size(); ++i) {
+        const ImageResource &img_res = logical_images[i];
+        if (img_res.view.type == rhi::ImageViewType::None) {
+            continue;
+        }
+        const u32 base = physical.image_base[i];
+        const u32 vc = physical.image_version_count[i];
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Image *img = physical.images[base + v];
+            if (img == nullptr) {
+                continue;
+            }
+            rhi::ImageViewDesc desc = img_res.view;
+            if (desc.mip_count == 0) {
+                desc.mip_count = img->desc.mip_levels;
+            }
+            physical.image_view_index[base + v] = mint_transient_view(*this, img, desc);
+        }
+    }
+    for (ExtraImageView &ev : extra_views) {
+        const u32 base = physical.image_base[ev.img.id];
+        const u32 vc = physical.image_version_count[ev.img.id];
+        ev.slots.clear();
+        ev.mips_per_version = 0;
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Image *img = physical.images[base + v];
+            if (img == nullptr) {
+                continue;
+            }
+            if (ev.all_mips) {
+                u32 mips = img->desc.mip_levels;
+                if (ev.mips_per_version == 0) {
+                    ev.mips_per_version = mips;
+                    ev.slots.resize(vc * mips, INVALID_VIEW_INDEX);
+                }
+                for (u32 mip = 0; mip < mips && mip < ev.mips_per_version; ++mip) {
+                    rhi::ImageViewDesc desc{};
+                    desc.aspect = rhi::ImageAspect::Color;
+                    desc.dimension = rhi::TextureViewDimension::TEXTURE_2D;
+                    desc.type = rhi::ImageViewType::Storage;
+                    desc.mip_start = mip;
+                    desc.mip_count = 1;
+                    ev.slots[v * ev.mips_per_version + mip] = mint_transient_view(*this, img, desc);
+                }
+            } else {
+                if (ev.slots.empty()) {
+                    ev.slots.assign(vc, INVALID_VIEW_INDEX);
+                }
+                rhi::ImageViewDesc desc{};
+                desc.type = rhi::ImageViewType::Storage;
+                ev.slots[v] = mint_transient_view(*this, img, desc);
+            }
+        }
+    }
+
+    // 3. Allocate Physical Buffers (imports borrow; survivors are reused)
+    physical.buffers.resize(buf_total);
+    for (u32 i = 0; i < logical_buffers.size(); ++i) {
+        BufferResource &buf_res = logical_buffers[i];
+        const u32 base = physical.buffer_base[i];
+        if (buf_res.lifetime == Lifetime::Imported) {
+            if (buf_res.external == nullptr) {
+                VEL_CRITICAL("FrameGraph::compile: imported buffer {} has no external buffer; aborting compile", i);
+                return false;
+            }
+            physical.buffers[base] = buf_res.external;
+            continue;
+        }
+
+        const u32 vc = physical.buffer_version_count[i];
+        for (u32 v = 0; v < vc; ++v) {
+            rhi::Buffer &buf = physical.owned_buffers[base + v];
+            if (rhi::valid(buf)) {
+                // persistent/history survivor: reuse if its descriptor still
+                // matches the resolved target, otherwise recreate (e.g. resize)
+                rhi::BufferDesc want = resolve_buffer_desc(buf_res, buffer_usage[i], width, height);
+                if (same_buffer_desc(buf.desc, want)) {
+                    physical.buffers[base + v] = &buf;
+                    continue;
+                }
+                release_buffer(*this, buf);
+                rhi::destroy_buffer(*device, buf);
+            }
+
+            rhi::BufferDesc desc = resolve_buffer_desc(buf_res, buffer_usage[i], width, height);
+            if (!buf_res.name.empty()) {
+                desc.name = buf_res.name;
+                if (vc > 1) {
+                    desc.name += "#v" + std::to_string(v);
+                }
+            }
+            if (!rhi::create_buffer(*device, desc, buf)) {
+                VEL_CRITICAL("FrameGraph::compile: failed physical buffer allocation at index {} v{}", i, v);
+                physical.buffers[base + v] = nullptr;
+                continue;
+            }
+            physical.buffers[base + v] = &buf;
+        }
+    }
+
+    image_barriers.clear();
+    buffer_barriers.clear();
+
+    auto slot_index = [](i32 version_offset) -> u32 { return (version_offset < 0) ? 1u : 0u; };
+
+    std::vector<std::array<rhi::ResourceState, 2>> sim_img(logical_images.size());
+    std::vector<std::array<rhi::ResourceState, 2>> sim_buf(logical_buffers.size());
+
+    for (u32 i = 0; i < logical_images.size(); ++i) {
+        if (logical_images[i].lifetime == Lifetime::Imported) {
+            sim_img[i][0] = logical_images[i].entry_state;
+        } else if (
+            (logical_images[i].lifetime == Lifetime::Persistent || logical_images[i].lifetime == Lifetime::History) &&
+            rhi::valid(physical.owned_images[physical.image_base[i]])
+        ) {
+            sim_img[i][0] = physical.owned_images[physical.image_base[i]].state;
+            sim_img[i][1] = sim_img[i][0];
+        } else {
+            sim_img[i] = {};
+        }
+    }
+    for (u32 i = 0; i < logical_buffers.size(); ++i) {
+        if (logical_buffers[i].lifetime == Lifetime::Imported) {
+            sim_buf[i][0] = logical_buffers[i].entry_state;
+        } else if (
+            (logical_buffers[i].lifetime == Lifetime::Persistent || logical_buffers[i].lifetime == Lifetime::History) &&
+            rhi::valid(physical.owned_buffers[physical.buffer_base[i]])
+        ) {
+            sim_buf[i][0] = physical.owned_buffers[physical.buffer_base[i]].state;
+            sim_buf[i][1] = sim_buf[i][0];
+        } else {
+            sim_buf[i] = {};
+        }
+    }
+
+    for (u32 lap = 0; lap < 2; ++lap) {
+        const bool bake = (lap == 1);
+        for (u32 pi = 0; pi < passes.size(); ++pi) {
+            PassBuilder &pass = passes[pi];
+            if (bake) {
+                pass.image_barrier_start = static_cast<u32>(image_barriers.size());
+                pass.buffer_barrier_start = static_cast<u32>(buffer_barriers.size());
+            }
+
+            for (u32 ri = 0; ri < pass.image_ref_count; ++ri) {
+                const ImageResourceRef &ref = image_refs[pass.image_ref_start + ri];
+                const u32 id = ref.img.id;
+                const u32 slot = slot_index(ref.version_offset);
+
+                rhi::ImageAspect aspect = rhi::ImageAspect::Color;
+                rhi::Image *phys0 = physical.image(id, 0);
+                if (phys0) {
+                    aspect = aspect_from_format(phys0->desc.format);
+                }
+
+                rhi::ResourceState tgt = ref.state;
+                rhi::ResourceState &cur = sim_img[id][slot];
+
+                const bool read_after_read = state_is_read_only(tgt) && state_is_read_only(cur) && cur == tgt;
+                if (!read_after_read) {
+                    // write-after-anything, anything-after-write, or a state change
+                    // Idle cur == fresh entry -> legal discard transition
+                    if (bake) {
+                        image_barriers.push_back({
+                            .image_id = id,
+                            .version_offset = ref.version_offset,
+                            .before = cur,
+                            .after = tgt,
+                            .aspect = aspect,
+                        });
+                    }
+                    cur = tgt;
+                } else {
+                    // pure same-state read-after-read: no barrier
+                    cur = tgt;
+                }
+            }
+
+            for (u32 ri = 0; ri < pass.buffer_ref_count; ++ri) {
+                const BufferResourceRef &ref = buffer_refs[pass.buffer_ref_start + ri];
+                const u32 id = ref.buf.id;
+                const u32 slot = slot_index(ref.version_offset);
+
+                rhi::ResourceState tgt = ref.state;
+                rhi::ResourceState &cur = sim_buf[id][slot];
+
+                const bool read_after_read = state_is_read_only(tgt) && state_is_read_only(cur) && cur == tgt;
+                if (!read_after_read) {
+                    if (bake) {
+                        buffer_barriers.push_back({
+                            .buffer_id = id,
+                            .version_offset = ref.version_offset,
+                            .before = cur,
+                            .after = tgt,
+                        });
+                    }
+                    cur = tgt;
+                } else {
+                    cur = tgt;
+                }
+            }
+
+            if (bake) {
+                pass.image_barrier_count = static_cast<u32>(image_barriers.size()) - pass.image_barrier_start;
+                pass.buffer_barrier_count = static_cast<u32>(buffer_barriers.size()) - pass.buffer_barrier_start;
+            }
+        }
+    }
+
+    // The first execute() after a compile patches each physical slot's first
+    // baked barrier with its live state (fresh creates enter Idle, survivors
+    // may differ from steady state). Thereafter it replays the pure baked plan
+    pending_state_fixup = true;
+    touch_img.assign(img_total, 0);
+    touch_buf.assign(buf_total, 0);
+
+    is_compiled = true;
+    return true;
+}
+
+void FrameGraph::execute(rhi::CmdBuffer &cmd, const GraphExecInfo &info) {
+    if (!is_compiled) {
+        VEL_ERROR("FrameGraph::execute: graph is not compiled; ignoring execute");
+        return;
+    }
+
+    // on the first execute after a compile, patch each physical slot's first
+    // baked barrier with its live state. See pending_state_fixup in compile()
+    const bool fixup = pending_state_fixup;
+    pending_state_fixup = false;
+    if (fixup) {
+        touch_img.assign(touch_img.size(), 0);
+        touch_buf.assign(touch_buf.size(), 0);
+    }
+
+    if (timings) {
+        timings->reset_frame(cmd, info.frame_index);
+    }
+
+    for (u32 pass_index = 0; pass_index < passes.size(); ++pass_index) {
+        PassBuilder &pass = passes[pass_index];
+
+        for (u32 i = 0; i < pass.image_barrier_count; ++i) {
+            const ImageBarrierBaked &b = image_barriers[pass.image_barrier_start + i];
+            const u32 vc = physical.image_version_count[b.image_id];
+            i32 v = ((i32)info.frame_index + b.version_offset) % (i32)vc;
+            if (v < 0) {
+                v += (i32)vc;
+            }
+            rhi::Image &img = *physical.image(b.image_id, (u32)v);
+            const bool always_live = (vc > 1) || logical_images[b.image_id].lifetime == Lifetime::Imported;
+            bool first_touch = false;
+            if (fixup && !always_live) {
+                const u32 slot = physical.image_base[b.image_id] + (u32)v;
+                if (slot < touch_img.size() && !touch_img[slot]) {
+                    touch_img[slot] = 1;
+                    first_touch = true;
+                }
+            }
+            const rhi::ResourceState before = (always_live || first_touch) ? img.state : b.before;
+            rhi::ImageRange range{};
+            range.aspect = b.aspect;
+            rhi::barrier(cmd, img, range, before, b.after);
+        }
+
+        for (u32 i = 0; i < pass.buffer_barrier_count; ++i) {
+            const BufferBarrierBaked &b = buffer_barriers[pass.buffer_barrier_start + i];
+            const u32 vc = physical.buffer_version_count[b.buffer_id];
+            i32 v = ((i32)info.frame_index + b.version_offset) % (i32)vc;
+            if (v < 0) {
+                v += (i32)vc;
+            }
+            rhi::Buffer &buf = *physical.buffer(b.buffer_id, (u32)v);
+            const bool always_live = (vc > 1) || logical_buffers[b.buffer_id].lifetime == Lifetime::Imported;
+            bool first_touch = false;
+            if (fixup && !always_live) {
+                const u32 slot = physical.buffer_base[b.buffer_id] + (u32)v;
+                if (slot < touch_buf.size() && !touch_buf[slot]) {
+                    touch_buf[slot] = 1;
+                    first_touch = true;
+                }
+            }
+            rhi::barrier(cmd, buf, (always_live || first_touch) ? buf.state : b.before, b.after);
+        }
+
+        if (pass.execute_fn) {
+            if (timings) {
+                timings->begin_pass(cmd, pass_index, info.frame_index);
+            }
+            PassContext ctx{
+                cmd,
+                *device,
+                physical,
+                &extra_views,
+                info.frame_data,
+                info.render_data,
+                info.scene,
+                info.frame_index,
+                info.frame_count,
+                width,
+                height,
+            };
+            pass.execute_fn(ctx);
+            if (timings) {
+                timings->end_pass(cmd, pass_index, info.frame_index);
+            }
+        }
+    }
+}
+
+void FrameGraph::destroy() {
+    destroy_physicals(*this, true);
+    init();
+}
+
+void FrameGraph::reset() {
+    destroy_physicals(*this, true);
+    init();
+}
+
+ImageHandle FrameGraph::import_image(rhi::Image *img, rhi::ResourceState entry_state, const rhi::ImageViewDesc &view) {
+    assert(img && "import_image requires a valid external image");
+    ImageResource res;
+    res.desc = img->desc;
+    res.lifetime = Lifetime::Imported;
+    res.size_class = SizeOp::Absolute;
+    res.external = img;
+    res.entry_state = entry_state;
+    res.view = view;
+    return add_image(res);
+}
+
+BufferHandle FrameGraph::import_buffer(rhi::Buffer *buf, rhi::ResourceState entry_state) {
+    assert(buf && "import_buffer requires a valid external buffer");
+    BufferResource res;
+    res.desc = buf->desc;
+    res.lifetime = Lifetime::Imported;
+    res.size_class = SizeOp::Absolute;
+    res.external = buf;
+    res.entry_state = entry_state;
+    return add_buffer(res);
+}
+
+void FrameGraph::overwrite_imported_image(ImageHandle h, rhi::Image *img) {
+    assert(h.is_valid() && h.id < logical_images.size() && "invalid imported image handle");
+    assert(logical_images[h.id].lifetime == Lifetime::Imported && "only imported images can be overwritten");
+    assert(img != nullptr && "overwrite_imported_image requires a valid image");
+    logical_images[h.id].external = img;
+    u32 base = physical.image_base[h.id];
+    if (base < physical.images.size()) {
+        physical.images[base] = img;
+    }
+}
ADD · src/passes/fg.h +354 -0
--- a/src/passes/fg.h
+++ b/src/passes/fg.h
@@ -0,0 +1,354 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include "core/globals.h"
+#include "core/math_rtm.h"
+#include "shaders/renderer_types.h"
+#include <cassert>
+#include <functional>
+#include <string>
+#include <vector>
+
+struct ImageHandle {
+    u32 id = UINT32_MAX;
+    bool is_valid() const {
+        return id != UINT32_MAX;
+    }
+};
+
+struct BufferHandle {
+    u32 id = UINT32_MAX;
+    bool is_valid() const {
+        return id != UINT32_MAX;
+    }
+};
+
+enum class Operation : u8 {
+    Read,
+    Write,
+    ReadWrite
+};
+
+enum class Lifetime : u8 {
+    Transient,  // graph-allocated & memory aliased
+    Persistent, // graph-managed across frames
+    History,    // cross-frame temporal history (2 versions, ping-ponged per frame)
+    Imported    // externally-managed
+};
+
+// I haven't actually tested this path much, TODO: TAA
+inline u32 get_version_count(Lifetime lifetime) {
+    return (lifetime == Lifetime::History) ? 2u : 1u;
+}
+
+enum class SizeOp : u8 {
+    Absolute,
+    Relative,
+    Swapchain
+};
+
+// read/write: Operation says read vs write vs both; state says in which
+// layout/access the pass needs it. No usage/stage params (implied by state).
+struct ImageResourceRef {
+    ImageHandle img;
+    Operation operation = Operation::Read;
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+    i32 version_offset = 0; // 0 = current, -1 = previous (History resources)
+};
+
+// read/write
+struct BufferResourceRef {
+    BufferHandle buf;
+    Operation operation = Operation::Read;
+    rhi::ResourceState state = rhi::ResourceState::Idle;
+    i32 version_offset = 0; // 0 = current, -1 = previous (History resources)
+};
+
+// add_image()
+struct ImageResource {
+    rhi::ImageDesc desc;
+    std::string name;
+    Lifetime lifetime = Lifetime::Transient;
+    SizeOp size_class = SizeOp::Swapchain;
+    vec2 scale{1.0f, 1.0f};
+    rhi::ImageViewDesc view{
+        .type = rhi::ImageViewType::None
+    }; // None is an RHI sentinal just used here, not sure if it'l stick around
+    rhi::ResourceState entry_state = rhi::ResourceState::Idle; // entry state to reset an imported resource to
+    rhi::Image *external = nullptr;                            // set by import_image(); borrowed, never owned
+};
+
+// add_buffer()
+struct BufferResource {
+    rhi::BufferDesc desc;
+    std::string name;
+    u64 (*size_fn)(u32 width, u32 height) =
+        nullptr; // really only need this for cluster bounds? Not sure of a better solution yet
+    Lifetime lifetime = Lifetime::Transient;
+    SizeOp size_class = SizeOp::Absolute;
+    vec2 scale{1.0f, 1.0f}; // TODO: nuke
+    rhi::ResourceState entry_state = rhi::ResourceState::Idle;
+    rhi::Buffer *external = nullptr; // set by import_buffer(); borrowed, never owned
+};
+
+constexpr u32 INVALID_VIEW_INDEX = 0xFFFFFFFFu;
+
+struct PhysicalStorage {
+    std::vector<rhi::Image> owned_images;
+    std::vector<rhi::Buffer> owned_buffers;
+    std::vector<rhi::Image *> images;
+    std::vector<rhi::Buffer *> buffers;
+
+    std::vector<u32> image_base;           // per logical image id: base slot index
+    std::vector<u32> buffer_base;          // per logical buffer id: base slot index
+    std::vector<u32> image_version_count;  // per logical image id: version stride
+    std::vector<u32> buffer_version_count; // per logical buffer id: version stride
+
+    std::vector<u32> image_view_index;
+
+    std::vector<rhi::ImageView> transient_views;
+
+    rhi::Image &owned_image(u32 id, u32 version) {
+        return owned_images[image_base[id] + version];
+    }
+    rhi::Buffer &owned_buffer(u32 id, u32 version) {
+        return owned_buffers[buffer_base[id] + version];
+    }
+    rhi::Image *image(u32 id, u32 version) {
+        return images[image_base[id] + version];
+    }
+    rhi::Buffer *buffer(u32 id, u32 version) {
+        return buffers[buffer_base[id] + version];
+    }
+};
+
+struct FrameData;
+struct RenderData;
+struct Scene;
+
+struct ExtraImageView {
+    ImageHandle img;
+    // true: one storage slot per mip (e.g. HiZ downsample targets);
+    // false: a single whole-image storage slot (e.g. DDGI atlas UAV).
+    bool all_mips = false;
+    // version_count * mips_per_version bindless slots.
+    std::vector<u32> slots;
+    u32 mips_per_version = 0;
+};
+
+struct ImageBarrierBaked {
+    u32 image_id;
+    i32 version_offset; // 0 = current, -1 = previous (resolved per frame)
+    rhi::ResourceState before;
+    rhi::ResourceState after;
+    rhi::ImageAspect aspect;
+};
+
+struct BufferBarrierBaked {
+    u32 buffer_id;
+    i32 version_offset; // 0 = current, -1 = previous (resolved per frame)
+    rhi::ResourceState before;
+    rhi::ResourceState after;
+};
+
+struct PassContext {
+    rhi::CmdBuffer &cmd;
+    rhi::Device &device;
+    PhysicalStorage &storage;
+
+    const std::vector<ExtraImageView> *extra_views = nullptr;
+    FrameData *frame_data = nullptr;
+    RenderData *render_data = nullptr;
+    Scene *scene = nullptr;
+    u32 frame_index = 0;
+    u64 frame_count = 0;
+    u32 render_width = 0;
+    u32 render_height = 0;
+
+    rhi::Image &get_image(ImageHandle handle, i32 version_offset = 0) const {
+        u32 vc = storage.image_version_count[handle.id];
+        i32 v = ((i32)frame_index + version_offset) % (i32)vc;
+        if (v < 0) {
+            v += (i32)vc;
+        }
+        return *storage.image(handle.id, (u32)v);
+    }
+    rhi::Buffer &get_buffer(BufferHandle handle, i32 version_offset = 0) const {
+        u32 vc = storage.buffer_version_count[handle.id];
+        i32 v = ((i32)frame_index + version_offset) % (i32)vc;
+        if (v < 0) {
+            v += (i32)vc;
+        }
+        return *storage.buffer(handle.id, (u32)v);
+    }
+
+    rhi::ImageView image_view(ImageHandle handle, const rhi::ImageViewDesc &desc) const;
+
+    u32 view(ImageHandle handle, i32 version_offset = 0) const {
+        u32 vc = storage.image_version_count[handle.id];
+        i32 v = ((i32)frame_index + version_offset) % (i32)vc;
+        if (v < 0) {
+            v += (i32)vc;
+        }
+        u32 idx = storage.image_view_index[storage.image_base[handle.id] + (u32)v];
+        assert(idx != INVALID_VIEW_INDEX && "view(): image declares no primary view (or arena missing at compile)");
+        return idx;
+    }
+
+    rhi::BufferView buffer_view(BufferHandle handle, const rhi::BufferViewDesc &desc) const {
+        rhi::Buffer &buf = get_buffer(handle);
+        rhi::BufferViewDesc full = desc;
+        full.buffer = &buf;
+        if (full.size == 0) {
+            full.size = buf.desc.size;
+        }
+        rhi::BufferView v{};
+        v.buffer = &buf;
+        v.desc = full;
+        return v;
+    }
+
+    u32 view_extra(u32 extra_idx, i32 version_offset = 0, u32 mip = 0) const;
+};
+
+struct GraphExecInfo {
+    FrameData *frame_data = nullptr;
+    RenderData *render_data = nullptr;
+    Scene *scene = nullptr;
+    u32 frame_index = 0;
+    u64 frame_count = 0;
+};
+
+using PassExecuteFn = std::function<void(PassContext &ctx)>;
+
+struct FrameGraph;
+struct PassTimings;
+struct PassBuilder {
+    const char *name;
+    FrameGraph *graph_ = nullptr;
+
+    // recording-time: slice ranges into image_refs / buffer_refs
+    u32 image_ref_start = 0;
+    u32 image_ref_count = 0;
+
+    u32 buffer_ref_start = 0;
+    u32 buffer_ref_count = 0;
+
+    // compile-time: slice ranges into the baked barrier lists
+    u32 image_barrier_start = 0;
+    u32 image_barrier_count = 0;
+
+    u32 buffer_barrier_start = 0;
+    u32 buffer_barrier_count = 0;
+
+    PassExecuteFn execute_fn = nullptr;
+    // void *user_data = nullptr;
+
+    PassBuilder &execute(PassExecuteFn fn) {
+        execute_fn = fn;
+        return *this;
+    }
+
+    // Explicit graph form. State implies the sync (no usage/stage params).
+    PassBuilder &read(FrameGraph &g, ImageHandle img, rhi::ResourceState state);
+    PassBuilder &write(FrameGraph &g, ImageHandle image, rhi::ResourceState state);
+    PassBuilder &read_write(FrameGraph &g, ImageHandle image, rhi::ResourceState state);
+
+    PassBuilder &read(FrameGraph &g, BufferHandle buf, rhi::ResourceState state);
+    PassBuilder &write(FrameGraph &g, BufferHandle buffer, rhi::ResourceState state);
+    PassBuilder &read_write(FrameGraph &g, BufferHandle buffer, rhi::ResourceState state);
+
+    // Owner-aware forms: forward to the graph this pass was recorded on.
+    PassBuilder &read(ImageHandle img, rhi::ResourceState state);
+    PassBuilder &write(ImageHandle image, rhi::ResourceState state);
+    PassBuilder &read_write(ImageHandle image, rhi::ResourceState state);
+
+    PassBuilder &read(BufferHandle buf, rhi::ResourceState state);
+    PassBuilder &write(BufferHandle buffer, rhi::ResourceState state);
+    PassBuilder &read_write(BufferHandle buffer, rhi::ResourceState state);
+
+    // history resource versioning: write the current frame's version, read the
+    // previous frame's version. Declared so the planner keeps prev-read and
+    // curr-write on separate physical versions (no false dependency).
+    PassBuilder &write_current(FrameGraph &g, ImageHandle img, rhi::ResourceState state);
+    PassBuilder &read_previous(FrameGraph &g, ImageHandle img, rhi::ResourceState state);
+    PassBuilder &write_current(FrameGraph &g, BufferHandle buf, rhi::ResourceState state);
+    PassBuilder &read_previous(FrameGraph &g, BufferHandle buf, rhi::ResourceState state);
+
+    PassBuilder &write_current(ImageHandle img, rhi::ResourceState state);
+    PassBuilder &read_previous(ImageHandle img, rhi::ResourceState state);
+    PassBuilder &write_current(BufferHandle buf, rhi::ResourceState state);
+    PassBuilder &read_previous(BufferHandle buf, rhi::ResourceState state);
+
+    // shared ref-recording
+    PassBuilder &
+    add_image_ref(FrameGraph &g, ImageHandle img, rhi::ResourceState state, Operation op, i32 version_offset);
+    PassBuilder &
+    add_buffer_ref(FrameGraph &g, BufferHandle buf, rhi::ResourceState state, Operation op, i32 version_offset);
+};
+
+struct FrameGraph {
+    rhi::Device *device = nullptr;
+
+    u32 request_extra_view(ImageHandle img, bool all_mips);
+    std::vector<ExtraImageView> extra_views;
+
+    u32 width;
+    u32 height;
+
+    bool image_readback = true; // TODO: nuke
+
+    // logical resources
+    std::vector<ImageResource> logical_images;
+    std::vector<BufferResource> logical_buffers;
+
+    // flat lists of typed pass dependencies
+    std::vector<ImageResourceRef> image_refs;
+    std::vector<BufferResourceRef> buffer_refs;
+
+    PhysicalStorage physical;
+    std::vector<PassBuilder> passes;
+
+    // baked at compile(): flat barrier lists, sliced by PassBuilder
+    std::vector<ImageBarrierBaked> image_barriers;
+    std::vector<BufferBarrierBaked> buffer_barriers;
+
+    // NOTE: execute() issues one state barrier per baked edge directly;
+    // no staging vectors (batching is a future backend-internal optimization).
+
+    void init();
+    bool compile(rhi::Device &device, rhi::Extent2D swapchain_extent);
+    void execute(rhi::CmdBuffer &cmd, const GraphExecInfo &info);
+    void destroy(); // releases all owned GPU storage, then init()
+    void reset();   // destroy() + init(): full teardown, ready to re-record
+
+    ImageHandle add_image(ImageResource img);
+    BufferHandle add_buffer(BufferResource buf);
+    ImageHandle import_image(
+        rhi::Image *img,
+        rhi::ResourceState entry_state = rhi::ResourceState::Idle,
+        const rhi::ImageViewDesc &view = {.type = rhi::ImageViewType::None}
+    );
+    BufferHandle import_buffer(rhi::Buffer *buf, rhi::ResourceState entry_state = rhi::ResourceState::Idle);
+
+    void overwrite_imported_image(ImageHandle h, rhi::Image *img);
+
+    PassBuilder &add_pass(const char *name);
+
+    PassTimings *timings = nullptr;
+    void set_timings(PassTimings *t) {
+        timings = t;
+    }
+
+    // First execute() after compile patches the initial barrier per slot with live resource state
+    bool pending_state_fixup = false;
+
+    // execute() scratch for fixup patching: first-touch flags per physical
+    // slot, sized in compile(), cleared on each fixup execute.
+    std::vector<u8> touch_img;
+    std::vector<u8> touch_buf;
+
+    // true after a successful compile(); execute() refuses to run an un-compiled
+    // graph. Reset by init()/destroy()/reset().
+    bool is_compiled = false;
+};
ADD · src/passes/fg_utils.h +137 -0
--- a/src/passes/fg_utils.h
+++ b/src/passes/fg_utils.h
@@ -0,0 +1,137 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct PassInspectorEntry {
+    const char *name = nullptr;
+    f32 gpu_ms = 0.0f;
+    bool timing_valid = false;
+};
+
+class PassTimings {
+  public:
+    PassTimings() = default;
+    ~PassTimings() = default;
+
+    void enable(FrameGraph &fg, rhi::Device &device, u32 max_frames_in_flight) {
+        destroy(device);
+
+        fg_ = &fg;
+        timestamp_period_ns_ = static_cast<f64>(device.timestamp_period);
+
+        u32 steps = static_cast<u32>(fg.passes.size());
+        if (steps == 0) {
+            return;
+        }
+
+        rhi::QueryPoolDesc desc;
+        desc.queryType = rhi::QueryType::TIMESTAMP;
+        desc.capacity = steps * 2 * max_frames_in_flight;
+        desc.name = "queries/pass-timings";
+        rhi::create_query_pool(device, desc, pool_);
+
+        max_frames_ = max_frames_in_flight;
+        query_count_per_frame_ = steps * 2;
+        entries_.resize(steps);
+        slot_written_.assign(max_frames_in_flight, false);
+        for (u32 i = 0; i < steps; ++i) {
+            entries_[i].name = fg.passes[i].name;
+        }
+
+        fg.set_timings(this);
+    }
+
+    void destroy(rhi::Device &device) {
+        if (rhi::valid(pool_)) {
+            rhi::destroy_query_pool(device, pool_);
+            pool_ = {};
+        }
+        if (fg_) {
+            fg_->set_timings(nullptr);
+        }
+        fg_ = nullptr;
+        entries_.clear();
+        slot_written_.clear();
+        max_frames_ = 0;
+        query_count_per_frame_ = 0;
+    }
+
+    void reset_frame(rhi::CmdBuffer &cmd, u32 frame_slot) {
+        if (!rhi::valid(pool_) || frame_slot >= max_frames_) {
+            return;
+        }
+        rhi::reset_query_pool(cmd, pool_, frame_slot * query_count_per_frame_, query_count_per_frame_);
+    }
+
+    void begin_pass(rhi::CmdBuffer &cmd, u32 pass_index, u32 frame_slot) {
+        if (!rhi::valid(pool_) || frame_slot >= max_frames_) {
+            return;
+        }
+        rhi::write_timestamp(
+            cmd, pool_, frame_slot * query_count_per_frame_ + pass_index * 2, rhi::PipelineStages::TOP_OF_PIPE
+        );
+    }
+
+    void end_pass(rhi::CmdBuffer &cmd, u32 pass_index, u32 frame_slot) {
+        if (!rhi::valid(pool_) || frame_slot >= max_frames_) {
+            return;
+        }
+        rhi::write_timestamp(
+            cmd, pool_, frame_slot * query_count_per_frame_ + pass_index * 2 + 1, rhi::PipelineStages::BOTTOM_OF_PIPE
+        );
+    }
+
+    void readback(rhi::Device &device, u32 frame_slot) {
+        if (!rhi::valid(pool_) || frame_slot >= slot_written_.size()) {
+            return;
+        }
+        u32 query_count = query_count_per_frame_;
+        if (!slot_written_[frame_slot]) {
+            slot_written_[frame_slot] = true;
+            return;
+        }
+
+        std::vector<u64> results(query_count * 2);
+        bool ok = rhi::query_pool_results(
+            device,
+            pool_,
+            frame_slot * query_count,
+            query_count,
+            results.data(),
+            results.size() * sizeof(u64),
+            sizeof(u64) * 2,
+            true
+        );
+        if (!ok) {
+            return;
+        }
+
+        u32 steps = static_cast<u32>(entries_.size());
+        for (u32 pass_idx = 0; pass_idx < steps; ++pass_idx) {
+            u64 begin_timestamp = results[(pass_idx * 2 + 0) * 2 + 0];
+            u64 begin_available = results[(pass_idx * 2 + 0) * 2 + 1];
+            u64 end_timestamp = results[(pass_idx * 2 + 1) * 2 + 0];
+            u64 end_available = results[(pass_idx * 2 + 1) * 2 + 1];
+            if (begin_available != 0 && end_available != 0 && end_timestamp >= begin_timestamp) {
+                entries_[pass_idx].gpu_ms = static_cast<f32>(
+                    static_cast<f64>(end_timestamp - begin_timestamp) * timestamp_period_ns_ / 1000000.0
+                );
+                entries_[pass_idx].timing_valid = true;
+            }
+        }
+    }
+
+    const PassInspectorEntry *entries(u32 &count) const {
+        count = static_cast<u32>(entries_.size());
+        return entries_.data();
+    }
+
+  private:
+    rhi::QueryPool pool_ = {};
+    FrameGraph *fg_ = nullptr;
+    f64 timestamp_period_ns_ = 0.0;
+    std::vector<PassInspectorEntry> entries_;
+    std::vector<bool> slot_written_;
+    u32 max_frames_ = 0;
+    u32 query_count_per_frame_ = 0;
+};<
\ No newline at end of file
ADD · src/passes/forward/forward.cpp +170 -0
--- a/src/passes/forward/forward.cpp
+++ b/src/passes/forward/forward.cpp
@@ -0,0 +1,170 @@
+#include "forward.h"
+
+#include "backend/rhi_types.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace forward {
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    ImageHandle cascade[Light::CASCADE_COUNT],
+    BufferHandle cluster_bounds,
+    BufferHandle cluster_records,
+    BufferHandle light_index_list,
+    ddgi_trace::Resources &ddgi,
+    ImageHandle &depth_texture
+) {
+    rhi::RenderPipelineDesc forward_p;
+    forward_p.device = &device;
+    forward_p.set_shaders(sc, "src/passes/forward/forward.slang", "vsMain", "fsMain");
+    forward_p.set_depth_testing(true, false, rhi::PipelineCompareOp::EQUAL);
+    forward_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    forward_p.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CW);
+    forward_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    forward_p.set_multisampling(MSAA_SAMPLE_COUNT);
+    pipelines.add_render("Forward", forward_p);
+
+    rhi::RenderPipelineDesc wireframe_p;
+    wireframe_p.device = &device;
+    wireframe_p.set_shaders(sc, "src/passes/forward/forward.slang", "vsMain", "fsWireMain");
+    wireframe_p.set_depth_testing(true, false, rhi::PipelineCompareOp::GREATER_EQUAL);
+    wireframe_p.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CW);
+    wireframe_p.set_polygon_mode(rhi::PipelineFillMode::WIREFRAME);
+    wireframe_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    wireframe_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    wireframe_p.set_multisampling(MSAA_SAMPLE_COUNT);
+    pipelines.add_render("Wireframe", wireframe_p);
+
+    Resources res;
+    res.hdr = fg.add_image({
+        .desc = {.format = rhi::ImageFormat::RGBA16_FLOAT},
+        .name = "fg/forward/hdr",
+        .size_class = SizeOp::Swapchain,
+        .view = {.type = rhi::ImageViewType::Sampled},
+    });
+    res.depth = depth_texture; // just to keep the passes after this working for now
+    if constexpr (MSAA_SAMPLE_COUNT != rhi::SampleCount::Sample1) {
+        res.hdr_msaa = fg.add_image({
+            .desc = {.sample_count = MSAA_SAMPLE_COUNT, .format = rhi::ImageFormat::RGBA16_FLOAT},
+            .name = "fg/forward/hdr-msaa",
+            .size_class = SizeOp::Swapchain,
+        });
+        res.depth_msaa = fg.add_image({
+            .desc = {.sample_count = MSAA_SAMPLE_COUNT, .format = rhi::ImageFormat::D32_FLOAT},
+            .name = "fg/forward/depth-msaa",
+            .size_class = SizeOp::Swapchain,
+        });
+    }
+
+    auto &builder = fg.add_pass("Forward");
+    builder.read(indirect, rhi::ResourceState::IndirectFetch);
+    builder.read(draw_count, rhi::ResourceState::IndirectFetch);
+    builder.read(visible, rhi::ResourceState::StorageRead);
+    // Depth is tested (read) and stored (write): LOAD + depth-test + STORE.
+    builder.read_write(res.depth, rhi::ResourceState::DepthDraw);
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        builder.read(cascade[i], rhi::ResourceState::TextureSample);
+    }
+    builder.read(cluster_bounds, rhi::ResourceState::StorageRead);
+    builder.read(cluster_records, rhi::ResourceState::StorageRead);
+    builder.read(light_index_list, rhi::ResourceState::StorageRead);
+    builder.write(res.hdr, rhi::ResourceState::ColorDraw);
+    if constexpr (MSAA_SAMPLE_COUNT != rhi::SampleCount::Sample1) {
+        builder.write(res.hdr_msaa, rhi::ResourceState::ColorDraw);
+        builder.write(res.depth_msaa, rhi::ResourceState::DepthDraw);
+    }
+
+    rhi::RenderPipeline &pipeline = pipelines.get_render("Forward");
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        auto main_view = ctx.image_view(res.hdr, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+        auto depth_view = ctx.image_view(res.depth, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachmentCount = 1;
+        ri.colorAttachments[0].loadOp = rhi::LoadOp::CLEAR;
+        ri.colorAttachments[0].clearValue.color.float32[0] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[1] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[2] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[3] = 1.0f;
+        ri.depthAttachment.loadOp = rhi::LoadOp::LOAD;
+        ri.depthAttachment.clearValue.depthStencil = {0.0f, 0};
+
+        // Views must outlive begin_rendering(); default (invalid) when MSAA is off.
+        rhi::ImageView msaa_color{};
+        rhi::ImageView msaa_depth{};
+        if constexpr (MSAA_SAMPLE_COUNT != rhi::SampleCount::Sample1) {
+            msaa_color = ctx.image_view(res.hdr_msaa, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+            msaa_depth = ctx.image_view(res.depth_msaa, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+
+            // written by the resolve. MSAA contents are fully consumed by it.
+            ri.colorAttachments[0].img = &msaa_color;
+            ri.colorAttachments[0].storeOp = rhi::StoreOp::DISCARD;
+            ri.colorAttachments[0].resolveImg = &main_view;
+            ri.colorAttachments[0].resolveOp = rhi::ResolveOp::AVERAGE;
+            ri.depthAttachment.img = &msaa_depth;
+            ri.depthAttachment.storeOp = rhi::StoreOp::DISCARD;
+            ri.depthAttachment.resolveImg = &depth_view;
+            ri.depthAttachment.resolveOp = rhi::ResolveOp::MAX;
+        } else {
+            ri.colorAttachments[0].img = &main_view;
+            ri.colorAttachments[0].storeOp = rhi::StoreOp::STORE;
+            ri.depthAttachment.img = &depth_view;
+            ri.depthAttachment.storeOp = rhi::StoreOp::STORE;
+        }
+        ri.width = ctx.render_width;
+        ri.height = ctx.render_height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)ctx.render_width;
+        vp.height = (f32)ctx.render_height;
+        rhi::set_viewports(ctx.cmd, &vp);
+        rhi::Rect scissor{};
+        scissor.width = (i32)ctx.render_width;
+        scissor.height = (i32)ctx.render_height;
+        rhi::set_scissors(ctx.cmd, &scissor);
+
+        FwdDrawPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.vertex = (u64)ctx.render_data->vertex_view.slot;
+        pc.visible_items = ctx.get_buffer(visible).address;
+        pc.ddgi_irradiance = (u32)ctx.view(ddgi.irradiance_img);
+        pc.ddgi_distance = (u32)ctx.view(ddgi.distance_img);
+        pc.ddgi_probe_state = ctx.get_buffer(ddgi.probe_state).address;
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        rhi::set_index_buffer(ctx.cmd, ctx.render_data->index_buffer);
+        rhi::draw_indexed_indirect(
+            ctx.cmd,
+            ctx.get_buffer(indirect),
+            &ctx.get_buffer(draw_count),
+            ctx.render_data->render_item_count,
+            rhi::DRAW_INDEXED_INDIRECT_STRIDE,
+            0,
+            0
+        );
+
+        rhi::end_rendering(ctx.cmd);
+    });
+    return res;
+}
+
+} // namespace forward
ADD · src/passes/forward/forward.h +37 -0
--- a/src/passes/forward/forward.h
+++ b/src/passes/forward/forward.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "passes/ddgi/ddgi_trace.h"
+#include "passes/fg.h"
+#include "pipelines.h"
+#include "scene/light.h"
+
+struct FrameData;
+struct RenderData;
+struct Scene;
+
+namespace forward {
+
+struct Resources {
+    ImageHandle hdr;
+    ImageHandle depth;
+    ImageHandle hdr_msaa;
+    ImageHandle depth_msaa;
+};
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    ImageHandle cascade[Light::CASCADE_COUNT],
+    BufferHandle cluster_bounds,
+    BufferHandle cluster_records,
+    BufferHandle light_index_list,
+    ddgi_trace::Resources &ddgi,
+    ImageHandle &depth_texture
+);
+
+} // namespace forward
ADD · src/passes/forward/forward.slang +153 -0
--- a/src/passes/forward/forward.slang
+++ b/src/passes/forward/forward.slang
@@ -0,0 +1,153 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/brdf.slang"
+#include "lib/frustum_culling.slang"
+#include "lib/shadow_sample.slang"
+#include "ibl/ibl_lighting.slang"
+#include "lib/cluster_lighting.slang"
+#include "debug/debug_views.slang"
+#include "lib/ddgi_common.slang"
+
+[vk::push_constant]
+FwdDrawPushConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID, u32 drawID: SV_DrawIndex, u32 instanceID: SV_InstanceID) {
+    VtxOut o;
+
+    FrameUBO frame = *pc.frame;
+
+    u32 item_idx = pc.visible_items[drawID].id;
+    RenderItemGPU item = frame.render_items[item_idx];
+    SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+    TransformGPU xform = frame.transforms[item.instance_id];
+    Vertex v = pc.vertex[vertexID + submesh.base_vertex];
+    mat3 world3x3 = (mat3)xform.world;
+    mat3 normalMat = (mat3)transpose(xform.normal_world);
+
+    vec3 N = v.normal * normalMat;
+    vec3 T = v.tangent.xyz * world3x3;
+    vec4 worldPos = vec4(v.pos, 1.0) * xform.world;
+
+    o.view_pos = worldPos * frame.view;
+    o.clip_pos = o.view_pos * frame.proj;
+    o.world_pos = worldPos.xyz;
+    o.clip_debug = o.clip_pos;
+    o.normal = N;
+    o.tangent = vec4(T, v.tangent.w);
+    o.uv = v.uv;
+    o.material_index = item.material_index;
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target {
+    FrameUBO frame = *pc.frame;
+
+    MaterialGPU material = frame.materials[input.material_index];
+    SamplerState material_sampler = frame.aniso_wrap_mips;
+
+    vec4 albedo = material.albedo.Sample(material_sampler, input.uv) * material.base_color;
+    f32 alpha = albedo.a;
+    vec3 mrSample = material.metal_rough.Sample(material_sampler, input.uv).rgb;
+    f32 metallic = mrSample.b * material.metallic_factor;
+    f32 roughness = mrSample.g * material.roughness_factor;
+    roughness = max(roughness, 0.045);
+    vec3 emissive = material.emissive.Sample(material_sampler, input.uv).rgb * material.emissive_factor;
+
+    vec3 N = normalize(input.normal);
+    vec3 T = normalize(input.tangent.xyz);
+    T = normalize(T - N * dot(N, T));
+    vec3 B = cross(N, T) * input.tangent.w;
+    mat3 TBN = mat3(T, B, N);
+    vec3 normalTS = material.normal.Sample(material_sampler, input.uv).xyz * 2.0 - 1.0;
+    vec3 normalWS = normalize(normalTS * TBN);
+
+#ifdef DEBUG
+    vec4 dbg_result;
+    if (try_debug_view_pre(
+            input, frame, albedo, alpha, normalWS, metallic, roughness, emissive, N, T, B, normalTS, dbg_result
+        )) {
+        return dbg_result;
+    }
+#endif
+    vec3 worldPos = input.world_pos;
+    vec3 cameraPos = frame.position_ws.xyz;
+    vec3 V = normalize(cameraPos - input.world_pos);
+
+    vec3 L = normalize(frame.light_dir);
+    vec3 H = normalize(V + L);
+
+    f32 NdotL = saturate(dot(normalWS, L));
+    f32 NdotV = saturate(dot(normalWS, V));
+    f32 NdotH = saturate(dot(normalWS, H));
+    f32 VdotH = saturate(dot(V, H));
+
+    // direct light
+    vec3 direct_light_radiance = frame.light_color * frame.light_intensity;
+
+    vec3 F0 = lerp(vec3(0.04, 0.04, 0.04), albedo.rgb, metallic);
+    f32 D = D_GGX(NdotH, roughness);
+    f32 G = G_Smith_Direct(NdotV, NdotL, roughness);
+    vec3 F = F_Schlick(VdotH, F0);
+
+    vec3 specular = (D * G * F) / max(4.0 * NdotV * NdotL, 1e-5);
+    vec3 kS = F;
+    vec3 kD = (1.0 - kS) * (1.0 - metallic);
+    vec3 diffuse = kD * albedo.xyz * (1.0 / 3.14159265);
+
+    // direct shadow eval
+    f32 shadow_factor = sample_shadow(
+        worldPos, normalWS, input.clip_pos.xy, NdotL, frame.position_ws.xyz, frame.shadows, frame.cmp_greater
+    );
+
+    // indirect ibl (diffuse + specular)
+    vec3 indirect_env_ibl = evaluate_ibl(
+        albedo.rgb,
+        normalWS,
+        V,
+        NdotV,
+        roughness,
+        metallic,
+        F0,
+        frame.linear_clamp_mips,
+        frame.env_irradiance,
+        frame.env_prefiltered,
+        frame.env_brdf,
+        frame.env_prefilter_mip
+    );
+
+    // indirect ddgi
+    vec3 ddgi_irradiance = sample_ddgi_irradiance(
+        worldPos, normalWS, frame.ddgi_grid, frame, pc.ddgi_irradiance, pc.ddgi_distance, pc.ddgi_probe_state, false
+    );
+
+    // fade DDGI contribution out near the grid edges and let the environment diffuse fill in
+    f32 volume_fade = ddgi_volume_blend_weight(worldPos, frame.ddgi_grid);
+    vec3 sky_ambient = frame.env_irradiance.Sample(material_sampler, normalWS).rgb;
+    ddgi_irradiance = lerp(sky_ambient, ddgi_irradiance, volume_fade);
+
+    vec3 F_ibl = F_SchlickRoughness(NdotV, F0, roughness);
+    vec3 kD_ibl = (1.0 - F_ibl) * (1.0 - metallic);
+    vec3 indirect_diffuse = kD_ibl * (ddgi_irradiance) * (albedo.rgb / 3.14159265);
+
+    vec3 direct_lighting = (diffuse + specular) * direct_light_radiance * NdotL * shadow_factor;
+
+    ClusterRecord cr;
+    vec3 point_lighting =
+        evaluate_cluster_lights(input, worldPos, normalWS, V, NdotV, roughness, metallic, F0, albedo, frame, cr);
+
+    vec3 color = direct_lighting + indirect_diffuse + emissive + point_lighting;
+
+#ifdef DEBUG
+    apply_debug_view_post(color, input, cr, frame);
+#endif
+
+    return vec4(color, alpha);
+}
+
+[shader("fragment")]
+vec4 fsWireMain(VtxOut input) : SV_Target {
+    return vec4(0.0, 0.85, 1.0, 1.0);
+}
ADD · src/passes/fullscreen/fullscreen.cpp +101 -0
--- a/src/passes/fullscreen/fullscreen.cpp
+++ b/src/passes/fullscreen/fullscreen.cpp
@@ -0,0 +1,101 @@
+#include "fullscreen.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace fullscreen_fg {
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main,
+    ImageHandle depth,
+    rhi::ImageFormat output_format,
+    ImageHandle output,
+    ImageHandle ssr
+) {
+
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/fullscreen/fullscreen.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::LESS_EQUAL);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    pd.set_color_format(output_format);
+    rhi::RenderPipeline &pipeline = pipelines.add_render("Fullscreen", pd);
+
+    Resources out;
+    if (output.is_valid()) {
+        out.display = output;
+    } else {
+        out.display = fg.add_image(
+            {.desc = {.format = output_format}, .name = "fg/fullscreen/display", .size_class = SizeOp::Swapchain}
+        );
+    }
+
+    auto &builder = fg.add_pass("Fullscreen");
+    builder.read(main, rhi::ResourceState::TextureSample);
+    builder.read(depth, rhi::ResourceState::TextureSample);
+    if (ssr.is_valid()) {
+        builder.read(ssr, rhi::ResourceState::TextureSample);
+    }
+    builder.write(out.display, rhi::ResourceState::ColorDraw);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        auto main_view = ctx.image_view(main, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+        auto depth_view = ctx.image_view(depth, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+        auto display_view = ctx.image_view(out.display, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &display_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.float32[0] = 0.0f;
+        color_att.clearValue.color.float32[1] = 0.0f;
+        color_att.clearValue.color.float32[2] = 0.0f;
+        color_att.clearValue.color.float32[3] = 1.0f;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = ctx.render_width;
+        ri.height = ctx.render_height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)ctx.render_width;
+        vp.height = (f32)ctx.render_height;
+        rhi::set_viewports(ctx.cmd, &vp);
+
+        rhi::Rect scissor{};
+        scissor.width = (i32)ctx.render_width;
+        scissor.height = (i32)ctx.render_height;
+        rhi::set_scissors(ctx.cmd, &scissor);
+
+        FullscreenPushConstants pc{};
+        pc.lighting = (u32)ctx.view(main);
+        pc.depth = (u32)ctx.view(depth);
+        pc.ssr = ssr.is_valid() ? (u32)ctx.view(ssr) : UINT64_MAX; // canonical null handle
+        pc.samp = ctx.render_data->linear_clamp;
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        rhi::draw(ctx.cmd, 3, 1, 0, 0);
+        rhi::end_rendering(ctx.cmd);
+    });
+
+    return out;
+};
+
+} // namespace fullscreen_fg<
\ No newline at end of file
ADD · src/passes/fullscreen/fullscreen.h +27 -0
--- a/src/passes/fullscreen/fullscreen.h
+++ b/src/passes/fullscreen/fullscreen.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct RenderData;
+struct Pipelines;
+
+namespace fullscreen_fg {
+
+struct Resources {
+    ImageHandle display;
+};
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main,
+    ImageHandle depth,
+    rhi::ImageFormat output_format,
+    ImageHandle output = {},
+    ImageHandle ssr = {}
+);
+
+} // namespace fullscreen_fg
ADD · src/passes/fullscreen/fullscreen.slang +73 -0
--- a/src/passes/fullscreen/fullscreen.slang
+++ b/src/passes/fullscreen/fullscreen.slang
@@ -0,0 +1,73 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+vec3 to_srgb(vec3 x) {
+    return clamp(select(x <= 0.0031308, x * 12.92, 1.055 * pow(x, 1.0 / 2.2) - 0.055), 0.0, 1.0);
+}
+
+inline vec3 tonemapFilmic(vec3 color) {
+    vec3 temp = max(vec3(0.0F), color - vec3(0.004F));
+    vec3 result = (temp * (vec3(6.2F) * temp + vec3(0.5F))) / (temp * (vec3(6.2F) * temp + vec3(1.7F)) + vec3(0.06F));
+    return result;
+}
+
+/*-------------------------------------------------------------------------------------------------
+# Function `tonemapUncharted`
+> Tone mapping operator from Uncharted 2 by John Hable. sRGB correction is built in.
+
+See: http://filmicworlds.com/blog/filmic-tonemapping-operators/
+-------------------------------------------------------------------------------------------------*/
+
+inline vec3 tonemapUncharted2Impl(vec3 color) {
+    const f32 a = 0.15F;
+    const f32 b = 0.50F;
+    const f32 c = 0.10F;
+    const f32 d = 0.20F;
+    const f32 e = 0.02F;
+    const f32 f = 0.30F;
+    return ((color * (a * color + c * b) + d * e) / (color * (a * color + b) + d * f)) - e / f;
+}
+
+inline vec3 tonemapUncharted2(vec3 color) {
+    const f32 W = 11.2F;
+    const f32 exposure_bias = 2.0F;
+    color = tonemapUncharted2Impl(color * exposure_bias);
+    vec3 white_scale = vec3(1.0F) / tonemapUncharted2Impl(vec3(W));
+    return pow(color * white_scale, vec3(1.0F / 2.2F));
+}
+
+[vk::push_constant]
+FullscreenPushConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID) {
+    VtxOut o;
+    o.uv = vec2((vertexID << 1) & 2, vertexID & 2);
+    o.clip_pos = vec4(o.uv * 2.0f - 1.0f, 0.0f, 1.0f);
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target {
+    // yikes on this
+    // wrap up ssr or dump but get rid of this line
+    Texture2D.Handle ssr_null = reinterpret<Texture2D.Handle>(uint2(0xFFFFFFFFu, 0xFFFFFFFFu));
+    vec4 main = pc.lighting.Sample(pc.samp, input.uv);
+    vec3 ssr = vec3(0.0f);
+    if (pc.ssr != ssr_null) {
+        ssr = pc.ssr.Sample(pc.samp, input.uv).rgb;
+    }
+
+    vec3 comp = main.rgb + ssr;
+
+    f32 EV = 2.0f;
+    f32 exposure = exp2(EV);
+    vec4 hdr = vec4(comp, main.a) * exposure; // + ssr;
+
+    // vec3 out = tonemapFilmic(hdr.rgb);
+    vec3 out = tonemapUncharted2(comp);
+    // vec3 out = to_srgb(hdr.rgb);
+
+    return vec4(out, main.a);
+}
+
ADD · src/passes/fwd_cpu/fwd_cpu.cpp +89 -0
--- a/src/passes/fwd_cpu/fwd_cpu.cpp
+++ b/src/passes/fwd_cpu/fwd_cpu.cpp
@@ -0,0 +1,89 @@
+#include "fwd_cpu.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace fwd_cpu {
+
+Resources record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, BufferHandle vb, BufferHandle ib
+) {
+    rhi::RenderPipelineDesc fwd_cpu_p;
+    fwd_cpu_p.device = &device;
+    fwd_cpu_p.set_shaders(sc, "src/passes/fwd_cpu/fwd_cpu.slang", "vsMain", "fsMain");
+    fwd_cpu_p.add_vertex_binding(0, sizeof(Vertex));
+    fwd_cpu_p.add_vertex_attribute(0, 0, rhi::ImageFormat::RGB32_FLOAT, offsetof(Vertex, pos));
+    fwd_cpu_p.add_vertex_attribute(1, 0, rhi::ImageFormat::RGB32_FLOAT, offsetof(Vertex, normal));
+    fwd_cpu_p.add_vertex_attribute(2, 0, rhi::ImageFormat::RG32_FLOAT, offsetof(Vertex, uv));
+    fwd_cpu_p.add_vertex_attribute(3, 0, rhi::ImageFormat::RGBA32_FLOAT, offsetof(Vertex, tangent));
+    fwd_cpu_p.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    fwd_cpu_p.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    fwd_cpu_p.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CW);
+    fwd_cpu_p.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    fwd_cpu_p.set_multisampling(MSAA_SAMPLE_COUNT);
+    pipelines.add_render("ForwardCpuPipeline", fwd_cpu_p);
+    Resources res = {};
+    res.hdr = fg.add_image({.desc = {.format = rhi::ImageFormat::RGBA16_FLOAT}, .name = "fg/fwdcpu/hdr"});
+    res.depth = fg.add_image({.desc = {.format = rhi::ImageFormat::D32_FLOAT}, .name = "fg/fwdcpu/depth"});
+    auto &builder = fg.add_pass("FwdCpu");
+    builder.read(vb, rhi::ResourceState::VertexFetch);
+    builder.read(ib, rhi::ResourceState::IndexFetch);
+    builder.write(res.hdr, rhi::ResourceState::ColorDraw);
+    builder.write(res.depth, rhi::ResourceState::DepthDraw);
+
+    rhi::RenderPipeline &pipeline = pipelines.get_render("ForwardCpuPipeline");
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+        auto main_view = ctx.image_view(res.hdr, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+        auto depth_view = ctx.image_view(res.depth, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+        rhi::RenderingInfo ri{};
+        ri.colorAttachmentCount = 1;
+        ri.colorAttachments[0].loadOp = rhi::LoadOp::CLEAR;
+        ri.colorAttachments[0].clearValue.color.float32[0] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[1] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[2] = 0.0f;
+        ri.colorAttachments[0].clearValue.color.float32[3] = 1.0f;
+        ri.depthAttachment.loadOp = rhi::LoadOp::CLEAR;
+        ri.depthAttachment.clearValue.depthStencil = {0.0f, 0};
+        ri.colorAttachments[0].img = &main_view;
+        ri.colorAttachments[0].storeOp = rhi::StoreOp::STORE;
+        ri.depthAttachment.img = &depth_view;
+        ri.depthAttachment.storeOp = rhi::StoreOp::STORE;
+
+        ri.width = ctx.render_width;
+        ri.height = ctx.render_height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        rhi::set_vertex_buffer(ctx.cmd, ctx.render_data->vertex_buffer);
+        rhi::set_index_buffer(ctx.cmd, ctx.render_data->index_buffer);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)ctx.render_width;
+        vp.height = (f32)ctx.render_height;
+        rhi::set_viewports(ctx.cmd, &vp);
+        rhi::Rect scissor{};
+        scissor.width = (i32)ctx.render_width;
+        scissor.height = (i32)ctx.render_height;
+        rhi::set_scissors(ctx.cmd, &scissor);
+
+        FwdPC pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        for (u32 i = 0; i < ctx.render_data->submeshes.size(); i++) {
+            SubmeshGPU &sm = ctx.render_data->submeshes[i];
+            rhi::draw_indexed(ctx.cmd, sm.index_count, 1, sm.first_index, sm.base_vertex, 0);
+        }
+
+        rhi::end_rendering(ctx.cmd);
+    });
+    return res;
+}
+
+} // namespace fwd_cpu<
\ No newline at end of file
ADD · src/passes/fwd_cpu/fwd_cpu.h +17 -0
--- a/src/passes/fwd_cpu/fwd_cpu.h
+++ b/src/passes/fwd_cpu/fwd_cpu.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "passes/fg.h"
+#include "pipelines.h"
+
+namespace fwd_cpu {
+
+struct Resources {
+    ImageHandle hdr;
+    ImageHandle depth;
+};
+
+Resources record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, BufferHandle vb, BufferHandle ib
+);
+
+} // namespace fwd_cpu
ADD · src/passes/fwd_cpu/fwd_cpu.slang +44 -0
--- a/src/passes/fwd_cpu/fwd_cpu.slang
+++ b/src/passes/fwd_cpu/fwd_cpu.slang
@@ -0,0 +1,44 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[vk::push_constant]
+FwdPC pc;
+
+struct VSIn {
+    [[vk::location(0)]]
+    float3 pos : POSITION;
+    [[vk::location(1)]]
+    float3 normal : NORMAL;
+    [[vk::location(2)]]
+    float2 uv : TEXCOORD0;
+    [[vk::location(3)]]
+    float4 tangent : TANGENT;
+};
+
+struct VSOut {
+    float4 position : SV_Position;
+    float3 normal : NORMAL;
+    float2 uv : TEXCOORD0;
+    float4 tangent : TANGENT;
+};
+
+[shader("vertex")]
+VSOut vsMain(VSIn input, u32 instanceID: SV_InstanceID) {
+    VSOut o;
+
+    FrameUBO frame = *pc.frame;
+    mat4 transform = frame.transforms[0].world;
+
+    vec4 world_pos = vec4(input.pos, 1.0) * transform;
+    o.position = world_pos * frame.view * frame.proj;
+    o.normal = input.normal;
+    o.uv = input.uv;
+    o.tangent = input.tangent;
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VSOut input) {
+    return vec4(input.normal, 1.0);
+}
ADD · src/passes/grid/grid.cpp +102 -0
--- a/src/passes/grid/grid.cpp
+++ b/src/passes/grid/grid.cpp
@@ -0,0 +1,102 @@
+#include "grid.h"
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace grid {
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image
+) {
+
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/grid/grid.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(true, false, rhi::PipelineCompareOp::GREATER_EQUAL);
+    pd.set_blending();
+    pd.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &pipeline = pipelines.add_render("Grid", pd);
+
+    // Depth is tested (read) and stored (write): LOAD + depth-test + STORE.
+    auto &builder = fg.add_pass("Grid")
+                        .write(main_image, rhi::ResourceState::ColorDraw)
+                        .read_write(depth_image, rhi::ResourceState::DepthDraw)
+                        .execute([=, &pipeline](PassContext &ctx) {
+                            auto main_view = ctx.image_view(
+                                main_image,
+                                {
+                                    .aspect = rhi::ImageAspect::Color,
+                                    .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+                                    .mip_start = 0,
+                                    .mip_count = 1,
+                                    .layer_start = 0,
+                                    .layer_count = 1,
+                                }
+                            );
+
+                            auto depth_view = ctx.image_view(
+                                depth_image,
+                                {
+                                    .aspect = rhi::ImageAspect::Depth,
+                                    .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+                                    .mip_start = 0,
+                                    .mip_count = 1,
+                                    .layer_start = 0,
+                                    .layer_count = 1,
+                                }
+                            );
+
+                            rhi::AttachmentDesc color_att{};
+                            color_att.img = &main_view;
+                            color_att.loadOp = rhi::LoadOp::LOAD;
+                            color_att.storeOp = rhi::StoreOp::STORE;
+
+                            rhi::AttachmentDesc depth_att{};
+                            depth_att.img = &depth_view;
+                            depth_att.loadOp = rhi::LoadOp::LOAD;
+                            depth_att.storeOp = rhi::StoreOp::STORE;
+
+                            rhi::RenderingInfo ri{};
+                            ri.colorAttachments[0] = color_att;
+                            ri.colorAttachmentCount = 1;
+                            ri.depthAttachment = depth_att;
+                            ri.width = ctx.render_width;
+                            ri.height = ctx.render_height;
+
+                            rhi::begin_rendering(ctx.cmd, ri);
+                            rhi::set_pipeline(ctx.cmd, pipeline);
+
+                            rhi::Viewport viewport{};
+                            viewport.width = (f32)ctx.render_width;
+                            viewport.height = (f32)ctx.render_height;
+                            rhi::set_viewports(ctx.cmd, &viewport);
+
+                            rhi::Rect scissor{};
+                            scissor.width = (i32)ctx.render_width;
+                            scissor.height = (i32)ctx.render_height;
+                            rhi::set_scissors(ctx.cmd, &scissor);
+
+                            FrameData &frame = ctx.frame_data[ctx.frame_index];
+                            GridPushConstants pc{};
+                            pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+                            {
+                                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                                char pc128[128] = {};
+                                std::memcpy(pc128, &pc, sizeof(pc));
+                                rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+                            }
+
+                            rhi::draw(ctx.cmd, 3, 1, 0, 0);
+                            rhi::end_rendering(ctx.cmd);
+                        });
+}
+
+} // namespace grid<
\ No newline at end of file
ADD · src/passes/grid/grid.h +19 -0
--- a/src/passes/grid/grid.h
+++ b/src/passes/grid/grid.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct Pipelines;
+
+namespace grid {
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image
+);
+
+}
ADD · src/passes/grid/grid.slang +112 -0
--- a/src/passes/grid/grid.slang
+++ b/src/passes/grid/grid.slang
@@ -0,0 +1,112 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+// https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8
+f32 PristineGrid(vec2 uv, vec2 lineWidth) {
+    lineWidth = saturate(lineWidth);
+    vec4 uvDDXY = vec4(ddx(uv), ddy(uv));
+    vec2 uvDeriv = vec2(length(uvDDXY.xz), length(uvDDXY.yw));
+    uvDeriv = clamp(uvDeriv, 1e-5, 5.0);
+    bvec2 invertLine = lineWidth > 0.5;
+    vec2 targetWidth = select(invertLine, 1.0 - lineWidth, lineWidth);
+    vec2 drawWidth = clamp(targetWidth, uvDeriv, 0.5);
+    vec2 lineAA = max(uvDeriv, 0.000001) * 1.5;
+    vec2 gridUV = abs(frac(uv) * 2.0 - 1.0);
+    gridUV = select(invertLine, gridUV, 1.0 - gridUV);
+    vec2 grid2 = smoothstep(drawWidth + lineAA, drawWidth - lineAA, gridUV);
+    grid2 *= saturate(targetWidth / drawWidth);
+    grid2 = lerp(grid2, targetWidth, saturate(uvDeriv * 2.0 - 1.0));
+    grid2 = select(invertLine, 1.0 - grid2, grid2);
+    return lerp(grid2.x, 1.0, grid2.y);
+}
+
+f32 ScreenSpaceLine(f32 value, f32 pixelWidth) {
+    f32 deriv = fwidth(value);
+    f32 width = deriv * pixelWidth;
+    return 1.0 - smoothstep(width, width + deriv, abs(value));
+}
+
+[vk::push_constant]
+GridPushConstants pc;
+
+static vec2 GRID_SCALE = vec2(1.0, 1.0);
+static f32 THIN_LINE_WIDTH = 0.1;
+static vec4 THIN_COLOR = vec4(0.25, 0.25, 0.25, 1.0f);
+
+static f32 MAJOR_DIVISION = 10.0;
+static f32 THICK_LINE_WIDTH = 0.01; // gets lerped with thin so has to be lower than it
+static vec4 THICK_COLOR = vec4(0.55, 0.55, 0.55, 1.0f);
+
+static f32 FADE_DISTANCE = 250.f;
+
+static f32 AXIS_WIDTH_PX = 0.01;
+static vec4 X_AXIS_COLOR = vec4(1.0, 0.0, 0.0, 1.0);
+static vec4 Y_AXIS_COLOR = vec4(0.0, 1.0, 0.0, 1.0);
+static vec4 Z_AXIS_COLOR = vec4(0.0, 0.5, 1.0, 1.0);
+
+static const vec2 fullscreen_quad_verts[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+
+struct VSOutput {
+    vec4 position : SV_Position;
+    vec3 ray_dir : TEXCOORD0;
+    vec3 ray_org : TEXCOORD1;
+}
+
+[shader("vertex")]
+VSOutput vsMain(u32 vertexID: SV_VertexID) {
+    VSOutput o;
+
+    FrameUBO frame = *pc.frame;
+
+    vec2 ndc = fullscreen_quad_verts[vertexID];
+    vec4 clip = vec4(ndc, 1.0, 1.0);
+    vec4 world = clip * frame.inv_view_proj;
+
+    world.xyz /= world.w;
+    o.ray_org = frame.position_ws.xyz;
+    o.ray_dir = world.xyz - frame.position_ws.xyz;
+    o.position = vec4(ndc, 0.0, 1.0);
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VSOutput input) : SV_Target {
+    FrameUBO frame = *pc.frame;
+
+    vec3 rayOrigin = input.ray_org;
+    vec3 rayDir = normalize(input.ray_dir);
+
+    if (abs(rayDir.z) < 1e-4) {
+        discard;
+    }
+
+    f32 t = -rayOrigin.z / rayDir.z;
+
+    if (t <= 0.0) {
+        discard;
+    }
+
+    vec3 worldPos = rayOrigin + rayDir * t;
+    vec2 cameraGridOrigin = floor(frame.position_ws.xy / MAJOR_DIVISION) * MAJOR_DIVISION;
+    vec2 uv = (worldPos.xy - cameraGridOrigin) * GRID_SCALE;
+
+    f32 minor = PristineGrid(uv, vec2(THIN_LINE_WIDTH));
+    f32 major = PristineGrid(uv / MAJOR_DIVISION, vec2(THICK_LINE_WIDTH));
+
+    vec4 color = THIN_COLOR * minor;
+    color = lerp(color, THICK_COLOR, major);
+
+    // override if  axis
+    f32 xAxis = ScreenSpaceLine(worldPos.y, AXIS_WIDTH_PX);
+    f32 yAxis = ScreenSpaceLine(worldPos.x, AXIS_WIDTH_PX);
+    color = lerp(color, X_AXIS_COLOR, xAxis);
+    color = lerp(color, Y_AXIS_COLOR, yAxis);
+
+    f32 dist = distance(frame.position_ws.xy, worldPos.xy);
+    f32 fade = 1.0 - saturate(dist / FADE_DISTANCE);
+    color.a *= fade;
+
+    return color;
+}
+
ADD · src/passes/hiz/hiz.cpp +122 -0
--- a/src/passes/hiz/hiz.cpp
+++ b/src/passes/hiz/hiz.cpp
@@ -0,0 +1,122 @@
+#include "hiz.h"
+
+#include "passes/fg.h"
+#include "pipelines.h"
+#include "shaders/renderer_types.h"
+
+namespace hiz {
+
+Resources create(FrameGraph &fg) {
+
+    Resources out;
+    out.hiz = fg.add_image({
+        .desc = {.mip_levels = 0, .format = rhi::ImageFormat::R32_FLOAT},
+        .name = "fg/hiz/hiz",
+        .lifetime = Lifetime::Transient,
+        .size_class = SizeOp::Swapchain,
+        .scale = {0.5f, 0.5f},
+        // Full-chain sampled view (mip_count 0 = full chain, substituted at
+        // compile). Per-mip storage views stay on the lazy push path.
+        .view = {.type = rhi::ImageViewType::Sampled, .mip_count = 0},
+    });
+    return out;
+};
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &res,
+    ImageHandle depth
+) {
+
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/hiz/hiz_downsample.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("HiZ", pd);
+
+    auto &builder = fg.add_pass("HiZ");
+    builder.read(depth, rhi::ResourceState::TextureSampleNonFragment);
+    builder.write(res.hiz, rhi::ResourceState::StorageReadWrite);
+    builder.read(res.hiz, rhi::ResourceState::TextureSampleNonFragment);
+
+    // Per-mip storage views resolved once per compile(); execute only reads.
+    res.storage_views = fg.request_extra_view(res.hiz, true);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        auto &img = ctx.get_image(res.hiz);
+        u32 mip_count = img.desc.mip_levels;
+        u32 w = img.desc.width;
+        u32 h = img.desc.height;
+
+        auto &depth_img = ctx.get_image(depth);
+        u32 depth_w = depth_img.desc.width;
+        u32 depth_h = depth_img.desc.height;
+
+        for (u32 mip = 0; mip < mip_count; ++mip) {
+            u32 src_w = (mip == 0) ? depth_w : std::max(w >> (mip - 1), 1u);
+            u32 src_h = (mip == 0) ? depth_h : std::max(h >> (mip - 1), 1u);
+            u32 dst_w = std::max(w >> mip, 1u);
+            u32 dst_h = std::max(h >> mip, 1u);
+
+            rhi::set_pipeline(ctx.cmd, pipeline);
+
+            HiZPushConstants pc{};
+            pc.depth = (u32)ctx.view(depth);
+            pc.hiz_src = (u32)ctx.view(res.hiz);
+            pc.hiz_dst = (u32)ctx.view_extra(res.storage_views, 0, mip);
+            pc.mip_level = mip;
+            pc.src_width = src_w;
+            pc.src_height = src_h;
+            {
+                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                char pc128[128] = {};
+                std::memcpy(pc128, &pc, sizeof(pc));
+                rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+            }
+
+            u32 gx = (dst_w + 15u) / 16u;
+            u32 gy = (dst_h + 15u) / 16u;
+            if (gx > 0 && gy > 0) {
+                rhi::dispatch(ctx.cmd, gx, gy);
+            }
+
+            if (mip < mip_count - 1) {
+                rhi::ImageRange range{};
+                range.mip = mip;
+                range.mip_count = 1;
+                rhi::barrier(
+                    ctx.cmd,
+                    ctx.get_image(res.hiz),
+                    range,
+                    rhi::ResourceState::StorageReadWrite,
+                    rhi::ResourceState::TextureSampleNonFragment
+                );
+            }
+        }
+
+        // Restore: mips 0..n-2 were left in SHADER_READ_ONLY_OPTIMAL for
+        // sampling, but the FG tracks this image as one whole-image
+        // StorageReadWrite (GENERAL) state. Without per-mip state tracking,
+        // the next frame's dispatches (STORAGE_IMAGE descriptors expecting
+        // GENERAL) would hit the SRO leftovers. Transition every non-last
+        // mip back to GENERAL so pass boundaries always leave a uniform
+        // GENERAL image matching the tracked state. Per-mip ranges never
+        // touch image.state, so no tracking divergence.
+        for (u32 mip = 0; mip + 1 < mip_count; ++mip) {
+            rhi::ImageRange range{};
+            range.mip = mip;
+            range.mip_count = 1;
+            rhi::barrier(
+                ctx.cmd,
+                ctx.get_image(res.hiz),
+                range,
+                rhi::ResourceState::TextureSampleNonFragment,
+                rhi::ResourceState::StorageReadWrite
+            );
+        }
+    });
+}
+
+} // namespace hiz<
\ No newline at end of file
ADD · src/passes/hiz/hiz.h +30 -0
--- a/src/passes/hiz/hiz.h
+++ b/src/passes/hiz/hiz.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "core/globals.h"
+#include "passes/fg.h"
+
+struct FrameGraph;
+struct Pipelines;
+
+namespace hiz {
+
+struct Resources {
+    ImageHandle hiz;
+    u32 mip_count = 0;
+    u32 width = 0;
+    u32 height = 0;
+    // Compile-resolved per-mip storage views (ExtraImageView registry index).
+    u32 storage_views = UINT32_MAX;
+};
+
+Resources create(FrameGraph &fg);
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &hiz,
+    ImageHandle depth
+);
+
+} // namespace hiz
ADD · src/passes/hiz/hiz_downsample.slang +53 -0
--- a/src/passes/hiz/hiz_downsample.slang
+++ b/src/passes/hiz/hiz_downsample.slang
@@ -0,0 +1,53 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+HiZPushConstants pc;
+
+[numthreads(16, 16, 1)]
+void csMain(uvec3 gtid: SV_GroupThreadID, uvec3 gid: SV_GroupID) {
+    uvec2 src_size = uvec2(pc.src_width, pc.src_height);
+    uvec2 dst_size = max(uvec2(1, 1), src_size >> 1);
+
+    uvec2 px = gid.xy * 16 + gtid.xy;
+
+    if (px.x >= dst_size.x || px.y >= dst_size.y)
+        return;
+
+    uvec2 sx = px * 2;
+
+    uvec2 p0 = min(sx + uvec2(0, 0), src_size - 1);
+    uvec2 p1 = min(sx + uvec2(1, 0), src_size - 1);
+    uvec2 p2 = min(sx + uvec2(0, 1), src_size - 1);
+    uvec2 p3 = min(sx + uvec2(1, 1), src_size - 1);
+
+    f32 d0, d1, d2, d3;
+
+    if (pc.mip_level == 0) {
+        d0 = pc.depth[p0].r; // reverse-Z depth buffer
+        d1 = pc.depth[p1].r;
+        d2 = pc.depth[p2].r;
+        d3 = pc.depth[p3].r;
+    } else {
+        int src_mip = int(pc.mip_level) - 1;
+        d0 = pc.hiz_src.Load(ivec3(p0, src_mip)).r;
+        d1 = pc.hiz_src.Load(ivec3(p1, src_mip)).r;
+        d2 = pc.hiz_src.Load(ivec3(p2, src_mip)).r;
+        d3 = pc.hiz_src.Load(ivec3(p3, src_mip)).r;
+    }
+
+    // NOTE: I'm yet to truly wrap up hiz, and I've looked into it twice
+    // so the long comment stays
+
+    // MAX reduction: stores the closest depth per 2×2 block
+    // (reverse-Z: larger values = closer to camera)
+    // storage_images[pc.hiz_dst_idx][px] = max(max(d0, d1), max(d2, d3));
+
+    // MIN reduction: stores the farthest (smallest) depth per 2×2 block.
+    // Reverse-Z: 0.0 = far plane, 1.0 = near plane.
+    // Conservative occlusion testing needs the FARTHEST occluder in the region
+    // (= smallest value in reverse-Z) to avoid false occlusion:
+    //   "is the entire object behind everything in this tile?"
+    // MIN is correct here, NOT MAX (MAX = closest, would over-occlude).
+    pc.hiz_dst[px] = min(min(d0, d1), min(d2, d3));
+}
ADD · src/passes/id_blit/id_blit.cpp +99 -0
--- a/src/passes/id_blit/id_blit.cpp
+++ b/src/passes/id_blit/id_blit.cpp
@@ -0,0 +1,99 @@
+#include "id_blit.h"
+
+#include "passes/fg.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace id_blit {
+
+ImageHandle record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    ImageHandle depth
+) {
+
+    ImageHandle out = fg.add_image(
+        {.desc = {.format = rhi::ImageFormat::R32_UINT}, .name = "fg/idblit/id", .size_class = SizeOp::Swapchain}
+    );
+
+    rhi::RenderPipelineDesc id_blit_p;
+    id_blit_p.device = &device;
+    id_blit_p.set_shaders(sc, "src/passes/id_blit/id_blit.slang", "vtx_main", "fs_main");
+    id_blit_p.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    id_blit_p.set_color_format(rhi::ImageFormat::R32_UINT);
+    rhi::RenderPipeline &pipeline = pipelines.add_render("IDBlitPipeline", id_blit_p);
+
+    auto &builder = fg.add_pass("ID_Blit");
+    builder.read(depth, rhi::ResourceState::TextureSample);
+    builder.read(indirect, rhi::ResourceState::IndirectFetch);
+    builder.read(draw_count, rhi::ResourceState::IndirectFetch);
+    builder.read(visible, rhi::ResourceState::StorageRead);
+    builder.write(out, rhi::ResourceState::ColorDraw);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        auto display_view = ctx.image_view(out, {.aspect = rhi::ImageAspect::Color});
+
+        rhi::AttachmentDesc color_att{};
+        color_att.img = &display_view;
+        color_att.loadOp = rhi::LoadOp::CLEAR;
+        color_att.storeOp = rhi::StoreOp::STORE;
+        color_att.clearValue.color.uint32[0] = 0u; // 0 = "no hit"; editor subtracts 1 from stored ids
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = color_att;
+        ri.colorAttachmentCount = 1;
+        ri.width = ctx.render_width;
+        ri.height = ctx.render_height;
+
+        rhi::begin_rendering(ctx.cmd, ri);
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        rhi::Viewport vp{};
+        vp.width = (f32)ctx.render_width;
+        vp.height = (f32)ctx.render_height;
+        rhi::set_viewports(ctx.cmd, &vp);
+
+        rhi::Rect scissor{};
+        scissor.width = (i32)ctx.render_width;
+        scissor.height = (i32)ctx.render_height;
+        rhi::set_scissors(ctx.cmd, &scissor);
+
+        IdBlitPushConstants pc{};
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.vertex = (u64)ctx.render_data->vertex_view.slot;
+        pc.visible_items = rhi::buffer_device_address(ctx.device, ctx.get_buffer(visible));
+        pc.depth = (u32)ctx.view(depth);
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        rhi::set_index_buffer(ctx.cmd, ctx.render_data->index_buffer);
+        rhi::draw_indexed_indirect(
+            ctx.cmd,
+            ctx.get_buffer(indirect),
+            &ctx.get_buffer(draw_count),
+            ctx.render_data->render_item_count,
+            rhi::DRAW_INDEXED_INDIRECT_STRIDE,
+            0,
+            0
+        );
+
+        rhi::end_rendering(ctx.cmd);
+    });
+
+    return out;
+};
+
+} // namespace id_blit<
\ No newline at end of file
ADD · src/passes/id_blit/id_blit.h +22 -0
--- a/src/passes/id_blit/id_blit.h
+++ b/src/passes/id_blit/id_blit.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct RenderData;
+struct Pipelines;
+
+namespace id_blit {
+
+ImageHandle record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    ImageHandle depth
+);
+
+} // namespace id_blit
ADD · src/passes/id_blit/id_blit.slang +36 -0
--- a/src/passes/id_blit/id_blit.slang
+++ b/src/passes/id_blit/id_blit.slang
@@ -0,0 +1,36 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[vk::push_constant]
+IdBlitPushConstants pc;
+
+struct VsOut {
+    vec4 pos : SV_Position;
+    u32 id;
+}
+
+[shader("vertex")]
+VsOut vtx_main(u32 vertexID: SV_VertexID, u32 drawID: SV_DrawIndex, u32 instanceID: SV_InstanceID) {
+    VsOut out;
+    FrameUBO frame = *pc.frame;
+
+    u32 item_idx = pc.visible_items[drawID].id;
+    RenderItemGPU item = frame.render_items[item_idx];
+    SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+    TransformGPU xform = frame.transforms[item.instance_id];
+    Vertex v = pc.vertex[vertexID + submesh.base_vertex];
+
+    out.pos = (vec4(v.pos, 1.0) * xform.world) * frame.view * frame.proj;
+    out.id = item.entity_id;
+
+    return out;
+}
+
+[shader("fragment")]
+u32 fs_main(VsOut input) : SV_Target {
+    f32 sd = pc.depth.Load(uvec3(u32(input.pos.x), u32(input.pos.y), 0)).r;
+    if (input.pos.z < sd - 1e-4f) {
+        discard;
+    }
+    return input.id;
+};
ADD · src/passes/imgui/imgui.cpp +27 -0
--- a/src/passes/imgui/imgui.cpp
+++ b/src/passes/imgui/imgui.cpp
@@ -0,0 +1,27 @@
+#include "imgui.h"
+
+#include "passes/fg.h"
+#include "pipelines.h"
+#include "shaders/renderer_types.h"
+
+namespace imgui_pass {
+
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, rhi::ImageFormat output_format
+) {
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/imgui/imgui.slang", "vsMain", "fsMain");
+    pd.add_vertex_binding(0, VERTEX_STRIDE, false);
+    pd.add_vertex_attribute(0, 0, rhi::ImageFormat::RG32_FLOAT, 0);
+    pd.add_vertex_attribute(1, 0, rhi::ImageFormat::RG32_FLOAT, 8);
+    pd.add_vertex_attribute(2, 0, rhi::ImageFormat::RGBA8_UNORM, 16);
+    pd.set_input_topology(rhi::PipelineTopology::TRIANGLES);
+    pd.set_depth_testing(false, false, rhi::PipelineCompareOp::ALWAYS);
+    pd.set_blending();
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CCW);
+    pd.set_color_format(output_format);
+    pipelines.add_render("ImGui", pd);
+}
+
+} // namespace imgui_pass
ADD · src/passes/imgui/imgui.h +17 -0
--- a/src/passes/imgui/imgui.h
+++ b/src/passes/imgui/imgui.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "backend/rhi.h"
+
+struct Pipelines;
+struct FrameGraph;
+
+namespace imgui_pass {
+
+// ImDrawVert layout: pos float2 + uv float2 + col u32 (20 bytes).
+inline constexpr u32 VERTEX_STRIDE = 20;
+
+void record(
+    rhi::Device &device, Pipelines &pipelines, rhi::ShaderCompiler &sc, FrameGraph &fg, rhi::ImageFormat output_format
+);
+
+} // namespace imgui_pass
ADD · src/passes/imgui/imgui.slang +35 -0
--- a/src/passes/imgui/imgui.slang
+++ b/src/passes/imgui/imgui.slang
@@ -0,0 +1,35 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+struct VsIn {
+    [[vk::location(0)]]
+    vec2 pos;
+    [[vk::location(1)]]
+    vec2 uv;
+    [[vk::location(2)]]
+    vec4 col;
+};
+
+struct VsOut {
+    vec4 clip_pos : SV_Position;
+    vec4 col : TEXCOORD0;
+    vec2 uv : TEXCOORD1;
+};
+
+[[vk::push_constant]]
+ImGuiPushConstants pc;
+
+[shader("vertex")]
+VsOut vsMain(VsIn input) {
+    VsOut o;
+    vec2 fb = input.pos * pc.scale + pc.translate;
+    o.clip_pos = vec4(2.0f * fb.x / pc.display_size.x - 1.0f, 1.0f - 2.0f * fb.y / pc.display_size.y, 0.0f, 1.0f);
+    o.col = input.col;
+    o.uv = input.uv;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VsOut input) : SV_Target {
+    return pc.tex.Sample(pc.samp, input.uv) * input.col;
+}
ADD · src/passes/rt_build.cpp +123 -0
--- a/src/passes/rt_build.cpp
+++ b/src/passes/rt_build.cpp
@@ -0,0 +1,123 @@
+#include "rt_build.h"
+
+#include "core/math_rtm.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace rt_build {
+void record(FrameGraph &fg, BufferHandle tlas_buf) {
+    auto &builder = fg.add_pass("RT Build");
+    builder.write(tlas_buf, rhi::ResourceState::AccelBuild);
+
+    builder.execute([=](PassContext &ctx) {
+        RtScene &rt = ctx.render_data->rt_scene;
+        if (ctx.render_data->mesh_rt.empty() || !rhi::valid(rt.tlas)) {
+            return;
+        }
+
+        u32 render_item_count = (u32)ctx.render_data->render_items.size();
+        if (render_item_count == 0) {
+            return;
+        }
+
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+        const TransformGPU *transforms = (const TransformGPU *)frame.transform_buffer.mapped;
+        const u32 transform_capacity = frame.transform_capacity;
+
+        u64 total_expected_instances = ctx.render_data->render_item_count;
+        std::vector<rhi::AccelStructInstance> instances;
+        std::vector<InstanceData> cpu_inst_data;
+        instances.reserve(total_expected_instances);
+        cpu_inst_data.reserve(total_expected_instances);
+
+        for (u32 i = 0; i < render_item_count; ++i) {
+            const RenderItemGPU &item = ctx.render_data->render_items[i];
+            if (item.submesh_index >= ctx.render_data->mesh_rt.size()) {
+                continue;
+            }
+            const MeshRT &mesh_rt = ctx.render_data->mesh_rt[item.submesh_index];
+            if (mesh_rt.blas_device_address == 0) {
+                continue;
+            }
+            {
+                u32 xform_idx = item.instance_id;
+                if (xform_idx >= transform_capacity) {
+                    continue;
+                }
+                mat4 world = transforms[xform_idx].world;
+                rhi::AccelStructInstance instance{};
+                mat4 trans = transpose(world);
+                memcpy(&instance.transform, &trans, sizeof(instance.transform));
+                instance.instance_custom_index = (u32)instances.size();
+                instance.mask = 0xFF;
+                instance.sbt_record_offset = 0;
+                instance.flags = 0;
+                instance.acceleration_structure_reference = mesh_rt.blas_device_address;
+
+                assert(mesh_rt.blas_device_address != 0);
+                assert(instance.acceleration_structure_reference != 0);
+                assert(instance.mask == 0xFF);
+
+                instances.push_back(instance);
+                cpu_inst_data.push_back(InstanceData{item.instance_id, i});
+            }
+        }
+
+        u32 instance_count = (u32)instances.size();
+        if (instance_count == 0) {
+            return;
+        }
+
+        memcpy(rt.instance_buffer.mapped, instances.data(), instance_count * sizeof(rhi::AccelStructInstance));
+        u64 inst_buf_addr = rhi::buffer_device_address(ctx.device, rt.instance_buffer);
+        memcpy(rt.instance_data_buffer.mapped, cpu_inst_data.data(), instance_count * sizeof(InstanceData));
+
+        // Host-written instance data must be visible before the AS build.
+        rhi::barrier(ctx.cmd, rhi::ResourceState::HostRead, rhi::ResourceState::AccelBuild);
+        rhi::barrier(ctx.cmd, rt.instance_data_buffer, rhi::ResourceState::HostRead, rhi::ResourceState::StorageRead);
+
+        rhi::AccelStructGeometryInstancesData instances_data{
+            .data = inst_buf_addr,
+            .array_of_pointers = false,
+        };
+        rhi::AccelStructGeometry tlas_geom{
+            .type = rhi::AccelStructGeometryType::Instances,
+            .flags = rhi::AccelStructGeometryFlags::Opaque,
+            .instances = instances_data,
+        };
+        rhi::AccelStructBuildGeometryInfo tlas_build{
+            .type = rhi::AccelStructType::TopLevel,
+            .flags = rhi::AccelStructBuildFlags::PreferFastTrace,
+            .dst_acceleration_structure = &rt.tlas,
+            .geometries = &tlas_geom,
+            .geometry_count = 1,
+            .scratch_data = rt.scratch_device_addr,
+        };
+        rhi::AccelStructBuildRangeInfo tlas_range{
+            .primitive_count = instance_count,
+            .primitive_offset = 0,
+            .first_vertex = 0,
+            .transform_offset = 0,
+        };
+        rhi::barrier(ctx.cmd, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelBuild);
+        rhi::barrier(ctx.cmd, rt.tlas_buffer, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelBuild);
+
+        const rhi::AccelStructBuildRangeInfo *p_range = &tlas_range;
+        rhi::cmd_build_acceleration_structures(ctx.cmd, &tlas_build, &p_range, 1);
+
+        rhi::barrier(ctx.cmd, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelTrace);
+
+        // TLAS BDA � no heap
+
+        assert(render_item_count > 0);
+        assert(total_expected_instances > 0);
+        assert(instance_count > 0);
+        assert(rhi::valid(rt.tlas));
+        assert(rt.scratch_device_addr != 0);
+        assert(rhi::valid(rt.instance_buffer));
+        assert(rt.instance_buffer.mapped != nullptr);
+        assert(inst_buf_addr != 0);
+        assert(rt.instance_data_buffer.mapped != nullptr);
+    });
+}
+} // namespace rt_build
ADD · src/passes/rt_build.h +9 -0
--- a/src/passes/rt_build.h
+++ b/src/passes/rt_build.h
@@ -0,0 +1,9 @@
+#pragma once
+#include "passes/fg.h"
+
+struct RenderData;
+struct Scene;
+
+namespace rt_build {
+void record(FrameGraph &fg, BufferHandle tlas_buf);
+} // namespace rt_build
ADD · src/passes/shadow/shadow.cpp +142 -0
--- a/src/passes/shadow/shadow.cpp
+++ b/src/passes/shadow/shadow.cpp
@@ -0,0 +1,142 @@
+#include "shadow.h"
+
+#include <cstdio>
+
+#include "backend/rhi.h"
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace shadow {
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    const u32 cascade_sizes[Light::CASCADE_COUNT]
+) {
+
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/shadow/shadow.slang", "vsMain", "fsMain");
+    pd.set_cull_mode(rhi::PipelineCullMode::BACK, rhi::PipelineTriangleWindingOrder::CW);
+    pd.set_depth_testing(true, true, rhi::PipelineCompareOp::GREATER_EQUAL);
+    pd.set_depth_clamp(true);
+    pd.set_depth_bias(true, -1.0f, 0.0f, -2.0f);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &pipeline = pipelines.add_render("Shadow", pd);
+
+    Resources res;
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        char cascade_name[64];
+        (void)snprintf(cascade_name, sizeof(cascade_name), "fg/shadow/cascade[%u]", i);
+        res.cascade[i] = fg.add_image(
+            {.desc = {.width = cascade_sizes[i], .height = cascade_sizes[i], .format = rhi::ImageFormat::D32_FLOAT},
+             .name = cascade_name,
+             .lifetime = Lifetime::Persistent,
+             .size_class = SizeOp::Absolute,
+             .view = {.aspect = rhi::ImageAspect::Depth, .type = rhi::ImageViewType::Sampled, .mip_count = 1}}
+        );
+    }
+
+    auto &builder = fg.add_pass("CSM Gen");
+    builder.read(indirect, rhi::ResourceState::IndirectFetch);
+    builder.read(draw_count, rhi::ResourceState::IndirectFetch);
+    builder.read(visible, rhi::ResourceState::StorageRead);
+
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        builder.write(res.cascade[i], rhi::ResourceState::DepthDraw);
+    }
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        FrameData &frame = ctx.frame_data[ctx.frame_index];
+
+        ShadowCascadesGPU rc{};
+        rc.cascade_count = Light::CASCADE_COUNT;
+        auto &sun = ctx.scene->directional_lights[0];
+        for (u32 ci = 0; ci < Light::CASCADE_COUNT; ++ci) {
+            ShadowCascade &ls = sun.cascades[ci];
+            ShadowCascadeGPU &cv = rc.cascade[ci];
+
+            cv.view = ls.view;
+            cv.view_proj = ls.view_proj;
+            cv.caster_min_ls = ls.caster_min_ls;
+            cv.caster_max_ls = ls.caster_max_ls;
+            f32 texel_world = fmax(ls.width, ls.height) / (f32)cascade_sizes[ci];
+            cv.texel_size = texel_world;
+            cv.texel_depth = texel_world / ls.depth;
+            cv.img = (u32)ctx.view(res.cascade[ci]);
+        }
+        memcpy((u8 *)frame.frame_ubo.mapped + offsetof(FrameUBO, shadows), &rc, sizeof(ShadowCascadesGPU));
+
+        for (u32 ci = 0; ci < Light::CASCADE_COUNT; ++ci) {
+            auto cascade_view = ctx.image_view(
+                res.cascade[ci],
+                {
+                    .aspect = rhi::ImageAspect::Depth,
+                    .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+                    .mip_start = 0,
+                    .mip_count = 1,
+                }
+            );
+
+            // Dimensions are image properties — read off the resource, not the view.
+            u32 cw = ctx.get_image(res.cascade[ci]).desc.width;
+            u32 ch = ctx.get_image(res.cascade[ci]).desc.height;
+
+            rhi::RenderingInfo ri{};
+            ri.depthAttachment.img = &cascade_view;
+            ri.depthAttachment.loadOp = rhi::LoadOp::CLEAR;
+            ri.depthAttachment.storeOp = rhi::StoreOp::STORE;
+            ri.depthAttachment.clearValue.depthStencil = {0.0f, 0};
+            ri.width = cw;
+            ri.height = ch;
+
+            rhi::begin_rendering(ctx.cmd, ri);
+            rhi::set_pipeline(ctx.cmd, pipeline);
+
+            rhi::Viewport vp{};
+            vp.width = (f32)cw;
+            vp.height = (f32)ch;
+            rhi::set_viewports(ctx.cmd, &vp);
+
+            rhi::Rect scissor{};
+            scissor.width = (i32)cw;
+            scissor.height = (i32)ch;
+            rhi::set_scissors(ctx.cmd, &scissor);
+
+            ShadowPushConstants pc{};
+            pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+            pc.visible_items = rhi::buffer_device_address(ctx.device, ctx.get_buffer(visible));
+            pc.cascade_idx = ci;
+            pc.vertex = (u64)ctx.render_data->vertex_view.slot;
+
+            {
+                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                char pc128[128] = {};
+                std::memcpy(pc128, &pc, sizeof(pc));
+                rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+            }
+
+            rhi::set_index_buffer(ctx.cmd, ctx.render_data->index_buffer);
+            rhi::draw_indexed_indirect(
+                ctx.cmd,
+                ctx.get_buffer(indirect),
+                &ctx.get_buffer(draw_count),
+                ctx.render_data->render_item_count,
+                rhi::DRAW_INDEXED_INDIRECT_STRIDE,
+                0,
+                0
+            );
+
+            rhi::end_rendering(ctx.cmd);
+        }
+    });
+    return res;
+}
+
+} // namespace shadow<
\ No newline at end of file
ADD · src/passes/shadow/shadow.h +27 -0
--- a/src/passes/shadow/shadow.h
+++ b/src/passes/shadow/shadow.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "passes/fg.h"
+#include "scene/light.h"
+
+struct FrameData;
+struct RenderData;
+struct Pipelines;
+
+namespace shadow {
+
+struct Resources {
+    ImageHandle cascade[Light::CASCADE_COUNT];
+};
+
+Resources record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    BufferHandle indirect,
+    BufferHandle draw_count,
+    BufferHandle visible,
+    const u32 cascade_sizes[Light::CASCADE_COUNT]
+);
+
+} // namespace shadow
ADD · src/passes/shadow/shadow.slang +33 -0
--- a/src/passes/shadow/shadow.slang
+++ b/src/passes/shadow/shadow.slang
@@ -0,0 +1,33 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+ShadowPushConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID, u32 drawID: SV_DrawIndex, u32 instanceID: SV_InstanceID) {
+    VtxOut o;
+
+    FrameUBO frame = *pc.frame;
+    u32 item_idx = pc.visible_items[drawID].id;
+    RenderItemGPU item = frame.render_items[item_idx];
+    SubmeshGPU submesh = frame.submeshes[item.submesh_index];
+    TransformGPU xform = frame.transforms[item.instance_id];
+
+    Vertex v = pc.vertex[vertexID + submesh.base_vertex];
+    vec4 worldPos = vec4(v.pos, 1.0) * xform.world;
+
+    // CSM matrices are built in render-relative space. frame.position_ws.xyz is
+    // currently the render origin. (light.h)
+    vec3 shadowPos = worldPos.xyz - frame.position_ws.xyz;
+
+    mat4 light_vp = frame.shadows.cascade[pc.cascade_idx].view_proj;
+    o.clip_pos = vec4(shadowPos, 1.0) * light_vp;
+
+    return o;
+}
+
+[shader("fragment")]
+f32 fsMain(VtxOut input) : SV_Depth {
+    return input.clip_pos.z;
+}
ADD · src/passes/skybox/skybox.cpp +78 -0
--- a/src/passes/skybox/skybox.cpp
+++ b/src/passes/skybox/skybox.cpp
@@ -0,0 +1,78 @@
+#include "skybox.h"
+
+#include "backend/rhi.h"
+#include "pipelines.h"
+#include "renderer.h"
+
+void skybox::record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image,
+    ImageHandle env_image
+) {
+
+    rhi::RenderPipelineDesc pd;
+    pd.device = &device;
+    pd.set_shaders(sc, "src/passes/skybox/skybox.slang", "vsMain", "fsMain");
+    pd.set_depth_testing(true, false, rhi::PipelineCompareOp::GREATER_EQUAL);
+    pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    pd.set_depth_format(rhi::ImageFormat::D32_FLOAT);
+    rhi::RenderPipeline &pipeline = pipelines.add_render("Skybox", pd);
+
+    fg.add_pass("Skybox")
+        .read(env_image, rhi::ResourceState::TextureSample)
+        .write(main_image, rhi::ResourceState::ColorDraw)
+        .write(depth_image, rhi::ResourceState::DepthDraw)
+        .execute([=, &pipeline](PassContext &ctx) {
+            auto main_view = ctx.image_view(main_image, {.aspect = rhi::ImageAspect::Color, .mip_count = 1});
+            auto depth_attach = ctx.image_view(depth_image, {.aspect = rhi::ImageAspect::Depth, .mip_count = 1});
+
+            rhi::AttachmentDesc color_att{};
+            color_att.img = &main_view;
+            color_att.loadOp = rhi::LoadOp::LOAD;
+            color_att.storeOp = rhi::StoreOp::STORE;
+            rhi::AttachmentDesc depth_att{};
+            depth_att.img = &depth_attach;
+            depth_att.loadOp = rhi::LoadOp::LOAD;
+            depth_att.storeOp = rhi::StoreOp::STORE;
+
+            rhi::RenderingInfo ri{};
+            ri.colorAttachments[0] = color_att;
+            ri.colorAttachmentCount = 1;
+            ri.depthAttachment = depth_att;
+            ri.width = ctx.render_width;
+            ri.height = ctx.render_height;
+
+            rhi::begin_rendering(ctx.cmd, ri);
+            rhi::set_pipeline(ctx.cmd, pipeline);
+
+            rhi::Viewport vp{};
+            vp.width = (f32)ctx.render_width;
+            vp.height = (f32)ctx.render_height;
+            rhi::set_viewports(ctx.cmd, &vp);
+            rhi::Rect scissor{};
+            scissor.width = (i32)ctx.render_width;
+            scissor.height = (i32)ctx.render_height;
+            rhi::set_scissors(ctx.cmd, &scissor);
+
+            auto &frame = ctx.frame_data[ctx.frame_index];
+            SkyboxPushConstants pc{};
+            // Persistent IBL cubemap slot, written once at startup — no per-frame write.
+            pc.cubemap = ctx.scene->env.environmentIdx;
+            pc.depth_tex_idx = ctx.view(depth_image);
+            pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+            {
+                static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+                char pc128[128] = {};
+                std::memcpy(pc128, &pc, sizeof(pc));
+                rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+            }
+
+            rhi::draw(ctx.cmd, 3, 1, 0, 0);
+            rhi::end_rendering(ctx.cmd);
+        });
+}<
\ No newline at end of file
ADD · src/passes/skybox/skybox.h +20 -0
--- a/src/passes/skybox/skybox.h
+++ b/src/passes/skybox/skybox.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct FrameData;
+struct Pipelines;
+
+namespace skybox {
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    ImageHandle main_image,
+    ImageHandle depth_image,
+    ImageHandle env_image
+);
+
+}
ADD · src/passes/skybox/skybox.slang +43 -0
--- a/src/passes/skybox/skybox.slang
+++ b/src/passes/skybox/skybox.slang
@@ -0,0 +1,43 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+SkyboxPushConstants pc;
+
+struct VSOutput {
+    vec4 position : SV_Position;
+    vec3 ray_dir : TEXCOORD0;
+};
+
+static vec2 pos[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+
+[shader("vertex")]
+VSOutput vsMain(u32 vertexID: SV_VertexID) {
+    VSOutput o;
+
+    vec2 ndc = pos[vertexID];
+
+    FrameUBO frame = *pc.frame;
+
+    vec4 clip = vec4(ndc, 1.0, 1.0);
+    vec4 world = clip * frame.inv_view_proj;
+
+    world.xyz /= world.w;
+
+    o.ray_dir = world.xyz - frame.position_ws.xyz;
+
+    o.position = vec4(ndc, 0.0, 1.0);
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VSOutput input) : SV_Target {
+    FrameUBO frame = *pc.frame;
+    vec3 dir = normalize(input.ray_dir);
+    vec3 hdr = pc.cubemap.SampleLevel(frame.linear_clamp, dir, 0.0).rgb;
+    f32 exposure = 1.5;
+    vec3 ldr = 1.0 - exp(-hdr * exposure);
+    return vec4(ldr, 1.0);
+}
+
ADD · src/passes/ssr/ssr.cpp +82 -0
--- a/src/passes/ssr/ssr.cpp
+++ b/src/passes/ssr/ssr.cpp
@@ -0,0 +1,82 @@
+#include "ssr.h"
+
+#include <cstring>
+
+#include "pipelines.h"
+#include "renderer.h"
+#include "shaders/renderer_types.h"
+
+namespace ssr {
+
+Resources create(FrameGraph &fg) {
+    Resources out;
+    out.output = fg.add_image({
+        .desc = {.format = rhi::ImageFormat::RGBA16_FLOAT},
+        .name = "fg/ssr/output",
+        .lifetime = Lifetime::Transient,
+        .size_class = SizeOp::Swapchain,
+        .view = {.type = rhi::ImageViewType::Sampled},
+    });
+    return out;
+}
+
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &res,
+    ImageHandle color,
+    ImageHandle depth,
+    ImageHandle normal,
+    ImageHandle hiz
+) {
+    rhi::ComputePipelineDesc pd;
+    pd.device = &device;
+    pd.set_shader(sc, "src/passes/ssr/ssr.slang", "csMain");
+    rhi::ComputePipeline &pipeline = pipelines.add_compute("SSR", pd);
+
+    auto &builder = fg.add_pass("SSR");
+    builder.read(color, rhi::ResourceState::TextureSampleNonFragment);
+    builder.read(depth, rhi::ResourceState::TextureSampleNonFragment);
+    builder.read(normal, rhi::ResourceState::TextureSampleNonFragment);
+    if (hiz.is_valid()) {
+        builder.read(hiz, rhi::ResourceState::TextureSampleNonFragment);
+    }
+    builder.write(res.output, rhi::ResourceState::StorageReadWrite);
+
+    // Whole-image storage view resolved once per compile(); execute only reads.
+    res.storage_view = fg.request_extra_view(res.output, false);
+
+    builder.execute([=, &pipeline](PassContext &ctx) {
+        rhi::set_pipeline(ctx.cmd, pipeline);
+
+        SsrPushConstants pc{};
+        pc.color = (u32)ctx.view(color);
+        pc.depth = (u32)ctx.view(depth);
+        pc.normal = (u32)ctx.view(normal);
+        pc.output = (u32)ctx.view_extra(res.storage_view);
+        pc.frame = (u64)ctx.render_data->frame_ubo_view[ctx.frame_index].slot;
+        pc.width = ctx.render_width;
+        pc.height = ctx.render_height;
+        pc.max_dist = 50.0f;
+        pc.thickness = 0.005f;
+        pc.max_steps = 64;
+        pc.stride = 50.0f / 64.0f;
+
+        {
+            static_assert(sizeof(pc) <= 128, "push constants exceed global 128B range");
+            char pc128[128] = {};
+            std::memcpy(pc128, &pc, sizeof(pc));
+            rhi::set_constants(ctx.cmd, pipeline, rhi::ShaderStage::ALL, sizeof(pc128), pc128);
+        }
+
+        u32 gx = (ctx.render_width + 7u) / 8u;
+        u32 gy = (ctx.render_height + 7u) / 8u;
+        if (gx > 0 && gy > 0) {
+            rhi::dispatch(ctx.cmd, gx, gy);
+        }
+    });
+}
+
+} // namespace ssr
ADD · src/passes/ssr/ssr.h +27 -0
--- a/src/passes/ssr/ssr.h
+++ b/src/passes/ssr/ssr.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include "passes/fg.h"
+
+struct Pipelines;
+
+namespace ssr {
+
+struct Resources {
+    ImageHandle output;
+    u32 storage_view = UINT32_MAX;
+};
+
+Resources create(FrameGraph &fg);
+void record(
+    rhi::Device &device,
+    Pipelines &pipelines,
+    rhi::ShaderCompiler &sc,
+    FrameGraph &fg,
+    Resources &res,
+    ImageHandle color,
+    ImageHandle depth,
+    ImageHandle normal,
+    ImageHandle hiz
+);
+
+} // namespace ssr
ADD · src/passes/ssr/ssr.slang +90 -0
--- a/src/passes/ssr/ssr.slang
+++ b/src/passes/ssr/ssr.slang
@@ -0,0 +1,90 @@
+#include "shared.h"
+#include "renderer_types.h"
+
+[[vk::push_constant]]
+SsrPushConstants pc;
+
+[shader("compute")]
+[numthreads(8, 8, 1)]
+void csMain(uvec3 dtid: SV_DispatchThreadID) {
+    if (dtid.x >= pc.width || dtid.y >= pc.height)
+        return;
+    int2 pix = int2(dtid.xy);
+
+    f32 depth = pc.depth[pix].r;
+    if (depth <= 0.0001f) {
+        pc.output[pix] = vec4(0.0f, 0.0f, 0.0f, 0.0f);
+        return;
+    }
+
+    vec3 N = pc.normal[pix].xyz;
+    if (dot(N, N) < 1e-6f) {
+        pc.output[pix] = vec4(0.0f, 0.0f, 0.0f, 0.0f);
+        return;
+    }
+    N = normalize(N);
+
+    FrameUBO frame = *pc.frame;
+
+    vec2 uv = (vec2(dtid.xy) + 0.5f) / vec2(f32(pc.width), f32(pc.height));
+    vec4 ndc = vec4(uv * 2.0f - 1.0f, depth, 1.0f);
+    vec4 world4 = ndc * frame.inv_view_proj;
+    vec3 world = world4.xyz / world4.w;
+
+    vec3 V = normalize(frame.position_ws.xyz - world);
+    vec3 R = reflect(-V, N);
+
+    f32 NdotV = max(dot(N, V), 0.0f);
+    // self-intersection, grazing
+    f32 t = max(0.1f, 0.1f / max(dot(V, N), 0.1f));
+
+    f32 t_hit = -1.0f;
+    vec2 hit_uv = vec2(-1.0f);
+
+    [loop]
+    for (int i = 0; i < 128; i++) {
+        if (i >= pc.max_steps)
+            break;
+        if (t > pc.max_dist)
+            break;
+
+        vec3 pos = world + R * t;
+        vec4 clip = vec4(pos, 1.0f) * frame.view_proj;
+        if (clip.w <= 0.0f) {
+            t += pc.stride;
+            continue;
+        }
+
+        vec2 suv = clip.xy / clip.w * 0.5f + 0.5f;
+        if (any(suv < 0.0f) || any(suv > 1.0f)) {
+            t += pc.stride;
+            continue;
+        }
+
+        f32 ray_d = clip.z / clip.w;
+        f32 scene_d = pc.depth.SampleLevel(frame.linear_clamp, suv, 0.0f).r;
+        // rev-Z: closer surfaces hold LARGER depth, so a ray passing
+        // behind a surface sees scene_d slightly above ray_d.
+        f32 diff = scene_d - ray_d;
+        if (diff >= 0.0f && diff < pc.thickness) {
+            t_hit = t;
+            hit_uv = suv;
+            break;
+        }
+        t += pc.stride;
+    }
+
+    vec3 reflection = vec3(0.0f);
+    if (t_hit > 0.0f) {
+        vec3 sample = pc.color.SampleLevel(frame.linear_clamp, hit_uv, 0.0f).rgb;
+        vec3 F0 = vec3(0.04f);
+        vec3 fresnel = F0 + (vec3(1.0f) - F0) * pow(1.0f - NdotV, 5.0f);
+        vec2 edge_dist = min(hit_uv, 1.0f - hit_uv);
+        f32 edge_fade = saturate(min(edge_dist.x, edge_dist.y) * 8.0f);
+        f32 dist_fade = 1.0f - t_hit / pc.max_dist;
+        dist_fade *= dist_fade;
+        reflection = sample * fresnel * edge_fade * dist_fade;
+    }
+
+    pc.output[pix] = vec4(reflection, 1.0f);
+}
ADD · src/pipelines.cpp +109 -0
--- a/src/pipelines.cpp
+++ b/src/pipelines.cpp
@@ -0,0 +1,109 @@
+#include "pipelines.h"
+
+#include <volk.h>
+
+#include "core/logger.h"
+
+Pipelines::Pipelines(rhi::Device &device, rhi::ShaderCompiler &compiler) : device(device), compiler(compiler) {
+}
+
+rhi::RenderPipeline &Pipelines::add_render(const char *name, rhi::RenderPipelineDesc desc) {
+    desc.name = name;
+    u64 mtime = rhi::get_file_last_write_time(desc.shader_path.c_str());
+    assert(desc.device != nullptr && "Pipelines::add_render: RenderPipelineDesc::device not assigned");
+    rhi::RenderPipeline p = desc.build();
+    auto it = render_entries.emplace(name, RenderEntry{std::move(desc), p, mtime}).first;
+    return it->second.pipeline;
+}
+
+rhi::ComputePipeline &Pipelines::add_compute(const char *name, rhi::ComputePipelineDesc desc) {
+    desc.name = name;
+    u64 mtime = rhi::get_file_last_write_time(desc.shader_path.c_str());
+    assert(desc.device != nullptr && "Pipelines::add_compute: ComputePipelineDesc::device not assigned");
+    rhi::ComputePipeline p = desc.build();
+    auto it = compute_entries.emplace(name, ComputeEntry{std::move(desc), p, mtime}).first;
+    return it->second.pipeline;
+}
+
+rhi::RenderPipeline &Pipelines::get_render(const char *name) {
+    return render_entries.at(name).pipeline;
+}
+
+rhi::ComputePipeline &Pipelines::get_compute(const char *name) {
+    return compute_entries.at(name).pipeline;
+}
+
+void Pipelines::clear() {
+    for (auto &[name, e] : render_entries) {
+        if (rhi::valid(e.pipeline)) {
+            rhi::destroy_pipeline(device, e.pipeline);
+        }
+    }
+    render_entries.clear();
+    for (auto &[name, e] : compute_entries) {
+        if (rhi::valid(e.pipeline)) {
+            rhi::destroy_pipeline(device, e.pipeline);
+        }
+    }
+    compute_entries.clear();
+}
+
+void Pipelines::reload() {
+    if (!compiler.recreate_session()) {
+        VEL_ERROR("Reload aborted — failed to create fresh Slang session");
+        return;
+    }
+    bool any = false;
+
+    for (auto &[name, e] : render_entries) {
+        u64 mtime = rhi::get_file_last_write_time(e.desc.shader_path.c_str());
+        if (mtime == 0 || mtime == e.source_mtime) {
+            continue;
+        }
+
+        rhi::RenderPipelineDesc new_desc = e.desc;
+        new_desc.set_shaders(
+            compiler, new_desc.shader_path.c_str(), new_desc.vs_entry.c_str(), new_desc.fs_entry.c_str()
+        );
+
+        rhi::RenderPipeline np = new_desc.build();
+        if (!rhi::valid(np)) {
+            VEL_ERROR("Reload failed for '{}' — keeping old version", name);
+            continue;
+        }
+
+        rhi::device_wait_idle(device);
+        rhi::destroy_pipeline(device, e.pipeline);
+        e.pipeline = np;
+        e.source_mtime = mtime;
+        VEL_INFO("Reloaded '{}'", name);
+        any = true;
+    }
+
+    for (auto &[name, e] : compute_entries) {
+        u64 mtime = rhi::get_file_last_write_time(e.desc.shader_path.c_str());
+        if (mtime == 0 || mtime == e.source_mtime) {
+            continue;
+        }
+
+        rhi::ComputePipelineDesc new_desc = e.desc;
+        new_desc.set_shader(compiler, new_desc.shader_path.c_str(), new_desc.cs_entry.c_str());
+
+        rhi::ComputePipeline np = new_desc.build();
+        if (!rhi::valid(np)) {
+            VEL_ERROR("Reload failed for '{}' — keeping old version", name);
+            continue;
+        }
+
+        rhi::device_wait_idle(device);
+        rhi::destroy_pipeline(device, e.pipeline);
+        e.pipeline = np;
+        e.source_mtime = mtime;
+        VEL_INFO("Reloaded '{}'", name);
+        any = true;
+    }
+
+    if (!any) {
+        VEL_INFO("No shaders changed");
+    }
+}
ADD · src/pipelines.h +39 -0
--- a/src/pipelines.h
+++ b/src/pipelines.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "backend/rhi.h"
+
+struct Pipelines {
+    Pipelines(rhi::Device &device, rhi::ShaderCompiler &compiler);
+    ~Pipelines() = default;
+
+    struct RenderEntry {
+        rhi::RenderPipelineDesc desc;
+        rhi::RenderPipeline pipeline;
+        u64 source_mtime = 0;
+    };
+
+    struct ComputeEntry {
+        rhi::ComputePipelineDesc desc;
+        rhi::ComputePipeline pipeline;
+        u64 source_mtime = 0;
+    };
+
+    rhi::RenderPipeline &add_render(const char *name, rhi::RenderPipelineDesc desc);
+    rhi::ComputePipeline &add_compute(const char *name, rhi::ComputePipelineDesc desc);
+    rhi::RenderPipeline &get_render(const char *name);
+    rhi::ComputePipeline &get_compute(const char *name);
+    void clear();
+
+    void reload();
+
+  private:
+    rhi::Device &device;
+    rhi::ShaderCompiler &compiler;
+    std::unordered_map<std::string, RenderEntry> render_entries;
+    std::unordered_map<std::string, ComputeEntry> compute_entries;
+};
ADD · src/quick_submit.cpp +156 -0
--- a/src/quick_submit.cpp
+++ b/src/quick_submit.cpp
@@ -0,0 +1,156 @@
+#include "quick_submit.h"
+
+#include <cassert>
+
+#include "core/logger.h"
+
+void qs_init(QuickSubmit &qs, rhi::Queue queue, rhi::Device &device) {
+    qs.device = &device;
+    qs.queue = queue;
+    qs.next_idx = 0;
+    qs.timeline_ctr = 0;
+    qs.timeline_value = 0;
+
+    qs.timeline = rhi::sync_create(device, 0, "quick-submit");
+    if (!rhi::valid(qs.timeline)) {
+        VEL_CRITICAL("qs_init: upload timeline creation failed");
+    }
+
+    rhi::CmdPoolDesc cmd_pool_dsc;
+    cmd_pool_dsc.queue_family_index = rhi::queue_family_index(qs.queue);
+    cmd_pool_dsc.flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer;
+    rhi::create_cmd_pool(device, cmd_pool_dsc, qs.pool);
+
+    for (u32 i = 0; i < qs.max_buffer_count; ++i) {
+        QsCmd &buf = qs.buffers[i];
+        buf.index = i;
+        buf.state = QsCmdState::Free;
+        buf.submitted_value = 0;
+
+        rhi::CmdBufferDesc cmd_desc;
+        cmd_desc.pool = &qs.pool;
+        cmd_desc.level = rhi::CmdBufferLevel::Primary;
+        rhi::create_cmd_buffer(device, cmd_desc, buf.cmd);
+    }
+}
+
+void qs_shutdown(QuickSubmit &qs) {
+    qs_wait_all(qs);
+
+    rhi::Device &device = *qs.device;
+
+    for (u32 i = 0; i < qs.max_buffer_count; ++i) {
+        qs.buffers[i].state = QsCmdState::Free;
+        qs.buffers[i].submitted_value = 0;
+    }
+
+    rhi::destroy_cmd_pool(device, qs.pool);
+
+    rhi::sync_destroy(qs.timeline);
+    qs.timeline = nullptr;
+
+    qs.next_idx = 0;
+    qs.timeline_value = 0;
+    qs.timeline_ctr = 0;
+}
+
+void qs_purge(QuickSubmit &qs) {
+    const u64 current = rhi::sync_get_completed_value(qs.timeline);
+
+    for (QsCmd &buf : qs.buffers) {
+        if (buf.state == QsCmdState::Submitted && buf.submitted_value <= current) {
+            buf.state = QsCmdState::Free;
+        }
+    }
+}
+
+QsCmd *qs_acquire(QuickSubmit &qs) {
+    qs_purge(qs);
+
+    for (u32 i = 0; i < qs.max_buffer_count; ++i) {
+        const u32 idx = (qs.next_idx + i) % qs.max_buffer_count;
+        QsCmd &buf = qs.buffers[idx];
+
+        if (buf.state == QsCmdState::Free) {
+            qs.next_idx = (idx + 1) % qs.max_buffer_count;
+
+            rhi::reset_cmd_buffer(buf.cmd);
+            rhi::begin_cmd_buffer(buf.cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+
+            buf.state = QsCmdState::Recording;
+            return &buf;
+        }
+    }
+
+    u64 oldest = UINT64_MAX;
+    for (QsCmd &buf : qs.buffers) {
+        if (buf.state == QsCmdState::Submitted) {
+            oldest = std::min(oldest, buf.submitted_value);
+        }
+    }
+
+    assert(oldest != UINT64_MAX && "No buffers available and none submitted?");
+
+    rhi::sync_host_wait(qs.timeline, oldest);
+    qs_purge(qs);
+
+    for (QsCmd &buf : qs.buffers) {
+        if (buf.state == QsCmdState::Free) {
+            rhi::reset_cmd_buffer(buf.cmd);
+            rhi::begin_cmd_buffer(buf.cmd, rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit});
+
+            buf.state = QsCmdState::Recording;
+            return &buf;
+        }
+    }
+
+    VEL_CRITICAL("QuickSubmit: acquire failed after wait — all buffers exhausted");
+    return nullptr;
+}
+
+QsSubmitHandle qs_submit(QuickSubmit &qs, QsCmd &buf) {
+    assert(buf.state == QsCmdState::Recording);
+
+    rhi::end_cmd_buffer(buf.cmd);
+
+    qs.timeline_ctr++;
+    const u64 signal_value = qs.timeline_ctr;
+    qs.timeline_value = signal_value;
+
+    rhi::QueueSignal signal{{qs.timeline, signal_value}};
+    rhi::QueueSubmitDesc desc{};
+    desc.cmd_count = 1;
+    desc.cmds = &buf.cmd;
+    desc.signal_count = 1;
+    desc.signals = &signal;
+
+    rhi::queue_submit(*qs.device, qs.queue, desc);
+
+    buf.state = QsCmdState::Submitted;
+    buf.submitted_value = signal_value;
+    return QsSubmitHandle{signal_value};
+}
+
+void qs_submit_and_wait(QuickSubmit &qs, QsCmd &buf) {
+    QsSubmitHandle h = qs_submit(qs, buf);
+    qs_wait(qs, h);
+}
+
+bool qs_is_ready(QuickSubmit &qs, QsSubmitHandle h) {
+    return rhi::sync_get_completed_value(qs.timeline) >= h.value;
+}
+
+void qs_wait(QuickSubmit &qs, QsSubmitHandle h) {
+    rhi::sync_host_wait(qs.timeline, h.value);
+}
+
+void qs_wait_all(QuickSubmit &qs) {
+    if (qs.timeline_value == 0) {
+        return;
+    }
+
+    const u64 target = qs.timeline_value;
+
+    rhi::sync_host_wait(qs.timeline, target);
+    qs_purge(qs);
+}
ADD · src/quick_submit.h +47 -0
--- a/src/quick_submit.h
+++ b/src/quick_submit.h
@@ -0,0 +1,47 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include "core/globals.h"
+
+#define MAX_QUICK_SUBMIT_BUFFERS 64
+
+enum class QsCmdState : u8 {
+    Free,
+    Recording,
+    Submitted,
+};
+
+struct QsSubmitHandle {
+    u64 value;
+};
+
+struct QsCmd {
+    QsCmdState state = QsCmdState::Free;
+    u32 index;
+    rhi::CmdBuffer cmd;
+    u64 submitted_value;
+};
+
+struct QuickSubmit {
+    rhi::Device *device = nullptr;
+    rhi::Queue queue;
+    rhi::CmdPool pool;
+    QsCmd buffers[MAX_QUICK_SUBMIT_BUFFERS];
+    u32 max_buffer_count = MAX_QUICK_SUBMIT_BUFFERS;
+    u32 next_idx;
+    rhi::Sync *timeline = nullptr;
+    u64 timeline_ctr;
+    u64 timeline_value;
+};
+
+void qs_init(QuickSubmit &qs, rhi::Queue queue, rhi::Device &device);
+void qs_shutdown(QuickSubmit &qs);
+QsCmd *qs_acquire(QuickSubmit &qs);
+
+QsSubmitHandle qs_submit(QuickSubmit &qs, QsCmd &buf);
+
+void qs_submit_and_wait(QuickSubmit &qs, QsCmd &buf);
+void qs_purge(QuickSubmit &qs);
+bool qs_is_ready(QuickSubmit &qs, QsSubmitHandle h);
+void qs_wait(QuickSubmit &qs, QsSubmitHandle h);
+void qs_wait_all(QuickSubmit &qs);
ADD · src/renderer.cpp +1470 -0
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -0,0 +1,1470 @@
+#include "renderer.h"
+
+#include <cmath>
+#include <cstdlib>
+#include <vector>
+
+#include "passes/cluster/cluster_bounds.h"
+#include "passes/cluster/light_cull.h"
+#include "passes/ddgi/ddgi_classify.h"
+#include "passes/ddgi/ddgi_probes_dbg.h"
+#include "passes/ddgi/ddgi_relocate.h"
+#include "passes/ddgi/ddgi_trace.h"
+#include "passes/ddgi/ddgi_update.h"
+#include "passes/debug/debug_lines.h"
+#include "passes/depth_pre/depth_normal.h"
+#include "passes/dispatch_mdi/build_indirect.h"
+#include "passes/fg.h"
+#include "passes/fg_utils.h"
+#include "passes/forward/forward.h"
+#include "passes/fullscreen/fullscreen.h"
+#include "passes/grid/grid.h"
+#include "passes/hiz/hiz.h"
+#include "passes/id_blit/id_blit.h"
+#include "passes/rt_build.h"
+#include "passes/shadow/shadow.h"
+#include "passes/skybox/skybox.h"
+#include "passes/ssr/ssr.h"
+#include "shaders/renderer_types.h"
+
+#define STB_IMAGE_IMPLEMENTATION
+#include <stb_image.h>
+
+#include "asset/asset.h"
+#include "asset/texture.h"
+#include "core/globals.h"
+#include "core/logger.h"
+#include "core/math_rtm.h"
+#include "core/platform.h"
+#include "core/profile.h"
+
+#ifdef ENABLE_EDITOR
+#include "editor/editor.h"
+#endif
+
+#include "pipelines.h"
+#include "quick_submit.h"
+#include "scene/camera.h"
+#include "scene/ibl.h"
+#include "scene/scene.h"
+#include "shaders/renderer_types.h"
+
+struct DefaultTexture {
+    rhi::Image image;
+    rhi::ImageView view{};
+    u32 slot = UINT32_MAX;
+};
+
+struct DefaultTextures {
+    DefaultTexture white_srgb;
+    DefaultTexture white_linear;
+    DefaultTexture black_srgb;
+    DefaultTexture flat_normal;
+    DefaultTexture error;
+};
+
+static void build_ubo(Scene &scene, RenderData &rd, rhi::Device &device, FrameData &frame, rhi::Extent2D &extent) {
+    FrameUBO out{};
+
+    Camera camera = scene.cameras[scene.active_camera];
+
+    out.view = camera.view;
+    out.proj = camera.proj;
+    out.view_proj = camera.view_proj;
+    out.inv_view = camera.inv_view;
+    out.inv_proj = camera.inv_proj;
+    out.inv_view_proj = camera.inv_view_proj;
+    out.position_ws = vec4(camera.position.x, camera.position.y, camera.position.z, 1.0);
+    out.forward_ws = camera.forward();
+    out.near_plane = camera.near_plane;
+    out.far_plane = camera.far_plane;
+
+    out.render_items = rhi::buffer_device_address(device, rd.render_item_buffer);
+    out.submeshes = rhi::buffer_device_address(device, rd.submesh_buffer);
+    out.transforms = rhi::buffer_device_address(device, frame.transform_buffer);
+
+    out.screen_w = extent.width;
+    out.screen_h = extent.height;
+
+    out.materials = rhi::buffer_device_address(device, rd.material_buffer);
+
+    Light light = scene.directional_lights[0];
+    out.light_dir = light.direction;
+    out.light_color = light.color;
+    out.light_intensity = light.intensity;
+
+    out.env = scene.env.environmentIdx;
+    out.env_brdf = scene.env.brdfLutIdx;
+    out.env_irradiance = scene.env.irradianceIdx;
+    out.env_prefiltered = scene.env.prefilteredIdx;
+    out.env_prefilter_mip = scene.env.prefilter_mip_count;
+
+    out.main_light_view_proj = light.view_proj;
+
+    out.point_lights = rhi::buffer_device_address(device, frame.point_light_buffer);
+    out.point_light_count = (u32)scene.point_lights.size();
+    out.tlas_address =
+        rhi::valid(rd.rt_scene.tlas) ? rhi::get_acceleration_structure_device_address(device, rd.rt_scene.tlas) : 0;
+    out.debug = rd.debug;
+
+    out.aniso_wrap_mips = static_cast<u32>(rd.aniso_wrap_mips);
+    out.linear_clamp_mips = static_cast<u32>(rd.linear_clamp_mips);
+    out.linear_clamp = static_cast<u32>(rd.linear_clamp);
+    out.cmp_greater = static_cast<u32>(rd.cmp_greater);
+
+    out.ddgi_grid = rd.ddgi_grid;
+    out.ddgi_cfg = rd.ddgi_cfg;
+
+    memcpy(frame.frame_ubo.mapped, &out, sizeof(out));
+}
+
+static void create_gpu_buffer_and_upload(
+    rhi::Device &device,
+    Arena &staging,
+    rhi::Buffer &out_buffer,
+    const void *data,
+    usize element_count,
+    usize element_stride,
+    QsCmd &cmd,
+    rhi::BufferUsage usage = rhi::BufferUsage::StorageBuffer,
+    const char *name = nullptr
+) {
+    const usize total_size = element_count * element_stride;
+
+    rhi::BufferDesc info = {};
+    info.usage = rhi::BufferUsage::CopyDst | rhi::BufferUsage::ShaderAddr | usage;
+    info.size = total_size;
+    if (name != nullptr) {
+        info.name = name;
+    }
+    rhi::create_buffer(device, info, out_buffer);
+
+    u64 offset = stage_to_arena(staging, data, total_size);
+    if (offset != UINT64_MAX) {
+        rhi::buffer_flush(device, staging.buffer, offset, total_size);
+        rhi::copy_buffer_to_device(device, staging.buffer, offset, out_buffer, 0, total_size, cmd.cmd);
+    }
+}
+
+static void create_frame_data(rhi::Device &device, FrameData *frames, u32 max_transform_count) {
+    constexpr u32 runtime_transform_headroom = 4096;
+
+    u64 ubo_align = device.min_ubo_alignment;
+    if (ubo_align < 16) {
+        ubo_align = 16;
+    }
+
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+        FrameData &frame = frames[i];
+        {
+            // FrameUBO
+            rhi::BufferDesc frame_ubo_desc{};
+            frame_ubo_desc.size = 64 * 1024; //  2 * 1024 * 1024;
+            frame_ubo_desc.usage =
+                rhi::BufferUsage::CopySrc | rhi::BufferUsage::CopyDst | rhi::BufferUsage::UniformBuffer;
+            frame_ubo_desc.memory = rhi::BufferMemType::Upload;
+            frame_ubo_desc.name = ("Frame UBO [" + std::to_string(i) + "]").c_str();
+            rhi::create_buffer(device, frame_ubo_desc, frame.frame_ubo);
+        }
+        {
+            // point lights
+            rhi::BufferDesc pl_buffer_desc{};
+            pl_buffer_desc.size = 64 * 1024; // 2 * 1024 * 1024;
+            pl_buffer_desc.usage = rhi::BufferUsage::CopySrc | rhi::BufferUsage::CopyDst |
+                                   rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr;
+            pl_buffer_desc.memory = rhi::BufferMemType::Upload;
+            pl_buffer_desc.name = ("Point Light Buffer [" + std::to_string(i) + "]").c_str();
+            rhi::create_buffer(device, pl_buffer_desc, frame.point_light_buffer);
+        }
+        {
+            frame.transform_capacity = max_transform_count + runtime_transform_headroom;
+
+            rhi::BufferDesc xform_info{};
+            xform_info.size = frame.transform_capacity * sizeof(TransformGPU);
+            xform_info.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr;
+            xform_info.memory = rhi::BufferMemType::Upload;
+            xform_info.name = "Transform Buffer [" + std::to_string(i) + "]";
+            rhi::create_buffer(device, xform_info, frame.transform_buffer);
+        }
+    }
+}
+
+static void upload_transforms(Scene &scene, FrameData &frame) {
+    TransformGPU *dst = (TransformGPU *)frame.transform_buffer.mapped;
+    const u32 capacity = frame.transform_capacity;
+    SceneGraph &sg = scene.scene_graph;
+
+    for (u32 n : scene.mesh_nodes) {
+        const u32 base = sg.instance_base[n];
+        const u32 ic = sg.instance_count[n];
+
+        if (ic > 0) {
+            for (u32 k = 0; k < ic; ++k) {
+                u32 slot = base + k;
+                if (slot >= capacity) {
+                    break;
+                }
+
+                // instance TRS under the node's own locals under the parent world.
+                mat4 instance_world = scene.instance_world(n, k);
+                dst[slot].active = 1;
+                dst[slot].world = instance_world;
+                dst[slot].normal_world = inverse(instance_world);
+            }
+        } else {
+            if (base >= capacity) {
+                continue;
+            }
+            dst[base].active = sg.is_node_alive(n) ? 1 : 0;
+            dst[base].world = sg.worlds[n];
+            dst[base].normal_world = inverse(sg.worlds[n]);
+        }
+    }
+}
+
+static void upload_scene_data(Scene &scene, FrameData &frame) {
+    upload_transforms(scene, frame);
+
+    u32 pl_count = (u32)std::min(scene.point_lights.size(), (usize)MAX_POINT_LIGHTS);
+    PointLightGPU *pl_dst = (PointLightGPU *)frame.point_light_buffer.mapped;
+    for (u32 i = 0; i < pl_count; ++i) {
+        pl_dst[i].position = scene.point_lights[i].position;
+        pl_dst[i].range = scene.point_lights[i].range;
+        pl_dst[i].color = scene.point_lights[i].color;
+        pl_dst[i].intensity = scene.point_lights[i].intensity;
+    }
+}
+
+static void create_render_data(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    AssetManager &assets,
+    const Scene &scene,
+    RenderData &out,
+    DefaultTextures &default_textures,
+    FrameGraph &fg
+) {
+    const u32 asset_count = assets.count();
+
+    std::vector<u32> submesh_offset(asset_count, 0);
+    std::vector<u32> material_offset(asset_count, 0);
+    u32 total_submeshes = 0;
+    u32 total_materials = 0;
+    for (u32 ai = 0; ai < asset_count; ++ai) {
+        const AssetScene *in = assets.get({ai});
+        submesh_offset[ai] = total_submeshes;
+        material_offset[ai] = total_materials;
+        total_submeshes += (u32)in->submeshes.size();
+        total_materials += (u32)in->materials.size();
+    }
+
+    out.submeshes.resize(total_submeshes);
+
+    for (u32 ai = 0; ai < asset_count; ++ai) {
+        const AssetScene &in = *assets.get({ai});
+        for (usize i = 0; i < in.submeshes.size(); ++i) {
+            const AssetSubmesh &src = in.submeshes[i];
+            const AssetGeometry &geom = in.geometries[src.geometry];
+
+            SubmeshGPU &dst = out.submeshes[submesh_offset[ai] + i];
+            dst.first_index = (u32)out.indices.size();
+            dst.index_count = geom.index_count;
+            dst.base_vertex = (u32)out.vertices.size();
+            dst.local_aabb_min = src.aabb_min;
+            dst.local_aabb_max = src.aabb_max;
+            dst.local_sphere = src.sphere;
+
+            const Vertex *vsrc = in.vertices.data() + geom.first_vertex;
+            out.vertices.insert(out.vertices.end(), vsrc, vsrc + geom.vertex_count);
+
+            const u32 *isrc = in.indices.data() + geom.first_index;
+            out.indices.insert(out.indices.end(), isrc, isrc + geom.index_count);
+        }
+    }
+
+    auto load = [&](const AssetScene &in, u32 tex_idx, ImageColorSpace cs, u64 fallback) -> u64 {
+        if (tex_idx == ASSET_INVALID) {
+            return fallback;
+        }
+        assert(tex_idx < in.textures.size());
+
+        const AssetTexture &tex = in.textures[tex_idx];
+
+        rhi::Image img;
+        rhi::ImageView view{};
+        bool ok = false;
+
+        std::string tex_name = "tex/" + (!tex.path.empty() ? tex.path : ("blob#" + std::to_string(tex_idx)));
+        if (tex.blob && tex.blob_size > 0) {
+            ok = tex.is_ktx ? load_texture_ktx2_from_memory(
+                                  device, qs, out.staging, img, view, tex.blob, tex.blob_size, cs, tex_name.c_str()
+                              )
+                            : load_texture_from_memory(
+                                  device, qs, out.staging, img, view, tex.blob, tex.blob_size, cs, tex_name.c_str()
+                              );
+        } else if (!tex.path.empty()) {
+            ok = load_texture(device, qs, out.staging, tex.path.c_str(), img, view, cs);
+        }
+
+        if (!ok) {
+            return rhi::handle_id(device, default_textures.error.view);
+        }
+
+        const u64 handle = rhi::handle_id(device, view);
+        out.loaded_textures.emplace_back(std::move(img), std::move(view));
+        auto &stored = out.loaded_textures.back();
+        stored.second.desc.image = &stored.first;
+        return handle;
+    };
+
+    out.materials.reserve(std::max<usize>(total_materials, 1));
+    for (u32 ai = 0; ai < asset_count; ++ai) {
+        const AssetScene &in = *assets.get({ai});
+        for (const AssetMaterial &mat : in.materials) {
+            MaterialGPU gpu{};
+            gpu.base_color = mat.base_color;
+            gpu.metallic_factor = mat.metallic;
+            gpu.roughness_factor = mat.roughness;
+            gpu.emissive_factor = mat.emissive;
+            gpu.albedo = load(
+                in, mat.base_color_tex, ImageColorSpace::SRGB, rhi::handle_id(device, default_textures.white_srgb.view)
+            );
+            gpu.normal = load(
+                in, mat.normal_tex, ImageColorSpace::Linear, rhi::handle_id(device, default_textures.flat_normal.view)
+            );
+            gpu.metal_rough = load(
+                in, mat.mr_tex, ImageColorSpace::Linear, rhi::handle_id(device, default_textures.white_linear.view)
+            );
+            gpu.emissive = load(
+                in, mat.emissive_tex, ImageColorSpace::SRGB, rhi::handle_id(device, default_textures.black_srgb.view)
+            );
+            out.materials.push_back(gpu);
+        }
+    }
+    if (out.materials.empty()) {
+        MaterialGPU mat{};
+        mat.base_color = vec4(0.5f, 0.5f, 0.5f, 1.0f);
+        mat.metallic_factor = 0.5f;
+        mat.roughness_factor = 0.5f;
+        mat.emissive_factor = vec3(0.0f, 0.0f, 0.0f);
+        mat.albedo = rhi::handle_id(device, default_textures.white_srgb.view);
+        mat.normal = rhi::handle_id(device, default_textures.flat_normal.view);
+        mat.metal_rough = rhi::handle_id(device, default_textures.white_linear.view);
+        mat.emissive = rhi::handle_id(device, default_textures.black_srgb.view);
+        out.materials.push_back(mat);
+    }
+
+    const SceneGraph &sg = scene.scene_graph;
+    for (u32 n : scene.mesh_nodes) {
+        AssetHandle ah = sg.asset[n];
+        if (!ah.valid()) {
+            continue;
+        }
+
+        const AssetScene *asset = assets.get(ah);
+        if (!asset) {
+            continue;
+        }
+
+        u32 ai = sg.asset_index[n];
+        assert(ai < asset->nodes.size());
+        const AssetNode &node = asset->nodes[ai];
+        if (node.mesh == ASSET_INVALID) {
+            continue;
+        }
+
+        assert(node.mesh < asset->meshes.size());
+        const AssetMesh &mesh = asset->meshes[node.mesh];
+        u32 inst_count = sg.instance_count[n];
+        if (inst_count == 0) {
+            inst_count = 1;
+        }
+        u32 base = sg.instance_base[n];
+        for (u32 si = 0; si < mesh.submesh_count; ++si) {
+            u32 sm_idx = asset->mesh_submeshes[mesh.first_submesh + si];
+            assert(sm_idx < asset->submeshes.size());
+            u32 mat = asset->submeshes[sm_idx].material;
+            u32 material_index = material_offset[ah.id] + ((mat == ASSET_INVALID) ? 0 : mat);
+            u32 submesh_index = submesh_offset[ah.id] + sm_idx;
+
+            for (u32 k = 0; k < inst_count; ++k) {
+                RenderItemGPU item{};
+                item.instance_id = base + k;
+                item.submesh_index = submesh_index;
+                item.material_index = material_index;
+                // +1 so the ID-blit clear value (0) means "no hit"; editor subtracts 1.
+                // I might just get rid of this, and raycast instead
+                item.entity_id = n + 1;
+                out.render_items.push_back(item);
+            }
+        }
+    }
+    out.render_item_count = (u32)out.render_items.size();
+}
+
+static bool create_rt_scene(rhi::Device &device, rhi::CmdBuffer *cmd, RenderData &rd) {
+    RtScene &rt = rd.rt_scene;
+
+    u32 total_verts = (u32)rd.vertices.size();
+    u32 total_indices = (u32)rd.indices.size();
+    if (total_verts == 0 || total_indices == 0 || rd.submeshes.empty()) {
+        VEL_WARN("create_rt_scene: skipped (no vertex/index/submesh data)");
+        return false;
+    }
+
+    u64 vb_addr = rhi::buffer_device_address(device, rd.vertex_buffer);
+    u64 ib_addr = rhi::buffer_device_address(device, rd.index_buffer);
+
+    u32 max_instances = rd.render_item_count;
+
+    rd.mesh_rt.clear();
+    rd.mesh_rt.resize(rd.submeshes.size());
+
+    std::vector<rhi::AccelStructBuildSizesInfo> blas_sizes(rd.submeshes.size());
+    std::vector<u32> primitive_counts(rd.submeshes.size());
+
+    u64 max_blas_scratch_size = 0;
+    auto blas_build_flags = [](bool dynamic) -> rhi::AccelStructBuildFlags {
+        return dynamic ? rhi::AccelStructBuildFlags::AllowUpdate : rhi::AccelStructBuildFlags::PreferFastTrace;
+    };
+
+    for (u32 mesh_id = 0; mesh_id < (u32)rd.submeshes.size(); ++mesh_id) {
+        const SubmeshGPU &submesh = rd.submeshes[mesh_id];
+        primitive_counts[mesh_id] = submesh.index_count / 3;
+        if (primitive_counts[mesh_id] == 0) {
+            continue;
+        }
+
+        MeshRT &mesh_rt = rd.mesh_rt[mesh_id];
+
+        rhi::AccelStructGeometryTrianglesData triangles{
+            .vertex_format = rhi::VertexFormat::R32G32B32_FLOAT,
+            .vertex_data = vb_addr + offsetof(Vertex, pos),
+            .vertex_stride = sizeof(Vertex),
+            .max_vertex = total_verts - 1,
+            .index_type = rhi::IndexType::UINT32,
+            .index_data = ib_addr + (u64)submesh.first_index * sizeof(u32),
+        };
+
+        rhi::AccelStructGeometry as_geom{
+            .type = rhi::AccelStructGeometryType::Triangles,
+            .flags = rhi::AccelStructGeometryFlags::Opaque,
+            .triangles = triangles,
+        };
+
+        rhi::AccelStructBuildGeometryInfo build_info{
+            .type = rhi::AccelStructType::BottomLevel,
+            .flags = blas_build_flags(mesh_rt.dynamic),
+            .geometries = &as_geom,
+            .geometry_count = 1,
+        };
+
+        rhi::get_acceleration_structure_build_sizes(
+            device, build_info, &primitive_counts[mesh_id], blas_sizes[mesh_id]
+        );
+        max_blas_scratch_size = std::max(max_blas_scratch_size, blas_sizes[mesh_id].build_scratch_size);
+    }
+
+    if (max_blas_scratch_size == 0) {
+        VEL_WARN("create_rt_scene: skipped (no BLAS geometry)");
+        return false;
+    }
+
+    u64 tlas_build_scratch_size = 0;
+    if (max_instances > 0) {
+        rhi::AccelStructGeometry tlas_size_geom{
+            .type = rhi::AccelStructGeometryType::Instances,
+            .flags = rhi::AccelStructGeometryFlags::Opaque,
+        };
+        rhi::AccelStructBuildGeometryInfo tlas_size_info{
+            .type = rhi::AccelStructType::TopLevel,
+            .flags = rhi::AccelStructBuildFlags::PreferFastTrace,
+            .geometries = &tlas_size_geom,
+            .geometry_count = 1,
+        };
+        rhi::AccelStructBuildSizesInfo tlas_size_query{};
+        rhi::get_acceleration_structure_build_sizes(device, tlas_size_info, &max_instances, tlas_size_query);
+        tlas_build_scratch_size = tlas_size_query.build_scratch_size;
+    }
+    const u64 scratch_size = std::max(max_blas_scratch_size, tlas_build_scratch_size);
+
+    rhi::BufferDesc scratch_desc{};
+    scratch_desc.size = scratch_size;
+    scratch_desc.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr;
+    scratch_desc.memory = rhi::BufferMemType::Device;
+    scratch_desc.dedicated = true;
+    scratch_desc.name = "rt/accel-scratch";
+    rhi::create_buffer(device, scratch_desc, rt.scratch_buffer);
+    rt.scratch_size = scratch_size;
+    rt.scratch_device_addr = rhi::buffer_device_address(device, rt.scratch_buffer);
+
+    rhi::barrier(*cmd, rd.vertex_buffer, rhi::ResourceState::TransferTo, rhi::ResourceState::AccelBuild);
+    rhi::barrier(*cmd, rd.index_buffer, rhi::ResourceState::TransferTo, rhi::ResourceState::AccelBuild);
+
+    // BLAS: one acceleration structure per submesh
+    for (u32 mesh_id = 0; mesh_id < (u32)rd.submeshes.size(); ++mesh_id) {
+        if (primitive_counts[mesh_id] == 0) {
+            continue;
+        }
+
+        const SubmeshGPU &submesh = rd.submeshes[mesh_id];
+        MeshRT &mesh_rt = rd.mesh_rt[mesh_id];
+
+        rhi::BufferDesc blas_desc{};
+        blas_desc.size = blas_sizes[mesh_id].acceleration_structure_size;
+        blas_desc.usage = rhi::BufferUsage::AccelStructStorage | rhi::BufferUsage::ShaderAddr;
+        blas_desc.memory = rhi::BufferMemType::Device;
+        blas_desc.dedicated = true;
+        blas_desc.name = "rt/blas[submesh#" + std::to_string(mesh_id) + "]";
+        rhi::create_buffer(device, blas_desc, mesh_rt.blas_buffer);
+
+        rhi::create_acceleration_structure(
+            device,
+            {.buffer = &mesh_rt.blas_buffer,
+             .size = blas_sizes[mesh_id].acceleration_structure_size,
+             .type = rhi::AccelStructType::BottomLevel,
+             .name = "rt/blas[submesh#" + std::to_string(mesh_id) + "]"},
+            mesh_rt.blas
+        );
+
+        rhi::AccelStructGeometryTrianglesData triangles{
+            .vertex_format = rhi::VertexFormat::R32G32B32_FLOAT,
+            .vertex_data = vb_addr + offsetof(Vertex, pos),
+            .vertex_stride = sizeof(Vertex),
+            .max_vertex = total_verts - 1,
+            .index_type = rhi::IndexType::UINT32,
+            .index_data = ib_addr + (u64)submesh.first_index * sizeof(u32),
+        };
+
+        rhi::AccelStructGeometry as_geom{
+            .type = rhi::AccelStructGeometryType::Triangles,
+            .flags = rhi::AccelStructGeometryFlags::Opaque,
+            .triangles = triangles,
+        };
+
+        rhi::AccelStructBuildGeometryInfo build_info{
+            .type = rhi::AccelStructType::BottomLevel,
+            .flags = blas_build_flags(mesh_rt.dynamic),
+            .dst_acceleration_structure = &mesh_rt.blas,
+            .geometries = &as_geom,
+            .geometry_count = 1,
+            .scratch_data = rt.scratch_device_addr,
+        };
+
+        rhi::AccelStructBuildRangeInfo range{
+            .primitive_count = primitive_counts[mesh_id],
+            .primitive_offset = 0,
+            .first_vertex = submesh.base_vertex,
+            .transform_offset = 0,
+        };
+
+        const rhi::AccelStructBuildRangeInfo *p_range = &range;
+        rhi::cmd_build_acceleration_structures(*cmd, &build_info, &p_range, 1);
+
+        mesh_rt.blas_device_address = rhi::get_acceleration_structure_device_address(device, mesh_rt.blas);
+
+        if (mesh_id + 1 < (u32)rd.submeshes.size()) {
+            rhi::barrier(*cmd, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelBuild);
+        }
+    }
+    rhi::barrier(*cmd, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelBuild);
+
+    // Instance buffer for per-frame TLAS build (CPU-writable)
+    u64 inst_buf_size = std::max(1u, max_instances) * sizeof(rhi::AccelStructInstance);
+    rhi::BufferDesc inst_desc{};
+    inst_desc.size = inst_buf_size;
+    inst_desc.usage = rhi::BufferUsage::AccelStructBuildInput | rhi::BufferUsage::ShaderAddr;
+    inst_desc.memory = rhi::BufferMemType::Upload;
+    inst_desc.name = "rt/tlas-instances";
+    rhi::create_buffer(device, inst_desc, rt.instance_buffer);
+    rt.instance_buffer_size = inst_buf_size;
+
+    // Instance metadata buffer (GPU-readable)
+    u64 inst_data_size = std::max(1u, max_instances) * sizeof(InstanceData);
+    rhi::BufferDesc inst_data_desc{};
+    inst_data_desc.size = inst_data_size;
+    inst_data_desc.usage = rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr;
+    inst_data_desc.memory = rhi::BufferMemType::Upload;
+    inst_data_desc.name = "rt/instance-data";
+    rhi::create_buffer(device, inst_data_desc, rt.instance_data_buffer);
+
+    // TLAS backing buffer and acceleration structure (pre-allocated, reused every frame)
+    if (max_instances > 0) {
+        u64 inst_dev_addr = rhi::buffer_device_address(device, rt.instance_buffer);
+
+        rhi::AccelStructGeometryInstancesData instances_data{
+            .data = inst_dev_addr,
+            .array_of_pointers = false,
+        };
+        rhi::AccelStructGeometry tlas_geom{
+            .type = rhi::AccelStructGeometryType::Instances,
+            .flags = rhi::AccelStructGeometryFlags::Opaque,
+            .instances = instances_data,
+        };
+
+        rhi::AccelStructBuildGeometryInfo tlas_info{
+            .type = rhi::AccelStructType::TopLevel,
+            .flags = rhi::AccelStructBuildFlags::PreferFastTrace,
+            .geometries = &tlas_geom,
+            .geometry_count = 1,
+        };
+
+        rhi::AccelStructBuildSizesInfo tlas_sizes{};
+        rhi::get_acceleration_structure_build_sizes(device, tlas_info, &max_instances, tlas_sizes);
+
+        rhi::BufferDesc tlas_desc{};
+        tlas_desc.size = tlas_sizes.acceleration_structure_size;
+        tlas_desc.usage = rhi::BufferUsage::AccelStructStorage | rhi::BufferUsage::ShaderAddr;
+        tlas_desc.memory = rhi::BufferMemType::Device;
+        tlas_desc.dedicated = true;
+        tlas_desc.name = "rt/tlas";
+        rhi::create_buffer(device, tlas_desc, rt.tlas_buffer);
+        rt.tlas_buffer_size = tlas_sizes.acceleration_structure_size;
+
+        rhi::create_acceleration_structure(
+            device,
+            {.buffer = &rt.tlas_buffer,
+             .size = tlas_sizes.acceleration_structure_size,
+             .type = rhi::AccelStructType::TopLevel,
+             .name = "rt/tlas"},
+            rt.tlas
+        );
+
+        rhi::barrier(*cmd, rt.tlas_buffer, rhi::ResourceState::Idle, rhi::ResourceState::AccelBuild);
+        {
+            rhi::AccelStructGeometryInstancesData init_instances{
+                .data = inst_dev_addr,
+                .array_of_pointers = false,
+            };
+            rhi::AccelStructGeometry init_geom{
+                .type = rhi::AccelStructGeometryType::Instances,
+                .flags = rhi::AccelStructGeometryFlags::Opaque,
+                .instances = init_instances,
+            };
+            rhi::AccelStructBuildGeometryInfo init_build{
+                .type = rhi::AccelStructType::TopLevel,
+                .flags = rhi::AccelStructBuildFlags::PreferFastTrace,
+                .dst_acceleration_structure = &rt.tlas,
+                .geometries = &init_geom,
+                .geometry_count = 1,
+                .scratch_data = rt.scratch_device_addr,
+            };
+            rhi::AccelStructBuildRangeInfo init_range{
+                .primitive_count = 0,
+                .primitive_offset = 0,
+                .first_vertex = 0,
+                .transform_offset = 0,
+            };
+            const rhi::AccelStructBuildRangeInfo *p_init_range = &init_range;
+            rhi::cmd_build_acceleration_structures(*cmd, &init_build, &p_init_range, 1);
+        }
+        rhi::barrier(*cmd, rhi::ResourceState::AccelBuild, rhi::ResourceState::AccelBuild);
+    }
+
+    // TLAS now BDA via FrameUBO.tlas_address — no descriptor arena
+    return true;
+};
+
+static void destroy_rt_scene(rhi::Device &device, RenderData &rd) {
+    RtScene &rt = rd.rt_scene;
+
+    rhi::destroy_acceleration_structure(device, rt.tlas);
+
+    for (MeshRT &mesh_rt : rd.mesh_rt) {
+        rhi::destroy_acceleration_structure(device, mesh_rt.blas);
+        if (rhi::valid(mesh_rt.blas_buffer)) {
+            rhi::destroy_buffer(device, mesh_rt.blas_buffer);
+            mesh_rt.blas_buffer = {};
+        }
+    }
+    rd.mesh_rt.clear();
+
+    if (rhi::valid(rt.scratch_buffer)) {
+        rhi::destroy_buffer(device, rt.scratch_buffer);
+        rt.scratch_buffer = {};
+    }
+    if (rhi::valid(rt.instance_buffer)) {
+        rhi::destroy_buffer(device, rt.instance_buffer);
+        rt.instance_buffer = {};
+    }
+    if (rhi::valid(rt.instance_data_buffer)) {
+        rhi::destroy_buffer(device, rt.instance_data_buffer);
+        rt.instance_data_buffer = {};
+    }
+    if (rhi::valid(rt.tlas_buffer)) {
+        rhi::destroy_buffer(device, rt.tlas_buffer);
+        rt.tlas_buffer = {};
+    }
+    rt = {};
+}
+
+static void destroy_default_textures(rhi::Device &device, DefaultTextures &tex) {
+    auto destroy = [&](DefaultTexture &t) {
+        rhi::destroy_image_view(device, t.view);
+        rhi::destroy_image(device, t.image);
+    };
+    destroy(tex.white_srgb);
+    destroy(tex.white_linear);
+    destroy(tex.black_srgb);
+    destroy(tex.flat_normal);
+    destroy(tex.error);
+}
+
+static f32 randf(f32 min, f32 max) {
+    return min + (max - min) * (f32(rand()) / f32(RAND_MAX));
+}
+
+static u32 scatter_instances(AssetManager &assets, Scene &scene, AssetHandle ah, u32 count, f32 spread) {
+    const AssetScene *asset = assets.get(ah);
+    if (!asset) {
+        return SCENE_INVALID;
+    }
+
+    u32 base = scene.scene_graph.node_count;
+    u32 root = scene.instantiate(assets, ah);
+    if (root == SCENE_INVALID) {
+        return SCENE_INVALID;
+    }
+
+    // asset_node_index that has the first mesh
+    u32 mesh_asset_node = SCENE_INVALID;
+    for (u32 i = 0; i < (u32)asset->nodes.size(); ++i) {
+        if (asset->nodes[i].mesh != ASSET_INVALID) {
+            mesh_asset_node = i;
+            break;
+        }
+    }
+    if (mesh_asset_node == SCENE_INVALID) {
+        return SCENE_INVALID;
+    }
+
+    u32 mesh_node = base + mesh_asset_node;
+
+    // instance locals
+    u32 offset = (u32)scene.instance_locals.size();
+    scene.instance_locals.reserve(offset + count);
+    for (u32 i = 0; i < count; ++i) {
+        TRS trs;
+        trs.translation = vec3(randf(-spread, spread), randf(-spread, spread), randf(-spread, spread));
+        trs.rotation =
+            quat::from_axis_angle(vec3(randf(-1, 1), randf(-1, 1), randf(-1, 1)).normalized(), randf(0, 6.283f));
+        scene.instance_locals.push_back(trs);
+    }
+
+    SceneGraph &sg = scene.scene_graph;
+    sg.instance_count[mesh_node] = count;
+    sg.instance_base[mesh_node] = offset;
+
+    sg.update_world_transforms();
+    return root;
+}
+
+static void scatter_point_lights(Scene &scene, u32 count) {
+    scene.point_lights.reserve(count);
+    for (u32 i = 0; i < count; ++i) {
+        vec3 pos = {randf(-8.0f, 8.0f), randf(-12.0f, 12.0f), randf(0.2f, 9.5f)};
+        vec3 col = {randf(0.0f, 1.0f), randf(0.0f, 1.0f), randf(0.0f, 1.0f)};
+        NodeHandle pl_node = scene.scene_graph.add_node(-1, TRS{.translation = pos});
+        PointLight pl;
+        pl.node = pl_node;
+        pl.color = col;
+        pl.intensity = 5.0f;
+        pl.range = 2.0f;
+        scene.point_lights.push_back(pl);
+    }
+}
+
+int main() {
+    vel::Logger::init();
+    rhi::Config config{};
+    rhi::ShaderCompiler sc;
+    rhi::Device device{};
+    rhi::Swapchain swapchain{};
+
+    rhi::Sync *frame_sync = nullptr;
+    rhi::CmdPool frame_pools[MAX_FRAMES_IN_FLIGHT]{};
+    rhi::CmdBuffer frame_cmds[MAX_FRAMES_IN_FLIGHT]{};
+
+    FrameGraph fg;
+
+    config.vsync_enabled = true;
+    config.enable_validation = true;
+
+    Platform platform{};
+    QuickSubmit quick_submit;
+
+    init_compiler(sc);
+    init_platform(config.instance_extensions);
+    create_context(device, config);
+    create_memory_allocator(device);
+
+    qs_init(quick_submit, rhi::graphics_queue(device), device);
+
+    platform.width = 1920;
+    platform.height = 1080;
+    create_window(device, platform, "gfx-playground", WindowMode::Windowed, true);
+
+    rhi::SwapchainDesc swapchain_desc{};
+    swapchain_desc.native_window = platform_native_window(platform);
+    swapchain_desc.width = platform.width;
+    swapchain_desc.height = platform.height;
+    swapchain_desc.vsync_enabled = config.vsync_enabled;
+    swapchain_desc.image_count = config.swapchain_image_count;
+    create_swapchain(device, swapchain_desc, swapchain);
+
+    frame_sync = rhi::sync_create(device, 0, "frame");
+    if (!rhi::valid(frame_sync)) {
+        VEL_CRITICAL("Failed to create frame pacing timeline");
+        return 1;
+    }
+
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+
+        rhi::create_cmd_pool(
+            device,
+            rhi::CmdPoolDesc{
+                .queue_family_index = rhi::queue_family_index(rhi::graphics_queue(device)),
+                .flags = rhi::CmdPoolUsage::Transient | rhi::CmdPoolUsage::ResetCommandBuffer,
+            },
+            frame_pools[i]
+        );
+        rhi::CmdBufferDesc cmd_desc;
+        cmd_desc.pool = &frame_pools[i];
+        cmd_desc.level = rhi::CmdBufferLevel::Primary;
+        rhi::create_cmd_buffer(device, cmd_desc, frame_cmds[i]);
+    }
+
+#ifdef ENABLE_EDITOR
+    editor::Editor editor;
+#endif
+    Pipelines pipelines(device, sc);
+    AssetManager assets;
+
+    RenderData render_data{};
+    FrameData frame_data[MAX_FRAMES_IN_FLIGHT]{};
+
+    DefaultTextures textures;
+    Scene scene;
+
+    rhi::Extent2D render_size;
+
+    {
+        NodeHandle cam_node = scene.scene_graph.add_node(
+            -1,
+            TRS{
+                .translation = vec3(-3.6f, -1.2f, 3.7f),
+            }
+        );
+        Camera cam;
+        cam.node = cam_node;
+        scene.cameras.push_back(cam);
+        scene.active_camera = (u32)scene.cameras.size() - 1;
+
+        NodeHandle cam2_node = scene.scene_graph.add_node(
+            -1,
+            TRS{
+                .translation = vec3(5.0f, 5.0f, 5.0f),
+            }
+        );
+        Camera cam2;
+        cam2.node = cam2_node;
+        scene.cameras.push_back(cam2);
+    }
+
+    {
+        vec3 target_dir = vec3(0.2f, 0.2f, 1.0f).normalized();
+        vec3 fwd = vec3(1.0f, 0.0f, 0.0f);
+        vec3 axis = cross(fwd, target_dir).normalized();
+        f32 angle = std::acos(std::clamp(fwd.dot(target_dir), -1.0f, 1.0f));
+
+        NodeHandle light_node = scene.scene_graph.add_node(
+            -1,
+            TRS{
+                .rotation = quat::from_axis_angle(axis, angle),
+            }
+        );
+        Light dl;
+        dl.node = light_node;
+        scene.directional_lights.push_back(dl);
+    }
+
+    fg.device = &device;
+
+    rhi::BufferDesc staging_arena_buffer_desc{};
+    staging_arena_buffer_desc.size = 8ull * 1024 * 1024 * 1024;
+    staging_arena_buffer_desc.usage = rhi::BufferUsage::CopySrc;
+    staging_arena_buffer_desc.memory = rhi::BufferMemType::Upload;
+    staging_arena_buffer_desc.name = "Staging Arena";
+
+    rhi::BufferViewDesc staging_arena_view_desc{};
+    staging_arena_view_desc.type = rhi::BufferViewType::Storage;
+    create_arena(device, render_data.staging, staging_arena_buffer_desc, staging_arena_view_desc);
+
+    {
+        rhi::Sampler shadow_sampler;
+        rhi::SamplerDesc compare_sampler_info;
+        compare_sampler_info.filter = rhi::SamplerFilter::LINEAR;
+        compare_sampler_info.address = rhi::SamplerAddressMode::CLAMP;
+        compare_sampler_info.comparison_func = rhi::SamplerComparisonFunc::GREATER_EQUAL;
+        compare_sampler_info.use_mips = false;
+        compare_sampler_info.name = "samp/shadow-compare";
+        rhi::create_sampler(device, compare_sampler_info, shadow_sampler);
+        render_data.cmp_greater = rhi::handle_id(device, shadow_sampler);
+
+        rhi::Sampler material_sampler;
+        rhi::SamplerDesc linear_sampler_info;
+        linear_sampler_info.filter = rhi::SamplerFilter::ANISOTROPIC;
+        linear_sampler_info.address = rhi::SamplerAddressMode::WRAP;
+        linear_sampler_info.comparison_func = rhi::SamplerComparisonFunc::NEVER;
+        linear_sampler_info.use_mips = true;
+        linear_sampler_info.name = "samp/material-aniso-wrap";
+        rhi::create_sampler(device, linear_sampler_info, material_sampler);
+        render_data.aniso_wrap_mips = rhi::handle_id(device, material_sampler);
+
+        rhi::Sampler atlas_sampler;
+        rhi::SamplerDesc atlas_sampler_info;
+        atlas_sampler_info.filter = rhi::SamplerFilter::LINEAR;
+        atlas_sampler_info.address = rhi::SamplerAddressMode::CLAMP;
+        atlas_sampler_info.comparison_func = rhi::SamplerComparisonFunc::NEVER;
+        atlas_sampler_info.use_mips = false;
+        atlas_sampler_info.name = "samp/atlas-linear-clamp";
+        rhi::create_sampler(device, atlas_sampler_info, atlas_sampler);
+        render_data.linear_clamp = rhi::handle_id(device, atlas_sampler);
+
+        rhi::Sampler linear_mip_sampler;
+        rhi::SamplerDesc linear_mip_info;
+        linear_mip_info.filter = rhi::SamplerFilter::LINEAR;
+        linear_mip_info.address = rhi::SamplerAddressMode::CLAMP;
+        linear_mip_info.comparison_func = rhi::SamplerComparisonFunc::NEVER;
+        linear_mip_info.use_mips = true;
+        linear_mip_info.name = "samp/linear-clamp-mips";
+        rhi::create_sampler(device, linear_mip_info, linear_mip_sampler);
+        render_data.linear_clamp_mips = rhi::handle_id(device, linear_mip_sampler);
+    }
+
+    {
+        auto push_tex = [&](DefaultTexture &dst,
+                            const void *pixels,
+                            u32 pixel_count,
+                            u32 pixel_stride,
+                            rhi::ImageFormat cs,
+                            const char *name) {
+            if (!create_texture_from_raw_rgba(
+                    device,
+                    quick_submit,
+                    render_data.staging,
+                    dst.image,
+                    dst.view,
+                    pixels,
+                    pixel_count,
+                    pixel_count,
+                    pixel_stride,
+                    cs,
+                    name
+                )) {
+                VEL_CRITICAL("Failed to create default texture");
+                return;
+            }
+            dst.slot = (u32)dst.view.slot;
+        };
+
+        u8 white[] = {192, 192, 192, 255};
+        u8 default_metal_rough[] = {0, 128, 128, 255};
+        u8 black[] = {0, 0, 0, 255};
+        u8 error[] = {255, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 0, 255, 255};
+        u8 flat_normal[] = {128, 128, 255, 255};
+
+        push_tex(textures.white_srgb, white, 1, 4, rhi::ImageFormat::RGBA8_SRGB, "tex/default/white-srgb");
+        push_tex(
+            textures.white_linear, default_metal_rough, 1, 4, rhi::ImageFormat::RGBA8_UNORM, "tex/default/white-linear"
+        );
+        push_tex(textures.black_srgb, black, 1, 4, rhi::ImageFormat::RGBA8_SRGB, "tex/default/black");
+        push_tex(textures.flat_normal, flat_normal, 1, 4, rhi::ImageFormat::RGBA8_UNORM, "tex/default/flat-normal");
+        push_tex(textures.error, error, 4, 4, rhi::ImageFormat::RGBA8_SRGB, "tex/default/error");
+    }
+#ifdef ENABLE_EDITOR
+    editor::init(editor, device, platform, quick_submit, render_data.staging, fg, assets);
+    editor::eval_render_size(editor.viewport_width, editor.viewport_height, swapchain, render_size);
+#else
+    render_size = rhi::swapchain_extent(swapchain);
+#endif
+    qs_wait_all(quick_submit);
+    reset_arena(render_data.staging);
+
+    if (!load_texture(
+            device,
+            quick_submit,
+            render_data.staging,
+            "assets/kloofendal_overcast_puresky_4k.hdr",
+            render_data.sky,
+            render_data.sky_view,
+            ImageColorSpace::Linear
+        )) {
+        VEL_ERROR("Failed to load HDR IMAGE, using fallback");
+    }
+    GenerateIBL(device, quick_submit, sc, scene.env, fg, render_data.sky_view, render_data.linear_clamp_mips);
+
+    AssetHandle sponza = assets.load("assets/gltf/Sponza-KTX.glb");
+    AssetHandle helmet = assets.load("assets/gltf/DamagedHelmet.glb");
+
+    u32 sponza_root = scene.instantiate(assets, sponza);
+    u32 helmet_root = scene.instantiate(assets, helmet);
+
+    // scatter_instances(assets, scene, helmet, 5000, 100.0f);
+    // scatter_point_lights(scene, 512);
+    // scene.scene_graph.set_scale(helmet_root, vec3(50.0, 50.0, 50.0f));
+    // scene.scene_graph.set_translation(helmet_root, vec3(0.0, 0.0, -1200.0f));
+    // scene.scene_graph.update_world_transforms();
+
+    create_render_data(device, quick_submit, assets, scene, render_data, textures, fg);
+    create_frame_data(device, frame_data, (u32)scene.instance_locals.size());
+
+    VEL_INFO("node_count={}, render_items={}", scene.scene_graph.node_count, render_data.render_items.size());
+    render_data.scene_graph = &scene.scene_graph;
+
+    upload_transforms(scene, frame_data[0]);
+
+    QsCmd *cmd = qs_acquire(quick_submit);
+    create_gpu_buffer_and_upload(
+        device,
+        render_data.staging,
+        render_data.vertex_buffer,
+        render_data.vertices.data(),
+        render_data.vertices.size(),
+        sizeof(Vertex),
+        *cmd,
+        rhi::BufferUsage::VertexBuffer | rhi::BufferUsage::StorageBuffer | rhi::BufferUsage::ShaderAddr |
+            rhi::BufferUsage::AccelStructBuildInput,
+        "buf/scene-vertices"
+    );
+    create_gpu_buffer_and_upload(
+        device,
+        render_data.staging,
+        render_data.index_buffer,
+        render_data.indices.data(),
+        render_data.indices.size(),
+        sizeof(u32),
+        *cmd,
+        rhi::BufferUsage::IndexBuffer | rhi::BufferUsage::AccelStructBuildInput,
+        "buf/scene-indices"
+    );
+    create_gpu_buffer_and_upload(
+        device,
+        render_data.staging,
+        render_data.submesh_buffer,
+        render_data.submeshes.data(),
+        render_data.submeshes.size(),
+        sizeof(SubmeshGPU),
+        *cmd,
+        rhi::BufferUsage::StorageBuffer,
+        "buf/scene-submeshes"
+    );
+    create_gpu_buffer_and_upload(
+        device,
+        render_data.staging,
+        render_data.material_buffer,
+        render_data.materials.data(),
+        render_data.materials.size(),
+        sizeof(MaterialGPU),
+        *cmd,
+        rhi::BufferUsage::StorageBuffer,
+        "buf/scene-materials"
+    );
+    create_gpu_buffer_and_upload(
+        device,
+        render_data.staging,
+        render_data.render_item_buffer,
+        render_data.render_items.data(),
+        render_data.render_items.size(),
+        sizeof(RenderItemGPU),
+        *cmd,
+        rhi::BufferUsage::StorageBuffer,
+        "buf/scene-render-items"
+    );
+    qs_submit(quick_submit, *cmd);
+    reset_arena(render_data.staging);
+
+    render_data.vertex_bda = rhi::buffer_device_address(device, render_data.vertex_buffer);
+    render_data.index_bda = rhi::buffer_device_address(device, render_data.index_buffer);
+
+    {
+        if (!rhi::create_buffer_view(
+                device,
+                {.buffer = &render_data.vertex_buffer, .type = rhi::BufferViewType::Storage},
+                render_data.vertex_view
+            )) {
+            VEL_CRITICAL("Failed to create vertex buffer view");
+        }
+        for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+            if (!rhi::create_buffer_view(
+                    device,
+                    {.buffer = &frame_data[i].frame_ubo, .type = rhi::BufferViewType::Uniform},
+                    render_data.frame_ubo_view[i]
+                )) {
+                VEL_CRITICAL("Failed to create frame UBO view");
+            }
+        }
+    }
+    u64 frame_count = 0;
+
+    PassTimings pass_timings;
+
+    u32 cascade_sizes[Light::CASCADE_COUNT] = {};
+    resolve_cascade_sizes(render_data.cascade_size, cascade_sizes);
+
+    u32 render_item_count = (u32)render_data.render_items.size();
+
+    BufferHandle render_items_buf = fg.import_buffer(&render_data.render_item_buffer);
+    BufferHandle submesh_buf = fg.import_buffer(&render_data.submesh_buffer);
+
+    ImageHandle env_cubemap = fg.import_image(&scene.env.environment_img, rhi::ResourceState::TextureSample);
+    // should handle this better instead of forcing some initial state?
+    scene.env.environment_img.state = rhi::ResourceState::TextureSample;
+
+    auto hiz_res = hiz::create(fg);
+    auto ddgi_res = ddgi_trace::create(fg);
+    render_data.ddgi_grid = ddgi_res.grid;
+    render_data.ddgi_cfg = ddgi_res.cfg;
+    auto main_bd = build_indirect::create(fg, render_item_count, "main");
+    auto shadow_bd = build_indirect::create(fg, render_item_count, "shadow");
+
+    build_indirect::record(
+        device, pipelines, sc, fg, render_items_buf, submesh_buf, main_bd, hiz_res.hiz, true, "Main Build Indirect"
+    );
+    build_indirect::record(
+        device,
+        pipelines,
+        sc,
+        fg,
+        render_items_buf,
+        submesh_buf,
+        shadow_bd,
+        ImageHandle{},
+        false,
+        "Shadow Build Indirect"
+    );
+    auto shadow_map = shadow::record(
+        device, pipelines, sc, fg, shadow_bd.indirect, shadow_bd.draw_count, shadow_bd.visible, cascade_sizes
+    );
+    auto dn = depth_normal::record(device, pipelines, sc, fg, main_bd.indirect, main_bd.draw_count, main_bd.visible);
+    auto clusters = cluster_bounds::record(device, pipelines, sc, fg, swapchain.extent.width, swapchain.extent.height);
+    auto light_cull = light_cull::record(device, pipelines, sc, fg, clusters.cluster_bounds, clusters.cluster_records);
+    auto forward = forward::record(
+        device,
+        pipelines,
+        sc,
+        fg,
+        main_bd.indirect,
+        main_bd.draw_count,
+        main_bd.visible,
+        shadow_map.cascade,
+        clusters.cluster_bounds,
+        clusters.cluster_records,
+        light_cull.light_index_list,
+        ddgi_res,
+        dn.depth
+    );
+
+    { // ddgi (deegee)
+        QsCmd *cmd = qs_acquire(quick_submit);
+        create_rt_scene(device, &cmd->cmd, render_data);
+        qs_submit(quick_submit, *cmd);
+        qs_wait_all(quick_submit);
+
+        BufferHandle tlas_buf = fg.import_buffer(&render_data.rt_scene.tlas_buffer, rhi::ResourceState::AccelBuild);
+        rt_build::record(fg, tlas_buf);
+
+        ddgi_trace::record(device, pipelines, sc, fg, ddgi_res, env_cubemap, tlas_buf);
+
+        rhi::ComputePipelineDesc ddgi_update_irr;
+        ddgi_update_irr.device = &device;
+        ddgi_update_irr.set_shader(sc, "src/passes/ddgi/ddgi_update_irradiance.slang", "csMain");
+        pipelines.add_compute("DdgiUpdateIrr", ddgi_update_irr);
+        ddgi_update::record(
+            fg, ddgi_res, ddgi_res.irradiance_img, pipelines.get_compute("DdgiUpdateIrr"), "Ddgi Update Irradiance"
+        );
+
+        rhi::ComputePipelineDesc ddgi_update_dist;
+        ddgi_update_dist.device = &device;
+        ddgi_update_dist.set_shader(sc, "src/passes/ddgi/ddgi_update_distance.slang", "csMain");
+        pipelines.add_compute("DdgiUpdateDist", ddgi_update_dist);
+        ddgi_update::record(
+            fg, ddgi_res, ddgi_res.distance_img, pipelines.get_compute("DdgiUpdateDist"), "Ddgi Update Distance"
+        );
+
+        // NOTE: silently ordered, relocate writes the probe offset, then classify
+        // reads that offset and the fixed-ray backface ratio to ease the probe state
+        ddgi_relocate::record(device, pipelines, sc, fg, ddgi_res);
+
+        ddgi_classify::record(device, pipelines, sc, fg, ddgi_res);
+
+        ddgi_probes::record(device, pipelines, sc, fg, forward.hdr, forward.depth, ddgi_res, &render_data.debug);
+    }
+
+    hiz::record(device, pipelines, sc, fg, hiz_res, forward.depth);
+    // ssr::record(device, pipelines, sc, fg, ssr_res, forward.hdr, dn.depth, dn.normal, hiz_res.hiz);
+    skybox::record(device, pipelines, sc, fg, forward.hdr, forward.depth, env_cubemap);
+    grid::record(device, pipelines, sc, fg, forward.hdr, forward.depth);
+
+#ifdef ENABLE_EDITOR
+    debug_lines::record(
+        device, pipelines, sc, fg, forward.hdr, forward.depth, debug_lines::Settings{.draw = &render_data.debug_draw}
+    );
+
+    ImageHandle display_target =
+        fg.add_image({.desc = {.format = rhi::swapchain_format(swapchain)}, .name = "fg/present/display"});
+    ImageHandle id_blit_target = id_blit::record(
+        device, pipelines, sc, fg, main_bd.indirect, main_bd.draw_count, main_bd.visible, forward.depth
+    );
+#endif
+
+    ImageHandle swapchain_target = fg.import_image(rhi::swapchain_image(swapchain, 0), rhi::ResourceState::ColorDraw);
+
+    fullscreen_fg::record(
+        device,
+        pipelines,
+        sc,
+        fg,
+        forward.hdr,
+        forward.depth,
+        rhi::swapchain_format(swapchain),
+#ifdef ENABLE_EDITOR
+        display_target
+#else
+        swapchain_target
+#endif
+        // , ssr_res.output
+    );
+
+#ifdef ENABLE_EDITOR
+    editor::PresentTargets present_targets{};
+    present_targets.display = display_target;
+    present_targets.id_blit = id_blit_target;
+    present_targets.irradiance = ddgi_res.irradiance_img;
+    present_targets.distance = ddgi_res.distance_img;
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        present_targets.cascade[i] = shadow_map.cascade[i];
+    }
+    present_targets.swapchain = swapchain_target;
+    editor::record_present(editor, pipelines, sc, fg, swapchain, present_targets, pass_timings);
+#endif
+
+    fg.compile(device, render_size);
+
+#ifdef ENABLE_EDITOR
+    pass_timings.enable(fg, device, MAX_FRAMES_IN_FLIGHT);
+#endif
+
+    while (platform_update(platform)) {
+        VEL_PROFILE_FRAME();
+
+        render_data.frame_stats.record((f32)(platform.raw_dt * 1000.0));
+
+        const u32 frame_slot = frame_count % MAX_FRAMES_IN_FLIGHT;
+        const u64 frame_wait_value =
+            (frame_count + 1 > MAX_FRAMES_IN_FLIGHT) ? (frame_count + 1 - MAX_FRAMES_IN_FLIGHT) : 0;
+
+        if (frame_wait_value != 0 && !rhi::sync_host_wait(frame_sync, frame_wait_value)) {
+            // GPU wedged (device lost / timeout)
+            VEL_CRITICAL("FRAME SYNC WAIT MISS");
+            rhi::device_wait_idle(device);
+        }
+
+        FrameData &frame = frame_data[frame_slot];
+
+        bool recreate_swap = platform.framebuffer_resized || rhi::swapchain_needs_recreate(swapchain);
+        platform.framebuffer_resized = false;
+
+        if (recreate_swap) {
+            if (!platform_wait_for_valid_framebuffer(platform)) {
+                continue;
+            }
+            rhi::queue_wait_idle(device);
+            destroy_swapchain(device, swapchain);
+            rhi::SwapchainDesc swapchain_desc{};
+            swapchain_desc.native_window = platform_native_window(platform);
+            swapchain_desc.width = platform.width;
+            swapchain_desc.height = platform.height;
+            swapchain_desc.vsync_enabled = config.vsync_enabled;
+            swapchain_desc.image_count = config.swapchain_image_count;
+            create_swapchain(device, swapchain_desc, swapchain);
+
+#ifdef ENABLE_EDITOR
+            editor::eval_render_size(editor.viewport_width, editor.viewport_height, swapchain, render_size);
+#else
+            render_size = rhi::swapchain_extent(swapchain);
+#endif
+
+            fg.overwrite_imported_image(swapchain_target, rhi::swapchain_image(swapchain, 0));
+            fg.compile(device, render_size);
+
+            Camera &cam = scene.cameras[scene.active_camera];
+            cam.aspect = static_cast<f32>(render_size.width) / static_cast<f32>(render_size.height);
+
+            rhi::Extent2D sc_extent = rhi::swapchain_extent(swapchain);
+            platform.width = sc_extent.width;
+            platform.height = sc_extent.height;
+
+            continue;
+        }
+
+#ifdef ENABLE_EDITOR
+        editor::handle_frame_begin(
+            editor,
+            render_data,
+            device,
+            swapchain,
+            fg,
+            swapchain_target,
+            render_size,
+            scene,
+            pipelines,
+            pass_timings,
+            frame_slot
+        );
+#endif
+        Camera &cam = scene.cameras[scene.active_camera];
+        cam.position = scene.scene_graph.translations[cam.node];
+        cam.aspect = static_cast<f32>(render_size.width) / static_cast<f32>(render_size.height);
+        cam.aspect = static_cast<f32>(render_size.width) / static_cast<f32>(render_size.height);
+        update_camera(cam, platform.input);
+        scene.scene_graph.set_translation(cam.node, cam.position);
+
+        update_light(scene.directional_lights[0], scene.cameras[scene.active_camera]);
+        update_light_cascades(scene.directional_lights[0], scene.cameras[scene.active_camera], cascade_sizes);
+
+        build_ubo(scene, render_data, device, frame, render_size);
+
+        scene.evaluate();
+        upload_scene_data(scene, frame);
+
+#ifdef ENABLE_EDITOR
+        render_data.debug_draw.clear();
+        editor::apply_debug_settings(editor, render_data.debug_draw);
+        if (editor.show_debug_lines) {
+            ddgi_trace::debug_draw(render_data.debug_draw, render_data);
+            editor::debug_draw_selection(render_data.debug_draw, scene, render_data, editor.selected_node);
+            editor::update_translate_gizmo(editor, scene, render_data.debug_draw);
+        }
+#endif
+
+        rhi::reset_cmd_pool(device, frame_pools[frame_slot]);
+
+        rhi::begin_cmd_buffer(
+            frame_cmds[frame_slot], rhi::CmdBufferBeginDesc{.usage = rhi::CmdBufferUsage::OneTimeSubmit}
+        );
+
+        u32 image_index;
+        if (!rhi::acquire_swapchain_image(device, swapchain, image_index, frame_cmds[frame_slot])) {
+            rhi::reset_cmd_buffer(frame_cmds[frame_slot]);
+            continue;
+        }
+
+        rhi::Image &swap_image = *rhi::swapchain_image(swapchain, image_index);
+        fg.overwrite_imported_image(swapchain_target, &swap_image);
+
+        fg.execute(
+            frame_cmds[frame_slot],
+            GraphExecInfo{
+                .frame_data = frame_data,
+                .render_data = &render_data,
+                .scene = &scene,
+                .frame_index = frame_slot,
+                .frame_count = frame_count,
+            }
+        );
+
+        {
+            rhi::ImageRange range{};
+            rhi::barrier(frame_cmds[frame_slot], swap_image, range, swap_image.state, rhi::ResourceState::Display);
+        }
+
+        rhi::end_cmd_buffer(frame_cmds[frame_slot]);
+
+        rhi::QueueSignal frame_signal{{frame_sync, frame_count + 1}};
+        rhi::QueueSubmitDesc submit_desc{};
+        submit_desc.cmd_count = 1;
+        submit_desc.cmds = &frame_cmds[frame_slot];
+        submit_desc.signal_count = 1;
+        submit_desc.signals = &frame_signal;
+        rhi::queue_submit(device, rhi::graphics_queue(device), submit_desc);
+        rhi::present_swapchain(device, swapchain, image_index, {frame_sync, frame_count + 1});
+        frame_count++;
+    }
+    rhi::device_wait_idle(device);
+#ifdef ENABLE_EDITOR
+    pass_timings.destroy(device);
+#endif
+    fg.destroy();
+
+#ifdef ENABLE_EDITOR
+    editor::shutdown(editor, device);
+#endif
+    destroy_rt_scene(device, render_data);
+    pipelines.clear();
+    destroy_default_textures(device, textures);
+    rhi::destroy_image_view(device, render_data.sky_view);
+    rhi::destroy_image(device, render_data.sky);
+    rhi::sync_destroy(frame_sync);
+    frame_sync = nullptr;
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+        rhi::destroy_cmd_buffer(device, frame_pools[i], frame_cmds[i]);
+        rhi::destroy_cmd_pool(device, frame_pools[i]);
+    }
+    destroy_swapchain(device, swapchain);
+    qs_shutdown(quick_submit);
+
+    auto destroy_buf = [&](rhi::Buffer &b) {
+        if (rhi::valid(b)) {
+            rhi::destroy_buffer(device, b);
+        }
+    };
+    auto destroy_img = [&](rhi::Image &i) {
+        if (rhi::valid(i)) {
+            rhi::destroy_image(device, i);
+        }
+    };
+    auto destroy_iv = [&](rhi::ImageView &v) {
+        if (rhi::valid(v)) {
+            rhi::destroy_image_view(device, v);
+        }
+    };
+    auto destroy_view = [&](rhi::ImageView &v) { rhi::destroy_image_view(device, v); };
+
+    destroy_view(scene.env.environment_view);
+    destroy_img(scene.env.environment_img);
+    destroy_view(scene.env.irradiance_view);
+    destroy_img(scene.env.irradiance_img);
+    destroy_view(scene.env.prefiltered_view);
+    destroy_img(scene.env.prefiltered_img);
+    destroy_view(scene.env.brdf_lut_view);
+    destroy_img(scene.env.brdf_lut_img);
+
+    for (auto &[img, view] : render_data.loaded_textures) {
+        destroy_iv(view);
+        destroy_img(img);
+    }
+    render_data.loaded_textures.clear();
+
+    rhi::destroy_buffer_view(device, render_data.vertex_view);
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
+        rhi::destroy_buffer_view(device, render_data.frame_ubo_view[i]);
+    }
+    destroy_buf(render_data.vertex_buffer);
+    destroy_buf(render_data.index_buffer);
+    destroy_buf(render_data.submesh_buffer);
+    destroy_buf(render_data.material_buffer);
+    destroy_buf(render_data.render_item_buffer);
+
+    for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) {
+        destroy_buf(frame_data[i].frame_ubo);
+        destroy_buf(frame_data[i].point_light_buffer);
+        destroy_buf(frame_data[i].transform_buffer);
+    }
+
+    destroy_arena(device, render_data.staging);
+    destroy_memory_allocator(device);
+    destroy_window(device, platform);
+    vel::Logger::shutdown();
+    return 0;
+}
ADD · src/renderer.h +97 -0
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -0,0 +1,97 @@
+#pragma once
+
+#include <cstdint>
+#include <vector>
+
+#include "backend/rhi.h"
+#include "core/frame_stats.h"
+#include "core/globals.h"
+#include "core/gpu_arena.h"
+#include "passes/debug/debug_draw.h"
+#include "scene/scene.h"
+#include "shaders/renderer_types.h"
+
+struct SceneGraph;
+
+struct MeshRT {
+    rhi::Buffer blas_buffer;
+    rhi::AccelStruct blas{};
+    u64 blas_device_address = 0;
+    bool dynamic = false;
+};
+
+struct RtScene {
+    rhi::AccelStruct tlas{};
+
+    rhi::Buffer scratch_buffer;
+    u64 scratch_device_addr = 0;
+    u64 scratch_size = 0;
+    rhi::Buffer tlas_buffer;
+    u64 tlas_buffer_size = 0;
+    rhi::Buffer instance_buffer;
+    u64 instance_buffer_size = 0;
+    rhi::Buffer instance_data_buffer;
+};
+
+constexpr rhi::SampleCount MSAA_SAMPLE_COUNT = rhi::SampleCount::Sample1;
+
+struct RenderData {
+    u64 vertex_bda = 0;
+    u64 index_bda = 0;
+
+    u64 aniso_wrap_mips = 0;
+    u64 linear_clamp_mips = 0;
+    u64 linear_clamp = 0;
+    u64 cmp_greater = 0;
+
+    rhi::BufferView vertex_view{};
+    rhi::BufferView frame_ubo_view[MAX_FRAMES_IN_FLIGHT]{};
+    u32 render_item_count = 0;
+
+    FrameStats frame_stats;
+
+    Arena staging;
+
+    std::vector<Vertex> vertices;
+    std::vector<u32> indices;
+    std::vector<SubmeshGPU> submeshes;
+    std::vector<MeshRT> mesh_rt;
+    std::vector<MaterialGPU> materials;
+    std::vector<RenderItemGPU> render_items;
+
+    rhi::Buffer vertex_buffer;
+    rhi::Buffer index_buffer;
+    rhi::Buffer submesh_buffer;
+    rhi::Buffer material_buffer;
+    rhi::Buffer render_item_buffer;
+
+    RtScene rt_scene;
+
+    rhi::Image display;
+    rhi::Image irr_atlas;
+    rhi::Image dis_atlas;
+    rhi::Image sky;
+    rhi::ImageView sky_view;
+    rhi::Image cascade[Light::CASCADE_COUNT];
+    rhi::Image id_blit;
+
+    u32 cascade_size = 2048;
+
+    std::vector<std::pair<rhi::Image, rhi::ImageView>> loaded_textures;
+
+    DdgiGridParams ddgi_grid{};
+    DdgiConfig ddgi_cfg{};
+
+    DebugViewMode debug = DebugViewMode::NONE;
+    DebugDraw debug_draw;
+    SceneGraph *scene_graph = nullptr;
+};
+
+struct FrameData {
+    rhi::Buffer frame_ubo;
+
+    rhi::Buffer point_light_buffer;
+
+    rhi::Buffer transform_buffer;
+    u32 transform_capacity = 0;
+};
ADD · src/scene/camera.h +94 -0
--- a/src/scene/camera.h
+++ b/src/scene/camera.h
@@ -0,0 +1,94 @@
+#pragma once
+
+#include <algorithm>
+
+#include "core/globals.h"
+#include "core/platform.h"
+#include "shaders/renderer_types.h"
+
+using NodeHandle = u32;
+constexpr NodeHandle NODE_INVALID = 0xffffffffu;
+
+struct Camera {
+    NodeHandle node = NODE_INVALID;
+
+    vec3 position = vec3(0.0f, 0.0f, 3.0f);
+
+    f32 aspect = 0;
+
+    // Degrees
+    f32 yaw_deg = 0.0f; // -Z forward
+    f32 pitch_deg = 0.0f;
+
+    f32 fov_y_deg = 60.0f;
+    f32 near_plane = 0.01f;
+    f32 far_plane = 1000.0f;
+
+    f32 move_speed = 10.0f;
+    f32 fast_multiplier = 5.0f;
+    f32 look_sensitivity = 0.10f; // deg per pixel
+
+    static constexpr f32 DEG_TO_RAD = 0.017453292519943295769f;
+
+    vec3 forward() const {
+        f32 yaw = yaw_deg * DEG_TO_RAD;
+        f32 pitch = pitch_deg * DEG_TO_RAD;
+        vec3 fwd;
+        fwd.x = std::cos(yaw) * std::cos(pitch);
+        fwd.y = std::sin(yaw) * std::cos(pitch);
+        fwd.z = std::sin(pitch);
+        return fwd.normalized();
+    }
+
+    vec3 right() const {
+        return cross(forward(), vec3(0.0f, 0.0f, 1.0f)).normalized();
+    }
+
+    vec3 up() const {
+        return cross(right(), forward()).normalized();
+    }
+
+    mat4 view;
+    mat4 proj;
+    mat4 view_proj;
+    mat4 inv_view;
+    mat4 inv_proj;
+    mat4 inv_view_proj;
+};
+
+static void update_camera(Camera &camera, PlatformInput &input) {
+    camera.yaw_deg -= input.mouse_dx * camera.look_sensitivity;
+    camera.pitch_deg -= input.mouse_dy * camera.look_sensitivity;
+    camera.pitch_deg = std::clamp(camera.pitch_deg, -89.0f, 89.0f);
+
+    vec3 move_dir(0.0f);
+    if (input.move_forward)
+        move_dir += camera.forward();
+    if (input.move_backward)
+        move_dir -= camera.forward();
+    if (input.move_right)
+        move_dir += camera.right();
+    if (input.move_left)
+        move_dir -= camera.right();
+    if (input.move_up)
+        move_dir += vec3(0.0f, 0.0f, 1.0f);
+    if (input.move_down)
+        move_dir -= vec3(0.0f, 0.0f, 1.0f);
+
+    if (move_dir.dot(move_dir) > 0.0f)
+        move_dir = move_dir.normalized();
+
+    f32 speed = camera.move_speed;
+    if (input.fast)
+        speed *= camera.fast_multiplier;
+
+    camera.position += move_dir * speed * input.dt;
+
+    vec3 upv = vec3(0.0f, 0.0f, 1.0f);
+    camera.view = look_at(camera.position, camera.position + camera.forward(), upv);
+    camera.proj = perspective(radians(camera.fov_y_deg), camera.aspect, camera.near_plane);
+    camera.view_proj = camera.view * camera.proj;
+    camera.inv_view = inverse(camera.view);
+    camera.inv_proj = inverse(camera.proj);
+    camera.inv_view_proj = inverse(camera.view_proj);
+}
ADD · src/scene/ibl.cpp +450 -0
--- a/src/scene/ibl.cpp
+++ b/src/scene/ibl.cpp
@@ -0,0 +1,450 @@
+#include "ibl.h"
+
+#include <array>
+#include <cstring>
+
+#include "core/globals.h"
+#include "passes/fg.h"
+#include "quick_submit.h"
+#include "shaders/renderer_types.h"
+
+static void transition_whole(rhi::CmdBuffer &cmd, rhi::Image &img, rhi::ResourceState after) {
+    if (img.state == after) {
+        return;
+    }
+    rhi::ImageRange range{};
+    rhi::barrier(cmd, img, range, img.state, after);
+}
+
+static void barrier_mip_layers(
+    rhi::CmdBuffer &cmd, rhi::Image &img, u32 mip, u32 layers, rhi::ResourceState before, rhi::ResourceState after
+) {
+    rhi::ImageRange range{};
+    range.mip = mip;
+    range.mip_count = 1;
+    range.layer_count = layers;
+    rhi::barrier(cmd, img, range, before, after);
+}
+
+static void push_ibl_constants(rhi::CmdBuffer &cmd, rhi::RenderPipeline &pipeline, const IblConstants &pc) {
+    static_assert(sizeof(pc) <= 128, "IblConstants exceeds global push-constant range");
+    char buf[128] = {};
+    std::memcpy(buf, &pc, sizeof(pc));
+    rhi::set_constants(cmd, pipeline, rhi::ShaderStage::ALL, sizeof(buf), buf);
+}
+
+constexpr u32 ibl_floor_log2(u32 v) {
+    return v <= 1 ? 0 : 1 + ibl_floor_log2(v >> 1);
+}
+constexpr u32 ibl_mip_count(u32 size) {
+    return 1 + ibl_floor_log2(size);
+}
+
+constexpr u32 ENV_SIZE = 2048;
+constexpr u32 ENV_MIP_COUNT = ibl_mip_count(ENV_SIZE);
+constexpr u32 IBL_IRRADIANCE_SIZE = 16;
+constexpr u32 PREFILTER_SIZE = 256;
+constexpr u32 PREFILTER_MIPS = ibl_mip_count(PREFILTER_SIZE);
+constexpr u32 BRDF_LUT_SIZE = 512;
+
+void GenerateIBL(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    rhi::ShaderCompiler &sc,
+    EnvMap &map,
+    FrameGraph & /*fg*/,
+    rhi::ImageView &hdr_view,
+    u64 samp_linear_clamp
+) {
+    // Environment cubemap
+    {
+        rhi::ImageDesc env_img_desc = {
+            .width = ENV_SIZE,
+            .height = ENV_SIZE,
+            .depth = 1,
+            .mip_levels = ENV_MIP_COUNT,
+            .layers = 6,
+            .is_cubemap = true,
+            .format = rhi::ImageFormat::RGBA16_FLOAT,
+            .usage = rhi::ImageUsage::ColorAttachment | rhi::ImageUsage::Sampled | rhi::ImageUsage::TransferSrc |
+                     rhi::ImageUsage::TransferDst,
+            .name = "ibl/environment",
+        };
+        rhi::create_image(device, env_img_desc, map.environment_img);
+
+        rhi::ImageViewDesc env_img_view_desc = {
+            .image = &map.environment_img,
+            .dimension = rhi::TextureViewDimension::TEXTURE_CUBE,
+            .mip_start = 0,
+            .mip_count = ENV_MIP_COUNT,
+            .layer_start = 0,
+            .layer_count = 6
+        };
+        rhi::create_image_view(device, env_img_view_desc, map.environment_view);
+    }
+
+    // Irradiance cubemap
+    {
+        rhi::ImageDesc irradiance_img_desc = {
+            .width = IBL_IRRADIANCE_SIZE,
+            .height = IBL_IRRADIANCE_SIZE,
+            .depth = 1,
+            .mip_levels = 1,
+            .layers = 6,
+            .is_cubemap = true,
+            .format = rhi::ImageFormat::RGBA16_FLOAT,
+            .usage = rhi::ImageUsage::ColorAttachment | rhi::ImageUsage::Sampled,
+            .name = "ibl/irradiance",
+        };
+        rhi::create_image(device, irradiance_img_desc, map.irradiance_img);
+
+        rhi::ImageViewDesc irradiance_img_view_desc = {
+            .image = &map.irradiance_img,
+            .dimension = rhi::TextureViewDimension::TEXTURE_CUBE,
+            .mip_start = 0,
+            .mip_count = 1,
+            .layer_start = 0,
+            .layer_count = 6,
+        };
+        rhi::create_image_view(device, irradiance_img_view_desc, map.irradiance_view);
+    }
+
+    // Prefilter cubemap
+    {
+        rhi::ImageDesc prefiltered_img_desc = {
+            .width = PREFILTER_SIZE,
+            .height = PREFILTER_SIZE,
+            .depth = 1,
+            .mip_levels = PREFILTER_MIPS,
+            .layers = 6,
+            .is_cubemap = true,
+            .format = rhi::ImageFormat::RGBA16_FLOAT,
+            .usage = rhi::ImageUsage::ColorAttachment | rhi::ImageUsage::Sampled,
+            .name = "ibl/prefiltered",
+        };
+        rhi::create_image(device, prefiltered_img_desc, map.prefiltered_img);
+        map.prefilter_mip_count = PREFILTER_MIPS;
+
+        rhi::ImageViewDesc prefiltered_img_view_desc = {
+            .image = &map.prefiltered_img,
+            .dimension = rhi::TextureViewDimension::TEXTURE_CUBE,
+            .mip_start = 0,
+            .mip_count = PREFILTER_MIPS,
+            .layer_start = 0,
+            .layer_count = 6
+        };
+        rhi::create_image_view(device, prefiltered_img_view_desc, map.prefiltered_view);
+    }
+
+    // BRDF LUT
+    {
+        rhi::ImageDesc brdf_lut_desc = {
+            .width = BRDF_LUT_SIZE,
+            .height = BRDF_LUT_SIZE,
+            .depth = 1,
+            .mip_levels = 1,
+            .layers = 1,
+            .format = rhi::ImageFormat::RGBA16_FLOAT,
+            .usage = rhi::ImageUsage::ColorAttachment | rhi::ImageUsage::Sampled,
+            .name = "ibl/brdf-lut",
+        };
+        rhi::create_image(device, brdf_lut_desc, map.brdf_lut_img);
+
+        rhi::ImageViewDesc brdf_lut_view_desc = {
+            .image = &map.brdf_lut_img,
+            .dimension = rhi::TextureViewDimension::TEXTURE_2D,
+            .mip_start = 0,
+            .mip_count = 1,
+            .layer_start = 0,
+            .layer_count = 1,
+        };
+        rhi::create_image_view(device, brdf_lut_view_desc, map.brdf_lut_view);
+    }
+
+    map.environmentIdx = rhi::handle_id(device, map.environment_view);
+    map.irradianceIdx = rhi::handle_id(device, map.irradiance_view);
+    map.prefilteredIdx = rhi::handle_id(device, map.prefiltered_view);
+    map.brdfLutIdx = rhi::handle_id(device, map.brdf_lut_view);
+
+    rhi::RenderPipelineDesc equirect_pd;
+    equirect_pd.device = &device;
+    equirect_pd.set_shaders(sc, "src/shaders/ibl/equirect_to_cube.slang", "vsMain", "fsMain");
+    equirect_pd.set_depth_testing(false, false, rhi::PipelineCompareOp::NEVER);
+    equirect_pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    equirect_pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    rhi::RenderPipeline equirect_pipeline = equirect_pd.build();
+
+    rhi::RenderPipelineDesc irradiance_pd;
+    irradiance_pd.device = &device;
+    irradiance_pd.set_shaders(sc, "src/shaders/ibl/irradiance_convolution.slang", "vsMain", "fsMain");
+    irradiance_pd.set_depth_testing(false, false, rhi::PipelineCompareOp::NEVER);
+    irradiance_pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    irradiance_pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    rhi::RenderPipeline irradiance_pipeline = irradiance_pd.build();
+
+    rhi::RenderPipelineDesc prefilter_pd;
+    prefilter_pd.device = &device;
+    prefilter_pd.set_shaders(sc, "src/shaders/ibl/prefilter_env.slang", "vsMain", "fsMain");
+    prefilter_pd.set_depth_testing(false, false, rhi::PipelineCompareOp::NEVER);
+    prefilter_pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    prefilter_pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    rhi::RenderPipeline prefilter_pipeline = prefilter_pd.build();
+
+    rhi::RenderPipelineDesc brdf_pd;
+    brdf_pd.device = &device;
+    brdf_pd.set_shaders(sc, "src/shaders/ibl/brdf_lut.slang", "vsMain", "fsMain");
+    brdf_pd.set_depth_testing(false, false, rhi::PipelineCompareOp::NEVER);
+    brdf_pd.set_cull_mode(rhi::PipelineCullMode::NONE, rhi::PipelineTriangleWindingOrder::CW);
+    brdf_pd.set_color_format(rhi::ImageFormat::RGBA16_FLOAT);
+    rhi::RenderPipeline brdf_lut_pipeline = brdf_pd.build();
+
+    QsCmd *cmd = qs_acquire(qs);
+
+    const u32 hdr_handle = (u32)rhi::handle_id(device, hdr_view);
+
+    transition_whole(cmd->cmd, map.environment_img, rhi::ResourceState::ColorDraw);
+    transition_whole(cmd->cmd, map.irradiance_img, rhi::ResourceState::ColorDraw);
+    transition_whole(cmd->cmd, map.prefiltered_img, rhi::ResourceState::ColorDraw);
+    transition_whole(cmd->cmd, map.brdf_lut_img, rhi::ResourceState::ColorDraw);
+
+    // 1. Equirectangular -> Cubemap
+    for (u32 face = 0; face < 6; ++face) {
+        rhi::ImageViewDesc face_view_desc{
+            .image = &map.environment_img, .mip_start = 0, .mip_count = 1, .layer_start = face, .layer_count = 1
+        };
+        rhi::ImageView face_view{};
+        rhi::create_image_view(device, face_view_desc, face_view);
+
+        rhi::AttachmentDesc attachment{};
+        attachment.img = &face_view;
+        attachment.loadOp = rhi::LoadOp::CLEAR;
+        attachment.storeOp = rhi::StoreOp::STORE;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = attachment;
+        ri.colorAttachmentCount = 1;
+        ri.width = ENV_SIZE;
+        ri.height = ENV_SIZE;
+
+        rhi::begin_rendering(cmd->cmd, ri);
+        rhi::set_pipeline(cmd->cmd, equirect_pipeline);
+
+        IblConstants pc{};
+        pc.hdrTexture = hdr_handle;
+        pc.faceidx = face;
+        pc.samp = samp_linear_clamp;
+
+        push_ibl_constants(cmd->cmd, equirect_pipeline, pc);
+
+        rhi::Viewport viewport{};
+        viewport.height = (f32)ENV_SIZE;
+        viewport.width = (f32)ENV_SIZE;
+        rhi::set_viewports(cmd->cmd, &viewport);
+
+        rhi::Rect scissor{};
+        scissor.width = ENV_SIZE;
+        scissor.height = ENV_SIZE;
+        rhi::set_scissors(cmd->cmd, &scissor);
+
+        rhi::draw(cmd->cmd, 3, 1, 0, 0);
+
+        rhi::end_rendering(cmd->cmd);
+
+        rhi::destroy_image_view(device, face_view);
+    }
+
+    // Generate environment cubemap mips
+    for (u32 mip = 0; mip < ENV_MIP_COUNT - 1; ++mip) {
+        u32 src_width = std::max(ENV_SIZE >> mip, 1u);
+        u32 src_height = std::max(ENV_SIZE >> mip, 1u);
+
+        u32 out_width = std::max(src_width >> 1, 1u);
+        u32 out_height = std::max(src_height >> 1, 1u);
+
+        barrier_mip_layers(
+            cmd->cmd,
+            map.environment_img,
+            mip,
+            6,
+            mip == 0 ? rhi::ResourceState::ColorDraw : rhi::ResourceState::TransferTo,
+            rhi::ResourceState::TransferFrom
+        );
+        barrier_mip_layers(
+            cmd->cmd, map.environment_img, mip + 1, 6, rhi::ResourceState::ColorDraw, rhi::ResourceState::TransferTo
+        );
+
+        u32 constexpr blit_count = 6;
+        rhi::ImageBlit blits[blit_count]{};
+        for (u32 face = 0; face < 6; ++face) {
+            blits[face].src_mip = mip;
+            blits[face].dst_mip = mip + 1;
+            blits[face].src_layer = face;
+            blits[face].dst_layer = face;
+            blits[face].src_x0 = 0;
+            blits[face].src_y0 = 0;
+            blits[face].src_x1 = (i32)src_width;
+            blits[face].src_y1 = (i32)src_height;
+            blits[face].dst_x0 = 0;
+            blits[face].dst_y0 = 0;
+            blits[face].dst_x1 = (i32)out_width;
+            blits[face].dst_y1 = (i32)out_height;
+        }
+
+        rhi::blit_image(cmd->cmd, map.environment_img, blits, blit_count);
+    }
+
+    for (u32 mip = 0; mip < ENV_MIP_COUNT; ++mip) {
+        barrier_mip_layers(
+            cmd->cmd,
+            map.environment_img,
+            mip,
+            6,
+            mip == ENV_MIP_COUNT - 1 ? rhi::ResourceState::TransferTo : rhi::ResourceState::TransferFrom,
+            rhi::ResourceState::TextureSample
+        );
+    }
+
+    map.environment_img.state = rhi::ResourceState::TextureSample;
+
+    // 2. Generate irradiance cubemap
+    for (u32 face = 0; face < 6; ++face) {
+        rhi::ImageViewDesc face_view_desc{
+            .image = &map.irradiance_img, .mip_start = 0, .mip_count = 1, .layer_start = face, .layer_count = 1
+        };
+
+        rhi::ImageView face_view{};
+        rhi::create_image_view(device, face_view_desc, face_view);
+        // Irradiance image is already ColorDraw (transitioned above).
+
+        rhi::AttachmentDesc attachment{};
+        attachment.img = &face_view;
+        attachment.loadOp = rhi::LoadOp::CLEAR;
+        attachment.storeOp = rhi::StoreOp::STORE;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = attachment;
+        ri.colorAttachmentCount = 1;
+        ri.width = IBL_IRRADIANCE_SIZE;
+        ri.height = IBL_IRRADIANCE_SIZE;
+
+        rhi::begin_rendering(cmd->cmd, ri);
+        rhi::set_pipeline(cmd->cmd, irradiance_pipeline);
+
+        IblConstants pc{};
+        pc.environment = map.environmentIdx;
+        pc.faceidx = face;
+        pc.samp = samp_linear_clamp;
+
+        push_ibl_constants(cmd->cmd, irradiance_pipeline, pc);
+
+        rhi::Viewport viewport{};
+        viewport.width = (f32)IBL_IRRADIANCE_SIZE;
+        viewport.height = (f32)IBL_IRRADIANCE_SIZE;
+        rhi::set_viewports(cmd->cmd, &viewport);
+
+        rhi::Rect scissor{};
+        scissor.width = IBL_IRRADIANCE_SIZE;
+        scissor.height = IBL_IRRADIANCE_SIZE;
+        rhi::set_scissors(cmd->cmd, &scissor);
+
+        rhi::draw(cmd->cmd, 3, 1, 0, 0);
+
+        rhi::end_rendering(cmd->cmd);
+
+        rhi::destroy_image_view(device, face_view);
+    }
+
+    // 3. Generate prefiltered cubemap
+    for (u32 mip = 0; mip < PREFILTER_MIPS; ++mip) {
+        u32 mip_width = PREFILTER_SIZE >> mip;
+        u32 mip_height = PREFILTER_SIZE >> mip;
+
+        f32 roughness = (f32)mip / (f32)(PREFILTER_MIPS - 1);
+
+        for (u32 face = 0; face < 6; ++face) {
+            rhi::ImageViewDesc face_view_desc{
+                .image = &map.prefiltered_img, .mip_start = mip, .mip_count = 1, .layer_start = face, .layer_count = 1
+            };
+
+            rhi::ImageView face_view{};
+            rhi::create_image_view(device, face_view_desc, face_view);
+            // Prefiltered image is already ColorDraw (transitioned above).
+
+            rhi::AttachmentDesc attachment{};
+            attachment.img = &face_view;
+            attachment.loadOp = rhi::LoadOp::CLEAR;
+            attachment.storeOp = rhi::StoreOp::STORE;
+
+            rhi::RenderingInfo ri{};
+            ri.colorAttachments[0] = attachment;
+            ri.colorAttachmentCount = 1;
+            ri.width = mip_width;
+            ri.height = mip_height;
+
+            rhi::begin_rendering(cmd->cmd, ri);
+            rhi::set_pipeline(cmd->cmd, prefilter_pipeline);
+
+            IblConstants pc{};
+            pc.faceidx = face;
+            pc.environment = map.environmentIdx;
+            pc.roughness = roughness;
+            pc.environment_resolution = (f32)ENV_SIZE;
+            pc.samp = samp_linear_clamp;
+
+            push_ibl_constants(cmd->cmd, prefilter_pipeline, pc);
+
+            rhi::Viewport viewport{};
+            viewport.width = (f32)mip_width;
+            viewport.height = (f32)mip_height;
+            rhi::set_viewports(cmd->cmd, &viewport);
+
+            rhi::Rect scissor{};
+            scissor.width = mip_width;
+            scissor.height = mip_height;
+            rhi::set_scissors(cmd->cmd, &scissor);
+
+            rhi::draw(cmd->cmd, 3, 1, 0, 0);
+
+            rhi::end_rendering(cmd->cmd);
+
+            rhi::destroy_image_view(device, face_view);
+        }
+    }
+
+    // 4. Generate brdf integration texture2d
+    {
+        rhi::AttachmentDesc attachment{};
+        attachment.img = &map.brdf_lut_view;
+        attachment.loadOp = rhi::LoadOp::CLEAR;
+        attachment.storeOp = rhi::StoreOp::STORE;
+
+        rhi::RenderingInfo ri{};
+        ri.colorAttachments[0] = attachment;
+        ri.colorAttachmentCount = 1;
+        ri.width = BRDF_LUT_SIZE;
+        ri.height = BRDF_LUT_SIZE;
+
+        rhi::begin_rendering(cmd->cmd, ri);
+        rhi::set_pipeline(cmd->cmd, brdf_lut_pipeline);
+
+        rhi::Viewport viewport{};
+        viewport.width = (f32)BRDF_LUT_SIZE;
+        viewport.height = (f32)BRDF_LUT_SIZE;
+        rhi::set_viewports(cmd->cmd, &viewport);
+
+        rhi::Rect scissor{};
+        scissor.width = BRDF_LUT_SIZE;
+        scissor.height = BRDF_LUT_SIZE;
+        rhi::set_scissors(cmd->cmd, &scissor);
+
+        rhi::draw(cmd->cmd, 3, 1, 0, 0);
+
+        rhi::end_rendering(cmd->cmd);
+    }
+
+    transition_whole(cmd->cmd, map.irradiance_img, rhi::ResourceState::TextureSample);
+    transition_whole(cmd->cmd, map.prefiltered_img, rhi::ResourceState::TextureSample);
+    transition_whole(cmd->cmd, map.brdf_lut_img, rhi::ResourceState::TextureSample);
+
+    qs_submit(qs, *cmd);
+}
ADD · src/scene/ibl.h +38 -0
--- a/src/scene/ibl.h
+++ b/src/scene/ibl.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "backend/rhi.h"
+#include "core/globals.h"
+
+struct FrameGraph;
+
+struct QuickSubmit;
+
+struct EnvMap {
+    rhi::Image environment_img;
+    rhi::ImageView environment_view;
+
+    rhi::Image irradiance_img;
+    rhi::ImageView irradiance_view;
+
+    rhi::Image prefiltered_img;
+    rhi::ImageView prefiltered_view;
+
+    rhi::Image brdf_lut_img;
+    rhi::ImageView brdf_lut_view;
+
+    u64 environmentIdx; // cubemap handle (rhi::handle_id)
+    u64 irradianceIdx;  // irradiance map handle
+    u64 prefilteredIdx; // prefiltered specular handle
+    u64 brdfLutIdx;     // brdf lut handle
+    u32 prefilter_mip_count;
+};
+
+void GenerateIBL(
+    rhi::Device &device,
+    QuickSubmit &qs,
+    rhi::ShaderCompiler &sc,
+    EnvMap &out,
+    FrameGraph &fg,
+    rhi::ImageView &hdr_view,
+    u64 samp_linear_clamp
+);
ADD · src/scene/light.h +243 -0
--- a/src/scene/light.h
+++ b/src/scene/light.h
@@ -0,0 +1,243 @@
+#pragma once
+
+#include "camera.h"
+#include "core/math_rtm.h"
+#include <float.h>
+
+struct ShadowCascade {
+    mat4 view;
+    mat4 view_proj;
+
+    // area that can receive shadows.
+    vec3 receiver_min_ls;
+    vec3 receiver_max_ls;
+
+    // area allowed to contribute shadow casters.
+    vec3 caster_min_ls;
+    vec3 caster_max_ls;
+
+    f32 width;  // right - left in light space
+    f32 height; // top - bottom in light space
+    f32 depth;  // far - near in light space
+    f32 split;  // far-plane of each cascade in view space
+};
+
+struct PointLight {
+    NodeHandle node = NODE_INVALID;
+
+    vec3 position = {0.0f, 0.0f, 0.0f};
+    vec3 color = {1.0f, 1.0f, 1.0f};
+    f32 intensity = 1.0f;
+    f32 range = 10.0f;
+};
+
+// TODO, rename to Directional Light
+struct Light {
+    NodeHandle node = NODE_INVALID;
+
+    static constexpr u32 CASCADE_COUNT = 4;
+    ShadowCascade cascades[CASCADE_COUNT] = {};
+    vec3 direction = {0.2f, 0.2f, 1.0f};
+    f32 distance = 50.0f;
+    vec3 color = {1.0f, 0.9f, 0.7f};
+    f32 intensity = 15.0f;
+    f32 max_shadow_distance = 400.0f;
+
+    mat4 view_proj = identity();
+};
+
+// NOTE: deprecated, old non csm path
+static void update_light(Light &light, Camera &camera) {
+    vec3 L = light.direction.normalized(); // world space direction from surface to light
+    vec3 center = camera.position;
+
+    vec3 eye = center + L * 50.0f;
+    vec3 up = fabs(L.dot(vec3(0, 0, 1))) > 0.99f ? vec3(0, 1, 0) : vec3(0, 0, 1);
+
+    mat4 view = look_at(eye, center, up);
+    mat4 proj = ortho(60.0f, 60.0f, 0.1f, 200.0f);
+    light.view_proj = view * proj;
+}
+
+static vec3 choose_light_up(vec3 light_dir) {
+    return fabsf(light_dir.dot(vec3(0, 0, 1))) > 0.99f ? vec3(0, 1, 0) : vec3(0, 0, 1);
+}
+
+// uses the common logarithmic/uniform blend (PSSM) so that more shadow
+// resolution is allocated near the camera while still covering distant areas.
+static void compute_cascade_splits(const Camera &camera, f32 max_shadow_distance, f32 *splits) {
+    splits[0] = camera.near_plane;
+
+    // lambda: blend factor between logarithmic and uniform partitioning.
+    constexpr f32 blend_factor = 0.9f;
+
+    for (u32 i = 1; i <= Light::CASCADE_COUNT; ++i) {
+        const f32 t = (f32)i / (f32)Light::CASCADE_COUNT;
+        const f32 log_split = camera.near_plane * powf(max_shadow_distance / camera.near_plane, t);
+        const f32 uniform_split = camera.near_plane + (max_shadow_distance - camera.near_plane) * t;
+        splits[i] = blend_factor * log_split + (1.0f - blend_factor) * uniform_split;
+    }
+}
+
+static mat4 make_light_grid_view(vec3 light_dir, vec3 up, f32 distance) {
+    return look_at(light_dir * distance, vec3(0.0f), up);
+}
+
+static void build_cascade_corners_vs(const Camera &camera, f32 near_d, f32 far_d, vec3 *corners) {
+    const f32 tan_half_fov = tanf(radians(camera.fov_y_deg) * 0.5f);
+
+    const f32 near_h = tan_half_fov * near_d;
+    const f32 near_w = near_h * camera.aspect;
+
+    const f32 far_h = tan_half_fov * far_d;
+    const f32 far_w = far_h * camera.aspect;
+
+    corners[0] = vec3(-near_w, -near_h, near_d);
+    corners[1] = vec3(near_w, -near_h, near_d);
+    corners[2] = vec3(-near_w, near_h, near_d);
+    corners[3] = vec3(near_w, near_h, near_d);
+
+    corners[4] = vec3(-far_w, -far_h, far_d);
+    corners[5] = vec3(far_w, -far_h, far_d);
+    corners[6] = vec3(-far_w, far_h, far_d);
+    corners[7] = vec3(far_w, far_h, far_d);
+}
+
+static void rotate_corners_to_render_relative(const Camera &camera, vec3 *corners, u32 count) {
+    for (u32 i = 0; i < count; ++i) {
+        corners[i] = transform_direction(corners[i], camera.inv_view);
+    }
+}
+
+static void compute_bounding_sphere(const vec3 *corners, u32 count, vec3 &center, f32 &radius) {
+    center = vec3(0.0f);
+
+    for (u32 i = 0; i < count; ++i) {
+        center += corners[i];
+    }
+
+    center /= (f32)count;
+
+    radius = 0.0f;
+
+    for (u32 i = 0; i < count; ++i) {
+        radius = fmaxf(radius, (corners[i] - center).length());
+    }
+
+    radius = ceilf(radius * 16.0f) / 16.0f;
+}
+
+static vec3 snap_center_to_light_texel_grid(
+    vec3 center_rel, vec3 render_origin_ws, mat4 light_grid_view, f32 radius, u32 shadow_width
+) {
+    const f32 texel = (radius * 2.0f) / (f32)shadow_width;
+
+    // The cascade matrices consume render-relative positions, but the snap grid
+    // must remain world-anchored. Snap the absolute cascade center in light space,
+    // then subtract the render origin's light-space offset so the final projection
+    // still matches render-relative shader inputs.
+    const vec3 center_ws = render_origin_ws + center_rel;
+
+    vec4 center_ls_world = transform_point(center_ws, light_grid_view);
+
+    center_ls_world.x = floorf(center_ls_world.x / texel) * texel;
+    center_ls_world.y = floorf(center_ls_world.y / texel) * texel;
+
+    const vec3 origin_offset_ls = transform_direction(render_origin_ws, light_grid_view);
+
+    return vec3(
+        center_ls_world.x - origin_offset_ls.x,
+        center_ls_world.y - origin_offset_ls.y,
+        center_ls_world.z - origin_offset_ls.z
+    );
+}
+
+static void
+compute_light_space_depth_bounds(const vec3 *corners_rel, u32 count, mat4 light_grid_view, f32 &min_z, f32 &max_z) {
+    min_z = FLT_MAX;
+    max_z = -FLT_MAX;
+
+    for (u32 i = 0; i < count; ++i) {
+        vec4 p = transform_point(corners_rel[i], light_grid_view);
+        min_z = fminf(min_z, p.z);
+        max_z = fmaxf(max_z, p.z);
+    }
+
+    const f32 z_padding = fmaxf((max_z - min_z) * 0.05f, 1.0f);
+    min_z -= z_padding;
+    max_z += z_padding;
+}
+
+static void store_shadow_cascade(
+    ShadowCascade &cascade,
+    mat4 light_grid_view,
+    mat4 light_proj,
+    f32 left,
+    f32 right,
+    f32 bottom,
+    f32 top,
+    f32 min_z,
+    f32 max_z,
+    f32 split
+) {
+    cascade.view = light_grid_view;
+    cascade.view_proj = light_grid_view * light_proj;
+
+    cascade.width = right - left;
+    cascade.height = top - bottom;
+    cascade.depth = max_z - min_z;
+    cascade.split = split;
+
+    cascade.receiver_min_ls = vec3(left, bottom, min_z);
+    cascade.receiver_max_ls = vec3(right, top, max_z);
+
+    cascade.caster_min_ls = vec3(left, bottom, min_z);
+    cascade.caster_max_ls = vec3(right, top, max_z);
+}
+
+static void update_light_cascades(Light &light, Camera &camera, const u32 shadow_sizes[Light::CASCADE_COUNT]) {
+    const vec3 light_dir = light.direction.normalized();
+    const vec3 up = choose_light_up(light_dir);
+    const mat4 light_grid_view = make_light_grid_view(light_dir, up, light.distance);
+
+    f32 splits[Light::CASCADE_COUNT + 1];
+    compute_cascade_splits(camera, light.max_shadow_distance, splits);
+
+    for (u32 cascade_idx = 0; cascade_idx < Light::CASCADE_COUNT; ++cascade_idx) {
+        const f32 near_d = splits[cascade_idx];
+        const f32 far_d = splits[cascade_idx + 1];
+
+        vec3 corners_rel[8];
+        build_cascade_corners_vs(camera, near_d, far_d, corners_rel);
+        rotate_corners_to_render_relative(camera, corners_rel, 8);
+
+        vec3 center_rel;
+        f32 radius;
+        compute_bounding_sphere(corners_rel, 8, center_rel, radius);
+
+        const vec3 center_ls = snap_center_to_light_texel_grid(
+            center_rel, camera.position, light_grid_view, radius, shadow_sizes[cascade_idx]
+        );
+
+        const f32 left = center_ls.x - radius;
+        const f32 right = center_ls.x + radius;
+        const f32 bottom = center_ls.y - radius;
+        const f32 top = center_ls.y + radius;
+
+        f32 min_z;
+        f32 max_z;
+        compute_light_space_depth_bounds(corners_rel, 8, light_grid_view, min_z, max_z);
+
+        const mat4 light_proj = ortho_offcenter(left, right, bottom, top, min_z, max_z);
+
+        store_shadow_cascade(
+            light.cascades[cascade_idx], light_grid_view, light_proj, left, right, bottom, top, min_z, max_z, far_d
+        );
+    }
+}
+
+static void resolve_cascade_sizes(u32 largest, u32 out[Light::CASCADE_COUNT]) {
+    for (u32 i = 0; i < Light::CASCADE_COUNT; ++i) {
+        out[i] = largest;
+    }
+}
ADD · src/scene/scene.cpp +523 -0
--- a/src/scene/scene.cpp
+++ b/src/scene/scene.cpp
@@ -0,0 +1,523 @@
+#include "scene.h"
+
+#include "asset/asset.h"
+#include "core/math_rtm.h"
+#include "rtm/quatf.h"
+
+static bool scene_parent_is_valid(const SceneGraph &scene, int parent_idx) {
+    return parent_idx < 0 || scene.is_node_alive((u32)parent_idx);
+}
+
+static void scene_remove_from_parent_chain(SceneGraph &scene, u32 node) {
+    int old_parent = scene.parent[node];
+    if (old_parent >= 0) {
+        if (scene.first_child[old_parent] == node) {
+            scene.first_child[old_parent] = scene.next_sibling[node];
+            return;
+        }
+
+        for (u32 sib = scene.first_child[old_parent]; sib != SCENE_INVALID; sib = scene.next_sibling[sib]) {
+            if (scene.next_sibling[sib] == node) {
+                scene.next_sibling[sib] = scene.next_sibling[node];
+                return;
+            }
+        }
+    } else {
+        for (usize i = 0; i < scene.roots.size(); ++i) {
+            if (scene.roots[i] == node) {
+                scene.roots.erase(scene.roots.begin() + i);
+                return;
+            }
+        }
+    }
+}
+
+u32 SceneGraph::add_node(int parent_idx, const TRS &local) {
+    if (!scene_parent_is_valid(*this, parent_idx)) {
+        return SCENE_INVALID;
+    }
+
+    u32 idx = SCENE_INVALID;
+
+    if (!free_nodes.empty()) {
+        idx = free_nodes.back();
+        free_nodes.pop_back();
+
+        translations[idx] = local.translation;
+        rotations[idx] = local.rotation;
+        scales[idx] = local.scale;
+        locals[idx] = trs_to_mat4(local);
+        worlds[idx] = identity();
+        parent[idx] = parent_idx;
+        first_child[idx] = SCENE_INVALID;
+        next_sibling[idx] = SCENE_INVALID;
+        alive[idx] = 1;
+        asset[idx] = AssetHandle{};
+        asset_index[idx] = 0;
+        instance_base[idx] = 0;
+        instance_count[idx] = 0;
+    } else {
+        idx = node_count++;
+
+        translations.push_back(local.translation);
+        rotations.push_back(local.rotation);
+        scales.push_back(local.scale);
+        locals.push_back(trs_to_mat4(local));
+        worlds.push_back(identity());
+        parent.push_back(parent_idx);
+        first_child.push_back(SCENE_INVALID);
+        next_sibling.push_back(SCENE_INVALID);
+        alive.push_back(1);
+        asset.push_back(AssetHandle{});
+        asset_index.push_back(0);
+        instance_base.push_back(0);
+        instance_count.push_back(0);
+    }
+
+    if (parent_idx >= 0) {
+        next_sibling[idx] = first_child[parent_idx];
+        first_child[parent_idx] = idx;
+    } else {
+        roots.push_back(idx);
+    }
+
+    return idx;
+}
+
+u32 SceneGraph::add_node(int parent_idx, const mat4 &local) {
+    return add_node(parent_idx, mat4_to_trs(local));
+}
+
+bool SceneGraph::delete_node(u32 node) {
+    if (!is_node_alive(node)) {
+        return false;
+    }
+
+    scene_remove_from_parent_chain(*this, node);
+
+    std::vector<u32> stack;
+    stack.push_back(node);
+
+    while (!stack.empty()) {
+        u32 current = stack.back();
+        stack.pop_back();
+
+        for (u32 child = first_child[current]; child != SCENE_INVALID; child = next_sibling[child]) {
+            stack.push_back(child);
+        }
+
+        parent[current] = -1;
+        first_child[current] = SCENE_INVALID;
+        next_sibling[current] = SCENE_INVALID;
+        locals[current] = identity();
+        worlds[current] = identity();
+        alive[current] = 0;
+        asset[current] = AssetHandle{};
+        asset_index[current] = 0;
+        instance_base[current] = 0;
+        instance_count[current] = 0;
+        free_nodes.push_back(current);
+    }
+
+    return true;
+}
+
+bool SceneGraph::is_node_alive(u32 node) const {
+    return node < node_count && node < alive.size() && alive[node] != 0;
+}
+
+bool SceneGraph::is_descendant(u32 node, u32 ancestor) const {
+    if (!is_node_alive(node) || !is_node_alive(ancestor)) {
+        return false;
+    }
+
+    for (int p = parent[node]; p >= 0; p = parent[p]) {
+        if ((u32)p == ancestor) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+bool SceneGraph::reparent(u32 node, int new_parent) {
+    if (!is_node_alive(node) || !scene_parent_is_valid(*this, new_parent)) {
+        return false;
+    }
+    if (new_parent >= 0 && ((u32)new_parent == node || is_descendant((u32)new_parent, node))) {
+        return false;
+    }
+
+    int old_parent = parent[node];
+    if (old_parent == new_parent) {
+        return true;
+    }
+
+    scene_remove_from_parent_chain(*this, node);
+
+    parent[node] = new_parent;
+
+    if (new_parent >= 0) {
+        next_sibling[node] = first_child[new_parent];
+        first_child[new_parent] = node;
+    } else {
+        next_sibling[node] = SCENE_INVALID;
+        roots.push_back(node);
+    }
+
+    return true;
+}
+
+bool SceneGraph::reparent_keep_world(u32 node, int new_parent) {
+    if (!is_node_alive(node) || !scene_parent_is_valid(*this, new_parent)) {
+        return false;
+    }
+    if (new_parent >= 0 && ((u32)new_parent == node || is_descendant((u32)new_parent, node))) {
+        return false;
+    }
+
+    update_world_transforms();
+    mat4 old_world = worlds[node];
+
+    if (!reparent(node, new_parent)) {
+        return false;
+    }
+
+    mat4 new_local = old_world;
+    if (new_parent >= 0) {
+        new_local = old_world * inverse(worlds[new_parent]);
+    }
+
+    set_local_matrix(node, new_local);
+    return true;
+}
+
+void SceneGraph::set_local_trs(u32 index, const TRS &trs) {
+    if (!is_node_alive(index)) {
+        return;
+    }
+
+    translations[index] = trs.translation;
+    rotations[index] = trs.rotation;
+    scales[index] = trs.scale;
+    locals[index] = trs_to_mat4(trs);
+}
+
+void SceneGraph::set_local_matrix(u32 index, const mat4 &m) {
+    if (!is_node_alive(index)) {
+        return;
+    }
+
+    TRS trs = mat4_to_trs(m);
+    translations[index] = trs.translation;
+    rotations[index] = trs.rotation;
+    scales[index] = trs.scale;
+    locals[index] = m;
+}
+
+void SceneGraph::set_translation(u32 index, const vec3 &translation) {
+    if (!is_node_alive(index)) {
+        return;
+    }
+
+    // should remove this
+    // no-op guard:
+    // skip the local-transform write when the value hasn't
+    // actually changed (e.g. idle camera),
+    if (translations[index].x == translation.x && translations[index].y == translation.y &&
+        translations[index].z == translation.z) {
+        return;
+    }
+
+    TRS trs = get_local_trs(index);
+    trs.translation = translation;
+    set_local_trs(index, trs);
+}
+
+void SceneGraph::set_rotation(u32 index, const rtm::quatf &rotation) {
+    if (!is_node_alive(index)) {
+        return;
+    }
+
+    TRS trs = get_local_trs(index);
+    trs.rotation = rotation;
+    set_local_trs(index, trs);
+}
+
+void SceneGraph::set_scale(u32 index, const vec3 &scale) {
+    if (!is_node_alive(index)) {
+        return;
+    }
+
+    TRS trs = get_local_trs(index);
+    trs.scale = scale;
+    set_local_trs(index, trs);
+}
+
+void SceneGraph::update_world_transforms() {
+    std::vector<u32> stack;
+    stack.reserve(node_count);
+
+    for (u32 root : roots) {
+        if (!is_node_alive(root)) {
+            continue;
+        }
+
+        worlds[root] = locals[root];
+
+        for (u32 child = first_child[root]; child != SCENE_INVALID; child = next_sibling[child]) {
+            stack.push_back(child);
+        }
+    }
+
+    while (!stack.empty()) {
+        u32 node = stack.back();
+        stack.pop_back();
+        if (!is_node_alive(node)) {
+            continue;
+        }
+
+        worlds[node] = locals[node] * worlds[parent[node]];
+
+        for (u32 child = first_child[node]; child != SCENE_INVALID; child = next_sibling[child]) {
+            stack.push_back(child);
+        }
+    }
+}
+
+TRS SceneGraph::get_local_trs(u32 index) const {
+    if (!is_node_alive(index)) {
+        return {};
+    }
+
+    return {translations[index], rotations[index], scales[index]};
+}
+
+mat4 SceneGraph::get_local_matrix(u32 index) const {
+    if (!is_node_alive(index)) {
+        return identity();
+    }
+
+    return locals[index];
+}
+
+mat4 SceneGraph::get_world(u32 index) const {
+    if (!is_node_alive(index)) {
+        return identity();
+    }
+
+    return worlds[index];
+}
+
+u32 Scene::instantiate(AssetManager &mgr, AssetHandle handle, int parent_idx) {
+    if (!handle.valid()) {
+        return SCENE_INVALID;
+    }
+    if (!scene_parent_is_valid(scene_graph, parent_idx)) {
+        return SCENE_INVALID;
+    }
+
+    const AssetScene *asset = mgr.get(handle);
+    if (!asset) {
+        return SCENE_INVALID;
+    }
+
+    SceneGraph &sg = scene_graph;
+    u32 n = (u32)asset->nodes.size();
+    u32 base = sg.node_count;
+    u32 end = base + n;
+
+    sg.translations.resize(end);
+    sg.rotations.resize(end);
+    sg.scales.resize(end);
+    sg.locals.resize(end);
+    sg.worlds.resize(end);
+    sg.parent.resize(end, -1);
+    sg.first_child.resize(end, SCENE_INVALID);
+    sg.next_sibling.resize(end, SCENE_INVALID);
+    sg.alive.resize(end, 1);
+    sg.asset.resize(end);
+    sg.asset_index.resize(end);
+    sg.instance_base.resize(end);
+    sg.instance_count.resize(end);
+    sg.node_count = end;
+
+    for (u32 i = 0; i < n; ++i) {
+        const AssetNode &src = asset->nodes[i];
+        u32 dst = base + i;
+
+        int sp;
+        if (src.parent >= 0) {
+            sp = (int)(base + src.parent);
+        } else {
+            sp = parent_idx;
+        }
+
+        TRS trs = mat4_to_trs(src.local);
+        sg.translations[dst] = trs.translation;
+        sg.rotations[dst] = trs.rotation;
+        sg.scales[dst] = trs.scale;
+        sg.locals[dst] = src.local;
+        sg.parent[dst] = sp;
+        sg.asset[dst] = handle;
+        sg.asset_index[dst] = i;
+
+        if (sp >= 0) {
+            sg.next_sibling[dst] = sg.first_child[sp];
+            sg.first_child[sp] = dst;
+        } else {
+            sg.roots.push_back(dst);
+        }
+
+        if (src.mesh != ASSET_INVALID) {
+            u32 count = src.instance_count;
+            u32 inst_base = (u32)instance_locals.size();
+
+            if (count > 0) {
+                instance_locals.resize(inst_base + count);
+            } else {
+                instance_locals.resize(inst_base + 1);
+            }
+
+            if (count > 0) {
+                for (u32 k = 0; k < count; ++k) {
+                    instance_locals[inst_base + k] = asset->instance_locals[src.first_instance + k];
+                }
+            } else {
+                instance_locals[inst_base] = TRS{};
+            }
+
+            sg.instance_base[dst] = inst_base;
+            sg.instance_count[dst] = count;
+            mesh_nodes.push_back(dst);
+        }
+
+        if (src.camera >= 0 && src.camera < (i32)asset->cameras.size()) {
+            const AssetCamera &ac = asset->cameras[src.camera];
+
+            Camera cam;
+            cam.node = dst;
+
+            if (ac.type == AssetCamera::Perspective) {
+                cam.fov_y_deg = degrees(ac.yfov);
+                cam.near_plane = ac.znear;
+                cam.far_plane = ac.zfar;
+                if (ac.aspect_ratio > 0.0f) {
+                    cam.aspect = ac.aspect_ratio;
+                }
+            }
+
+            cameras.push_back(cam);
+        }
+
+        if (src.light >= 0 && src.light < (i32)asset->lights.size()) {
+            const AssetLight &al = asset->lights[src.light];
+
+            if (al.type == AssetLight::Directional) {
+                Light dl;
+                dl.node = dst;
+                dl.color = al.color;
+                dl.intensity = al.intensity;
+                directional_lights.push_back(dl);
+            } else {
+                PointLight pl;
+                pl.node = dst;
+                pl.color = al.color;
+                pl.intensity = al.intensity;
+                if (al.range > 0.0f) {
+                    pl.range = al.range;
+                } else {
+                    pl.range = 10.0f;
+                }
+                point_lights.push_back(pl);
+            }
+        }
+    }
+
+    sg.update_world_transforms();
+    return base;
+}
+
+const AssetScene *Scene::node_source(const AssetManager &mgr, u32 node) const {
+    const SceneGraph &sg = scene_graph;
+    if (!sg.is_node_alive(node)) {
+        return nullptr;
+    }
+    if (!sg.asset[node].valid()) {
+        return nullptr;
+    }
+    const AssetScene *asset = mgr.get(sg.asset[node]);
+    if (!asset || sg.asset_index[node] >= asset->nodes.size()) {
+        return nullptr;
+    }
+    return asset;
+}
+
+const char *Scene::node_name(const AssetManager &mgr, u32 node) const {
+    const AssetScene *asset = node_source(mgr, node);
+    if (!asset) {
+        return nullptr;
+    }
+    const std::string &name = asset->node_names[scene_graph.asset_index[node]];
+    return name.empty() ? nullptr : name.c_str();
+}
+
+mat4 Scene::instance_world(u32 node, u32 k) const {
+    const SceneGraph &sg = scene_graph;
+    if (node >= sg.node_count || !sg.is_node_alive(node)) {
+        return identity();
+    }
+    u32 base = sg.instance_base[node];
+    u32 count = sg.instance_count[node];
+    if (k >= count || base + k >= (u32)instance_locals.size()) {
+        return identity();
+    }
+    int p = sg.parent[node];
+    mat4 parent_world = (p >= 0) ? sg.worlds[p] : identity();
+    return trs_to_mat4(instance_locals[base + k]) * sg.locals[node] * parent_world;
+}
+
+void Scene::evaluate() {
+    scene_graph.update_world_transforms();
+    const SceneGraph &sg = scene_graph;
+
+    for (usize i = 0; i < cameras.size(); ++i) {
+        Camera &cam = cameras[i];
+        if (cam.node == NODE_INVALID || !sg.is_node_alive(cam.node)) {
+            continue;
+        }
+
+        TRS trs = mat4_to_trs(sg.get_world(cam.node));
+        cam.position = trs.translation;
+
+        cam.view = look_at(cam.position, cam.position + cam.forward(), vec3(0.0f, 0.0f, 1.0f));
+        cam.proj = perspective(radians(cam.fov_y_deg), cam.aspect, cam.near_plane, cam.far_plane);
+        cam.view_proj = cam.view * cam.proj;
+        cam.inv_view = inverse(cam.view);
+        cam.inv_proj = inverse(cam.proj);
+        cam.inv_view_proj = inverse(cam.view_proj);
+    }
+
+    for (usize i = 0; i < directional_lights.size(); ++i) {
+        Light &dl = directional_lights[i];
+        if (dl.node == NODE_INVALID || !sg.is_node_alive(dl.node)) {
+            continue;
+        }
+
+        TRS trs = mat4_to_trs(sg.get_world(dl.node));
+
+        rtm::vector4f local_fwd = rtm::vector_set(1.0f, 0.0f, 0.0f, 0.0f);
+        rtm::vector4f world_fwd = rtm::quat_mul_vector3(local_fwd, trs.rotation.q);
+        dl.direction = vec3::from_vec4(world_fwd).normalized();
+    }
+
+    for (usize i = 0; i < point_lights.size(); ++i) {
+        PointLight &pl = point_lights[i];
+        if (pl.node == NODE_INVALID || !sg.is_node_alive(pl.node)) {
+            continue;
+        }
+
+        TRS trs = mat4_to_trs(sg.get_world(pl.node));
+        pl.position = trs.translation;
+    }
+}
ADD · src/scene/scene.h +90 -0
--- a/src/scene/scene.h
+++ b/src/scene/scene.h
@@ -0,0 +1,90 @@
+#pragma once
+
+#include <vector>
+
+#include "asset/asset.h"
+#include "core/globals.h"
+#include "core/math_rtm.h"
+#include "scene/camera.h"
+#include "scene/ibl.h"
+#include "scene/light.h"
+#include "shaders/renderer_types.h"
+
+class AssetManager;
+
+constexpr u32 SCENE_INVALID = 0xffffffffu;
+
+struct SceneGraph {
+    // Hierarchy (sibling-chain)
+    std::vector<int> parent;       // parent index (-1 = root)
+    std::vector<u32> first_child;  // first child index (SCENE_INVALID = none)
+    std::vector<u32> next_sibling; // next sibling index (SCENE_INVALID = none)
+    std::vector<u8> alive;
+    std::vector<u32> free_nodes;
+
+    // Local transforms (SoA)
+    std::vector<vec3> translations;
+    std::vector<rtm::quatf> rotations;
+    std::vector<vec3> scales;
+    std::vector<mat4> locals;
+
+    // Computed world transforms
+    std::vector<mat4> worlds;
+
+    // Roots
+    std::vector<u32> roots;
+
+    // Per-node source asset link (parallel; ASSET_INVALID = manual node)
+    std::vector<AssetHandle> asset;
+    std::vector<u32> asset_index;
+
+    // Per-node runtime instance state (parallel; block base/count in Scene::instance_locals)
+    std::vector<u32> instance_base;
+    std::vector<u32> instance_count;
+
+    u32 node_count = 0;
+
+    u32 add_node(int parent_idx, const TRS &local);
+    u32 add_node(int parent_idx, const mat4 &local);
+
+    bool delete_node(u32 node);
+    bool is_node_alive(u32 node) const;
+    bool is_descendant(u32 node, u32 ancestor) const;
+
+    bool reparent(u32 node, int new_parent);
+    bool reparent_keep_world(u32 node, int new_parent);
+
+    void set_local_trs(u32 index, const TRS &trs);
+    void set_local_matrix(u32 index, const mat4 &m);
+    void set_translation(u32 index, const vec3 &translation);
+    void set_rotation(u32 index, const rtm::quatf &rotation);
+    void set_scale(u32 index, const vec3 &scale);
+
+    void update_world_transforms();
+
+    TRS get_local_trs(u32 index) const;
+    mat4 get_local_matrix(u32 index) const;
+    mat4 get_world(u32 index) const;
+};
+
+struct Scene {
+    SceneGraph scene_graph;
+    EnvMap env;
+
+    std::vector<TRS> instance_locals; // per-instance local TRS pool; slot index == GPU transform slot
+    std::vector<u32> mesh_nodes;      // scene nodes that carry a mesh (built at instantiate)
+
+    // Cameras / lights
+    std::vector<Camera> cameras;
+    u32 active_camera = NODE_INVALID;
+    std::vector<Light> directional_lights;
+    std::vector<PointLight> point_lights;
+
+    u32 instantiate(AssetManager &mgr, AssetHandle handle, int parent_idx = -1);
+    void evaluate();
+
+    mat4 instance_world(u32 node, u32 k) const;
+
+    const AssetScene *node_source(const AssetManager &mgr, u32 node) const;
+    const char *node_name(const AssetManager &mgr, u32 node) const;
+};
ADD · src/shaders/conformance/descriptor_handle.slang +45 -0
--- a/src/shaders/conformance/descriptor_handle.slang
+++ b/src/shaders/conformance/descriptor_handle.slang
@@ -0,0 +1,45 @@
+#include "shared.h"
+
+struct OffsetUBO {
+    float4 off;
+};
+
+struct Push {
+    float4 tint;                           // 0
+    Texture2D.Handle tex;                  // 16
+    SamplerState.Handle samp;              // 24
+    StructuredBuffer<float4>.Handle ubo;   // 32
+    ConstantBuffer<OffsetUBO>.Handle cbuf; // 40
+    ByteAddressBuffer.Handle bbuf;         // 48
+    u64 addr;                              // 56,
+};
+
+[vk::push_constant]
+Push pc;
+
+struct VSOut {
+    float4 pos : SV_Position;
+    float2 uv : TEXCOORD;
+};
+
+[shader("vertex")]
+VSOut vsMain(uint vertexID: SV_VertexID) {
+    float2 positions[3] = { float2(-0.5, -0.5), float2(0.5, -0.5), float2(0.0, 0.5) };
+    float2 uvs[3] = { float2(0.0, 0.0), float2(1.0, 0.0), float2(0.5, 1.0) };
+    VSOut o;
+
+    OffsetUBO cbuf = *pc.cbuf;
+    float4 o0 = pc.ubo[0];
+    float4 o1 = cbuf.off;
+    float4 o2 = pc.bbuf.Load<float4>(0);
+    float4 o3 = ((float4 *)pc.addr)[0];
+    float4 off = (o0 + o1 + o2 + o3) * 0.25;
+    o.pos = float4(positions[vertexID] + off.xy, 0.0, 1.0);
+    o.uv = uvs[vertexID];
+    return o;
+}
+
+[shader("fragment")]
+float4 fsMain(VSOut input) : SV_Target {
+    return pc.tex.SampleLevel(pc.samp, input.uv, 0.0) * pc.tint;
+}
ADD · src/shaders/conformance/indexed_quad.slang +38 -0
--- a/src/shaders/conformance/indexed_quad.slang
+++ b/src/shaders/conformance/indexed_quad.slang
@@ -0,0 +1,38 @@
+struct VSInput {
+    [[vk::location(0)]]
+    float2 position;
+    [[vk::location(1)]]
+    float3 color;
+};
+
+struct VSOutput {
+    float4 position : SV_Position;
+    float3 color : COLOR;
+};
+
+struct QuadPush {
+    float time;
+    float2 offset;
+    float4 tint;
+};
+
+[vk::push_constant]
+QuadPush pc;
+
+[shader("vertex")]
+VSOutput vsMain(VSInput input) {
+    float c = cos(pc.time);
+    float s = sin(pc.time);
+    float2 p = float2(input.position.x * c - input.position.y * s, input.position.x * s + input.position.y * c);
+    p += pc.offset;
+
+    VSOutput output;
+    output.position = float4(p, 0.0, 1.0);
+    output.color = input.color;
+    return output;
+}
+
+[shader("fragment")]
+float4 fsMain(VSOutput input) : SV_Target {
+    return float4(input.color * pc.tint.rgb, 1.0);
+}
ADD · src/shaders/conformance/ndc.slang +26 -0
--- a/src/shaders/conformance/ndc.slang
+++ b/src/shaders/conformance/ndc.slang
@@ -0,0 +1,26 @@
+struct VSOutput {
+    float4 position : SV_Position;
+    float2 ndc : TEXCOORD0;
+};
+
+[shader("vertex")]
+VSOutput vsMain(uint vertexID: SV_VertexID) {
+    VSOutput output;
+    float2 uv = float2((vertexID << 1) & 2, vertexID & 2);
+    float2 pos = uv * 2.0 - 1.0;
+    output.position = float4(pos, 0.0, 1.0);
+    output.ndc = pos;
+    return output;
+}
+
+[shader("fragment")]
+float4 fsMain(VSOutput input) : SV_Target {
+    float2 uv = input.ndc * 0.5 + 0.5;
+    float3 grad = float3(uv.x, uv.y, 0.0);
+
+    float2 d = abs(input.ndc);
+    float cross = (min(d.x, d.y) < 0.01) ? 1.0 : 0.0;
+    float3 color = lerp(grad, float3(1.0, 1.0, 1.0), cross);
+
+    return float4(color, 1.0);
+}
ADD · src/shaders/conformance/scene.slang +42 -0
--- a/src/shaders/conformance/scene.slang
+++ b/src/shaders/conformance/scene.slang
@@ -0,0 +1,42 @@
+#include "shared.h"
+
+struct ScenePush {
+    float4x4 viewProj;        // 0
+    Texture2D.Handle tex;     // 64
+    SamplerState.Handle samp; // 72
+    float4 lightDir;          // 80, xyz = direction TO light, w unused
+};
+
+[vk::push_constant]
+ScenePush pc;
+
+struct VSIn {
+    [[vk::location(0)]]
+    float3 pos;
+    [[vk::location(1)]]
+    float3 normal;
+    [[vk::location(2)]]
+    float2 uv;
+};
+
+struct VSOut {
+    float4 pos : SV_Position;
+    float3 normal : NORMAL;
+    float2 uv : TEXCOORD;
+};
+
+[shader("vertex")]
+VSOut vsMain(VSIn input) {
+    VSOut o;
+    o.pos = mul(float4(input.pos, 1.0), pc.viewProj);
+    o.normal = input.normal;
+    o.uv = input.uv;
+    return o;
+}
+
+[shader("fragment")]
+float4 fsMain(VSOut input) : SV_Target {
+    float4 albedo = pc.tex.SampleLevel(pc.samp, input.uv, 0.0);
+    float ndl = saturate(dot(normalize(input.normal), normalize(pc.lightDir.xyz)));
+    return float4(albedo.rgb * (0.2 + 0.8 * ndl), 1.0);
+}
ADD · src/shaders/conformance/triangle.slang +26 -0
--- a/src/shaders/conformance/triangle.slang
+++ b/src/shaders/conformance/triangle.slang
@@ -0,0 +1,26 @@
+#include "shared.h"
+
+struct VSInput {
+    [[vk::location(0)]]
+    float2 position;
+    [[vk::location(1)]]
+    float3 color;
+};
+
+struct VSOutput {
+    float4 position : SV_Position;
+    float3 color : COLOR;
+};
+
+[shader("vertex")]
+VSOutput vsMain(VSInput input) {
+    VSOutput output;
+    output.position = float4(input.position, 0.0, 1.0);
+    output.color = input.color;
+    return output;
+}
+
+[shader("fragment")]
+float4 fsMain(VSOutput input) : SV_Target {
+    return float4(input.color, 1.0);
+}
ADD · src/shaders/debug/debug_views.slang +178 -0
--- a/src/shaders/debug/debug_views.slang
+++ b/src/shaders/debug/debug_views.slang
@@ -0,0 +1,178 @@
+#pragma once
+#include "shared.h"
+#include "lib/shadow_sample.slang"
+
+#ifdef DEBUG
+
+vec3 TurboColormap(f32 x) {
+    // Source: https://research.google/blog/turbo-an-improved-rainbow-colormap-for-visualization/
+
+    vec4 kRedVec4 = vec4(0.13572138, 4.61539260, -42.66032258, 132.13108234);
+    vec4 kGreenVec4 = vec4(0.09140261, 2.19418839, 4.84296658, -14.18503333);
+    vec4 kBlueVec4 = vec4(0.10667330, 12.64194608, -60.58204836, 110.36276771);
+    vec2 kRedVec2 = vec2(-152.94239396, 59.28637943);
+    vec2 kGreenVec2 = vec2(4.27729857, 2.82956604);
+    vec2 kBlueVec2 = vec2(-89.90310912, 27.34824973);
+
+    x = clamp(x, 0, 1);
+    vec4 v4 = vec4(1.0, x, x * x, x * x * x);
+    vec2 v2 = v4.zw * v4.z;
+    return vec3(
+        dot(v4, kRedVec4) + dot(v2, kRedVec2),
+        dot(v4, kGreenVec4) + dot(v2, kGreenVec2),
+        dot(v4, kBlueVec4) + dot(v2, kBlueVec2)
+    );
+}
+
+bool try_debug_view_pre(
+    VtxOut input,
+    FrameUBO frame,
+    inout vec4 albedo,
+    inout f32 alpha,
+    inout vec3 normalWS,
+    inout f32 metallic,
+    inout f32 roughness,
+    inout vec3 emissive,
+    vec3 N,
+    vec3 T,
+    vec3 B,
+    vec3 normalTS,
+    out vec4 result
+) {
+
+    DebugViewMode dbg_flag = frame.debug;
+    f32 near_plane = frame.near_plane;
+    f32 far_plane = frame.far_plane;
+
+    switch (dbg_flag) {
+    case DebugViewMode::DEPTH_grayscale:
+        result = vec4(vec3(input.view_pos.z), 1.0);
+        return true;
+
+    case DebugViewMode::DEPTH_color:
+        result = vec4(TurboColormap(abs(input.view_pos.z)), 1.0);
+        return true;
+
+    case DebugViewMode::UV:
+        result = vec4(input.uv, 0.0, 1.0);
+        return true;
+
+    case DebugViewMode::NORMAL_TEX:
+        result = vec4(normalTS * 0.5 + 0.5, 1.0);
+        return true;
+
+    case DebugViewMode::NORMAL_GEO:
+        result = vec4(N * 0.5 + 0.5, 1.0);
+        return true;
+
+    case DebugViewMode::TANGENT_GEO:
+        result = vec4(T * 0.5 + 0.5, 1.0);
+        return true;
+
+    case DebugViewMode::BITANGENT_GEO:
+        result = vec4(B * 0.5 + 0.5, 1.0);
+        return true;
+
+    case DebugViewMode::TANGENT_GEO_W:
+        result = vec4(vec3(input.tangent.w * 0.5 + 0.5), 1.0);
+        return true;
+
+    case DebugViewMode::SHADING_NORMAL:
+        result = vec4(normalWS * 0.5 + 0.5, 1.0);
+        return true;
+
+    case DebugViewMode::ALPHA:
+        result = vec4(vec3(alpha), 1.0);
+        return true;
+
+    case DebugViewMode::EMISSIVE:
+        result = vec4(emissive, 1.0);
+        return true;
+
+    case DebugViewMode::ALBEDO:
+        result = vec4(pow(albedo.rgb, 1.0 / 2.0), 1.0);
+        return true;
+
+    case DebugViewMode::METALLIC:
+        result = vec4(vec3(metallic), 1.0);
+        return true;
+
+    case DebugViewMode::ROUGHNESS:
+        result = vec4(vec3(roughness), 1.0);
+        return true;
+
+    case DebugViewMode::OCCLUSION:
+        result = vec4(1.0, 0.0, 1.0, 1.0);
+        return true;
+
+    case DebugViewMode::SHADOW_CASCADE: {
+        u32 cascade_idx = select_cascade_aabb(input.world_pos, frame.position_ws.xyz, frame.shadows);
+        vec3 colors[3] = { vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1) };
+        vec4 albed = vec4(pow(albedo.rgb, 1.0 / 2.0), 1.0);
+        result = vec4(lerp(colors[cascade_idx], albed.xyz, 0.1), 0.25);
+        return true;
+    }
+
+    case DebugViewMode::LIGHTING_ONLY: {
+        albedo = vec4(0.5, 0.5, 0.5, 1.0);
+        // roughness = 0.25;
+        // metallic  = 0.0;
+        // emissive  = 0.0;
+        alpha = 1.0;
+        // normalWS  = input.normal;
+        return false;
+    }
+
+    default:
+        return false;
+    }
+}
+
+void apply_debug_view_post(inout vec3 color, VtxOut input, ClusterRecord cr, FrameUBO frame) {
+    ClusterGrid clusters = frame.cluster;
+    DebugViewMode dbg_flag = frame.debug;
+    f32 near_plane = frame.near_plane;
+    f32 far_plane = frame.far_plane;
+
+    switch (dbg_flag) {
+    case DebugViewMode::CLUSTER_HEATMAP: {
+        f32 h = f32(cr.lightCount) / 16.0;
+        vec4 heatmap = vec4(h, 0.5 - h, 0, 0.0);
+        color = lerp(color.rgb, heatmap.rgb, 0.65);
+        break;
+    }
+
+    case DebugViewMode::CLUSTER_BOUNDS: {
+        uint tileX = uint(input.clip_pos.x) / TILE_SIZE_X;
+        uint tileY = uint(input.clip_pos.y) / TILE_SIZE_Y;
+        f32 vDepth = clamp(abs(input.view_pos.z), near_plane, far_plane);
+
+        u32 tz = compute_depth_slice(vDepth, near_plane, far_plane, clusters.cluster_count_z);
+        u32 flatIdx = flatten_cluster_index(tileX, tileY, tz, clusters.cluster_count_x, clusters.cluster_count_y);
+
+        ClusterBounds c;
+        c.minPoint = clusters.clusters_bounds[flatIdx].minPoint;
+        c.maxPoint = clusters.clusters_bounds[flatIdx].maxPoint;
+
+        bool tileBorder = (uint(input.clip_pos.x) % TILE_SIZE_X) < 2 || (uint(input.clip_pos.y) % TILE_SIZE_Y) < 2;
+        f32 depthFrac = log(vDepth / near_plane) / log(far_plane / near_plane);
+        f32 sliceCoord = depthFrac * f32(clusters.cluster_count_z);
+
+        bool depthBorder = frac(sliceCoord) < 0.05;
+
+        if (tileBorder) {
+            color = lerp(color, vec3(1, 1, 1), 0.05);
+        }
+
+        if (depthBorder) {
+            color = lerp(color, vec3(1, 0, 0), 0.5);
+        }
+        break;
+    }
+
+    default:
+        break;
+    }
+}
+
+#endif
ADD · src/shaders/debug/frustum_debug.slang +148 -0
--- a/src/shaders/debug/frustum_debug.slang
+++ b/src/shaders/debug/frustum_debug.slang
@@ -0,0 +1,148 @@
+#include "shared.h"
+// set to 1 to compare against the inverse view-projection reference
+#define VISUALIZE_REFERENCE 0
+
+struct Frustum {
+    vec4 planes[6]; // left, right, top, bottom, near, far
+};
+
+// clang-format off
+static const vec4 FRUSTUM_CORNERS_CS[8] = {
+    vec4(-1, -1, 1,    1),
+    vec4( 1, -1, 1,    1),
+    vec4( 1,  1, 1,    1),
+    vec4(-1,  1, 1,    1),
+
+    vec4(-1, -1, 1e-6, 1),
+    vec4( 1, -1, 1e-6, 1),
+    vec4( 1,  1, 1e-6, 1),
+    vec4(-1,  1, 1e-6, 1),
+};
+
+// line list indices
+static const uint FRUSTUM_EDGES[24] = {
+    0,1, 1,2, 2,3, 3,0,
+    4,5, 5,6, 6,7, 7,4,
+    0,4, 1,5, 2,6, 3,7
+};
+
+// which 3 planes form each corner
+static const uint CORNER_PLANES[24] = {
+    4,2,0, 4,2,1,
+    4,3,1, 4,3,0,
+
+    5,2,0, 5,2,1,
+    5,3,1, 5,3,0,
+};
+// clang-format on
+
+[vk::push_constant]
+FrustumDebugPushConstants pc;
+
+// intersect 3 planes -> world-space point
+vec4 intersect_three_planes(vec4 p0, vec4 p1, vec4 p2) {
+    vec3 n0 = p0.xyz;
+    vec3 n1 = p1.xyz;
+    vec3 n2 = p2.xyz;
+
+    f32 d0 = p0.w;
+    f32 d1 = p1.w;
+    f32 d2 = p2.w;
+
+    vec3 cross12 = cross(n1, n2);
+    f32 det = dot(n0, cross12);
+
+    if (abs(det) < 1e-10)
+        return vec4(0);
+
+    vec3 point = -(d0 * cross12 + d1 * cross(n2, n0) + d2 * cross(n0, n1)) / det;
+
+    return vec4(point, 1.0);
+}
+
+Frustum extract_frustum_(mat4 view_proj) {
+    Frustum f;
+
+    mat4 rows = transpose(view_proj);
+
+    f.planes[0] = rows[3] + rows[0]; // left
+    f.planes[1] = rows[3] - rows[0]; // right
+    f.planes[2] = rows[3] + rows[1]; // bottom
+    f.planes[3] = rows[3] - rows[1]; // top
+    f.planes[4] = rows[3] - rows[2]; // near (reverse-z)
+
+    // placeholder, replaced with a far plane later
+    f.planes[5] = rows[2];
+
+    for (uint i = 0; i < 6; ++i)
+        f.planes[i] /= length(f.planes[i].xyz);
+
+    return f;
+}
+
+void build_culling_far_plane(inout Frustum frustum, FrameUBO frame) {
+    vec4 near_ws = vec4(0, 0, 1.0, 1.0) * pc.debug_inv_view_proj;
+    vec4 far_ws = vec4(0, 0, 1e-6, 1.0) * pc.debug_inv_view_proj;
+
+    near_ws /= near_ws.w;
+    far_ws /= far_ws.w;
+
+    vec3 forward = normalize(far_ws.xyz - near_ws.xyz);
+
+    // vec3 forward = vec3(0.0, 1.0, 0.0);
+
+    // todo: use pc.max_draw_distance
+    vec3 far_point = frame.position_ws.xyz + forward * 10000.0;
+
+    vec3 normal = -forward;
+
+    frustum.planes[5] = vec4(normal, -dot(normal, far_point));
+}
+
+// reference clip-space corner with the inverse view-projection matrix
+vec4 reconstruct_reference_corner(uint corner) {
+    vec4 world = FRUSTUM_CORNERS_CS[corner] * pc.debug_inv_view_proj;
+    return world / world.w;
+}
+
+// same as reconstruct_reference_corner, but using the extracted frustum planes
+vec4 reconstruct_extracted_corner(Frustum frustum, uint corner) {
+    uint base = corner * 3;
+
+    return intersect_three_planes(
+        frustum.planes[CORNER_PLANES[base + 0]],
+        frustum.planes[CORNER_PLANES[base + 1]],
+        frustum.planes[CORNER_PLANES[base + 2]]
+    );
+}
+
+[shader("vertex")]
+vec4 vsMain(uint vertex_id: SV_VertexID) : SV_Position {
+    FrameUBO frame = uniform_buffers[pc.frame_ubo_idx];
+
+    uint corner = FRUSTUM_EDGES[vertex_id];
+
+#if VISUALIZE_REFERENCE
+
+    vec4 world = reconstruct_reference_corner(corner);
+
+#else
+
+    Frustum frustum = extract_frustum_(pc.debug_view_proj);
+
+    build_culling_far_plane(frustum, frame);
+
+    vec4 world = reconstruct_extracted_corner(frustum, corner);
+
+#endif
+
+    return (world * frame.view_proj);
+}
+
+[shader("fragment")]
+vec4 fsMain() : SV_Target {
+#if VISUALIZE_REFERENCE
+    return vec4(100.0, 0.0, 100.0, 1.0);
+#endif
+    return vec4(0.0, 100.00, 100.0, 10.0);
+}
ADD · src/shaders/ibl/brdf_lut.slang +25 -0
--- a/src/shaders/ibl/brdf_lut.slang
+++ b/src/shaders/ibl/brdf_lut.slang
@@ -0,0 +1,25 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "lib/brdf.slang"
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID) {
+    VtxOut o;
+
+    vec2 positions[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+
+    vec2 pos = positions[vertexID];
+    o.clip_pos = vec4(pos, 0.0, 1.0);
+    o.uv = pos * 0.5 + 0.5;
+
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target0 {
+    f32 NdotV = saturate(input.uv.x);
+    f32 roughness = saturate(input.uv.y);
+
+    vec2 brdf = IntegrateBRDF(NdotV, roughness);
+    return vec4(brdf, 0.0, 1.0);
+}
ADD · src/shaders/ibl/cubemap.slang +30 -0
--- a/src/shaders/ibl/cubemap.slang
+++ b/src/shaders/ibl/cubemap.slang
@@ -0,0 +1,30 @@
+#pragma once
+
+vec3 CubemapFaceDirection(u32 face, vec2 uv) {
+    // top-left origin, flip V so 0 is at the bottom of the face
+    vec2 p = vec2(uv.x, 1.0 - uv.y) * 2.0 - 1.0;
+    vec3 dir;
+
+    switch (face) {
+    case 0:
+        dir = vec3(1.0, -p.y, -p.x);
+        break; // +X (Right)
+    case 1:
+        dir = vec3(-1.0, -p.y, p.x);
+        break; // -X (Left)
+    case 2:
+        dir = vec3(p.x, 1.0, p.y);
+        break; // +Y (Top)
+    case 3:
+        dir = vec3(p.x, -1.0, -p.y);
+        break; // -Y (Bottom)
+    case 4:
+        dir = vec3(p.x, -p.y, 1.0);
+        break; // +Z (Front)
+    default:
+        dir = vec3(-p.x, -p.y, -1.0);
+        break; // -Z (Back)
+    }
+
+    return normalize(dir);
+}
ADD · src/shaders/ibl/equirect_to_cube.slang +36 -0
--- a/src/shaders/ibl/equirect_to_cube.slang
+++ b/src/shaders/ibl/equirect_to_cube.slang
@@ -0,0 +1,36 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "cubemap.slang"
+
+[[vk::push_constant]]
+IblConstants pc;
+
+// convention: panorama center (u = 0.5) faces +Y, u increases toward +X
+// sources with a different forward requires re-yawing, not editing this
+// no clue if equirects are standardized at all
+// or if I'll need to re-yaw for each new source
+vec2 SampleSphericalMap(vec3 dir) {
+    dir = normalize(dir);
+    vec2 uv;
+    uv.x = atan2(dir.x, dir.y) * 0.15915494309 + 0.5;
+    uv.y = 0.5 - asin(dir.z) * 0.31830988618;
+    return uv;
+}
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID) {
+    VtxOut o;
+    vec2 positions[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+    vec2 pos = positions[vertexID];
+    o.clip_pos = vec4(pos, 0.0, 1.0);
+    o.uv = pos * 0.5 + 0.5;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target0 {
+    vec3 dir = CubemapFaceDirection(pc.faceidx, input.uv);
+    vec2 hdrUV = SampleSphericalMap(dir);
+    vec3 color = pc.hdrTexture.Sample(pc.samp, hdrUV).rgb;
+    return vec4(color, 1.0);
+}
ADD · src/shaders/ibl/ibl_lighting.slang +34 -0
--- a/src/shaders/ibl/ibl_lighting.slang
+++ b/src/shaders/ibl/ibl_lighting.slang
@@ -0,0 +1,34 @@
+#pragma once
+#include "shared.h"
+#include "lib/brdf.slang"
+
+vec3 evaluate_ibl(
+    vec3 albedo,
+    vec3 normalWS,
+    vec3 V,
+    f32 NdotV,
+    f32 roughness,
+    f32 metallic,
+    vec3 F0,
+    SamplerState samp,
+    TextureCube<float4> env_irradiance,
+    TextureCube<float4> env_prefilter,
+    Texture2D env_brdf_lut,
+    u32 env_prefilter_mip_count,
+
+) {
+    vec3 irradiance = env_irradiance.Sample(samp, normalWS.xyz).rgb;
+
+    vec3 F_ibl = F_SchlickRoughness(NdotV, F0, roughness);
+    vec3 kD_ibl = (1.0 - F_ibl) * (1.0 - metallic);
+
+    vec3 R = reflect(-V, normalWS);
+    f32 maxReflectionLod = f32(env_prefilter_mip_count - 1);
+    vec3 prefilteredColor = env_prefilter.SampleLevel(samp, R, roughness * maxReflectionLod).rgb;
+    vec2 brdf = env_brdf_lut.Sample(samp, vec2(NdotV, roughness)).rg;
+
+    vec3 diffuseIBL = irradiance * albedo * kD_ibl;
+    vec3 specularIBL = prefilteredColor * (F_ibl * brdf.x + brdf.y);
+
+    return specularIBL + diffuseIBL;
+};
ADD · src/shaders/ibl/irradiance_convolution.slang +50 -0
--- a/src/shaders/ibl/irradiance_convolution.slang
+++ b/src/shaders/ibl/irradiance_convolution.slang
@@ -0,0 +1,50 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "cubemap.slang"
+
+[[vk::push_constant]]
+IblConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID) {
+    VtxOut o;
+    vec2 positions[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+
+    vec2 pos = positions[vertexID];
+    o.clip_pos = vec4(pos, 0.0, 1.0);
+    o.uv = pos * 0.5 + 0.5;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target0 {
+    vec3 N = CubemapFaceDirection(pc.faceidx, input.uv);
+
+    vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
+    vec3 T = normalize(cross(up, N));
+    vec3 B = cross(N, T);
+
+    TextureCube<float4> env = pc.environment;
+    SamplerState samp = pc.samp;
+
+    vec3 irradiance = 0.0;
+    u32 sampleCount = 0;
+
+    const f32 PI = 3.14159265359;
+    const f32 sampleDelta = 0.0025;
+
+    for (f32 phi = 0.0; phi < 2.0 * PI; phi += sampleDelta) {
+        for (f32 theta = 0.0; theta < 0.5 * PI; theta += sampleDelta) {
+            vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
+
+            vec3 sampleDir = tangentSample.x * T + tangentSample.y * B + tangentSample.z * N;
+
+            irradiance += env.SampleLevel(samp, sampleDir, 0.0).rgb * cos(theta) * sin(theta);
+            sampleCount++;
+        }
+    }
+
+    irradiance = PI * irradiance / f32(sampleCount);
+    // irradiance *= sampleDelta * sampleDelta;
+    return vec4(irradiance, 1.0);
+}
ADD · src/shaders/ibl/prefilter_env.slang +80 -0
--- a/src/shaders/ibl/prefilter_env.slang
+++ b/src/shaders/ibl/prefilter_env.slang
@@ -0,0 +1,80 @@
+#include "shared.h"
+#include "renderer_types.h"
+#include "cubemap.slang"
+#include "lib/brdf.slang"
+
+[[vk::push_constant]]
+IblConstants pc;
+
+[shader("vertex")]
+VtxOut vsMain(u32 vertexID: SV_VertexID) {
+    VtxOut o;
+
+    vec2 positions[3] = { vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) };
+
+    vec2 pos = positions[vertexID];
+    o.clip_pos = vec4(pos, 0.0, 1.0);
+    o.uv = pos * 0.5 + 0.5;
+    return o;
+}
+
+[shader("fragment")]
+vec4 fsMain(VtxOut input) : SV_Target0 {
+    const f32 PI = 3.14159265359;
+
+    vec3 N = CubemapFaceDirection(pc.faceidx, input.uv);
+    vec3 V = N;
+
+    TextureCube<float4> env = pc.environment;
+    SamplerState samp = pc.samp;
+
+    const u32 SAMPLE_COUNT = 2048;
+
+    vec3 prefilteredColor = 0.0;
+    f32 totalWeight = 0.0;
+
+    // for (u32 i = 0u; i < SAMPLE_COUNT; ++i) {
+    //     vec2 xi = Hammersley(i, SAMPLE_COUNT);
+    //     vec3 H  = ImportanceSampleGGX(xi, N, pc.roughness);
+    //     vec3 L  = normalize(2.0 * dot(V, H) * H - V);
+    //
+    //     f32 NdotL = saturate(dot(N, L));
+    //
+    //     if (NdotL > 0.0) {
+    //         prefilteredColor += env.SampleLevel(samp, L, 0.0).rgb * NdotL;
+    //         totalWeight += NdotL;
+    //     }
+    // }
+
+    for (u32 i = 0u; i < SAMPLE_COUNT; ++i) {
+        vec2 xi = Hammersley(i, SAMPLE_COUNT);
+
+        vec3 H = ImportanceSampleGGX(xi, N, pc.roughness);
+        vec3 L = normalize(2.0 * dot(V, H) * H - V);
+
+        f32 NdotL = saturate(dot(N, L));
+
+        if (NdotL > 0.0) {
+            f32 NdotH = saturate(dot(N, H));
+            f32 HdotV = saturate(dot(H, V));
+
+            f32 D = D_GGX(NdotH, pc.roughness);
+
+            f32 pdf = (D * NdotH / (4.0 * HdotV)) + 0.0001;
+
+            // TODO: share this
+            f32 resolution = pc.environment_resolution;
+            f32 saTexel = 4.0 * PI / (6.0 * resolution * resolution);
+            f32 saSample = 1.0 / (f32(SAMPLE_COUNT) * pdf + 0.0001);
+
+            f32 mipLevel = pc.roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel);
+            vec3 sampleColor = env.SampleLevel(samp, L, mipLevel).rgb;
+
+            prefilteredColor += sampleColor * NdotL;
+            totalWeight += NdotL;
+        }
+    }
+
+    prefilteredColor /= max(totalWeight, 0.0001);
+    return vec4(prefilteredColor, 1.0);
+}
ADD · src/shaders/lib/brdf.slang +111 -0
--- a/src/shaders/lib/brdf.slang
+++ b/src/shaders/lib/brdf.slang
@@ -0,0 +1,111 @@
+#pragma once
+
+#include "shared.h"
+
+static const f32 PI = 3.14159265359;
+
+// --- Low-discrepancy sampling helpers ---
+
+f32 RadicalInverseVdC(u32 bits) {
+    bits = (bits << 16u) | (bits >> 16u);
+    bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
+    bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
+    bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
+    bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
+    return f32(bits) * 2.3283064365386963e-10;
+}
+
+vec2 Hammersley(u32 i, u32 n) {
+    return vec2(f32(i) / f32(n), RadicalInverseVdC(i));
+}
+
+vec3 ImportanceSampleGGX(vec2 xi, vec3 N, f32 roughness) {
+    f32 a = roughness * roughness;
+    f32 phi = 2.0 * PI * xi.x;
+    f32 cosTheta = sqrt((1.0 - xi.y) / (1.0 + (a * a - 1.0) * xi.y));
+    f32 sinTheta = sqrt(max(1.0 - cosTheta * cosTheta, 0.0));
+
+    vec3 H;
+    H.x = cos(phi) * sinTheta;
+    H.y = sin(phi) * sinTheta;
+    H.z = cosTheta;
+
+    vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
+    vec3 T = normalize(cross(up, N));
+    vec3 B = cross(N, T);
+
+    return normalize(T * H.x + B * H.y + N * H.z);
+}
+
+// --- Normal distribution function (GGX / Trowbridge-Reitz) ---
+
+f32 D_GGX(f32 NdotH, f32 roughness) {
+    f32 a = roughness * roughness;
+    f32 a2 = a * a;
+    f32 denom = (NdotH * NdotH) * (a2 - 1.0) + 1.0;
+    return a2 / max(PI * denom * denom, 1e-7);
+}
+
+// --- Geometry (Smith-GGX with Schlick-GGX approximation) ---
+
+f32 G_SchlickGGX(f32 NdotV, f32 k) {
+    return NdotV / (NdotV * (1.0 - k) + k);
+}
+
+f32 G_Smith_Direct(f32 NdotV, f32 NdotL, f32 roughness) {
+    f32 r = roughness + 1.0;
+    f32 k = (r * r) / 8.0;
+    return G_SchlickGGX(NdotV, k) * G_SchlickGGX(NdotL, k);
+}
+
+f32 G_Smith_IBL(f32 NdotV, f32 NdotL, f32 roughness) {
+    f32 k = (roughness * roughness) / 2.0;
+    return G_SchlickGGX(NdotV, k) * G_SchlickGGX(NdotL, k);
+}
+
+// --- Fresnel (Schlick approximation) ---
+
+vec3 F_Schlick(f32 cosTheta, vec3 F0) {
+    return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);
+}
+
+vec3 F_SchlickRoughness(f32 cosTheta, vec3 F0, f32 roughness) {
+    return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(1.0 - cosTheta, 5.0);
+}
+
+// --- BRDF integration (split-sum approximation for the IBL LUT) ---
+
+vec2 IntegrateBRDF(f32 NdotV, f32 roughness) {
+    const u32 SAMPLE_COUNT = 1024u;
+
+    vec3 V;
+    V.x = sqrt(max(1.0 - NdotV * NdotV, 0.0));
+    V.y = 0.0;
+    V.z = NdotV;
+
+    vec3 N = vec3(0.0, 0.0, 1.0);
+
+    f32 A = 0.0;
+    f32 B = 0.0;
+
+    for (u32 i = 0u; i < SAMPLE_COUNT; ++i) {
+        vec2 xi = Hammersley(i, SAMPLE_COUNT);
+        vec3 H = ImportanceSampleGGX(xi, N, roughness);
+        vec3 L = normalize(2.0 * dot(V, H) * H - V);
+
+        f32 NdotL = saturate(L.z);
+        f32 NdotH = saturate(H.z);
+        f32 VdotH = saturate(dot(V, H));
+
+        if (NdotL > 0.0) {
+            f32 G = G_Smith_IBL(NdotV, NdotL, roughness);
+            f32 G_Vis = (G * VdotH) / max(NdotH * NdotV, 0.0001);
+            f32 Fc = pow(1.0 - VdotH, 5.0);
+
+            A += (1.0 - Fc) * G_Vis;
+            B += Fc * G_Vis;
+        }
+    }
+
+    return vec2(A, B) / f32(SAMPLE_COUNT);
+}
ADD · src/shaders/lib/cluster_lighting.slang +95 -0
--- a/src/shaders/lib/cluster_lighting.slang
+++ b/src/shaders/lib/cluster_lighting.slang
@@ -0,0 +1,95 @@
+#pragma once
+
+#include "shared.h"
+#include "lib/brdf.slang"
+
+u32 flatten_cluster_index(u32 tx, u32 ty, u32 tz, u32 countX, u32 countY) {
+    return tz * countX * countY + ty * countX + tx;
+}
+
+uvec3 compute_cluster_counts(u32 screen_width, u32 screen_height) {
+    u32 cluster_count_x = (screen_width + TILE_SIZE_X - 1) / TILE_SIZE_X;
+    u32 cluster_count_y = (screen_height + TILE_SIZE_Y - 1) / TILE_SIZE_Y;
+    u32 cluster_count_z = CLUSTER_COUNT_Z;
+    return uvec3(cluster_count_x, cluster_count_x, cluster_count_z);
+}
+
+// eval the depth slice index for a given view-space depth
+// logarithmic subdivision: slices are uniformly distributed in log space
+// TODO: link the gpu gems
+u32 compute_depth_slice(f32 viewDepth, f32 nearPlane, f32 farPlane, u32 numSlices) {
+    f32 slice = log(viewDepth / nearPlane) / log(farPlane / nearPlane) * f32(numSlices);
+    return min(u32(slice), numSlices - 1);
+}
+
+// evals all clustered point lights affecting the given fragment
+// outputs the ClusterRecord via `cr` so callers (e.g. debug views) can
+// inspect lightCount without re-loading from the buffer.
+vec3 evaluate_cluster_lights(
+    VtxOut input,
+    vec3 worldPos,
+    vec3 normalWS,
+    vec3 V,
+    f32 NdotV,
+    f32 roughness,
+    f32 metallic,
+    vec3 F0,
+    vec4 albedo,
+    // FwdDrawPushConstants pc,
+    FrameUBO frame,
+    ClusterRecord cr,
+) {
+    vec2 pixel = input.clip_pos.xy;
+
+    ClusterGrid data = frame.cluster;
+    LightCull lc_data = frame.light_cull;
+
+    uint tileX = uint(pixel.x) / TILE_SIZE_X;
+    uint tileY = uint(pixel.y) / TILE_SIZE_Y;
+    f32 vDepth = clamp(abs(input.view_pos.z), frame.near_plane, frame.far_plane);
+    u32 tz = compute_depth_slice(vDepth, frame.near_plane, frame.far_plane, data.cluster_count_z);
+    u32 flatIdx = flatten_cluster_index(tileX, tileY, tz, data.cluster_count_x, data.cluster_count_y);
+
+    cr.lightOffset = lc_data.clusters_records[flatIdx].lightOffset;
+    cr.lightCount = lc_data.clusters_records[flatIdx].lightCount;
+
+    vec3 point_lighting = 0.0;
+
+    for (u32 i = 0; i < cr.lightCount; ++i) {
+        u32 li = lc_data.light_index_list[cr.lightOffset + i];
+        PointLightGPU pl = frame.point_lights[li];
+        vec3 pl_pos = pl.position;
+        f32 pl_range = pl.range;
+        vec3 pl_col = pl.color;
+        f32 pl_int = pl.intensity;
+
+        vec3 L_pl = pl_pos - worldPos;
+        f32 dist = length(L_pl);
+        L_pl /= max(dist, 1e-6);
+
+        f32 atten = 1.0 / (dist * dist + 1.0);
+        atten = saturate(1.0 - (dist * dist) / (pl_range * pl_range));
+        atten *= atten;
+
+        vec3 H_pl = normalize(V + L_pl);
+
+        f32 NdotL_pl = saturate(dot(normalWS, L_pl));
+        f32 NdotH_pl = saturate(dot(normalWS, H_pl));
+        f32 VdotH_pl = saturate(dot(V, H_pl));
+
+        f32 D_pl = D_GGX(NdotH_pl, roughness);
+        f32 G_pl = G_Smith_Direct(NdotV, NdotL_pl, roughness);
+        vec3 F_pl = F_Schlick(VdotH_pl, F0);
+
+        vec3 specular_pl = (D_pl * G_pl * F_pl) / max(4.0 * NdotV * NdotL_pl, 1e-5);
+
+        vec3 kS_pl = F_pl;
+        vec3 kD_pl = (1.0 - kS_pl) * (1.0 - metallic);
+
+        vec3 diffuse_pl = kD_pl * albedo.xyz * (1.0 / 3.14159265);
+
+        point_lighting += (diffuse_pl + specular_pl) * pl_col * pl_int * NdotL_pl * atten;
+    }
+
+    return point_lighting;
+}
ADD · src/shaders/lib/ddgi_common.slang +213 -0
--- a/src/shaders/lib/ddgi_common.slang
+++ b/src/shaders/lib/ddgi_common.slang
@@ -0,0 +1,213 @@
+#pragma once
+
+#include "shared.h"
+#include "octahedral.slang"
+
+// linear probe index to 3d grid coord
+uvec3 ProbeCoord(u32 probe_idx, uvec3 dims) {
+    return uvec3(probe_idx % dims.x, (probe_idx / dims.x) % dims.y, probe_idx / (dims.x * dims.y));
+}
+
+u32 ProbeIndex(uvec3 coord, uvec3 dims) {
+    return coord.x + coord.y * dims.x + coord.z * dims.x * dims.y;
+}
+
+// world pos of probe from linear index
+vec3 ProbePosition(u32 probe_idx, vec3 origin, vec3 spacing, uvec3 dims) {
+    uvec3 coord = ProbeCoord(probe_idx, dims);
+    return origin + (vec3(coord) - (vec3(dims) - 1.0f) * 0.5f) * spacing;
+}
+
+// world pos of probe from grid coord
+vec3 ProbePositionFromCoord(uvec3 coord, vec3 origin, vec3 spacing, uvec3 dims) {
+    return origin + (vec3(coord) - (vec3(dims) - 1.0f) * 0.5f) * spacing;
+}
+
+// relocation offset, stored normalized (offset / spacing)
+vec3 ProbeOffset(ProbeState *probe_state, u32 probe_idx, vec3 spacing) {
+    return probe_state[probe_idx].offset_active.xyz * spacing;
+}
+
+// probe state, 0 = active, 1 = inactive
+f32 LoadProbeState(ProbeState *probe_state, u32 probe_idx) {
+    return probe_state[probe_idx].offset_active.w;
+}
+
+// spherical fibonacci dir for even ray spread
+vec3 fibonacci_ray_direction(uint ray_slot, uint rays_per_probe) {
+    const f32 PI = 3.14159265f;
+    const f32 GOLDEN_ANGLE = 2.39996323f;
+
+    f32 t = (f32(ray_slot) + 0.5f) / f32(rays_per_probe);
+    f32 y = 1.0f - 2.0f * t;
+    f32 r = sqrt(max(0.0f, 1.0f - y * y));
+    f32 phi = GOLDEN_ANGLE * f32(ray_slot);
+
+    return vec3(cos(phi) * r, y, sin(phi) * r);
+}
+
+// probe index to tile pixel origin in atlas
+uvec2 ProbeTileOrigin(uint probe_idx, uint tiles_per_row, uint tile_stride) {
+    return uvec2((probe_idx % tiles_per_row) * tile_stride, (probe_idx / tiles_per_row) * tile_stride);
+}
+
+// octahedral uv [0,1] to atlas uv for samplelevel
+vec2 OctUVtoAtlasUV(vec2 oct_uv, uvec2 tile_origin, vec2 atlas_size, uint atlas_tile_size) {
+    // interior texel i (local 1+i) holds oct_uv = (i + 0.5) / tile_size,
+    // so the inverse is local = oct_uv * tile_size + 1 (matches DDGIGetProbeUV)
+    vec2 local_pixel = oct_uv * f32(atlas_tile_size) + 1.0f;
+    return (vec2(tile_origin) + local_pixel) / atlas_size;
+}
+
+// low discrepancy sphere dir for sample index, same set every time
+static const f32 DDGI_PI = 3.1415926535897932f;
+static const f32 DDGI_2PI = 6.2831853071795864f;
+vec3 SphericalFibonacci(f32 sampleIndex, f32 numSamples) {
+    const f32 b = (sqrt(5.f) * 0.5f + 0.5f) - 1.f;
+    f32 phi = DDGI_2PI * frac(sampleIndex * b);
+    f32 cosTheta = 1.f - (2.f * sampleIndex + 1.f) * (1.f / numSamples);
+    f32 sinTheta = sqrt(saturate(1.f - (cosTheta * cosTheta)));
+
+    return vec3((cos(phi) * sinTheta), (sin(phi) * sinTheta), cosTheta);
+}
+
+f32 chebyshev_visibility(f32 surface_distance, f32 mean_depth, f32 mean_depth_squared) {
+    f32 variance = abs(mean_depth * mean_depth - mean_depth_squared);
+
+    f32 visibility = 1.0f;
+    if (surface_distance > mean_depth) {
+        f32 delta = surface_distance - mean_depth;
+        visibility = variance / (variance + delta * delta);
+        visibility = max(pow(visibility, 3.0f), 0.0f);
+    }
+
+    return max(visibility, 0.05f);
+}
+
+vec3 eval_sampling_bias(f32 probe_max_spacing, vec3 camera_position, vec3 position, vec3 geo_normal) {
+    const f32 BIAS_FACTOR = 0.25f;
+    const f32 NORMAL_TO_VIEW_WEIGHT = 0.3f;
+    const f32 origin_to_sample_dst = length(camera_position - position);
+    const f32 sample_offset = min(probe_max_spacing * BIAS_FACTOR, origin_to_sample_dst * 0.5f);
+    const vec3 sample_to_origin = normalize(camera_position - position);
+    return position + lerp(sample_to_origin, geo_normal, NORMAL_TO_VIEW_WEIGHT) * sample_offset;
+}
+
+// fade weight [0,1] near grid edges
+f32 ddgi_volume_blend_weight(vec3 world_position, DdgiGridParams grid) {
+    vec3 probe_coords = (world_position - grid.origin.xyz) / grid.spacing.xyz + (vec3(grid.dims.xyz) - 1.0f) * 0.5f;
+    vec3 over_max = vec3(grid.dims.xyz) - 1.0f - probe_coords;
+
+    f32 w = 1.0f;
+    w *= clamp(probe_coords.x, 0.0f, 1.0f) * clamp(over_max.x, 0.0f, 1.0f);
+    w *= clamp(probe_coords.y, 0.0f, 1.0f) * clamp(over_max.y, 0.0f, 1.0f);
+    w *= clamp(probe_coords.z, 0.0f, 1.0f) * clamp(over_max.z, 0.0f, 1.0f);
+    return w;
+}
+
+vec3 sample_ddgi_irradiance(
+    vec3 world_position,
+    vec3 world_normal,
+    DdgiGridParams grid,
+    FrameUBO frame,
+    Texture2D irradiance_atlas,
+    Texture2D distance_atlas,
+    ProbeState *probe_state,
+    bool is_camera_pass
+) {
+    vec4 probe_origin_packed = grid.origin;
+    vec3 probe_origin = probe_origin_packed.xyz;
+
+    vec4 probe_spacing_packed = grid.spacing;
+    vec3 probe_spacing = probe_spacing_packed.xyz;
+    f32 max_spacing = probe_spacing_packed.w;
+
+    vec4 probe_dims_packed = grid.dims;
+    uvec3 probe_dims = uvec3(probe_dims_packed.xyz);
+
+    vec4 cam_pos = frame.position_ws;
+    world_position = eval_sampling_bias(max_spacing, cam_pos.xyz, world_position, world_normal);
+
+    // grid coord, [0, dims-1] spans first to last probe
+    vec3 grid_fraction = (world_position - probe_origin) / probe_spacing + (vec3(probe_dims) - 1.0f) * 0.5f;
+
+    // clamp to grid range
+    vec3 clamped_fraction = clamp(grid_fraction, vec3(0.0f), vec3(probe_dims) - 1.0f - 1e-6f);
+    ivec3 cell_lower = ivec3(floor(clamped_fraction));
+    vec3 trilinear_alpha = clamped_fraction - vec3(cell_lower);
+
+    u32 irr_w;
+    u32 irr_h;
+    irradiance_atlas.GetDimensions(irr_w, irr_h);
+    u32 irr_tiles_per_row = irr_w / IRRADIANCE_TILE_STRIDE;
+
+    u32 dist_w;
+    u32 dist_h;
+    distance_atlas.GetDimensions(dist_w, dist_h);
+    u32 dist_tiles_per_row = dist_w / DISTANCE_TILE_STRIDE;
+
+    vec2 octahedral_uv = OctEncode(world_normal) * 0.5f + 0.5f;
+
+    vec3 accumulated_irradiance = vec3(0.0f);
+    f32 accumulated_weight = 0.0f;
+
+    for (int corner_index = 0; corner_index < 8; corner_index++) {
+        ivec3 corner_offset = ivec3(corner_index & 1, (corner_index >> 1) & 1, (corner_index >> 2) & 1);
+        ivec3 corner_coord = clamp(cell_lower + corner_offset, ivec3(0), ivec3(probe_dims) - 1);
+        u32 probe_index = corner_coord.z * probe_dims.y * probe_dims.x + corner_coord.y * probe_dims.x + corner_coord.x;
+
+        f32 weight = 1.0f;
+
+        f32 probe_state_value = LoadProbeState(probe_state, probe_index);
+        if (probe_state_value >= DDGI_STATE_PROBE_INACTIVE) {
+            continue;
+        }
+
+        vec3 trilinear = max(vec3(0.001f), lerp(1.0f - trilinear_alpha, trilinear_alpha, vec3(corner_offset)));
+        f32 trilinear_weight = trilinear.x * trilinear.y * trilinear.z;
+
+        uvec2 tile_origin = ProbeTileOrigin(probe_index, irr_tiles_per_row, IRRADIANCE_TILE_STRIDE);
+        vec2 atlas_uv = OctUVtoAtlasUV(octahedral_uv, tile_origin, vec2(irr_w, irr_h), IRRADIANCE_SIZE);
+        vec4 irradiance = irradiance_atlas.SampleLevel(frame.linear_clamp, atlas_uv, 0);
+
+        // dir from probe to surface, atlas is keyed by probe dir
+        vec3 grid_pos = probe_origin + (vec3(corner_coord) - (vec3(probe_dims) - 1.0f) * 0.5f) * probe_spacing;
+        vec3 probe_off = ProbeOffset(probe_state, probe_index, probe_spacing);
+        vec3 actual_probe_position = grid_pos + probe_off;
+        vec3 probe_to_surface = normalize(world_position - actual_probe_position);
+        f32 distance_to_surface = length(world_position - actual_probe_position);
+
+        vec3 unbiased_dir = normalize(actual_probe_position - world_position);
+        f32 wrap_shading = (dot(unbiased_dir, world_normal) + 1.0f) * 0.5f;
+        weight *= (wrap_shading * wrap_shading) + 0.2f;
+
+        // sample distance atlas
+        vec2 distance_uv = OctEncode(probe_to_surface) * 0.5f + 0.5f;
+        uvec2 dist_tile = ProbeTileOrigin(probe_index, dist_tiles_per_row, DISTANCE_TILE_STRIDE);
+        vec2 dist_atlas_uv = OctUVtoAtlasUV(distance_uv, dist_tile, vec2(dist_w, dist_h), ATLAS_SIZE);
+        vec4 distance_tex = distance_atlas.SampleLevel(frame.linear_clamp, dist_atlas_uv, 0);
+
+        f32 mean_depth = distance_tex.r * 2.0f;
+        f32 mean_depth2 = distance_tex.g * 2.0f;
+
+        weight *= chebyshev_visibility(distance_to_surface, mean_depth, mean_depth2);
+
+        // keep weight off zero
+        weight = max(0.00001f, weight);
+
+        const f32 crush_threshold = 0.2f;
+        if (weight < crush_threshold) {
+            weight *= (weight * weight) * (1.0f / (crush_threshold * crush_threshold));
+        }
+
+        weight *= trilinear_weight;
+        accumulated_irradiance += weight * pow(irradiance.rgb, frame.ddgi_cfg.irradiance_encoding_gamma * 0.5f);
+        accumulated_weight += weight;
+    }
+
+    // no live probes around, return black
+    vec3 result = accumulated_weight > 0.0f ? accumulated_irradiance / accumulated_weight : vec3(0.0f);
+    result = result * result * DDGI_2PI;
+
+    return result;
+}
ADD · src/shaders/lib/frustum_culling.slang +156 -0
--- a/src/shaders/lib/frustum_culling.slang
+++ b/src/shaders/lib/frustum_culling.slang
@@ -0,0 +1,156 @@
+#pragma once
+
+#include "shared.h"
+#include "renderer_types.h"
+
+struct Frustum {
+    vec4 planes[6]; // left, right, top, bottom, near, far
+};
+
+void set_far_plane(inout Frustum frustum, vec3 camera_position, vec3 camera_forward, f32 max_draw_distance) {
+    // point on the far plane
+    vec3 point = camera_position + camera_forward * max_draw_distance;
+
+    // plane normal points back toward the camera
+    vec3 normal = -normalize(camera_forward);
+
+    // plane equation: dot(n, x) + d = 0
+    f32 d = -dot(normal, point);
+
+    frustum.planes[5] = vec4(normal, d);
+}
+
+Frustum extract_frustum(mat4 view_proj) {
+    Frustum f;
+
+    mat4 rows = transpose(view_proj);
+
+    f.planes[0] = rows[3] + rows[0]; // left
+    f.planes[1] = rows[3] - rows[0]; // right
+    f.planes[2] = rows[3] + rows[1]; // bottom
+    f.planes[3] = rows[3] - rows[1]; // top
+    f.planes[4] = rows[3] - rows[2]; // near (reverse-z)
+
+    // placeholder, we'll replace this with our finite culling distance
+    f.planes[5] = rows[2];
+
+    for (uint i = 0; i < 6; ++i)
+        f.planes[i] /= length(f.planes[i].xyz);
+
+    return f;
+}
+
+bool sphere_visible_in_frustum(vec3 center, f32 radius, Frustum f) {
+    for (int i = 0; i < 6; i++) {
+        f32 dist = dot(f.planes[i].xyz, center) + f.planes[i].w;
+        if (dist < -radius) {
+            return false; // fully outside this plane
+        }
+    }
+    return true; // At least partially visible
+}
+
+bool is_object_visible(SubmeshGPU part, TransformGPU transform, Frustum frustum) {
+    vec4 sphere_center_ws4 = vec4(part.local_sphere.xyz, 1.0f) * transform.world;
+    vec3 sphere_center_ws = sphere_center_ws4.xyz / sphere_center_ws4.w;
+    vec3 scale_axis =
+        vec3(length(transform.world[0].xyz), length(transform.world[1].xyz), length(transform.world[2].xyz));
+    f32 sphere_radius_ws = part.local_sphere.w * max(max(scale_axis.x, scale_axis.y), scale_axis.z);
+
+    bool is_vis = sphere_visible_in_frustum(sphere_center_ws, sphere_radius_ws, frustum);
+    return is_vis;
+}
+
+// true if the AABB is entirely behind the depth buffer at its screen projection,
+// false if any part of the AABB is visible
+bool is_object_occluded(
+    vec3 local_aabb_min,
+    vec3 local_aabb_max,
+    TransformGPU transform,
+    mat4 view_proj,
+    Texture2D hiz_tex,
+    u32 hiz_width,
+    u32 hiz_height,
+    u32 hiz_mip_count
+) {
+    vec3 corners[8] = {
+        vec3(local_aabb_min.x, local_aabb_min.y, local_aabb_min.z),
+        vec3(local_aabb_max.x, local_aabb_min.y, local_aabb_min.z),
+        vec3(local_aabb_min.x, local_aabb_max.y, local_aabb_min.z),
+        vec3(local_aabb_max.x, local_aabb_max.y, local_aabb_min.z),
+        vec3(local_aabb_min.x, local_aabb_min.y, local_aabb_max.z),
+        vec3(local_aabb_max.x, local_aabb_min.y, local_aabb_max.z),
+        vec3(local_aabb_min.x, local_aabb_max.y, local_aabb_max.z),
+        vec3(local_aabb_max.x, local_aabb_max.y, local_aabb_max.z),
+    };
+
+    vec2 uv_min = vec2(1e30f);
+    vec2 uv_max = vec2(-1e30f);
+    f32 nearest_depth = 0.0f;
+
+    [unroll]
+    for (u32 i = 0; i < 8; ++i) {
+        vec4 clip = (vec4(corners[i], 1.0f) * transform.world) * view_proj;
+
+        if (clip.w <= 0.0f)
+            return false;
+
+        vec3 ndc = clip.xyz / clip.w;
+        vec2 uv = ndc.xy * vec2(0.5f, -0.5f) + vec2(0.5f);
+
+        uv_min = min(uv_min, uv);
+        uv_max = max(uv_max, uv);
+        nearest_depth = max(nearest_depth, ndc.z);
+    }
+
+    if (uv_max.x < 0.0f || uv_max.y < 0.0f || uv_min.x > 1.0f || uv_min.y > 1.0f)
+        return false;
+
+    uv_min = clamp(uv_min, 0.0f.xx, 1.0f.xx);
+    uv_max = clamp(uv_max, 0.0f.xx, 1.0f.xx);
+
+    vec2 rect_px = (uv_max - uv_min) * vec2(hiz_width, hiz_height);
+    f32 max_rect = max(rect_px.x, rect_px.y);
+    // u32  mip      = min(u32(floor(log2(max(max_rect, 1.0f)))), hiz_mip_count - 1);
+    // mip           = min(mip, hiz_mip_count - 1);
+    const u32 MAX_HIZ_MIP = 5;
+    // u32       mip         = min(u32(floor(log2(max(max_rect, 1.0f)))), min(hiz_mip_count - 1, MAX_HIZ_MIP));
+    //
+    // ceil(log2) ensures the projected rect fits within <=~2 texels per axis
+    // at the selected mip, making 4-corner sampling conservative.
+    // floor(log2) could let the rect span ~3 texels, allowing interior gaps
+    // where a different texel's far depth gets missed.
+    u32 mip = min(u32(ceil(log2(max(max_rect, 1.0f)))), min(hiz_mip_count - 1, MAX_HIZ_MIP));
+
+    vec2 expand = 0.5f / vec2(max(hiz_width >> mip, 1u), max(hiz_height >> mip, 1u));
+    uv_min = clamp(uv_min - expand, 0.0f.xx, 1.0f.xx);
+    uv_max = clamp(uv_max + expand, 0.0f.xx, 1.0f.xx);
+
+    uint w, h;
+    hiz_tex.GetDimensions(w, h);
+
+    uint mipW = max(1u, (w + (1u << mip) - 1u) >> mip);
+    uint mipH = max(1u, (h + (1u << mip) - 1u) >> mip);
+
+    uvec2 p0 = min(uvec2(uv_min * vec2(mipW, mipH)), uvec2(mipW - 1, mipH - 1));
+    uvec2 p1 = min(uvec2(vec2(uv_max.x, uv_min.y) * vec2(mipW, mipH)), uvec2(mipW - 1, mipH - 1));
+    uvec2 p2 = min(uvec2(vec2(uv_min.x, uv_max.y) * vec2(mipW, mipH)), uvec2(mipW - 1, mipH - 1));
+    uvec2 p3 = min(uvec2(uv_max * vec2(mipW, mipH)), uvec2(mipW - 1, mipH - 1));
+
+    f32 d0 = hiz_tex.Load(ivec3(p0, mip)).r;
+    f32 d1 = hiz_tex.Load(ivec3(p1, mip)).r;
+    f32 d2 = hiz_tex.Load(ivec3(p2, mip)).r;
+    f32 d3 = hiz_tex.Load(ivec3(p3, mip)).r;
+
+    f32 hiz_depth = min(min(d0, d1), min(d2, d3));
+    f32 bias = 0.1; // / 0.0001;  // TODO: 0.1 is the near plane
+
+    return nearest_depth + bias < hiz_depth;
+}
+
+bool sphere_intersects_aabb(vec3 center, f32 radius, vec3 bmin, vec3 bmax) {
+    vec3 closest = clamp(center, bmin, bmax);
+    vec3 d = center - closest;
+    return dot(d, d) <= radius * radius;
+}
+
ADD · src/shaders/lib/octahedral.slang +18 -0
--- a/src/shaders/lib/octahedral.slang
+++ b/src/shaders/lib/octahedral.slang
@@ -0,0 +1,18 @@
+#pragma once
+
+// octahedral encoding: unit direction <-> [-1, 1]²
+// from McGuire's reference, based on Meyer et al.
+
+vec2 OctEncode(vec3 n) {
+    n /= abs(n.x) + abs(n.y) + abs(n.z);
+    vec2 uv = n.z >= 0.0 ? n.xy : (1.0 - abs(n.yx)) * (vec2(n.x >= 0.0 ? 1.0 : -1.0, n.y >= 0.0 ? 1.0 : -1.0));
+    return uv;
+}
+
+vec3 OctDecode(vec2 uv) {
+    vec3 n = vec3(uv.x, uv.y, 1.0 - abs(uv.x) - abs(uv.y));
+    f32 t = max(-n.z, 0.0);
+    n.x += n.x >= 0.0 ? -t : t;
+    n.y += n.y >= 0.0 ? -t : t;
+    return normalize(n);
+}
ADD · src/shaders/lib/shadow_sample.slang +125 -0
--- a/src/shaders/lib/shadow_sample.slang
+++ b/src/shaders/lib/shadow_sample.slang
@@ -0,0 +1,125 @@
+#pragma once
+
+#include "shared.h"
+
+static const f32 NORMAL_BIAS = 1.0f; // world normal offset, texels (sun-facing)
+static const f32 NORMAL_BIAS_SLOPE = 0.25f;
+static const f32 PCF_RADIUS = 3.0f;
+static const int PCF_TAP_COUNT = 16;
+
+// poisson disk samples in [-1, 1] range, gpu gems
+static const vec2 POISSON_64[64] = {
+    vec2(0.1303, -0.4774),  vec2(-0.0790, 0.1597),  vec2(-0.2146, -0.7675), vec2(0.5641, 0.2770),
+    vec2(-0.8458, 0.0653),  vec2(-0.2290, 0.5203),  vec2(0.7014, -0.2814),  vec2(-0.5949, -0.2615),
+    vec2(0.0567, 0.8423),   vec2(-0.4671, -0.5259), vec2(0.9188, 0.1313),   vec2(0.3152, -0.1929),
+    vec2(-0.6835, 0.3073),  vec2(0.3916, -0.6913),  vec2(-0.2006, -0.1625), vec2(0.8501, -0.4715),
+    vec2(-0.3950, 0.7455),  vec2(0.1216, -0.0897),  vec2(0.5703, 0.5782),   vec2(-0.9340, -0.2388),
+    vec2(-0.0417, -0.4026), vec2(0.4583, -0.4611),  vec2(0.1635, 0.4569),   vec2(-0.5940, 0.5467),
+    vec2(-0.5231, -0.7638), vec2(-0.1682, 0.9132),  vec2(0.7403, 0.4275),   vec2(0.2742, -0.8772),
+    vec2(0.3046, 0.7118),   vec2(-0.3307, -0.3606), vec2(0.0315, -0.6573),  vec2(0.6764, -0.6494),
+    vec2(-0.0946, 0.3509),  vec2(-0.7726, -0.4933), vec2(-0.7603, 0.6081),  vec2(-0.4377, 0.0655),
+    vec2(0.0247, -0.2155),  vec2(0.8682, -0.2073),  vec2(0.4264, 0.1474),   vec2(-0.2869, -0.0960),
+    vec2(-0.6156, -0.0669), vec2(-0.1416, -0.8762), vec2(0.4938, 0.8424),   vec2(-0.8577, -0.3580),
+    vec2(0.9839, 0.0778),   vec2(0.0538, 0.6073),   vec2(0.5629, -0.1489),  vec2(0.1398, -0.5184),
+    vec2(-0.3444, 0.2341),  vec2(-0.4997, 0.4327),  vec2(-0.0025, 0.9896),  vec2(0.7817, -0.0236),
+    vec2(-0.2096, 0.6826),  vec2(0.2251, -0.3476),  vec2(0.6264, 0.7023),   vec2(0.0367, -0.0060),
+    vec2(-0.9582, 0.1479),  vec2(-0.6141, 0.7459),  vec2(0.3188, 0.4669),   vec2(0.4180, -0.3110),
+    vec2(-0.4167, -0.6154), vec2(-0.0996, -0.0930), vec2(0.8276, 0.2998),   vec2(-0.7435, -0.6373),
+};
+
+f32 hash2(vec2 p) {
+    return frac(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
+}
+
+u32 select_cascade_aabb(vec3 worldPos, vec3 camera_pos, ShadowCascadesGPU all_cascades) {
+    vec3 relPos = worldPos - camera_pos;
+    u32 cascade_idx = all_cascades.cascade_count - 1;
+    for (u32 i = 0; i < all_cascades.cascade_count; ++i) {
+        vec3 ls_pos = (vec4(relPos, 1.0) * all_cascades.cascade[i].view).xyz;
+        if (all(ls_pos >= all_cascades.cascade[i].caster_min_ls) &&
+            all(ls_pos <= all_cascades.cascade[i].caster_max_ls)) {
+            cascade_idx = i;
+            break;
+        }
+    }
+    return cascade_idx;
+}
+
+f32 sample_cascade_at(
+    vec3 worldPos,
+    vec3 normal,
+    f32 NdotL,
+    vec3 camera_pos,
+    vec2 screen_pos,
+    ShadowCascadeGPU cascade,
+    SamplerComparisonState cmp_samp
+) {
+    vec3 relPos = worldPos - camera_pos;
+
+    f32 NdotL_clamped = saturate(NdotL);
+    f32 grazing = sqrt(max(0.0f, 1.0f - NdotL_clamped * NdotL_clamped));
+    f32 normal_bias = NORMAL_BIAS + grazing * NORMAL_BIAS_SLOPE;
+
+    vec3 shadow_pos = relPos + normalize(normal) * (cascade.texel_size * normal_bias);
+    vec4 shadow_clip = vec4(shadow_pos, 1.0f) * cascade.view_proj;
+    vec2 shadow_uv = vec2(shadow_clip.x, -shadow_clip.y) * 0.5f + 0.5f;
+    f32 offset_depth = shadow_clip.z;
+
+    if (shadow_uv.x < 0.0f || shadow_uv.x > 1.0f || shadow_uv.y < 0.0f || shadow_uv.y > 1.0f || offset_depth < 0.0f ||
+        offset_depth > 1.0f) {
+        return 1.0f;
+    }
+
+    u32 width;
+    u32 height;
+    Texture2D shadow_map = cascade.img;
+    shadow_map.GetDimensions(width, height);
+    vec2 texel_uv = 1.0f / vec2(width, height);
+
+    f32 angle = hash2(screen_pos) * 6.2832f;
+    f32 cos_a = cos(angle);
+    f32 sin_a = sin(angle);
+
+    f32 shadow = 0.0f;
+    [unroll]
+    for (int i = 0; i < PCF_TAP_COUNT; ++i) {
+        vec2 rotated;
+        rotated.x = POISSON_64[i].x * cos_a - POISSON_64[i].y * sin_a;
+        rotated.y = POISSON_64[i].x * sin_a + POISSON_64[i].y * cos_a;
+        vec2 offset = rotated * texel_uv * PCF_RADIUS;
+        shadow += shadow_map.SampleCmpLevelZero(cmp_samp, shadow_uv + offset, offset_depth);
+    }
+    return shadow / (f32)PCF_TAP_COUNT;
+}
+
+f32 sample_shadow(
+    vec3 world_pos,
+    vec3 normal,
+    vec2 screen_pos,
+    f32 NdotL,
+    vec3 camera_pos,
+    ShadowCascadesGPU cascades,
+    SamplerComparisonState cmp_samp
+) {
+    u32 cascade_idx = select_cascade_aabb(world_pos, camera_pos, cascades);
+    ShadowCascadeGPU selected_cascade = cascades.cascade[cascade_idx];
+    f32 shadow = sample_cascade_at(world_pos, normal, NdotL, camera_pos, screen_pos, selected_cascade, cmp_samp);
+
+    // TODO: should do a cheaper path for this rather than just the same sampling
+    // blend with the next cascade near the current cascade bounds
+    // u32 next_idx = min(cascade_idx + 1, cascades.cascade_count - 1);
+    // if (next_idx != cascade_idx) {
+    //     vec3 relPos = worldPos - camera_pos;
+    //     vec3 ls_pos = (vec4(relPos, 1.0) * selected_cascade.view).xyz;
+    //     vec3 edge_dist = min(ls_pos - selected_cascade.caster_min_ls, selected_cascade.caster_max_ls - ls_pos);
+    //     f32 min_edge = min(edge_dist.x, min(edge_dist.y, edge_dist.z));
+    //     f32 blend = 1.0f - saturate(min_edge / (selected_cascade.texel_size * 4.0f));
+    //
+    //     if (blend > 0.0f) {
+    //         f32 shadow_next = sample_cascade_at(worldPos, normal, NdotL, worldPos, screen_pos, selected_cascade);
+    //         shadow = lerp(shadow, shadow_next, blend);
+    //     }
+    // }
+
+    return shadow;
+}
ADD · src/shaders/renderer_types.h +566 -0
--- a/src/shaders/renderer_types.h
+++ b/src/shaders/renderer_types.h
@@ -0,0 +1,566 @@
+#pragma once
+
+#include "shared.h"
+
+enum DebugViewMode {
+    NONE = 0,
+    DEPTH_grayscale = 1,
+    DEPTH_color = 2,
+    UV = 3,
+    NORMAL_TEX = 4,
+    NORMAL_GEO = 5,
+    TANGENT_GEO = 6,
+    BITANGENT_GEO = 7,
+    TANGENT_GEO_W = 8,
+    SHADING_NORMAL = 9,
+    ALPHA = 10,
+    EMISSIVE = 12,
+    ALBEDO = 13,
+    METALLIC = 14,
+    ROUGHNESS = 15,
+    OCCLUSION = 11,
+    SHADOW_CASCADE = 16,
+    LIGHTING_ONLY = 17,
+    CLUSTER_HEATMAP = 18,
+    CLUSTER_BOUNDS = 19,
+    WIREFRAME = 20,
+    PROBES_RAY_SAMPLES = 21,
+    PROBES_IRRADIANCE = 22,
+    PROBES_DISTANCE = 23,
+    PROBES_CLASSIFICATION = 24
+};
+
+struct Vertex {
+    vec3 pos;
+    f32 _pad0;
+    vec3 normal;
+    f32 _pad1;
+    vec2 uv;
+    vec2 _padUv;  // pad 40 ->
+    vec4 tangent; // w handedness
+};
+
+struct CameraGPU {
+    mat4 view;
+    mat4 inv_view;
+    mat4 proj;
+    mat4 inv_proj;
+    mat4 view_proj;
+    mat4 inv_view_proj;
+    vec4 position_ws;
+    vec3 forward_ws;
+    f32 near_plane;
+    f32 far_plane;
+    f32 screen_w;
+    f32 screen_h;
+};
+
+struct ShadowCascadeGPU {
+    mat4 view;
+    mat4 view_proj;
+    vec3 caster_min_ls;
+    f32 _pad0; // 16
+    vec3 caster_max_ls;
+    f32 texel_depth;
+    GPU_HND(Texture2D) img;
+    f32 texel_size;
+    u32 _tail0; // 176 stride preserved (was u32 img_idx + 2 tails)
+};
+
+struct ShadowCascadesGPU {
+    u32 cascade_count;
+    // NOTE: cascade array needs absolute 16-alignment, shadows 784 in FrameUBO,
+    // relative offset 16 lands at 800, FIX IT!!!
+    u32 _pad0;
+    u32 _pad1;
+    u32 _pad2;
+    ShadowCascadeGPU cascade[4];
+};
+
+struct PointLightGPU {
+    vec3 position;
+    f32 range;
+    vec3 color;
+    f32 intensity;
+};
+
+struct ClusterBounds {
+    vec4 minPoint; // empty w
+    vec4 maxPoint; // empty w
+};
+
+struct ClusterRecord {
+    u32 lightOffset; // offset into the lights array
+    u32 lightCount;  // total light count
+};
+
+struct RenderItemGPU {
+    u32 instance_id; // index into the per-frame transform buffer
+    u32 submesh_index;
+    u32 material_index;
+    u32 entity_id;
+};
+
+struct SubmeshGPU {
+    u32 first_index;
+    u32 index_count;
+    u32 base_vertex;
+    u32 _pad0;         // 16
+    vec4 local_sphere; // xyz = sphere center, w  = radius
+    vec3 local_aabb_min;
+    f32 _pad1;
+    vec3 local_aabb_max;
+    f32 _pad2;
+};
+
+struct TransformGPU {
+    mat4 world;
+    mat4 normal_world;
+    u32 active;
+    u32 _pad0;
+    u32 _pad1;
+    u32 _pad2;
+};
+
+struct MaterialGPU {
+    GPU_HND(Texture2D) albedo; // 0
+    GPU_HND(Texture2D) normal; // 8
+    GPU_HND(Texture2D) metal_rough; // 16
+    GPU_HND(Texture2D) emissive;   // 24
+    u32 _padA;            // 32
+    f32 metallic_factor;  // 36
+    f32 roughness_factor; // 40
+    u32 _padB;            // 44
+    vec3 emissive_factor; // 48
+    f32 _pad0;            // 60
+    vec4 base_color;      // 64..80
+};
+
+#ifndef __SLANG__
+static_assert(sizeof(MaterialGPU) == 80, "MaterialGPU size drift");
+static_assert(offsetof(MaterialGPU, emissive_factor) == 48, "MaterialGPU layout drift");
+static_assert(offsetof(MaterialGPU, base_color) == 64, "MaterialGPU layout drift");
+#endif
+
+struct ClusterGrid {
+    u32 cluster_count_x;
+    u32 cluster_count_y;
+    u32 cluster_count_z;
+    u32 cluster_total; // total number of clusters
+    GPU_PTR(ClusterBounds) clusters_bounds;
+    u32 _tail0; // 32
+    u32 _tail1;
+};
+
+struct LightCull {
+    GPU_PTR(ClusterRecord) clusters_records;
+    GPU_PTR(u32) light_index_list;
+};
+
+struct DdgiGridParams {
+    vec4 origin;  // xyz = world-space origin, w = unused
+    vec4 spacing; // xyz = per-axis probe spacing, w = max(spacing)
+    vec4 dims;    // xyz = grid dimensions X/Y/Z (float for cross-lang compat), w = unused
+    u32 probe_count;
+    u32 _pad0;
+    u32 _pad1;
+    u32 _pad2;
+};
+
+struct DdgiConfig {
+    u32 enable_accumulation = 1;
+    f32 history_alpha = 0.97f;
+    f32 irradiance_encoding_gamma = 5.0f;
+    f32 irradiance_threshold = 0.25f;
+    f32 brightness_threshold = 2.0f;
+    f32 probe_min_frontface_distance = 0.1f; // world meters
+    f32 probe_distance_scale = 1.0f;         // world meters
+    f32 fixed_ray_backface_threshold = 0.25f;
+    f32 random_ray_backface_threshold = 0.25f;
+    u32 _tail0 = 0; // round struct size to 16 (36 -> 48, std140 nested struct)
+    u32 _tail1 = 0;
+    u32 _tail2 = 0;
+};
+
+struct FrameUBO {
+    // camera
+    mat4 view;
+    mat4 inv_view;
+    mat4 proj;
+    mat4 inv_proj;
+    mat4 view_proj;
+    mat4 inv_view_proj;
+    vec4 position_ws;
+    vec3 forward_ws;
+    f32 near_plane;
+    f32 far_plane;
+    f32 screen_w;
+    f32 screen_h;
+    u32 _pad0;
+
+    // meshes
+    GPU_PTR(RenderItemGPU) render_items;
+    GPU_PTR(SubmeshGPU) submeshes;
+    GPU_PTR(MaterialGPU) materials;
+    GPU_PTR(TransformGPU) transforms;
+
+    // env (handles, rhi::handle_id filled)
+    GPU_HND(TextureCube<float4>) env;
+    GPU_HND(Texture2D) env_brdf;
+    GPU_HND(TextureCube<float4>) env_irradiance;
+    GPU_HND(TextureCube<float4>) env_prefiltered;
+    u32 env_prefilter_mip;
+    u32 _pad1;
+    u32 _pad2;
+    u32 _pad3;
+
+    mat4 dbg_view_proj;
+    mat4 dbg_inv_view_proj;
+    vec3 dbg_pos_ws;
+    f32 _pad4;
+    vec3 dbg_fwd_ws;
+    f32 _pad5;
+
+    vec3 light_dir;
+    f32 _pad6;
+    vec3 light_color;
+    f32 light_intensity;
+    mat4 main_light_view_proj;
+
+    GPU_PTR(PointLightGPU) point_lights;
+    u32 point_light_count;
+
+    u32 _pad_pl0;
+    u32 _pad_pl1;
+    u32 _pad_pl2;
+    u32 _pad_pl3;
+    u32 _pad_pl4;
+
+    ShadowCascadesGPU shadows;
+    ClusterGrid cluster;
+    LightCull light_cull;
+    DdgiGridParams ddgi_grid;
+    DdgiConfig ddgi_cfg;
+    u64 tlas_address = 0;
+    DebugViewMode debug = DebugViewMode::NONE;
+    GPU_HND(SamplerState) aniso_wrap_mips; // 24..32 (slot 1)
+    GPU_HND(SamplerState) linear_clamp_mips; // 32..40 (slot 2)
+    GPU_HND(SamplerState) linear_clamp; // 40..48 (slot 3)
+    GPU_HND(SamplerComparisonState) cmp_greater; // 48..56 (slot 0, comparison view for shadows)
+};
+#ifndef __SLANG__
+static_assert(sizeof(FrameUBO) % 16 == 0, "FrameUBO size must stay 16-multiple");
+#endif
+
+struct InstanceData {
+    u32 instance_id;
+    u32 render_item_idx;
+};
+
+// One visible (post-culling) draw entry produced by build_indirect.
+struct VisibleItem {
+    u32 id;          // render-item index
+    u32 instance_id; // instance/transform index
+};
+
+// Matches VkDrawIndexedIndirectCommand (5 x u32 = 20 bytes).
+struct DrawIndexedIndirectCommand {
+    u32 indexCount;
+    u32 instanceCount;
+    u32 firstIndex;
+    u32 vertexOffset;
+    u32 firstInstance;
+};
+
+struct ProbeState {
+    vec4 offset_active; // xyz = location offset, w = active 0/1
+};
+
+struct FwdPC {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+};
+
+struct FwdDrawPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_HND(StructuredBuffer<Vertex>) vertex;
+    GPU_PTR(VisibleItem) visible_items;
+    GPU_PTR(ProbeState) ddgi_probe_state;
+    GPU_HND(Texture2D) ddgi_irradiance;
+    GPU_HND(Texture2D) ddgi_distance;
+};
+
+struct IdBlitPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_HND(StructuredBuffer<Vertex>) vertex;
+    GPU_PTR(VisibleItem) visible_items;
+    GPU_HND(Texture2D) depth;
+};
+
+struct EquirectPushConstants {
+    u32 faceidx;
+    u32 hdrTextureIdx;
+};
+
+struct IrradiancePushConstants {
+    mat4 viewProj;
+    u32 faceidx;
+    u32 environmentIdx;
+};
+
+struct PrefilterPushConstants {
+    mat4 viewProj;
+    u32 faceidx;
+    u32 environmentIdx;
+    f32 roughness;
+    f32 environment_resolution;
+};
+
+struct IblConstants {
+    mat4 viewProj;
+    f32 roughness;
+    f32 environment_resolution;
+    u32 faceidx;
+    GPU_HND(Texture2D) hdrTexture;
+    GPU_HND(TextureCube<float4>) environment;
+    u32 _pad;
+    GPU_HND(SamplerState) samp; // rhi::handle_id (init-time passes have no frame access)
+};
+
+struct FrustumDebugPushConstants {
+    mat4 debug_view_proj;
+    mat4 debug_inv_view_proj;
+    u32 frame_idx;
+    u32 _pad0;
+};
+
+struct BuildIndirectPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+
+    GPU_PTR(DrawIndexedIndirectCommand) indirect_buffer;
+    GPU_PTR(VisibleItem) visible_items;
+    GPU_PTR(u32) draw_count_buffer;
+    u32 item_count;
+
+    GPU_HND(Texture2D) hiz; // UINT64_MAX disables (mint failure / culling off)
+    u32 hiz_width;
+    u32 hiz_height;
+    u32 hiz_mip_count;
+    u32 enable_culling;
+};
+
+struct FullscreenPushConstants {
+    GPU_HND(Texture2D) lighting;
+    GPU_HND(Texture2D) depth;
+    GPU_HND(Texture2D) ssr;
+    GPU_HND(SamplerState) samp; // rhi::handle_id, uniform (no frame access in this pass)
+};
+
+struct SkyboxPushConstants {
+    GPU_HND(TextureCube<float4>) cubemap;
+    u32 depth_tex_idx;
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+};
+
+struct GridPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+};
+
+struct DebugLineVertexGPU {
+    vec3 pos;
+    u32 packed; // [category:8][depth:8][reserved:16]
+    vec4 color;
+    u32 width_bits; // f32 screen-space width in px (thick quad expansion)
+    u32 _pad1;      // reserved: gizmo id
+};
+
+struct DebugLinesPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_PTR(DebugLineVertexGPU) lines;
+    f32 viewport_w;
+    f32 viewport_h;
+};
+
+struct ImGuiPushConstants {
+    vec2 scale;        // FramebufferScale (DisplaySize * scale = fb size)
+    vec2 translate;    // -DisplayPos * scale
+    vec2 display_size; // framebuffer extent
+    GPU_HND(Texture2D) tex; // bindless handle of font/user texture
+    GPU_HND(SamplerState) samp; // rhi::handle_id, uniform (no frame access in this pass)
+};
+
+// ---- cluster ----
+STATIC_CONST u32 MAX_POINT_LIGHTS = 2048;
+STATIC_CONST u32 NUM_POINT_LIGHTS = 512;
+
+// max lights per cluster
+// have to make sure this has enough of an additional buffer break down the math since all of this nonsense is
+// duplicated for each FIF
+STATIC_CONST u32 MAX_LIGHT_INDICES = MAX_POINT_LIGHTS * MAX_POINT_LIGHTS;
+
+// cluster grid constants
+STATIC_CONST u32 TILE_SIZE_X = 64;
+STATIC_CONST u32 TILE_SIZE_Y = 64;
+STATIC_CONST u32 CLUSTER_COUNT_Z = 32;
+
+struct ClusterBoundsPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+};
+
+struct LightCullPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    u32 light_count;
+    u32 _pad0; // keep BDA 8-aligned
+    GPU_PTR(u32) light_index_counter; // single uint counter
+    u32 phase;               // 0 = count, 1 = fill
+    u32 _tail;               // round size to 8 (struct holds u64s: 28 -> 32)
+};
+
+// ---- shadows ----
+struct ShadowPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_PTR(VisibleItem) visible_items;
+    u32 cascade_idx;
+    GPU_HND(StructuredBuffer<Vertex>) vertex;
+};
+
+// ---- ssr ----
+struct SsrPushConstants {
+    GPU_HND(Texture2D) color;
+    GPU_HND(Texture2D) depth;
+    GPU_HND(Texture2D) normal;
+    GPU_HND(RWTexture2D<float4>) output;
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    u32 width;
+    u32 height;
+    u32 _pad0;
+    f32 max_dist;  // march distance cap, world units
+    f32 thickness; // hit epsilon in post-projection depth units (reverse-Z)
+    i32 max_steps; // fixed march iteration count
+    f32 stride;    // world-space step per iteration
+    u32 _tail;     // round size to 8 (struct holds u64s)
+};
+
+#ifndef __SLANG__
+static_assert(offsetof(SsrPushConstants, frame) == 32);
+static_assert(offsetof(SsrPushConstants, max_dist) == 52);
+static_assert(sizeof(SsrPushConstants) == 72);
+static_assert(sizeof(SsrPushConstants) <= 128);
+#endif
+
+// ---- hiz ----
+struct HiZPushConstants {
+    GPU_HND(Texture2D) depth; // bindless handle of depth texture (for level 1 source)
+    GPU_HND(Texture2D) hiz_src; // bindless handle of hi-z texture (sampled) for higher level source
+    GPU_HND(RWTexture2D<float4>) hiz_dst; // bindless handle of current mip's storage image (writable)
+    u32 mip_level;               // 1 = first level to generate
+    u32 src_width;               // width at current mip level's source
+    u32 src_height;              // height at current mip level's source
+    u32 _tail;                   // round size to 8 (struct holds u64s: 36 -> 40)
+};
+
+// ---- ddgi ----
+STATIC_CONST u32 RAYS_PER_PROBE = 128;
+STATIC_CONST u32 FIXED_RAY_COUNT = 32;
+
+STATIC_CONST u32 ATLAS_SIZE = 16;
+STATIC_CONST u32 IRRADIANCE_SIZE = 8;
+STATIC_CONST int DDGI_TILE_BORDER = 2; // 2 pixel border around the tile for better alignment
+STATIC_CONST int IRRADIANCE_TILE_STRIDE = IRRADIANCE_SIZE + DDGI_TILE_BORDER;
+STATIC_CONST int DISTANCE_TILE_STRIDE = ATLAS_SIZE + DDGI_TILE_BORDER;
+
+STATIC_CONST f32 HISTORY_ALPHA = 0.97;
+
+// 1 = inactive, 0 = active (inverted)
+STATIC_CONST f32 DDGI_STATE_PROBE_INACTIVE = 1.0f;
+STATIC_CONST f32 DDGI_STATE_PROBE_ACTIVE = 0.0f;
+
+struct ProbeRaySample {
+    vec4 radiance_distance; // rgb = radiance, a = hit distance
+    vec4 direction;         // xyz = ray direction, a = unused
+};
+
+struct DdgiAtlasMeta {
+    u32 tiles_per_row;
+    u32 row_count;
+    u32 width;
+    u32 height;
+};
+
+struct ProbeSpherePushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_PTR(vec4) sphere_mesh;
+    u32 sphere_vertex_count;
+    GPU_PTR(ProbeRaySample) samples_buffer;
+    GPU_HND(Texture2D) atlas_sampled;
+    GPU_PTR(ProbeState) probe_state;
+    u32 rays_per_probe;
+    DebugViewMode debug_flag;
+};
+
+struct DdgiTracePushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    u64 framecount_idx;
+
+    u32 tlas_idx;
+    GPU_PTR(ProbeRaySample) samples_buffer;
+
+    GPU_PTR(InstanceData) instance_data;
+
+    GPU_HND(Texture2D) irradiance;
+    GPU_HND(Texture2D) distance;
+    GPU_PTR(ProbeState) probe_state;
+    u32 cascade_count;
+    GPU_HND(StructuredBuffer<Vertex>) vertex;
+    GPU_PTR(u32) index_bda;
+    u32 _pad0; // align random_rotation to 16 (std430 vec4 after u64 block ends @72)
+    u32 _pad1;
+    vec4 random_rotation; // xyz = random axis, w = random angle [0, 2PI]
+};
+
+struct DdgiUpdatePushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    u32 frame_counter;
+    GPU_PTR(ProbeRaySample) samples_buffer;
+    GPU_PTR(ProbeState) probe_state;
+    GPU_HND(Texture2D) atlas_sample;
+    GPU_HND(RWTexture2D<float4>) atlas_storage;
+};
+
+struct DdgiRelocatePushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    GPU_PTR(ProbeRaySample) samples_buffer;
+    GPU_PTR(ProbeState) probe_state;
+};
+
+struct DdgiClassifyPushConstants {
+    GPU_HND(ConstantBuffer<FrameUBO>) frame;
+    u64 frame_counter;
+    GPU_PTR(ProbeRaySample) samples_buffer;
+    GPU_PTR(ProbeState) probe_state;
+};
+
+#ifndef __SLANG__
+static_assert(offsetof(DdgiTracePushConstants, frame) == 0);
+static_assert(offsetof(DdgiTracePushConstants, framecount_idx) == 8);
+static_assert(offsetof(DdgiTracePushConstants, vertex) == 72);
+static_assert(offsetof(DdgiTracePushConstants, index_bda) == 80);
+static_assert(offsetof(DdgiTracePushConstants, random_rotation) == 96);
+static_assert(sizeof(DdgiTracePushConstants) == 112);
+#endif
+
+#ifdef __SLANG__
+struct VtxOut {
+    vec4 clip_pos : SV_Position;
+    vec4 view_pos : TEXCOORD0;
+    vec3 world_pos : TEXCOORD1;
+    vec3 normal : TEXCOORD2;
+    vec4 tangent : TEXCOORD3;
+    vec2 uv : TEXCOORD4;
+
+    nointerpolation uint material_index : MATERIAL_INDEX;
+
+    vec4 clip_debug : TEXCOORD7;
+    // nointerpolation f32 frustum_pass : TEXCOORD9;
+    // nointerpolation f32 visible : TEXCOORD10;
+};
+#endif
ADD · src/shaders/shared.h +86 -0
--- a/src/shaders/shared.h
+++ b/src/shaders/shared.h
@@ -0,0 +1,86 @@
+#pragma once
+
+#ifdef __SLANG__
+
+typealias f32 = float;
+typealias f64 = double;
+
+typealias vec2 = float2;
+typealias vec3 = float3;
+typealias vec4 = float4;
+typealias mat3 = float3x3;
+typealias mat4 = float4x4;
+
+typealias u32 = uint32_t;
+typealias u64 = uint64_t;
+
+typealias uvec2 = uint2;
+typealias uvec3 = uint3;
+typealias uvec4 = uint4;
+
+typealias i32 = int32_t;
+typealias i64 = int64_t;
+
+typealias ivec2 = int2;
+typealias ivec3 = int3;
+typealias ivec4 = int4;
+
+typealias bvec2 = bool2;
+typealias bvec3 = bool3;
+typealias bvec4 = bool4;
+
+float4 operator*(float4 vec, float4x4 matrix) {
+    return mul(vec, matrix);
+}
+
+float3 operator*(float3 vec, float3x3 matrix) {
+    return mul(vec, matrix);
+}
+
+float4x4 operator*(float4x4 matrixLeft, float4x4 matrixRight) {
+    return mul(matrixLeft, matrixRight);
+}
+
+#define GPU_PTR(T)   T *
+#define GPU_HND(T)   T.Handle
+#define STATIC_CONST static const
+
+#else
+
+#include "core/globals.h"
+#include "core/math_rtm.h"
+
+#define GPU_PTR(type) u64
+#define GPU_HND(type) u64
+#define STATIC_CONST  const
+
+#endif
+
+STATIC_CONST int VK_DESCRIPTOR_SET = 0;
+STATIC_CONST int VK_MUTABLE_BINDING = 0;
+STATIC_CONST int VK_SAMPLER_BINDING = 1;
+
+#ifdef __SLANG__
+[[vk::binding(VK_MUTABLE_BINDING, VK_DESCRIPTOR_SET)]]
+__DynamicResource<__DynamicResourceKind.General> vk_mutable_set[];
+[[vk::binding(VK_SAMPLER_BINDING, VK_DESCRIPTOR_SET)]]
+__DynamicResource<__DynamicResourceKind.Sampler> vk_sampler_set[];
+
+export T getDescriptorFromHandle<T>(DescriptorHandle<T> handle) where T : IOpaqueDescriptor {
+    __target_switch {
+    case spirv:
+        if (T.kind == DescriptorKind.Sampler) {
+            return vk_sampler_set[((uint2)handle).x].asOpaqueDescriptor<T>(); // 32-bit OpAccessChain
+        } else {
+            return vk_mutable_set[((uint2)handle).x].asOpaqueDescriptor<T>(); // 32-bit OpAccessChain
+        }
+    default:
+        return defaultGetDescriptorFromHandle(handle);
+    }
+}
+
+// nuked FetchConstant(), but the underlying issue persists using * workaround to deref for now
+// https://github.com/shader-slang/slang/pull/11685
+// https://github.com/shader-slang/slang/issues/11681
+// https://github.com/shader-slang/slang/issues/11681#issuecomment-4896244646
+#endif
ADD · third-party/KTX-Software +1 -0
--- a/third-party/KTX-Software
+++ b/third-party/KTX-Software
@@ -0,0 +1 @@
+Subproject commit 4d6fc70eaf62ad0558e63e8d97eb9766118327a6
ADD · third-party/VMA +1 -0
--- a/third-party/VMA
+++ b/third-party/VMA
@@ -0,0 +1 @@
+Subproject commit 3aa921224c154a0d2c43912bc88e1c42ce1f7607
ADD · third-party/cgltf.h +7240 -0
--- a/third-party/cgltf.h
+++ b/third-party/cgltf.h
@@ -0,0 +1,7240 @@
+/**
+ * cgltf - a single-file glTF 2.0 parser written in C99.
+ *
+ * Version: 1.15
+ *
+ * Website: https://github.com/jkuhlmann/cgltf
+ *
+ * Distributed under the MIT License, see notice at the end of this file.
+ *
+ * Building:
+ * Include this file where you need the struct and function
+ * declarations. Have exactly one source file where you define
+ * `CGLTF_IMPLEMENTATION` before including this file to get the
+ * function definitions.
+ *
+ * Reference:
+ * `cgltf_result cgltf_parse(const cgltf_options*, const void*,
+ * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If
+ * this function returns `cgltf_result_success`, you have to call
+ * `cgltf_free()` on the created `cgltf_data*` variable.
+ * Note that contents of external files for buffers and images are not
+ * automatically loaded. You'll need to read these files yourself using
+ * URIs in the `cgltf_data` structure.
+ *
+ * `cgltf_options` is the struct passed to `cgltf_parse()` to control
+ * parts of the parsing process. You can use it to force the file type
+ * and provide memory allocation as well as file operation callbacks.
+ * Should be zero-initialized to trigger default behavior.
+ *
+ * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`.
+ * It generally mirrors the glTF format as described by the spec (see
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0).
+ *
+ * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data`
+ * variable.
+ *
+ * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*,
+ * const char* gltf_path)` can be optionally called to open and read buffer
+ * files using the `FILE*` APIs. The `gltf_path` argument is the path to
+ * the original glTF file, which allows the parser to resolve the path to
+ * buffer files.
+ *
+ * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options,
+ * cgltf_size size, const char* base64, void** out_data)` decodes
+ * base64-encoded data content. Used internally by `cgltf_load_buffers()`.
+ * This is useful when decoding data URIs in images.
+ *
+ * `cgltf_result cgltf_parse_file(const cgltf_options* options, const
+ * char* path, cgltf_data** out_data)` can be used to open the given
+ * file using `FILE*` APIs and parse the data using `cgltf_parse()`.
+ *
+ * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional
+ * checks to make sure the parsed glTF data is valid.
+ *
+ * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node
+ * into a mat4.
+ *
+ * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order
+ * to compute the root-to-node transformation.
+ *
+ * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any),
+ * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called.
+ * By passing null for the output pointer, users can find out how many floats are required in the
+ * output buffer.
+ *
+ * `cgltf_accessor_unpack_indices` reads in the index data from an accessor. Assumes that
+ * `cgltf_load_buffers` has already been called. By passing null for the output pointer, users can
+ * find out how many indices are required in the output buffer. Returns 0 if the accessor is
+ * sparse or if the output component size is less than the accessor's component size.
+ *
+ * `cgltf_num_components` is a tiny utility that tells you the dimensionality of
+ * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
+ * the necessary amount of memory. `cgltf_component_size` and `cgltf_calc_size` exist for
+ * similar purposes.
+ *
+ * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
+ * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
+ * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns
+ * false if the passed-in element_size is too small, or if the accessor is sparse.
+ *
+ * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading
+ * vector types and does not support matrix types. The passed-in element size is the number of uints
+ * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in
+ * element_size is too small, or if the accessor is sparse.
+ *
+ * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
+ * and only works with single-component data types.
+ *
+ * `cgltf_copy_extras_json` allows users to retrieve the "extras" data that can be attached to many
+ * glTF objects (which can be arbitrary JSON data). This is a legacy function, consider using
+ * cgltf_extras::data directly instead. You can parse this data using your own JSON parser
+ * or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
+ */
+#ifndef CGLTF_H_INCLUDED__
+#define CGLTF_H_INCLUDED__
+
+#include <stddef.h>
+#include <stdint.h> /* For uint8_t, uint32_t */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef size_t cgltf_size;
+typedef long long int cgltf_ssize;
+typedef float cgltf_float;
+typedef int cgltf_int;
+typedef unsigned int cgltf_uint;
+typedef int cgltf_bool;
+
+typedef enum cgltf_file_type
+{
+	cgltf_file_type_invalid,
+	cgltf_file_type_gltf,
+	cgltf_file_type_glb,
+	cgltf_file_type_max_enum
+} cgltf_file_type;
+
+typedef enum cgltf_result
+{
+	cgltf_result_success,
+	cgltf_result_data_too_short,
+	cgltf_result_unknown_format,
+	cgltf_result_invalid_json,
+	cgltf_result_invalid_gltf,
+	cgltf_result_invalid_options,
+	cgltf_result_file_not_found,
+	cgltf_result_io_error,
+	cgltf_result_out_of_memory,
+	cgltf_result_legacy_gltf,
+    cgltf_result_max_enum
+} cgltf_result;
+
+typedef struct cgltf_memory_options
+{
+	void* (*alloc_func)(void* user, cgltf_size size);
+	void (*free_func) (void* user, void* ptr);
+	void* user_data;
+} cgltf_memory_options;
+
+typedef struct cgltf_file_options
+{
+	cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data);
+	void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data, cgltf_size size);
+	void* user_data;
+} cgltf_file_options;
+
+typedef struct cgltf_options
+{
+	cgltf_file_type type; /* invalid == auto detect */
+	cgltf_size json_token_count; /* 0 == auto */
+	cgltf_memory_options memory;
+	cgltf_file_options file;
+} cgltf_options;
+
+typedef enum cgltf_buffer_view_type
+{
+	cgltf_buffer_view_type_invalid,
+	cgltf_buffer_view_type_indices,
+	cgltf_buffer_view_type_vertices,
+	cgltf_buffer_view_type_max_enum
+} cgltf_buffer_view_type;
+
+typedef enum cgltf_attribute_type
+{
+	cgltf_attribute_type_invalid,
+	cgltf_attribute_type_position,
+	cgltf_attribute_type_normal,
+	cgltf_attribute_type_tangent,
+	cgltf_attribute_type_texcoord,
+	cgltf_attribute_type_color,
+	cgltf_attribute_type_joints,
+	cgltf_attribute_type_weights,
+	cgltf_attribute_type_custom,
+	cgltf_attribute_type_max_enum
+} cgltf_attribute_type;
+
+typedef enum cgltf_component_type
+{
+	cgltf_component_type_invalid,
+	cgltf_component_type_r_8, /* BYTE */
+	cgltf_component_type_r_8u, /* UNSIGNED_BYTE */
+	cgltf_component_type_r_16, /* SHORT */
+	cgltf_component_type_r_16u, /* UNSIGNED_SHORT */
+	cgltf_component_type_r_32u, /* UNSIGNED_INT */
+	cgltf_component_type_r_32f, /* FLOAT */
+    cgltf_component_type_max_enum
+} cgltf_component_type;
+
+typedef enum cgltf_type
+{
+	cgltf_type_invalid,
+	cgltf_type_scalar,
+	cgltf_type_vec2,
+	cgltf_type_vec3,
+	cgltf_type_vec4,
+	cgltf_type_mat2,
+	cgltf_type_mat3,
+	cgltf_type_mat4,
+	cgltf_type_max_enum
+} cgltf_type;
+
+typedef enum cgltf_primitive_type
+{
+	cgltf_primitive_type_invalid,
+	cgltf_primitive_type_points,
+	cgltf_primitive_type_lines,
+	cgltf_primitive_type_line_loop,
+	cgltf_primitive_type_line_strip,
+	cgltf_primitive_type_triangles,
+	cgltf_primitive_type_triangle_strip,
+	cgltf_primitive_type_triangle_fan,
+	cgltf_primitive_type_max_enum
+} cgltf_primitive_type;
+
+typedef enum cgltf_alpha_mode
+{
+	cgltf_alpha_mode_opaque,
+	cgltf_alpha_mode_mask,
+	cgltf_alpha_mode_blend,
+	cgltf_alpha_mode_max_enum
+} cgltf_alpha_mode;
+
+typedef enum cgltf_animation_path_type {
+	cgltf_animation_path_type_invalid,
+	cgltf_animation_path_type_translation,
+	cgltf_animation_path_type_rotation,
+	cgltf_animation_path_type_scale,
+	cgltf_animation_path_type_weights,
+	cgltf_animation_path_type_max_enum
+} cgltf_animation_path_type;
+
+typedef enum cgltf_interpolation_type {
+	cgltf_interpolation_type_linear,
+	cgltf_interpolation_type_step,
+	cgltf_interpolation_type_cubic_spline,
+	cgltf_interpolation_type_max_enum
+} cgltf_interpolation_type;
+
+typedef enum cgltf_camera_type {
+	cgltf_camera_type_invalid,
+	cgltf_camera_type_perspective,
+	cgltf_camera_type_orthographic,
+	cgltf_camera_type_max_enum
+} cgltf_camera_type;
+
+typedef enum cgltf_light_type {
+	cgltf_light_type_invalid,
+	cgltf_light_type_directional,
+	cgltf_light_type_point,
+	cgltf_light_type_spot,
+	cgltf_light_type_max_enum
+} cgltf_light_type;
+
+typedef enum cgltf_data_free_method {
+	cgltf_data_free_method_none,
+	cgltf_data_free_method_file_release,
+	cgltf_data_free_method_memory_free,
+	cgltf_data_free_method_max_enum
+} cgltf_data_free_method;
+
+typedef struct cgltf_extras {
+	cgltf_size start_offset; /* this field is deprecated and will be removed in the future; use data instead */
+	cgltf_size end_offset; /* this field is deprecated and will be removed in the future; use data instead */
+
+	char* data;
+} cgltf_extras;
+
+typedef struct cgltf_extension {
+	char* name;
+	char* data;
+} cgltf_extension;
+
+typedef struct cgltf_buffer
+{
+	char* name;
+	cgltf_size size;
+	char* uri;
+	void* data; /* loaded by cgltf_load_buffers */
+	cgltf_data_free_method data_free_method;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_buffer;
+
+typedef enum cgltf_meshopt_compression_mode {
+	cgltf_meshopt_compression_mode_invalid,
+	cgltf_meshopt_compression_mode_attributes,
+	cgltf_meshopt_compression_mode_triangles,
+	cgltf_meshopt_compression_mode_indices,
+	cgltf_meshopt_compression_mode_max_enum
+} cgltf_meshopt_compression_mode;
+
+typedef enum cgltf_meshopt_compression_filter {
+	cgltf_meshopt_compression_filter_none,
+	cgltf_meshopt_compression_filter_octahedral,
+	cgltf_meshopt_compression_filter_quaternion,
+	cgltf_meshopt_compression_filter_exponential,
+	cgltf_meshopt_compression_filter_color,
+	cgltf_meshopt_compression_filter_max_enum
+} cgltf_meshopt_compression_filter;
+
+typedef struct cgltf_meshopt_compression
+{
+	cgltf_buffer* buffer;
+	cgltf_size offset;
+	cgltf_size size;
+	cgltf_size stride;
+	cgltf_size count;
+	cgltf_meshopt_compression_mode mode;
+	cgltf_meshopt_compression_filter filter;
+	cgltf_bool is_khr;
+} cgltf_meshopt_compression;
+
+typedef struct cgltf_buffer_view
+{
+	char *name;
+	cgltf_buffer* buffer;
+	cgltf_size offset;
+	cgltf_size size;
+	cgltf_size stride; /* 0 == automatically determined by accessor */
+	cgltf_buffer_view_type type;
+	void* data; /* overrides buffer->data if present, filled by extensions */
+	cgltf_bool has_meshopt_compression;
+	cgltf_meshopt_compression meshopt_compression;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_buffer_view;
+
+typedef struct cgltf_accessor_sparse
+{
+	cgltf_size count;
+	cgltf_buffer_view* indices_buffer_view;
+	cgltf_size indices_byte_offset;
+	cgltf_component_type indices_component_type;
+	cgltf_buffer_view* values_buffer_view;
+	cgltf_size values_byte_offset;
+} cgltf_accessor_sparse;
+
+typedef struct cgltf_accessor
+{
+	char* name;
+	cgltf_component_type component_type;
+	cgltf_bool normalized;
+	cgltf_type type;
+	cgltf_size offset;
+	cgltf_size count;
+	cgltf_size stride;
+	cgltf_buffer_view* buffer_view;
+	cgltf_bool has_min;
+	cgltf_float min[16];
+	cgltf_bool has_max;
+	cgltf_float max[16];
+	cgltf_bool is_sparse;
+	cgltf_accessor_sparse sparse;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_accessor;
+
+typedef struct cgltf_attribute
+{
+	char* name;
+	cgltf_attribute_type type;
+	cgltf_int index;
+	cgltf_accessor* data;
+} cgltf_attribute;
+
+typedef struct cgltf_image
+{
+	char* name;
+	char* uri;
+	cgltf_buffer_view* buffer_view;
+	char* mime_type;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_image;
+
+typedef enum cgltf_filter_type {
+    cgltf_filter_type_undefined = 0,
+    cgltf_filter_type_nearest = 9728,
+    cgltf_filter_type_linear = 9729,
+    cgltf_filter_type_nearest_mipmap_nearest = 9984,
+    cgltf_filter_type_linear_mipmap_nearest = 9985,
+    cgltf_filter_type_nearest_mipmap_linear = 9986,
+    cgltf_filter_type_linear_mipmap_linear = 9987
+} cgltf_filter_type;
+
+typedef enum cgltf_wrap_mode {
+    cgltf_wrap_mode_clamp_to_edge = 33071,
+    cgltf_wrap_mode_mirrored_repeat = 33648,
+    cgltf_wrap_mode_repeat = 10497
+} cgltf_wrap_mode;
+
+typedef struct cgltf_sampler
+{
+	char* name;
+	cgltf_filter_type mag_filter;
+	cgltf_filter_type min_filter;
+	cgltf_wrap_mode wrap_s;
+	cgltf_wrap_mode wrap_t;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_sampler;
+
+typedef struct cgltf_texture
+{
+	char* name;
+	cgltf_image* image;
+	cgltf_sampler* sampler;
+	cgltf_bool has_basisu;
+	cgltf_image* basisu_image;
+	cgltf_bool has_webp;
+	cgltf_image* webp_image;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_texture;
+
+typedef struct cgltf_texture_transform
+{
+	cgltf_float offset[2];
+	cgltf_float rotation;
+	cgltf_float scale[2];
+	cgltf_bool has_texcoord;
+	cgltf_int texcoord;
+} cgltf_texture_transform;
+
+typedef struct cgltf_texture_view
+{
+	cgltf_texture* texture;
+	cgltf_int texcoord;
+	cgltf_float scale; /* equivalent to strength for occlusion_texture */
+	cgltf_bool has_transform;
+	cgltf_texture_transform transform;
+} cgltf_texture_view;
+
+typedef struct cgltf_pbr_metallic_roughness
+{
+	cgltf_texture_view base_color_texture;
+	cgltf_texture_view metallic_roughness_texture;
+
+	cgltf_float base_color_factor[4];
+	cgltf_float metallic_factor;
+	cgltf_float roughness_factor;
+} cgltf_pbr_metallic_roughness;
+
+typedef struct cgltf_pbr_specular_glossiness
+{
+	cgltf_texture_view diffuse_texture;
+	cgltf_texture_view specular_glossiness_texture;
+
+	cgltf_float diffuse_factor[4];
+	cgltf_float specular_factor[3];
+	cgltf_float glossiness_factor;
+} cgltf_pbr_specular_glossiness;
+
+typedef struct cgltf_clearcoat
+{
+	cgltf_texture_view clearcoat_texture;
+	cgltf_texture_view clearcoat_roughness_texture;
+	cgltf_texture_view clearcoat_normal_texture;
+
+	cgltf_float clearcoat_factor;
+	cgltf_float clearcoat_roughness_factor;
+} cgltf_clearcoat;
+
+typedef struct cgltf_transmission
+{
+	cgltf_texture_view transmission_texture;
+	cgltf_float transmission_factor;
+} cgltf_transmission;
+
+typedef struct cgltf_ior
+{
+	cgltf_float ior;
+} cgltf_ior;
+
+typedef struct cgltf_specular
+{
+	cgltf_texture_view specular_texture;
+	cgltf_texture_view specular_color_texture;
+	cgltf_float specular_color_factor[3];
+	cgltf_float specular_factor;
+} cgltf_specular;
+
+typedef struct cgltf_volume
+{
+	cgltf_texture_view thickness_texture;
+	cgltf_float thickness_factor;
+	cgltf_float attenuation_color[3];
+	cgltf_float attenuation_distance;
+} cgltf_volume;
+
+typedef struct cgltf_sheen
+{
+	cgltf_texture_view sheen_color_texture;
+	cgltf_float sheen_color_factor[3];
+	cgltf_texture_view sheen_roughness_texture;
+	cgltf_float sheen_roughness_factor;
+} cgltf_sheen;
+
+typedef struct cgltf_emissive_strength
+{
+	cgltf_float emissive_strength;
+} cgltf_emissive_strength;
+
+typedef struct cgltf_iridescence
+{
+	cgltf_float iridescence_factor;
+	cgltf_texture_view iridescence_texture;
+	cgltf_float iridescence_ior;
+	cgltf_float iridescence_thickness_min;
+	cgltf_float iridescence_thickness_max;
+	cgltf_texture_view iridescence_thickness_texture;
+} cgltf_iridescence;
+
+typedef struct cgltf_diffuse_transmission
+{
+	cgltf_texture_view diffuse_transmission_texture;
+	cgltf_float diffuse_transmission_factor;
+	cgltf_float diffuse_transmission_color_factor[3];
+	cgltf_texture_view diffuse_transmission_color_texture;
+} cgltf_diffuse_transmission;
+
+typedef struct cgltf_anisotropy
+{
+	cgltf_float anisotropy_strength;
+	cgltf_float anisotropy_rotation;
+	cgltf_texture_view anisotropy_texture;
+} cgltf_anisotropy;
+
+typedef struct cgltf_dispersion
+{
+	cgltf_float dispersion;
+} cgltf_dispersion;
+
+typedef struct cgltf_material
+{
+	char* name;
+	cgltf_bool has_pbr_metallic_roughness;
+	cgltf_bool has_pbr_specular_glossiness;
+	cgltf_bool has_clearcoat;
+	cgltf_bool has_transmission;
+	cgltf_bool has_volume;
+	cgltf_bool has_ior;
+	cgltf_bool has_specular;
+	cgltf_bool has_sheen;
+	cgltf_bool has_emissive_strength;
+	cgltf_bool has_iridescence;
+	cgltf_bool has_diffuse_transmission;
+	cgltf_bool has_anisotropy;
+	cgltf_bool has_dispersion;
+	cgltf_pbr_metallic_roughness pbr_metallic_roughness;
+	cgltf_pbr_specular_glossiness pbr_specular_glossiness;
+	cgltf_clearcoat clearcoat;
+	cgltf_ior ior;
+	cgltf_specular specular;
+	cgltf_sheen sheen;
+	cgltf_transmission transmission;
+	cgltf_volume volume;
+	cgltf_emissive_strength emissive_strength;
+	cgltf_iridescence iridescence;
+	cgltf_diffuse_transmission diffuse_transmission;
+	cgltf_anisotropy anisotropy;
+	cgltf_dispersion dispersion;
+	cgltf_texture_view normal_texture;
+	cgltf_texture_view occlusion_texture;
+	cgltf_texture_view emissive_texture;
+	cgltf_float emissive_factor[3];
+	cgltf_alpha_mode alpha_mode;
+	cgltf_float alpha_cutoff;
+	cgltf_bool double_sided;
+	cgltf_bool unlit;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_material;
+
+typedef struct cgltf_material_mapping
+{
+	cgltf_size variant;
+	cgltf_material* material;
+	cgltf_extras extras;
+} cgltf_material_mapping;
+
+typedef struct cgltf_morph_target {
+	cgltf_attribute* attributes;
+	cgltf_size attributes_count;
+} cgltf_morph_target;
+
+typedef struct cgltf_draco_mesh_compression {
+	cgltf_buffer_view* buffer_view;
+	cgltf_attribute* attributes;
+	cgltf_size attributes_count;
+} cgltf_draco_mesh_compression;
+
+typedef struct cgltf_mesh_gpu_instancing {
+	cgltf_attribute* attributes;
+	cgltf_size attributes_count;
+} cgltf_mesh_gpu_instancing;
+
+typedef struct cgltf_primitive {
+	cgltf_primitive_type type;
+	cgltf_accessor* indices;
+	cgltf_material* material;
+	cgltf_attribute* attributes;
+	cgltf_size attributes_count;
+	cgltf_morph_target* targets;
+	cgltf_size targets_count;
+	cgltf_extras extras;
+	cgltf_bool has_draco_mesh_compression;
+	cgltf_draco_mesh_compression draco_mesh_compression;
+	cgltf_material_mapping* mappings;
+	cgltf_size mappings_count;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_primitive;
+
+typedef struct cgltf_mesh {
+	char* name;
+	cgltf_primitive* primitives;
+	cgltf_size primitives_count;
+	cgltf_float* weights;
+	cgltf_size weights_count;
+	char** target_names;
+	cgltf_size target_names_count;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_mesh;
+
+typedef struct cgltf_node cgltf_node;
+
+typedef struct cgltf_skin {
+	char* name;
+	cgltf_node** joints;
+	cgltf_size joints_count;
+	cgltf_node* skeleton;
+	cgltf_accessor* inverse_bind_matrices;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_skin;
+
+typedef struct cgltf_camera_perspective {
+	cgltf_bool has_aspect_ratio;
+	cgltf_float aspect_ratio;
+	cgltf_float yfov;
+	cgltf_bool has_zfar;
+	cgltf_float zfar;
+	cgltf_float znear;
+	cgltf_extras extras;
+} cgltf_camera_perspective;
+
+typedef struct cgltf_camera_orthographic {
+	cgltf_float xmag;
+	cgltf_float ymag;
+	cgltf_float zfar;
+	cgltf_float znear;
+	cgltf_extras extras;
+} cgltf_camera_orthographic;
+
+typedef struct cgltf_camera {
+	char* name;
+	cgltf_camera_type type;
+	union {
+		cgltf_camera_perspective perspective;
+		cgltf_camera_orthographic orthographic;
+	} data;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_camera;
+
+typedef struct cgltf_light {
+	char* name;
+	cgltf_float color[3];
+	cgltf_float intensity;
+	cgltf_light_type type;
+	cgltf_float range;
+	cgltf_float spot_inner_cone_angle;
+	cgltf_float spot_outer_cone_angle;
+	cgltf_extras extras;
+} cgltf_light;
+
+struct cgltf_node {
+	char* name;
+	cgltf_node* parent;
+	cgltf_node** children;
+	cgltf_size children_count;
+	cgltf_skin* skin;
+	cgltf_mesh* mesh;
+	cgltf_camera* camera;
+	cgltf_light* light;
+	cgltf_float* weights;
+	cgltf_size weights_count;
+	cgltf_bool has_translation;
+	cgltf_bool has_rotation;
+	cgltf_bool has_scale;
+	cgltf_bool has_matrix;
+	cgltf_float translation[3];
+	cgltf_float rotation[4];
+	cgltf_float scale[3];
+	cgltf_float matrix[16];
+	cgltf_extras extras;
+	cgltf_bool has_mesh_gpu_instancing;
+	cgltf_mesh_gpu_instancing mesh_gpu_instancing;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+};
+
+typedef struct cgltf_scene {
+	char* name;
+	cgltf_node** nodes;
+	cgltf_size nodes_count;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_scene;
+
+typedef struct cgltf_animation_sampler {
+	cgltf_accessor* input;
+	cgltf_accessor* output;
+	cgltf_interpolation_type interpolation;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_animation_sampler;
+
+typedef struct cgltf_animation_channel {
+	cgltf_animation_sampler* sampler;
+	cgltf_node* target_node;
+	cgltf_animation_path_type target_path;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_animation_channel;
+
+typedef struct cgltf_animation {
+	char* name;
+	cgltf_animation_sampler* samplers;
+	cgltf_size samplers_count;
+	cgltf_animation_channel* channels;
+	cgltf_size channels_count;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_animation;
+
+typedef struct cgltf_material_variant
+{
+	char* name;
+	cgltf_extras extras;
+} cgltf_material_variant;
+
+typedef struct cgltf_asset {
+	char* copyright;
+	char* generator;
+	char* version;
+	char* min_version;
+	cgltf_extras extras;
+	cgltf_size extensions_count;
+	cgltf_extension* extensions;
+} cgltf_asset;
+
+typedef struct cgltf_data
+{
+	cgltf_file_type file_type;
+	void* file_data;
+	cgltf_size file_size;
+
+	cgltf_asset asset;
+
+	cgltf_mesh* meshes;
+	cgltf_size meshes_count;
+
+	cgltf_material* materials;
+	cgltf_size materials_count;
+
+	cgltf_accessor* accessors;
+	cgltf_size accessors_count;
+
+	cgltf_buffer_view* buffer_views;
+	cgltf_size buffer_views_count;
+
+	cgltf_buffer* buffers;
+	cgltf_size buffers_count;
+
+	cgltf_image* images;
+	cgltf_size images_count;
+
+	cgltf_texture* textures;
+	cgltf_size textures_count;
+
+	cgltf_sampler* samplers;
+	cgltf_size samplers_count;
+
+	cgltf_skin* skins;
+	cgltf_size skins_count;
+
+	cgltf_camera* cameras;
+	cgltf_size cameras_count;
+
+	cgltf_light* lights;
+	cgltf_size lights_count;
+
+	cgltf_node* nodes;
+	cgltf_size nodes_count;
+
+	cgltf_scene* scenes;
+	cgltf_size scenes_count;
+
+	cgltf_scene* scene;
+
+	cgltf_animation* animations;
+	cgltf_size animations_count;
+
+	cgltf_material_variant* variants;
+	cgltf_size variants_count;
+
+	cgltf_extras extras;
+
+	cgltf_size data_extensions_count;
+	cgltf_extension* data_extensions;
+
+	char** extensions_used;
+	cgltf_size extensions_used_count;
+
+	char** extensions_required;
+	cgltf_size extensions_required_count;
+
+	const char* json;
+	cgltf_size json_size;
+
+	const void* bin;
+	cgltf_size bin_size;
+
+	cgltf_memory_options memory;
+	cgltf_file_options file;
+} cgltf_data;
+
+cgltf_result cgltf_parse(
+		const cgltf_options* options,
+		const void* data,
+		cgltf_size size,
+		cgltf_data** out_data);
+
+cgltf_result cgltf_parse_file(
+		const cgltf_options* options,
+		const char* path,
+		cgltf_data** out_data);
+
+cgltf_result cgltf_load_buffers(
+		const cgltf_options* options,
+		cgltf_data* data,
+		const char* gltf_path);
+
+cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data);
+
+cgltf_size cgltf_decode_string(char* string);
+cgltf_size cgltf_decode_uri(char* uri);
+
+cgltf_result cgltf_validate(cgltf_data* data);
+
+void cgltf_free(cgltf_data* data);
+
+void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
+void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix);
+
+const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view);
+
+const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index);
+
+cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
+cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
+cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
+
+cgltf_size cgltf_num_components(cgltf_type type);
+cgltf_size cgltf_component_size(cgltf_component_type component_type);
+cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
+
+cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
+cgltf_size cgltf_accessor_unpack_indices(const cgltf_accessor* accessor, void* out, cgltf_size out_component_size, cgltf_size index_count);
+
+/* this function is deprecated and will be removed in the future; use cgltf_extras::data instead */
+cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
+
+cgltf_size cgltf_mesh_index(const cgltf_data* data, const cgltf_mesh* object);
+cgltf_size cgltf_material_index(const cgltf_data* data, const cgltf_material* object);
+cgltf_size cgltf_accessor_index(const cgltf_data* data, const cgltf_accessor* object);
+cgltf_size cgltf_buffer_view_index(const cgltf_data* data, const cgltf_buffer_view* object);
+cgltf_size cgltf_buffer_index(const cgltf_data* data, const cgltf_buffer* object);
+cgltf_size cgltf_image_index(const cgltf_data* data, const cgltf_image* object);
+cgltf_size cgltf_texture_index(const cgltf_data* data, const cgltf_texture* object);
+cgltf_size cgltf_sampler_index(const cgltf_data* data, const cgltf_sampler* object);
+cgltf_size cgltf_skin_index(const cgltf_data* data, const cgltf_skin* object);
+cgltf_size cgltf_camera_index(const cgltf_data* data, const cgltf_camera* object);
+cgltf_size cgltf_light_index(const cgltf_data* data, const cgltf_light* object);
+cgltf_size cgltf_node_index(const cgltf_data* data, const cgltf_node* object);
+cgltf_size cgltf_scene_index(const cgltf_data* data, const cgltf_scene* object);
+cgltf_size cgltf_animation_index(const cgltf_data* data, const cgltf_animation* object);
+cgltf_size cgltf_animation_sampler_index(const cgltf_animation* animation, const cgltf_animation_sampler* object);
+cgltf_size cgltf_animation_channel_index(const cgltf_animation* animation, const cgltf_animation_channel* object);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef CGLTF_H_INCLUDED__ */
+
+/*
+ *
+ * Stop now, if you are only interested in the API.
+ * Below, you find the implementation.
+ *
+ */
+
+#if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__)
+/* This makes MSVC/CLion intellisense work. */
+#define CGLTF_IMPLEMENTATION
+#endif
+
+#ifdef CGLTF_IMPLEMENTATION
+
+#include <assert.h> /* For assert */
+#include <string.h> /* For strncpy */
+#include <stdio.h>  /* For fopen */
+#include <limits.h> /* For UINT_MAX etc */
+#include <float.h>  /* For FLT_MAX */
+
+#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF) || !defined(CGLTF_ATOLL)
+#include <stdlib.h> /* For malloc, free, atoi, atof */
+#endif
+
+/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */
+#define JSMN_PARENT_LINKS
+
+/* JSMN_STRICT is necessary to reject invalid JSON documents */
+#define JSMN_STRICT
+
+/*
+ * -- jsmn.h start --
+ * Source: https://github.com/zserge/jsmn
+ * License: MIT
+ */
+typedef enum {
+	JSMN_UNDEFINED = 0,
+	JSMN_OBJECT = 1,
+	JSMN_ARRAY = 2,
+	JSMN_STRING = 3,
+	JSMN_PRIMITIVE = 4
+} jsmntype_t;
+enum jsmnerr {
+	/* Not enough tokens were provided */
+	JSMN_ERROR_NOMEM = -1,
+	/* Invalid character inside JSON string */
+	JSMN_ERROR_INVAL = -2,
+	/* The string is not a full JSON packet, more bytes expected */
+	JSMN_ERROR_PART = -3
+};
+typedef struct {
+	jsmntype_t type;
+	ptrdiff_t start;
+	ptrdiff_t end;
+	int size;
+#ifdef JSMN_PARENT_LINKS
+	int parent;
+#endif
+} jsmntok_t;
+typedef struct {
+	size_t pos; /* offset in the JSON string */
+	unsigned int toknext; /* next token to allocate */
+	int toksuper; /* superior token node, e.g parent object or array */
+} jsmn_parser;
+static void jsmn_init(jsmn_parser *parser);
+static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens);
+/*
+ * -- jsmn.h end --
+ */
+
+
+#ifndef CGLTF_CONSTS
+#define GlbHeaderSize 12
+#define GlbChunkHeaderSize 8
+static const uint32_t GlbVersion = 2;
+static const uint32_t GlbMagic = 0x46546C67;
+static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
+static const uint32_t GlbMagicBinChunk = 0x004E4942;
+#define CGLTF_CONSTS
+#endif
+
+#ifndef CGLTF_MALLOC
+#define CGLTF_MALLOC(size) malloc(size)
+#endif
+#ifndef CGLTF_FREE
+#define CGLTF_FREE(ptr) free(ptr)
+#endif
+#ifndef CGLTF_ATOI
+#define CGLTF_ATOI(str) atoi(str)
+#endif
+#ifndef CGLTF_ATOF
+#define CGLTF_ATOF(str) atof(str)
+#endif
+#ifndef CGLTF_ATOLL
+#define CGLTF_ATOLL(str) atoll(str)
+#endif
+#ifndef CGLTF_VALIDATE_ENABLE_ASSERTS
+#define CGLTF_VALIDATE_ENABLE_ASSERTS 0
+#endif
+
+static void* cgltf_default_alloc(void* user, cgltf_size size)
+{
+	(void)user;
+	return CGLTF_MALLOC(size);
+}
+
+static void cgltf_default_free(void* user, void* ptr)
+{
+	(void)user;
+	CGLTF_FREE(ptr);
+}
+
+static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count)
+{
+	if (SIZE_MAX / element_size < count)
+	{
+		return NULL;
+	}
+	void* result = options->memory.alloc_func(options->memory.user_data, element_size * count);
+	if (!result)
+	{
+		return NULL;
+	}
+	memset(result, 0, element_size * count);
+	return result;
+}
+
+static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data)
+{
+	(void)file_options;
+	void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc_func ? memory_options->alloc_func : &cgltf_default_alloc;
+	void (*memory_free)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
+
+	FILE* file = fopen(path, "rb");
+	if (!file)
+	{
+		return cgltf_result_file_not_found;
+	}
+
+	cgltf_size file_size = size ? *size : 0;
+
+	if (file_size == 0)
+	{
+		fseek(file, 0, SEEK_END);
+
+#ifdef _MSC_VER
+		__int64 length = _ftelli64(file);
+#else
+		long length = ftell(file);
+#endif
+
+		if (length < 0)
+		{
+			fclose(file);
+			return cgltf_result_io_error;
+		}
+
+		fseek(file, 0, SEEK_SET);
+		file_size = (cgltf_size)length;
+	}
+
+	char* file_data = (char*)memory_alloc(memory_options->user_data, file_size);
+	if (!file_data)
+	{
+		fclose(file);
+		return cgltf_result_out_of_memory;
+	}
+
+	cgltf_size read_size = fread(file_data, 1, file_size, file);
+
+	fclose(file);
+
+	if (read_size != file_size)
+	{
+		memory_free(memory_options->user_data, file_data);
+		return cgltf_result_io_error;
+	}
+
+	if (size)
+	{
+		*size = file_size;
+	}
+	if (data)
+	{
+		*data = file_data;
+	}
+
+	return cgltf_result_success;
+}
+
+static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data, cgltf_size size)
+{
+	(void)file_options;
+	(void)size;
+	void (*memfree)(void*, void*) = memory_options->free_func ? memory_options->free_func : &cgltf_default_free;
+	memfree(memory_options->user_data, data);
+}
+
+static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data);
+
+cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data)
+{
+	if (size < GlbHeaderSize)
+	{
+		return cgltf_result_data_too_short;
+	}
+
+	if (options == NULL)
+	{
+		return cgltf_result_invalid_options;
+	}
+
+	cgltf_options fixed_options = *options;
+	if (fixed_options.memory.alloc_func == NULL)
+	{
+		fixed_options.memory.alloc_func = &cgltf_default_alloc;
+	}
+	if (fixed_options.memory.free_func == NULL)
+	{
+		fixed_options.memory.free_func = &cgltf_default_free;
+	}
+
+	uint32_t tmp;
+	// Magic
+	memcpy(&tmp, data, 4);
+	if (tmp != GlbMagic)
+	{
+		if (fixed_options.type == cgltf_file_type_invalid)
+		{
+			fixed_options.type = cgltf_file_type_gltf;
+		}
+		else if (fixed_options.type == cgltf_file_type_glb)
+		{
+			return cgltf_result_unknown_format;
+		}
+	}
+
+	if (fixed_options.type == cgltf_file_type_gltf)
+	{
+		cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data);
+		if (json_result != cgltf_result_success)
+		{
+			return json_result;
+		}
+
+		(*out_data)->file_type = cgltf_file_type_gltf;
+
+		return cgltf_result_success;
+	}
+
+	const uint8_t* ptr = (const uint8_t*)data;
+	// Version
+	memcpy(&tmp, ptr + 4, 4);
+	uint32_t version = tmp;
+	if (version != GlbVersion)
+	{
+		return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format;
+	}
+
+	// Total length
+	memcpy(&tmp, ptr + 8, 4);
+	if (tmp > size)
+	{
+		return cgltf_result_data_too_short;
+	}
+
+	const uint8_t* json_chunk = ptr + GlbHeaderSize;
+
+	if (GlbHeaderSize + GlbChunkHeaderSize > size)
+	{
+		return cgltf_result_data_too_short;
+	}
+
+	// JSON chunk: length
+	uint32_t json_length;
+	memcpy(&json_length, json_chunk, 4);
+	if (json_length > size - GlbHeaderSize - GlbChunkHeaderSize)
+	{
+		return cgltf_result_data_too_short;
+	}
+
+	// JSON chunk: magic
+	memcpy(&tmp, json_chunk + 4, 4);
+	if (tmp != GlbMagicJsonChunk)
+	{
+		return cgltf_result_unknown_format;
+	}
+
+	json_chunk += GlbChunkHeaderSize;
+
+	const void* bin = NULL;
+	cgltf_size bin_size = 0;
+
+	if (GlbChunkHeaderSize <= size - GlbHeaderSize - GlbChunkHeaderSize - json_length)
+	{
+		// We can read another chunk
+		const uint8_t* bin_chunk = json_chunk + json_length;
+
+		// Bin chunk: length
+		uint32_t bin_length;
+		memcpy(&bin_length, bin_chunk, 4);
+		if (bin_length > size - GlbHeaderSize - GlbChunkHeaderSize - json_length - GlbChunkHeaderSize)
+		{
+			return cgltf_result_data_too_short;
+		}
+
+		// Bin chunk: magic
+		memcpy(&tmp, bin_chunk + 4, 4);
+		if (tmp != GlbMagicBinChunk)
+		{
+			return cgltf_result_unknown_format;
+		}
+
+		bin_chunk += GlbChunkHeaderSize;
+
+		bin = bin_chunk;
+		bin_size = bin_length;
+	}
+
+	cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data);
+	if (json_result != cgltf_result_success)
+	{
+		return json_result;
+	}
+
+	(*out_data)->file_type = cgltf_file_type_glb;
+	(*out_data)->bin = bin;
+	(*out_data)->bin_size = bin_size;
+
+	return cgltf_result_success;
+}
+
+cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data)
+{
+	if (options == NULL)
+	{
+		return cgltf_result_invalid_options;
+	}
+
+	cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
+	void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data, cgltf_size size) = options->file.release ? options->file.release : cgltf_default_file_release;
+
+	void* file_data = NULL;
+	cgltf_size file_size = 0;
+	cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data);
+	if (result != cgltf_result_success)
+	{
+		return result;
+	}
+
+	result = cgltf_parse(options, file_data, file_size, out_data);
+
+	if (result != cgltf_result_success)
+	{
+		file_release(&options->memory, &options->file, file_data, file_size);
+		return result;
+	}
+
+	(*out_data)->file_data = file_data;
+	(*out_data)->file_size = file_size;
+
+	return cgltf_result_success;
+}
+
+static void cgltf_combine_paths(char* path, const char* base, const char* uri)
+{
+	const char* s0 = strrchr(base, '/');
+	const char* s1 = strrchr(base, '\\');
+	const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1;
+
+	if (slash)
+	{
+		size_t prefix = slash - base + 1;
+
+		strncpy(path, base, prefix);
+		strcpy(path + prefix, uri);
+	}
+	else
+	{
+		strcpy(path, uri);
+	}
+}
+
+static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data)
+{
+	void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
+	void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
+	cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
+
+	char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1);
+	if (!path)
+	{
+		return cgltf_result_out_of_memory;
+	}
+
+	cgltf_combine_paths(path, gltf_path, uri);
+
+	// after combining, the tail of the resulting path is a uri; decode_uri converts it into path
+	cgltf_decode_uri(path + strlen(path) - strlen(uri));
+
+	void* file_data = NULL;
+	cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data);
+
+	memory_free(options->memory.user_data, path);
+
+	*out_data = (result == cgltf_result_success) ? file_data : NULL;
+
+	return result;
+}
+
+cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data)
+{
+	void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc_func ? options->memory.alloc_func : &cgltf_default_alloc;
+	void (*memory_free)(void*, void*) = options->memory.free_func ? options->memory.free_func : &cgltf_default_free;
+
+	unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size);
+	if (!data)
+	{
+		return cgltf_result_out_of_memory;
+	}
+
+	unsigned int buffer = 0;
+	unsigned int buffer_bits = 0;
+
+	for (cgltf_size i = 0; i < size; ++i)
+	{
+		while (buffer_bits < 8)
+		{
+			char ch = *base64++;
+
+			int index =
+				(unsigned)(ch - 'A') < 26 ? (ch - 'A') :
+				(unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 :
+				(unsigned)(ch - '0') < 10 ? (ch - '0') + 52 :
+				ch == '+' ? 62 :
+				ch == '/' ? 63 :
+				-1;
+
+			if (index < 0)
+			{
+				memory_free(options->memory.user_data, data);
+				return cgltf_result_io_error;
+			}
+
+			buffer = (buffer << 6) | index;
+			buffer_bits += 6;
+		}
+
+		data[i] = (unsigned char)(buffer >> (buffer_bits - 8));
+		buffer_bits -= 8;
+	}
+
+	*out_data = data;
+
+	return cgltf_result_success;
+}
+
+static int cgltf_unhex(char ch)
+{
+	return
+		(unsigned)(ch - '0') < 10 ? (ch - '0') :
+		(unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 :
+		(unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 :
+		-1;
+}
+
+cgltf_size cgltf_decode_string(char* string)
+{
+	char* read = string + strcspn(string, "\\");
+	if (*read == 0)
+	{
+		return read - string;
+	}
+	char* write = string;
+	char* last = string;
+
+	for (;;)
+	{
+		// Copy characters since last escaped sequence
+		cgltf_size written = read - last;
+		memmove(write, last, written);
+		write += written;
+
+		if (*read++ == 0)
+		{
+			break;
+		}
+
+		// jsmn already checked that all escape sequences are valid
+		switch (*read++)
+		{
+		case '\"': *write++ = '\"'; break;
+		case '/':  *write++ = '/';  break;
+		case '\\': *write++ = '\\'; break;
+		case 'b':  *write++ = '\b'; break;
+		case 'f':  *write++ = '\f'; break;
+		case 'r':  *write++ = '\r'; break;
+		case 'n':  *write++ = '\n'; break;
+		case 't':  *write++ = '\t'; break;
+		case 'u':
+		{
+			// UCS-2 codepoint \uXXXX to UTF-8
+			int character = 0;
+			for (cgltf_size i = 0; i < 4; ++i)
+			{
+				character = (character << 4) + cgltf_unhex(*read++);
+			}
+
+			if (character <= 0x7F)
+			{
+				*write++ = character & 0xFF;
+			}
+			else if (character <= 0x7FF)
+			{
+				*write++ = 0xC0 | ((character >> 6) & 0xFF);
+				*write++ = 0x80 | (character & 0x3F);
+			}
+			else
+			{
+				*write++ = 0xE0 | ((character >> 12) & 0xFF);
+				*write++ = 0x80 | ((character >> 6) & 0x3F);
+				*write++ = 0x80 | (character & 0x3F);
+			}
+			break;
+		}
+		default:
+			break;
+		}
+
+		last = read;
+		read += strcspn(read, "\\");
+	}
+
+	*write = 0;
+	return write - string;
+}
+
+cgltf_size cgltf_decode_uri(char* uri)
+{
+	char* write = uri;
+	char* i = uri;
+
+	while (*i)
+	{
+		if (*i == '%')
+		{
+			int ch1 = cgltf_unhex(i[1]);
+
+			if (ch1 >= 0)
+			{
+				int ch2 = cgltf_unhex(i[2]);
+
+				if (ch2 >= 0)
+				{
+					*write++ = (char)(ch1 * 16 + ch2);
+					i += 3;
+					continue;
+				}
+			}
+		}
+
+		*write++ = *i++;
+	}
+
+	*write = 0;
+	return write - uri;
+}
+
+cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path)
+{
+	if (options == NULL)
+	{
+		return cgltf_result_invalid_options;
+	}
+
+	if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin)
+	{
+		if (data->bin_size < data->buffers[0].size)
+		{
+			return cgltf_result_data_too_short;
+		}
+
+		data->buffers[0].data = (void*)data->bin;
+		data->buffers[0].data_free_method = cgltf_data_free_method_none;
+	}
+
+	for (cgltf_size i = 0; i < data->buffers_count; ++i)
+	{
+		if (data->buffers[i].data)
+		{
+			continue;
+		}
+
+		const char* uri = data->buffers[i].uri;
+
+		if (uri == NULL)
+		{
+			continue;
+		}
+
+		if (strncmp(uri, "data:", 5) == 0)
+		{
+			const char* comma = strchr(uri, ',');
+
+			if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0)
+			{
+				cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data);
+				data->buffers[i].data_free_method = cgltf_data_free_method_memory_free;
+
+				if (res != cgltf_result_success)
+				{
+					return res;
+				}
+			}
+			else
+			{
+				return cgltf_result_unknown_format;
+			}
+		}
+		else if (strstr(uri, "://") == NULL && gltf_path)
+		{
+			cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data);
+			data->buffers[i].data_free_method = cgltf_data_free_method_file_release;
+
+			if (res != cgltf_result_success)
+			{
+				return res;
+			}
+		}
+		else
+		{
+			return cgltf_result_unknown_format;
+		}
+	}
+
+	return cgltf_result_success;
+}
+
+static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
+{
+	char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
+	cgltf_size bound = 0;
+
+	switch (component_type)
+	{
+	case cgltf_component_type_r_8u:
+		for (size_t i = 0; i < count; ++i)
+		{
+			cgltf_size v = ((unsigned char*)data)[i];
+			bound = bound > v ? bound : v;
+		}
+		break;
+
+	case cgltf_component_type_r_16u:
+		for (size_t i = 0; i < count; ++i)
+		{
+			cgltf_size v = ((unsigned short*)data)[i];
+			bound = bound > v ? bound : v;
+		}
+		break;
+
+	case cgltf_component_type_r_32u:
+		for (size_t i = 0; i < count; ++i)
+		{
+			cgltf_size v = ((unsigned int*)data)[i];
+			bound = bound > v ? bound : v;
+		}
+		break;
+
+	default:
+		;
+	}
+
+	return bound;
+}
+
+#if CGLTF_VALIDATE_ENABLE_ASSERTS
+#define CGLTF_ASSERT_IF(cond, result) assert(!(cond)); if (cond) return result;
+#else
+#define CGLTF_ASSERT_IF(cond, result) if (cond) return result;
+#endif
+
+cgltf_result cgltf_validate(cgltf_data* data)
+{
+	for (cgltf_size i = 0; i < data->accessors_count; ++i)
+	{
+		cgltf_accessor* accessor = &data->accessors[i];
+
+		CGLTF_ASSERT_IF(data->accessors[i].component_type == cgltf_component_type_invalid, cgltf_result_invalid_gltf);
+		CGLTF_ASSERT_IF(data->accessors[i].type == cgltf_type_invalid, cgltf_result_invalid_gltf);
+
+		cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type);
+
+		if (accessor->buffer_view)
+		{
+			cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size;
+
+			CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, cgltf_result_data_too_short);
+		}
+
+		if (accessor->is_sparse)
+		{
+			cgltf_accessor_sparse* sparse = &accessor->sparse;
+
+			cgltf_size indices_component_size = cgltf_component_size(sparse->indices_component_type);
+			cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count;
+			cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count;
+
+			CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size ||
+							sparse->values_buffer_view->size < values_req_size, cgltf_result_data_too_short);
+
+			CGLTF_ASSERT_IF(sparse->indices_component_type != cgltf_component_type_r_8u &&
+							sparse->indices_component_type != cgltf_component_type_r_16u &&
+							sparse->indices_component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
+
+			if (sparse->indices_buffer_view->buffer->data)
+			{
+				cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count);
+
+				CGLTF_ASSERT_IF(index_bound >= accessor->count, cgltf_result_data_too_short);
+			}
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
+	{
+		cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size;
+
+		CGLTF_ASSERT_IF(data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size, cgltf_result_data_too_short);
+
+		if (data->buffer_views[i].has_meshopt_compression)
+		{
+			cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression;
+
+			CGLTF_ASSERT_IF(mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size, cgltf_result_data_too_short);
+
+			CGLTF_ASSERT_IF(data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256), cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf);
+			CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8, cgltf_result_invalid_gltf);
+			CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_color && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf);
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->meshes_count; ++i)
+	{
+		if (data->meshes[i].weights)
+		{
+			CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count, cgltf_result_invalid_gltf);
+		}
+
+		if (data->meshes[i].target_names)
+		{
+			CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count, cgltf_result_invalid_gltf);
+		}
+
+		for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
+		{
+			CGLTF_ASSERT_IF(data->meshes[i].primitives[j].type == cgltf_primitive_type_invalid, cgltf_result_invalid_gltf);
+			CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes_count == 0, cgltf_result_invalid_gltf);
+
+			cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data;
+
+			CGLTF_ASSERT_IF(first->count == 0, cgltf_result_invalid_gltf);
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
+			{
+				CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
+			}
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
+			{
+				for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
+				{
+					CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count, cgltf_result_invalid_gltf);
+				}
+			}
+
+			cgltf_accessor* indices = data->meshes[i].primitives[j].indices;
+
+			CGLTF_ASSERT_IF(indices &&
+				indices->component_type != cgltf_component_type_r_8u &&
+				indices->component_type != cgltf_component_type_r_16u &&
+				indices->component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
+
+			CGLTF_ASSERT_IF(indices && indices->type != cgltf_type_scalar, cgltf_result_invalid_gltf);
+			CGLTF_ASSERT_IF(indices && indices->stride != cgltf_component_size(indices->component_type), cgltf_result_invalid_gltf);
+
+			if (indices && indices->buffer_view && indices->buffer_view->buffer->data)
+			{
+				cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count);
+
+				CGLTF_ASSERT_IF(index_bound >= first->count, cgltf_result_data_too_short);
+			}
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
+			{
+				CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= data->variants_count, cgltf_result_invalid_gltf);
+			}
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->nodes_count; ++i)
+	{
+		if (data->nodes[i].weights && data->nodes[i].mesh)
+		{
+			CGLTF_ASSERT_IF(data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
+		}
+
+		if (data->nodes[i].has_mesh_gpu_instancing)
+		{
+			CGLTF_ASSERT_IF(data->nodes[i].mesh == NULL, cgltf_result_invalid_gltf);
+			CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes_count == 0, cgltf_result_invalid_gltf);
+
+			cgltf_accessor* first = data->nodes[i].mesh_gpu_instancing.attributes[0].data;
+
+			for (cgltf_size k = 0; k < data->nodes[i].mesh_gpu_instancing.attributes_count; ++k)
+			{
+				CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
+			}
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->nodes_count; ++i)
+	{
+		cgltf_node* p1 = data->nodes[i].parent;
+		cgltf_node* p2 = p1 ? p1->parent : NULL;
+
+		while (p1 && p2)
+		{
+			CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf);
+
+			p1 = p1->parent;
+			p2 = p2->parent ? p2->parent->parent : NULL;
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->scenes_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
+		{
+			CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, cgltf_result_invalid_gltf);
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->animations_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
+		{
+			cgltf_animation_channel* channel = &data->animations[i].channels[j];
+
+			if (!channel->target_node)
+			{
+				continue;
+			}
+
+			cgltf_size components = 1;
+
+			if (channel->target_path == cgltf_animation_path_type_weights)
+			{
+				CGLTF_ASSERT_IF(!channel->target_node->mesh || !channel->target_node->mesh->primitives_count, cgltf_result_invalid_gltf);
+
+				components = channel->target_node->mesh->primitives[0].targets_count;
+			}
+
+			cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1;
+
+			CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != channel->sampler->output->count, cgltf_result_invalid_gltf);
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->variants_count; ++i)
+	{
+		CGLTF_ASSERT_IF(!data->variants[i].name, cgltf_result_invalid_gltf);
+	}
+
+	return cgltf_result_success;
+}
+
+cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size)
+{
+	cgltf_size json_size = extras->end_offset - extras->start_offset;
+
+	if (!dest)
+	{
+		if (dest_size)
+		{
+			*dest_size = json_size + 1;
+			return cgltf_result_success;
+		}
+		return cgltf_result_invalid_options;
+	}
+
+	if (*dest_size + 1 < json_size)
+	{
+		strncpy(dest, data->json + extras->start_offset, *dest_size - 1);
+		dest[*dest_size - 1] = 0;
+	}
+	else
+	{
+		strncpy(dest, data->json + extras->start_offset, json_size);
+		dest[json_size] = 0;
+	}
+
+	return cgltf_result_success;
+}
+
+static void cgltf_free_extras(cgltf_data* data, cgltf_extras* extras)
+{
+	data->memory.free_func(data->memory.user_data, extras->data);
+}
+
+static void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
+{
+	for (cgltf_size i = 0; i < extensions_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, extensions[i].name);
+		data->memory.free_func(data->memory.user_data, extensions[i].data);
+	}
+	data->memory.free_func(data->memory.user_data, extensions);
+}
+
+void cgltf_free(cgltf_data* data)
+{
+	if (!data)
+	{
+		return;
+	}
+
+	void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data, cgltf_size size) = data->file.release ? data->file.release : cgltf_default_file_release;
+
+	data->memory.free_func(data->memory.user_data, data->asset.copyright);
+	data->memory.free_func(data->memory.user_data, data->asset.generator);
+	data->memory.free_func(data->memory.user_data, data->asset.version);
+	data->memory.free_func(data->memory.user_data, data->asset.min_version);
+
+	cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
+	cgltf_free_extras(data, &data->asset.extras);
+
+	for (cgltf_size i = 0; i < data->accessors_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->accessors[i].name);
+
+		cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
+		cgltf_free_extras(data, &data->accessors[i].extras);
+	}
+	data->memory.free_func(data->memory.user_data, data->accessors);
+
+	for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->buffer_views[i].name);
+		data->memory.free_func(data->memory.user_data, data->buffer_views[i].data);
+
+		cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
+		cgltf_free_extras(data, &data->buffer_views[i].extras);
+	}
+	data->memory.free_func(data->memory.user_data, data->buffer_views);
+
+	for (cgltf_size i = 0; i < data->buffers_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->buffers[i].name);
+
+		if (data->buffers[i].data_free_method == cgltf_data_free_method_file_release)
+		{
+			file_release(&data->memory, &data->file, data->buffers[i].data, data->buffers[i].size);
+		}
+		else if (data->buffers[i].data_free_method == cgltf_data_free_method_memory_free)
+		{
+			data->memory.free_func(data->memory.user_data, data->buffers[i].data);
+		}
+
+		data->memory.free_func(data->memory.user_data, data->buffers[i].uri);
+
+		cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
+		cgltf_free_extras(data, &data->buffers[i].extras);
+	}
+	data->memory.free_func(data->memory.user_data, data->buffers);
+
+	for (cgltf_size i = 0; i < data->meshes_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->meshes[i].name);
+
+		for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
+		{
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
+			{
+				data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name);
+			}
+
+			data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].attributes);
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
+			{
+				for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
+				{
+					data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name);
+				}
+
+				data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes);
+			}
+
+			data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].targets);
+
+			if (data->meshes[i].primitives[j].has_draco_mesh_compression)
+			{
+				for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k)
+				{
+					data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name);
+				}
+
+				data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
+			}
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
+			{
+				cgltf_free_extras(data, &data->meshes[i].primitives[j].mappings[k].extras);
+			}
+
+			data->memory.free_func(data->memory.user_data, data->meshes[i].primitives[j].mappings);
+
+			cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
+			cgltf_free_extras(data, &data->meshes[i].primitives[j].extras);
+		}
+
+		data->memory.free_func(data->memory.user_data, data->meshes[i].primitives);
+		data->memory.free_func(data->memory.user_data, data->meshes[i].weights);
+
+		for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j)
+		{
+			data->memory.free_func(data->memory.user_data, data->meshes[i].target_names[j]);
+		}
+
+		cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
+		cgltf_free_extras(data, &data->meshes[i].extras);
+
+		data->memory.free_func(data->memory.user_data, data->meshes[i].target_names);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->meshes);
+
+	for (cgltf_size i = 0; i < data->materials_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->materials[i].name);
+
+		cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
+		cgltf_free_extras(data, &data->materials[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->materials);
+
+	for (cgltf_size i = 0; i < data->images_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->images[i].name);
+		data->memory.free_func(data->memory.user_data, data->images[i].uri);
+		data->memory.free_func(data->memory.user_data, data->images[i].mime_type);
+
+		cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
+		cgltf_free_extras(data, &data->images[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->images);
+
+	for (cgltf_size i = 0; i < data->textures_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->textures[i].name);
+
+		cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
+		cgltf_free_extras(data, &data->textures[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->textures);
+
+	for (cgltf_size i = 0; i < data->samplers_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->samplers[i].name);
+
+		cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
+		cgltf_free_extras(data, &data->samplers[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->samplers);
+
+	for (cgltf_size i = 0; i < data->skins_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->skins[i].name);
+		data->memory.free_func(data->memory.user_data, data->skins[i].joints);
+
+		cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
+		cgltf_free_extras(data, &data->skins[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->skins);
+
+	for (cgltf_size i = 0; i < data->cameras_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->cameras[i].name);
+
+		if (data->cameras[i].type == cgltf_camera_type_perspective)
+		{
+			cgltf_free_extras(data, &data->cameras[i].data.perspective.extras);
+		}
+		else if (data->cameras[i].type == cgltf_camera_type_orthographic)
+		{
+			cgltf_free_extras(data, &data->cameras[i].data.orthographic.extras);
+		}
+
+		cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
+		cgltf_free_extras(data, &data->cameras[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->cameras);
+
+	for (cgltf_size i = 0; i < data->lights_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->lights[i].name);
+
+		cgltf_free_extras(data, &data->lights[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->lights);
+
+	for (cgltf_size i = 0; i < data->nodes_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->nodes[i].name);
+		data->memory.free_func(data->memory.user_data, data->nodes[i].children);
+		data->memory.free_func(data->memory.user_data, data->nodes[i].weights);
+
+		if (data->nodes[i].has_mesh_gpu_instancing)
+		{
+			for (cgltf_size j = 0; j < data->nodes[i].mesh_gpu_instancing.attributes_count; ++j)
+			{
+				data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes[j].name);
+			}
+
+			data->memory.free_func(data->memory.user_data, data->nodes[i].mesh_gpu_instancing.attributes);
+		}
+
+		cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
+		cgltf_free_extras(data, &data->nodes[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->nodes);
+
+	for (cgltf_size i = 0; i < data->scenes_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->scenes[i].name);
+		data->memory.free_func(data->memory.user_data, data->scenes[i].nodes);
+
+		cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
+		cgltf_free_extras(data, &data->scenes[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->scenes);
+
+	for (cgltf_size i = 0; i < data->animations_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->animations[i].name);
+		for (cgltf_size j = 0; j <  data->animations[i].samplers_count; ++j)
+		{
+			cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
+			cgltf_free_extras(data, &data->animations[i].samplers[j].extras);
+		}
+		data->memory.free_func(data->memory.user_data, data->animations[i].samplers);
+
+		for (cgltf_size j = 0; j <  data->animations[i].channels_count; ++j)
+		{
+			cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
+			cgltf_free_extras(data, &data->animations[i].channels[j].extras);
+		}
+		data->memory.free_func(data->memory.user_data, data->animations[i].channels);
+
+		cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
+		cgltf_free_extras(data, &data->animations[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->animations);
+
+	for (cgltf_size i = 0; i < data->variants_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->variants[i].name);
+
+		cgltf_free_extras(data, &data->variants[i].extras);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->variants);
+
+	cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
+	cgltf_free_extras(data, &data->extras);
+
+	for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->extensions_used[i]);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->extensions_used);
+
+	for (cgltf_size i = 0; i < data->extensions_required_count; ++i)
+	{
+		data->memory.free_func(data->memory.user_data, data->extensions_required[i]);
+	}
+
+	data->memory.free_func(data->memory.user_data, data->extensions_required);
+
+	file_release(&data->memory, &data->file, data->file_data, data->file_size);
+
+	data->memory.free_func(data->memory.user_data, data);
+}
+
+void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix)
+{
+	cgltf_float* lm = out_matrix;
+
+	if (node->has_matrix)
+	{
+		memcpy(lm, node->matrix, sizeof(float) * 16);
+	}
+	else
+	{
+		float tx = node->translation[0];
+		float ty = node->translation[1];
+		float tz = node->translation[2];
+
+		float qx = node->rotation[0];
+		float qy = node->rotation[1];
+		float qz = node->rotation[2];
+		float qw = node->rotation[3];
+
+		float sx = node->scale[0];
+		float sy = node->scale[1];
+		float sz = node->scale[2];
+
+		lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx;
+		lm[1] = (2 * qx*qy + 2 * qz*qw) * sx;
+		lm[2] = (2 * qx*qz - 2 * qy*qw) * sx;
+		lm[3] = 0.f;
+
+		lm[4] = (2 * qx*qy - 2 * qz*qw) * sy;
+		lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy;
+		lm[6] = (2 * qy*qz + 2 * qx*qw) * sy;
+		lm[7] = 0.f;
+
+		lm[8] = (2 * qx*qz + 2 * qy*qw) * sz;
+		lm[9] = (2 * qy*qz - 2 * qx*qw) * sz;
+		lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz;
+		lm[11] = 0.f;
+
+		lm[12] = tx;
+		lm[13] = ty;
+		lm[14] = tz;
+		lm[15] = 1.f;
+	}
+}
+
+void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
+{
+	cgltf_float* lm = out_matrix;
+	cgltf_node_transform_local(node, lm);
+
+	const cgltf_node* parent = node->parent;
+
+	while (parent)
+	{
+		float pm[16];
+		cgltf_node_transform_local(parent, pm);
+
+		for (int i = 0; i < 4; ++i)
+		{
+			float l0 = lm[i * 4 + 0];
+			float l1 = lm[i * 4 + 1];
+			float l2 = lm[i * 4 + 2];
+
+			float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8];
+			float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9];
+			float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10];
+
+			lm[i * 4 + 0] = r0;
+			lm[i * 4 + 1] = r1;
+			lm[i * 4 + 2] = r2;
+		}
+
+		lm[12] += pm[12];
+		lm[13] += pm[13];
+		lm[14] += pm[14];
+
+		parent = parent->parent;
+	}
+}
+
+static cgltf_ssize cgltf_component_read_integer(const void* in, cgltf_component_type component_type)
+{
+	switch (component_type)
+	{
+		case cgltf_component_type_r_16:
+			return *((const int16_t*) in);
+		case cgltf_component_type_r_16u:
+			return *((const uint16_t*) in);
+		case cgltf_component_type_r_32u:
+			return *((const uint32_t*) in);
+		case cgltf_component_type_r_8:
+			return *((const int8_t*) in);
+		case cgltf_component_type_r_8u:
+			return *((const uint8_t*) in);
+		default:
+			return 0;
+	}
+}
+
+static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type)
+{
+	switch (component_type)
+	{
+		case cgltf_component_type_r_16u:
+			return *((const uint16_t*) in);
+		case cgltf_component_type_r_32u:
+			return *((const uint32_t*) in);
+		case cgltf_component_type_r_8u:
+			return *((const uint8_t*) in);
+		default:
+			return 0;
+	}
+}
+
+static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized)
+{
+	if (component_type == cgltf_component_type_r_32f)
+	{
+		return *((const float*) in);
+	}
+
+	if (normalized)
+	{
+		switch (component_type)
+		{
+			// note: glTF spec doesn't currently define normalized conversions for 32-bit integers
+			case cgltf_component_type_r_16:
+				return *((const int16_t*) in) / (cgltf_float)32767;
+			case cgltf_component_type_r_16u:
+				return *((const uint16_t*) in) / (cgltf_float)65535;
+			case cgltf_component_type_r_8:
+				return *((const int8_t*) in) / (cgltf_float)127;
+			case cgltf_component_type_r_8u:
+				return *((const uint8_t*) in) / (cgltf_float)255;
+			default:
+				return 0;
+		}
+	}
+
+	return (cgltf_float)cgltf_component_read_integer(in, component_type);
+}
+
+static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
+{
+	cgltf_size num_components = cgltf_num_components(type);
+
+	if (element_size < num_components) {
+		return 0;
+	}
+
+	// There are three special cases for component extraction, see #data-alignment in the 2.0 spec.
+
+	cgltf_size component_size = cgltf_component_size(component_type);
+
+	if (type == cgltf_type_mat2 && component_size == 1)
+	{
+		out[0] = cgltf_component_read_float(element, component_type, normalized);
+		out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
+		out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
+		out[3] = cgltf_component_read_float(element + 5, component_type, normalized);
+		return 1;
+	}
+
+	if (type == cgltf_type_mat3 && component_size == 1)
+	{
+		out[0] = cgltf_component_read_float(element, component_type, normalized);
+		out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
+		out[2] = cgltf_component_read_float(element + 2, component_type, normalized);
+		out[3] = cgltf_component_read_float(element + 4, component_type, normalized);
+		out[4] = cgltf_component_read_float(element + 5, component_type, normalized);
+		out[5] = cgltf_component_read_float(element + 6, component_type, normalized);
+		out[6] = cgltf_component_read_float(element + 8, component_type, normalized);
+		out[7] = cgltf_component_read_float(element + 9, component_type, normalized);
+		out[8] = cgltf_component_read_float(element + 10, component_type, normalized);
+		return 1;
+	}
+
+	if (type == cgltf_type_mat3 && component_size == 2)
+	{
+		out[0] = cgltf_component_read_float(element, component_type, normalized);
+		out[1] = cgltf_component_read_float(element + 2, component_type, normalized);
+		out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
+		out[3] = cgltf_component_read_float(element + 8, component_type, normalized);
+		out[4] = cgltf_component_read_float(element + 10, component_type, normalized);
+		out[5] = cgltf_component_read_float(element + 12, component_type, normalized);
+		out[6] = cgltf_component_read_float(element + 16, component_type, normalized);
+		out[7] = cgltf_component_read_float(element + 18, component_type, normalized);
+		out[8] = cgltf_component_read_float(element + 20, component_type, normalized);
+		return 1;
+	}
+
+	for (cgltf_size i = 0; i < num_components; ++i)
+	{
+		out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized);
+	}
+	return 1;
+}
+
+const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
+{
+	if (view->data)
+		return (const uint8_t*)view->data;
+
+	if (!view->buffer->data)
+		return NULL;
+
+	const uint8_t* result = (const uint8_t*)view->buffer->data;
+	result += view->offset;
+	return result;
+}
+
+const cgltf_accessor* cgltf_find_accessor(const cgltf_primitive* prim, cgltf_attribute_type type, cgltf_int index)
+{
+	for (cgltf_size i = 0; i < prim->attributes_count; ++i)
+	{
+		const cgltf_attribute* attr = &prim->attributes[i];
+		if (attr->type == type && attr->index == index)
+			return attr->data;
+	}
+
+	return NULL;
+}
+
+static const uint8_t* cgltf_find_sparse_index(const cgltf_accessor* accessor, cgltf_size needle)
+{
+	const cgltf_accessor_sparse* sparse = &accessor->sparse;
+	const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view);
+	const uint8_t* value_data = cgltf_buffer_view_data(sparse->values_buffer_view);
+
+	if (index_data == NULL || value_data == NULL)
+		return NULL;
+
+	index_data += sparse->indices_byte_offset;
+	value_data += sparse->values_byte_offset;
+
+	cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type);
+
+	cgltf_size offset = 0;
+	cgltf_size length = sparse->count;
+
+	while (length)
+	{
+		cgltf_size rem = length % 2;
+		length /= 2;
+
+		cgltf_size index = cgltf_component_read_index(index_data + (offset + length) * index_stride, sparse->indices_component_type);
+		offset += index < needle ? length + rem : 0;
+	}
+
+	if (offset == sparse->count)
+		return NULL;
+
+	cgltf_size index = cgltf_component_read_index(index_data + offset * index_stride, sparse->indices_component_type);
+	return index == needle ? value_data + offset * accessor->stride : NULL;
+}
+
+cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
+{
+	if (accessor->is_sparse)
+	{
+		const uint8_t* element = cgltf_find_sparse_index(accessor, index);
+		if (element)
+			return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size);
+	}
+	if (accessor->buffer_view == NULL)
+	{
+		memset(out, 0, element_size * sizeof(cgltf_float));
+		return 1;
+	}
+	const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
+	if (element == NULL)
+	{
+		return 0;
+	}
+	element += accessor->offset + accessor->stride * index;
+	return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size);
+}
+
+cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count)
+{
+	cgltf_size floats_per_element = cgltf_num_components(accessor->type);
+	cgltf_size available_floats = accessor->count * floats_per_element;
+	if (out == NULL)
+	{
+		return available_floats;
+	}
+
+	float_count = available_floats < float_count ? available_floats : float_count;
+	cgltf_size element_count = float_count / floats_per_element;
+
+	// First pass: convert each element in the base accessor.
+	if (accessor->buffer_view == NULL)
+	{
+		memset(out, 0, element_count * floats_per_element * sizeof(cgltf_float));
+	}
+	else
+	{
+		const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
+		if (element == NULL)
+		{
+			return 0;
+		}
+		element += accessor->offset;
+
+		if (accessor->component_type == cgltf_component_type_r_32f && accessor->stride == floats_per_element * sizeof(cgltf_float))
+		{
+			memcpy(out, element, element_count * floats_per_element * sizeof(cgltf_float));
+		}
+		else
+		{
+			cgltf_float* dest = out;
+
+			for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element, element += accessor->stride)
+			{
+				if (!cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, dest, floats_per_element))
+				{
+					return 0;
+				}
+			}
+		}
+	}
+
+	// Second pass: write out each element in the sparse accessor.
+	if (accessor->is_sparse)
+	{
+		const cgltf_accessor_sparse* sparse = &accessor->sparse;
+
+		const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view);
+		const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view);
+
+		if (index_data == NULL || reader_head == NULL)
+		{
+			return 0;
+		}
+
+		index_data += sparse->indices_byte_offset;
+		reader_head += sparse->values_byte_offset;
+
+		cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type);
+		for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride, reader_head += accessor->stride)
+		{
+			size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type);
+			float* writer_head = out + writer_index * floats_per_element;
+
+			if (!cgltf_element_read_float(reader_head, accessor->type, accessor->component_type, accessor->normalized, writer_head, floats_per_element))
+			{
+				return 0;
+			}
+		}
+	}
+
+	return element_count * floats_per_element;
+}
+
+static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type)
+{
+	switch (component_type)
+	{
+		case cgltf_component_type_r_8:
+			return *((const int8_t*) in);
+
+		case cgltf_component_type_r_8u:
+			return *((const uint8_t*) in);
+
+		case cgltf_component_type_r_16:
+			return *((const int16_t*) in);
+
+		case cgltf_component_type_r_16u:
+			return *((const uint16_t*) in);
+
+		case cgltf_component_type_r_32u:
+			return *((const uint32_t*) in);
+
+		default:
+			return 0;
+	}
+}
+
+static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size)
+{
+	cgltf_size num_components = cgltf_num_components(type);
+
+	if (element_size < num_components)
+	{
+		return 0;
+	}
+
+	// Reading integer matrices is not a valid use case
+	if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4)
+	{
+		return 0;
+	}
+
+	cgltf_size component_size = cgltf_component_size(component_type);
+
+	for (cgltf_size i = 0; i < num_components; ++i)
+	{
+		out[i] = cgltf_component_read_uint(element + component_size * i, component_type);
+	}
+	return 1;
+}
+
+cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size)
+{
+	if (accessor->is_sparse)
+	{
+		const uint8_t* element = cgltf_find_sparse_index(accessor, index);
+		if (element)
+			return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size);
+	}
+	if (accessor->buffer_view == NULL)
+	{
+		memset(out, 0, element_size * sizeof(cgltf_uint));
+		return 1;
+	}
+	const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
+	if (element == NULL)
+	{
+		return 0;
+	}
+	element += accessor->offset + accessor->stride * index;
+	return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size);
+}
+
+cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index)
+{
+	if (accessor->is_sparse)
+	{
+		const uint8_t* element = cgltf_find_sparse_index(accessor, index);
+		if (element)
+			return cgltf_component_read_index(element, accessor->component_type);
+	}
+	if (accessor->buffer_view == NULL)
+	{
+		return 0;
+	}
+	const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
+	if (element == NULL)
+	{
+		return 0; // This is an error case, but we can't communicate the error with existing interface.
+	}
+	element += accessor->offset + accessor->stride * index;
+	return cgltf_component_read_index(element, accessor->component_type);
+}
+
+cgltf_size cgltf_mesh_index(const cgltf_data* data, const cgltf_mesh* object)
+{
+	assert(object && (cgltf_size)(object - data->meshes) < data->meshes_count);
+	return (cgltf_size)(object - data->meshes);
+}
+
+cgltf_size cgltf_material_index(const cgltf_data* data, const cgltf_material* object)
+{
+	assert(object && (cgltf_size)(object - data->materials) < data->materials_count);
+	return (cgltf_size)(object - data->materials);
+}
+
+cgltf_size cgltf_accessor_index(const cgltf_data* data, const cgltf_accessor* object)
+{
+	assert(object && (cgltf_size)(object - data->accessors) < data->accessors_count);
+	return (cgltf_size)(object - data->accessors);
+}
+
+cgltf_size cgltf_buffer_view_index(const cgltf_data* data, const cgltf_buffer_view* object)
+{
+	assert(object && (cgltf_size)(object - data->buffer_views) < data->buffer_views_count);
+	return (cgltf_size)(object - data->buffer_views);
+}
+
+cgltf_size cgltf_buffer_index(const cgltf_data* data, const cgltf_buffer* object)
+{
+	assert(object && (cgltf_size)(object - data->buffers) < data->buffers_count);
+	return (cgltf_size)(object - data->buffers);
+}
+
+cgltf_size cgltf_image_index(const cgltf_data* data, const cgltf_image* object)
+{
+	assert(object && (cgltf_size)(object - data->images) < data->images_count);
+	return (cgltf_size)(object - data->images);
+}
+
+cgltf_size cgltf_texture_index(const cgltf_data* data, const cgltf_texture* object)
+{
+	assert(object && (cgltf_size)(object - data->textures) < data->textures_count);
+	return (cgltf_size)(object - data->textures);
+}
+
+cgltf_size cgltf_sampler_index(const cgltf_data* data, const cgltf_sampler* object)
+{
+	assert(object && (cgltf_size)(object - data->samplers) < data->samplers_count);
+	return (cgltf_size)(object - data->samplers);
+}
+
+cgltf_size cgltf_skin_index(const cgltf_data* data, const cgltf_skin* object)
+{
+	assert(object && (cgltf_size)(object - data->skins) < data->skins_count);
+	return (cgltf_size)(object - data->skins);
+}
+
+cgltf_size cgltf_camera_index(const cgltf_data* data, const cgltf_camera* object)
+{
+	assert(object && (cgltf_size)(object - data->cameras) < data->cameras_count);
+	return (cgltf_size)(object - data->cameras);
+}
+
+cgltf_size cgltf_light_index(const cgltf_data* data, const cgltf_light* object)
+{
+	assert(object && (cgltf_size)(object - data->lights) < data->lights_count);
+	return (cgltf_size)(object - data->lights);
+}
+
+cgltf_size cgltf_node_index(const cgltf_data* data, const cgltf_node* object)
+{
+	assert(object && (cgltf_size)(object - data->nodes) < data->nodes_count);
+	return (cgltf_size)(object - data->nodes);
+}
+
+cgltf_size cgltf_scene_index(const cgltf_data* data, const cgltf_scene* object)
+{
+	assert(object && (cgltf_size)(object - data->scenes) < data->scenes_count);
+	return (cgltf_size)(object - data->scenes);
+}
+
+cgltf_size cgltf_animation_index(const cgltf_data* data, const cgltf_animation* object)
+{
+	assert(object && (cgltf_size)(object - data->animations) < data->animations_count);
+	return (cgltf_size)(object - data->animations);
+}
+
+cgltf_size cgltf_animation_sampler_index(const cgltf_animation* animation, const cgltf_animation_sampler* object)
+{
+	assert(object && (cgltf_size)(object - animation->samplers) < animation->samplers_count);
+	return (cgltf_size)(object - animation->samplers);
+}
+
+cgltf_size cgltf_animation_channel_index(const cgltf_animation* animation, const cgltf_animation_channel* object)
+{
+	assert(object && (cgltf_size)(object - animation->channels) < animation->channels_count);
+	return (cgltf_size)(object - animation->channels);
+}
+
+cgltf_size cgltf_accessor_unpack_indices(const cgltf_accessor* accessor, void* out, cgltf_size out_component_size, cgltf_size index_count)
+{
+	if (out == NULL)
+	{
+		return accessor->count;
+	}
+
+	cgltf_size numbers_per_element = cgltf_num_components(accessor->type);
+	cgltf_size available_numbers = accessor->count * numbers_per_element;
+
+	index_count = available_numbers < index_count ? available_numbers : index_count;
+	cgltf_size index_component_size = cgltf_component_size(accessor->component_type);
+
+	if (accessor->is_sparse)
+	{
+		return 0;
+	}
+	if (accessor->buffer_view == NULL)
+	{
+		return 0;
+	}
+	if (index_component_size > out_component_size)
+	{
+		return 0;
+	}
+	const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
+	if (element == NULL)
+	{
+		return 0;
+	}
+	element += accessor->offset;
+
+	if (index_component_size == out_component_size && accessor->stride == out_component_size * numbers_per_element)
+	{
+		memcpy(out, element, index_count * index_component_size);
+		return index_count;
+	}
+
+	// Data couldn't be copied with memcpy due to stride being larger than the component size.
+	// OR
+	// The component size of the output array is larger than the component size of the index data, so index data will be padded.
+	switch (out_component_size)
+	{
+	case 1:
+		for (cgltf_size index = 0; index < index_count; index++, element += accessor->stride)
+		{
+			((uint8_t*)out)[index] = (uint8_t)cgltf_component_read_index(element, accessor->component_type);
+		}
+		break;
+	case 2:
+		for (cgltf_size index = 0; index < index_count; index++, element += accessor->stride)
+		{
+			((uint16_t*)out)[index] = (uint16_t)cgltf_component_read_index(element, accessor->component_type);
+		}
+		break;
+	case 4:
+		for (cgltf_size index = 0; index < index_count; index++, element += accessor->stride)
+		{
+			((uint32_t*)out)[index] = (uint32_t)cgltf_component_read_index(element, accessor->component_type);
+		}
+		break;
+	default:
+		return 0;
+	}
+
+	return index_count;
+}
+
+#define CGLTF_ERROR_JSON -1
+#define CGLTF_ERROR_NOMEM -2
+#define CGLTF_ERROR_LEGACY -3
+
+#define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; }
+#define CGLTF_CHECK_TOKTYPE_RET(tok_, type_, ret_) if ((tok_).type != (type_)) { return ret_; }
+#define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */
+
+#define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1)
+#define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; }
+#define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1];
+
+static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str)
+{
+	CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
+	size_t const str_len = strlen(str);
+	size_t const name_length = (size_t)(tok->end - tok->start);
+	return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
+}
+
+static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
+	char tmp[128];
+	int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
+	strncpy(tmp, (const char*)json_chunk + tok->start, size);
+	tmp[size] = 0;
+	return CGLTF_ATOI(tmp);
+}
+
+static cgltf_size cgltf_json_to_size(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	CGLTF_CHECK_TOKTYPE_RET(*tok, JSMN_PRIMITIVE, 0);
+	char tmp[128];
+	int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
+	strncpy(tmp, (const char*)json_chunk + tok->start, size);
+	tmp[size] = 0;
+	long long res = CGLTF_ATOLL(tmp);
+	return res < 0 ? 0 : (cgltf_size)res;
+}
+
+static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
+	char tmp[128];
+	int size = (size_t)(tok->end - tok->start) < sizeof(tmp) ? (int)(tok->end - tok->start) : (int)(sizeof(tmp) - 1);
+	strncpy(tmp, (const char*)json_chunk + tok->start, size);
+	tmp[size] = 0;
+	return (cgltf_float)CGLTF_ATOF(tmp);
+}
+
+static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	int size = (int)(tok->end - tok->start);
+	return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
+}
+
+static int cgltf_skip_json(jsmntok_t const* tokens, int i)
+{
+	int end = i + 1;
+
+	while (i < end)
+	{
+		switch (tokens[i].type)
+		{
+		case JSMN_OBJECT:
+			end += tokens[i].size * 2;
+			break;
+
+		case JSMN_ARRAY:
+			end += tokens[i].size;
+			break;
+
+		case JSMN_PRIMITIVE:
+		case JSMN_STRING:
+			break;
+
+		default:
+			return -1;
+		}
+
+		i++;
+	}
+
+	return i;
+}
+
+static void cgltf_fill_float_array(float* out_array, int size, float value)
+{
+	for (int j = 0; j < size; ++j)
+	{
+		out_array[j] = value;
+	}
+}
+
+static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
+	if (tokens[i].size != size)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+	++i;
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+		out_array[j] = cgltf_json_to_float(tokens + i, json_chunk);
+		++i;
+	}
+	return i;
+}
+
+static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
+	if (*out_string)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+	int size = (int)(tokens[i].end - tokens[i].start);
+	char* result = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
+	if (!result)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+	strncpy(result, (const char*)json_chunk + tokens[i].start, size);
+	result[size] = 0;
+	*out_string = result;
+	return i + 1;
+}
+
+static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size)
+{
+	(void)json_chunk;
+	if (tokens[i].type != JSMN_ARRAY)
+	{
+		return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON;
+	}
+	if (*out_array)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+	int size = tokens[i].size;
+	void* result = cgltf_calloc(options, element_size, size);
+	if (!result)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+	*out_array = result;
+	*out_size = size;
+	return i + 1;
+}
+
+static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < *out_size; ++j)
+	{
+		i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array));
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index)
+{
+	if (*name == '_')
+	{
+		*out_type = cgltf_attribute_type_custom;
+		return;
+	}
+
+	const char* us = strchr(name, '_');
+	size_t len = us ? (size_t)(us - name) : strlen(name);
+
+	if (len == 8 && strncmp(name, "POSITION", 8) == 0)
+	{
+		*out_type = cgltf_attribute_type_position;
+	}
+	else if (len == 6 && strncmp(name, "NORMAL", 6) == 0)
+	{
+		*out_type = cgltf_attribute_type_normal;
+	}
+	else if (len == 7 && strncmp(name, "TANGENT", 7) == 0)
+	{
+		*out_type = cgltf_attribute_type_tangent;
+	}
+	else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0)
+	{
+		*out_type = cgltf_attribute_type_texcoord;
+	}
+	else if (len == 5 && strncmp(name, "COLOR", 5) == 0)
+	{
+		*out_type = cgltf_attribute_type_color;
+	}
+	else if (len == 6 && strncmp(name, "JOINTS", 6) == 0)
+	{
+		*out_type = cgltf_attribute_type_joints;
+	}
+	else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0)
+	{
+		*out_type = cgltf_attribute_type_weights;
+	}
+	else
+	{
+		*out_type = cgltf_attribute_type_invalid;
+	}
+
+	if (us && *out_type != cgltf_attribute_type_invalid)
+	{
+		*out_index = CGLTF_ATOI(us + 1);
+		if (*out_index < 0)
+		{
+			*out_type = cgltf_attribute_type_invalid;
+			*out_index = 0;
+		}
+	}
+}
+
+static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	if (*out_attributes)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+
+	*out_attributes_count = tokens[i].size;
+	*out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count);
+	++i;
+
+	if (!*out_attributes)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+
+	for (cgltf_size j = 0; j < *out_attributes_count; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name);
+		if (i < 0)
+		{
+			return CGLTF_ERROR_JSON;
+		}
+
+		cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index);
+
+		(*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
+		++i;
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_extras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
+{
+	if (out_extras->data)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+
+	/* fill deprecated fields for now, this will be removed in the future */
+	out_extras->start_offset = tokens[i].start;
+	out_extras->end_offset = tokens[i].end;
+
+	size_t start = tokens[i].start;
+	size_t size = tokens[i].end - start;
+	out_extras->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
+	if (!out_extras->data)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+	strncpy(out_extras->data, (const char*)json_chunk + start, size);
+	out_extras->data[size] = '\0';
+
+	i = cgltf_skip_json(tokens, i);
+	return i;
+}
+
+static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
+	CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT);
+	if (out_extension->name)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+
+	cgltf_size name_length = tokens[i].end - tokens[i].start;
+	out_extension->name = (char*)options->memory.alloc_func(options->memory.user_data, name_length + 1);
+	if (!out_extension->name)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+	strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length);
+	out_extension->name[name_length] = 0;
+	i++;
+
+	size_t start = tokens[i].start;
+	size_t size = tokens[i].end - start;
+	out_extension->data = (char*)options->memory.alloc_func(options->memory.user_data, size + 1);
+	if (!out_extension->data)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+	strncpy(out_extension->data, (const char*)json_chunk + start, size);
+	out_extension->data[size] = '\0';
+
+	i = cgltf_skip_json(tokens, i);
+
+	return i;
+}
+
+static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions)
+{
+	++i;
+
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	if(*out_extensions)
+	{
+		return CGLTF_ERROR_JSON;
+	}
+
+	int extensions_size = tokens[i].size;
+	*out_extensions_count = 0;
+	*out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+
+	if (!*out_extensions)
+	{
+		return CGLTF_ERROR_NOMEM;
+	}
+
+	++i;
+
+	for (int j = 0; j < extensions_size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		cgltf_size extension_index = (*out_extensions_count)++;
+		cgltf_extension* extension = &((*out_extensions)[extension_index]);
+		i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension);
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
+		{
+			i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0)
+		{
+			++i;
+			out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_mesh_gpu_instancing(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh_gpu_instancing* out_mesh_gpu_instancing)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
+		{
+			i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_mesh_gpu_instancing->attributes, &out_mesh_gpu_instancing->attributes_count);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset)
+{
+	(void)options;
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+		int obj_size = tokens[i].size;
+		++i;
+
+		int material = -1;
+		int variants_tok = -1;
+		int extras_tok = -1;
+
+		for (int k = 0; k < obj_size; ++k)
+		{
+			CGLTF_CHECK_KEY(tokens[i]);
+
+			if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0)
+			{
+				++i;
+				material = cgltf_json_to_int(tokens + i, json_chunk);
+				++i;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
+			{
+				variants_tok = i+1;
+				CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY);
+
+				i = cgltf_skip_json(tokens, i+1);
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+			{
+				extras_tok = i + 1;
+				i = cgltf_skip_json(tokens, extras_tok);
+			}
+			else
+			{
+				i = cgltf_skip_json(tokens, i+1);
+			}
+
+			if (i < 0)
+			{
+				return i;
+			}
+		}
+
+		if (material < 0 || variants_tok < 0)
+		{
+			return CGLTF_ERROR_JSON;
+		}
+
+		if (out_mappings)
+		{
+			for (int k = 0; k < tokens[variants_tok].size; ++k)
+			{
+				int variant = cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk);
+				if (variant < 0)
+					return variant;
+
+				out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
+				out_mappings[*offset].variant = variant;
+
+				if (extras_tok >= 0)
+				{
+					int e = cgltf_parse_json_extras(options, tokens, extras_tok, json_chunk, &out_mappings[*offset].extras);
+					if (e < 0)
+						return e;
+				}
+
+				(*offset)++;
+			}
+		}
+		else
+		{
+			(*offset) += tokens[variants_tok].size;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_material_mappings(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0)
+		{
+			if (out_prim->mappings)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			cgltf_size mappings_offset = 0;
+			int k = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, NULL, &mappings_offset);
+			if (k < 0)
+			{
+				return k;
+			}
+
+			out_prim->mappings_count = mappings_offset;
+			out_prim->mappings = (cgltf_material_mapping*)cgltf_calloc(options, sizeof(cgltf_material_mapping), out_prim->mappings_count);
+
+			mappings_offset = 0;
+			i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, out_prim->mappings, &mappings_offset);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static cgltf_primitive_type cgltf_json_to_primitive_type(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	int type = cgltf_json_to_int(tok, json_chunk);
+
+	switch (type)
+	{
+	case 0:
+		return cgltf_primitive_type_points;
+	case 1:
+		return cgltf_primitive_type_lines;
+	case 2:
+		return cgltf_primitive_type_line_loop;
+	case 3:
+		return cgltf_primitive_type_line_strip;
+	case 4:
+		return cgltf_primitive_type_triangles;
+	case 5:
+		return cgltf_primitive_type_triangle_strip;
+	case 6:
+		return cgltf_primitive_type_triangle_fan;
+	default:
+		return cgltf_primitive_type_invalid;
+	}
+}
+
+static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	out_prim->type = cgltf_primitive_type_triangles;
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
+		{
+			++i;
+			out_prim->type = cgltf_json_to_primitive_type(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
+		{
+			++i;
+			out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0)
+		{
+			++i;
+			out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0)
+		{
+			i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_prim->targets_count; ++k)
+			{
+				i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count);
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_prim->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if(out_prim->extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			out_prim->extensions_count = 0;
+			out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+
+			if (!out_prim->extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			++i;
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0)
+				{
+					out_prim->has_draco_mesh_compression = 1;
+					i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
+				{
+					i = cgltf_parse_json_material_mappings(options, tokens, i + 1, json_chunk, out_prim);
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index)
+			{
+				i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]);
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			++i;
+
+			out_mesh->extras.start_offset = tokens[i].start;
+			out_mesh->extras.end_offset = tokens[i].end;
+
+			if (tokens[i].type == JSMN_OBJECT)
+			{
+				int extras_size = tokens[i].size;
+				++i;
+
+				for (int k = 0; k < extras_size; ++k)
+				{
+					CGLTF_CHECK_KEY(tokens[i]);
+
+					if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0 && tokens[i+1].type == JSMN_ARRAY)
+					{
+						i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count);
+					}
+					else
+					{
+						i = cgltf_skip_json(tokens, i+1);
+					}
+
+					if (i < 0)
+					{
+						return i;
+					}
+				}
+			}
+			else
+			{
+				i = cgltf_skip_json(tokens, i);
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->meshes_count; ++j)
+	{
+		i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk)
+{
+	int type = cgltf_json_to_int(tok, json_chunk);
+
+	switch (type)
+	{
+	case 5120:
+		return cgltf_component_type_r_8;
+	case 5121:
+		return cgltf_component_type_r_8u;
+	case 5122:
+		return cgltf_component_type_r_16;
+	case 5123:
+		return cgltf_component_type_r_16u;
+	case 5125:
+		return cgltf_component_type_r_32u;
+	case 5126:
+		return cgltf_component_type_r_32f;
+	default:
+		return cgltf_component_type_invalid;
+	}
+}
+
+static int cgltf_parse_json_accessor_sparse(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
+		{
+			++i;
+			out_sparse->count = cgltf_json_to_size(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int indices_size = tokens[i].size;
+			++i;
+
+			for (int k = 0; k < indices_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
+				{
+					++i;
+					out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
+				{
+					++i;
+					out_sparse->indices_byte_offset = cgltf_json_to_size(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
+				{
+					++i;
+					out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
+					++i;
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int values_size = tokens[i].size;
+			++i;
+
+			for (int k = 0; k < values_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
+				{
+					++i;
+					out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
+				{
+					++i;
+					out_sparse->values_byte_offset = cgltf_json_to_size(tokens + i, json_chunk);
+					++i;
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_accessor->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
+		{
+			++i;
+			out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
+		{
+			++i;
+			out_accessor->offset =
+					cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
+		{
+			++i;
+			out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0)
+		{
+			++i;
+			out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
+		{
+			++i;
+			out_accessor->count = cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0)
+			{
+				out_accessor->type = cgltf_type_scalar;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0)
+			{
+				out_accessor->type = cgltf_type_vec2;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0)
+			{
+				out_accessor->type = cgltf_type_vec3;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0)
+			{
+				out_accessor->type = cgltf_type_vec4;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0)
+			{
+				out_accessor->type = cgltf_type_mat2;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0)
+			{
+				out_accessor->type = cgltf_type_mat3;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0)
+			{
+				out_accessor->type = cgltf_type_mat4;
+			}
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0)
+		{
+			++i;
+			out_accessor->has_min = 1;
+			// note: we can't parse the precise number of elements since type may not have been computed yet
+			int min_size = tokens[i].size > 16 ? 16 : tokens[i].size;
+			i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0)
+		{
+			++i;
+			out_accessor->has_max = 1;
+			// note: we can't parse the precise number of elements since type may not have been computed yet
+			int max_size = tokens[i].size > 16 ? 16 : tokens[i].size;
+			i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0)
+		{
+			out_accessor->is_sparse = 1;
+			i = cgltf_parse_json_accessor_sparse(tokens, i + 1, json_chunk, &out_accessor->sparse);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_accessor->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0)
+		{
+			++i;
+			out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
+		{
+			++i;
+			out_texture_transform->has_texcoord = 1;
+			out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view)
+{
+	(void)options;
+
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	out_texture_view->scale = 1.0f;
+	cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0)
+		{
+			++i;
+			out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
+		{
+			++i;
+			out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
+		{
+			++i;
+			out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0)
+		{
+			++i;
+			out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			int extensions_size = tokens[i].size;
+
+			++i;
+
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0)
+				{
+					out_texture_view->has_transform = 1;
+					i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform);
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i + 1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0)
+		{
+			++i;
+			out_pbr->metallic_factor =
+				cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0)
+		{
+			++i;
+			out_pbr->roughness_factor =
+				cgltf_json_to_float(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->base_color_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->metallic_roughness_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0)
+		{
+			++i;
+			out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0)
+		{
+			++i;
+			out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0)
+		{
+			++i;
+			out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	// Default values
+	out_ior->ior = 1.5f;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0)
+		{
+			++i;
+			out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	// Default values
+	out_specular->specular_factor = 1.0f;
+	cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f);
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
+		{
+			++i;
+			out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularColorTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_color_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0)
+		{
+			++i;
+			out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_volume(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_volume* out_volume)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0)
+		{
+			++i;
+			out_volume->thickness_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_volume->thickness_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_volume->attenuation_color, 3);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationDistance") == 0)
+		{
+			++i;
+			out_volume->attenuation_distance = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0)
+		{
+			++i;
+			out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_emissive_strength(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_emissive_strength* out_emissive_strength)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	// Default
+	out_emissive_strength->emissive_strength = 1.f;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveStrength") == 0)
+		{
+			++i;
+			out_emissive_strength->emissive_strength = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_iridescence(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_iridescence* out_iridescence)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	// Default
+	out_iridescence->iridescence_ior = 1.3f;
+	out_iridescence->iridescence_thickness_min = 100.f;
+	out_iridescence->iridescence_thickness_max = 400.f;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceFactor") == 0)
+		{
+			++i;
+			out_iridescence->iridescence_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceIor") == 0)
+		{
+			++i;
+			out_iridescence->iridescence_ior = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMinimum") == 0)
+		{
+			++i;
+			out_iridescence->iridescence_thickness_min = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessMaximum") == 0)
+		{
+			++i;
+			out_iridescence->iridescence_thickness_max = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "iridescenceThicknessTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_iridescence->iridescence_thickness_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_diffuse_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_diffuse_transmission* out_diff_transmission)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+	// Defaults
+	cgltf_fill_float_array(out_diff_transmission->diffuse_transmission_color_factor, 3, 1.0f);
+	out_diff_transmission->diffuse_transmission_factor = 0.f;
+	
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseTransmissionFactor") == 0)
+		{
+			++i;
+			out_diff_transmission->diffuse_transmission_factor = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseTransmissionTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_diff_transmission->diffuse_transmission_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseTransmissionColorFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_diff_transmission->diffuse_transmission_color_factor, 3);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "diffuseTransmissionColorTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_diff_transmission->diffuse_transmission_color_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_anisotropy(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_anisotropy* out_anisotropy)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyStrength") == 0)
+		{
+			++i;
+			out_anisotropy->anisotropy_strength = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyRotation") == 0)
+		{
+			++i;
+			out_anisotropy->anisotropy_rotation = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "anisotropyTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_anisotropy->anisotropy_texture);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_dispersion(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_dispersion* out_dispersion)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+	int size = tokens[i].size;
+	++i;
+
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "dispersion") == 0)
+		{
+			++i;
+			out_dispersion->dispersion = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
+		{
+			++i;
+			out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_image->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler)
+{
+	(void)options;
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	out_sampler->wrap_s = cgltf_wrap_mode_repeat;
+	out_sampler->wrap_t = cgltf_wrap_mode_repeat;
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_sampler->name);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0)
+		{
+			++i;
+			out_sampler->mag_filter
+				= (cgltf_filter_type)cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0)
+		{
+			++i;
+			out_sampler->min_filter
+				= (cgltf_filter_type)cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0)
+		{
+			++i;
+			out_sampler->wrap_s
+				= (cgltf_wrap_mode)cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0)
+		{
+			++i;
+			out_sampler->wrap_t
+				= (cgltf_wrap_mode)cgltf_json_to_int(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0)
+		{
+			++i;
+			out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
+		{
+			++i;
+			out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_texture->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if (out_texture->extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			++i;
+			out_texture->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+			out_texture->extensions_count = 0;
+
+			if (!out_texture->extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_texture_basisu") == 0)
+				{
+					out_texture->has_basisu = 1;
+					++i;
+					CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+					int num_properties = tokens[i].size;
+					++i;
+
+					for (int t = 0; t < num_properties; ++t)
+					{
+						CGLTF_CHECK_KEY(tokens[i]);
+
+						if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
+						{
+							++i;
+							out_texture->basisu_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
+							++i;
+						}
+						else
+						{
+							i = cgltf_skip_json(tokens, i + 1);
+						}
+						if (i < 0)
+						{
+							return i;
+						}
+					}
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_texture_webp") == 0)
+				{
+					out_texture->has_webp = 1;
+					++i;
+					CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+					int num_properties = tokens[i].size;
+					++i;
+
+					for (int t = 0; t < num_properties; ++t)
+					{
+						CGLTF_CHECK_KEY(tokens[i]);
+
+						if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
+						{
+							++i;
+							out_texture->webp_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
+							++i;
+						}
+						else
+						{
+							i = cgltf_skip_json(tokens, i + 1);
+						}
+						if (i < 0)
+						{
+							return i;
+						}
+					}
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture->extensions[out_texture->extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f);
+	out_material->pbr_metallic_roughness.metallic_factor = 1.0f;
+	out_material->pbr_metallic_roughness.roughness_factor = 1.0f;
+
+	cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f);
+	cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f);
+	out_material->pbr_specular_glossiness.glossiness_factor = 1.0f;
+
+	cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f);
+	out_material->volume.attenuation_distance = FLT_MAX;
+
+	out_material->alpha_cutoff = 0.5f;
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0)
+		{
+			out_material->has_pbr_metallic_roughness = 1;
+			i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
+				&out_material->normal_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
+				&out_material->occlusion_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0)
+		{
+			i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
+				&out_material->emissive_texture);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0)
+			{
+				out_material->alpha_mode = cgltf_alpha_mode_opaque;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0)
+			{
+				out_material->alpha_mode = cgltf_alpha_mode_mask;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0)
+			{
+				out_material->alpha_mode = cgltf_alpha_mode_blend;
+			}
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0)
+		{
+			++i;
+			out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0)
+		{
+			++i;
+			out_material->double_sided =
+				cgltf_json_to_bool(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_material->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if(out_material->extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			++i;
+			out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+			out_material->extensions_count= 0;
+
+			if (!out_material->extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0)
+				{
+					out_material->has_pbr_specular_glossiness = 1;
+					i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0)
+				{
+					out_material->unlit = 1;
+					i = cgltf_skip_json(tokens, i+1);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0)
+				{
+					out_material->has_clearcoat = 1;
+					i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0)
+				{
+					out_material->has_ior = 1;
+					i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0)
+				{
+					out_material->has_specular = 1;
+					i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0)
+				{
+					out_material->has_transmission = 1;
+					i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_volume") == 0)
+				{
+					out_material->has_volume = 1;
+					i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, &out_material->volume);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0)
+				{
+					out_material->has_sheen = 1;
+					i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_emissive_strength") == 0)
+				{
+					out_material->has_emissive_strength = 1;
+					i = cgltf_parse_json_emissive_strength(tokens, i + 1, json_chunk, &out_material->emissive_strength);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_iridescence") == 0)
+				{
+					out_material->has_iridescence = 1;
+					i = cgltf_parse_json_iridescence(options, tokens, i + 1, json_chunk, &out_material->iridescence);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_diffuse_transmission") == 0)
+				{
+					out_material->has_diffuse_transmission = 1;
+					i = cgltf_parse_json_diffuse_transmission(options, tokens, i + 1, json_chunk, &out_material->diffuse_transmission);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_anisotropy") == 0)
+				{
+					out_material->has_anisotropy = 1;
+					i = cgltf_parse_json_anisotropy(options, tokens, i + 1, json_chunk, &out_material->anisotropy);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_dispersion") == 0)
+				{
+					out_material->has_dispersion = 1;
+					i = cgltf_parse_json_dispersion(tokens, i + 1, json_chunk, &out_material->dispersion);
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->accessors_count; ++j)
+	{
+		i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->materials_count; ++j)
+	{
+		i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->images_count; ++j)
+	{
+		i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->textures_count; ++j)
+	{
+		i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->samplers_count; ++j)
+	{
+		i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression)
+{
+	(void)options;
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
+		{
+			++i;
+			out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
+		{
+			++i;
+			out_meshopt_compression->offset = cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
+		{
+			++i;
+			out_meshopt_compression->size = cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
+		{
+			++i;
+			out_meshopt_compression->stride = cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
+		{
+			++i;
+			out_meshopt_compression->count = cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0)
+			{
+				out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0)
+			{
+				out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0)
+			{
+				out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices;
+			}
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0)
+			{
+				out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0)
+			{
+				out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0)
+			{
+				out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0)
+			{
+				out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential;
+			}
+			else if (cgltf_json_strcmp(tokens+i, json_chunk, "COLOR") == 0)
+			{
+				out_meshopt_compression->filter = cgltf_meshopt_compression_filter_color;
+			}
+			++i;
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer_view->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
+		{
+			++i;
+			out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
+		{
+			++i;
+			out_buffer_view->offset =
+					cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
+		{
+			++i;
+			out_buffer_view->size =
+					cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
+		{
+			++i;
+			out_buffer_view->stride =
+					cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
+		{
+			++i;
+			int type = cgltf_json_to_int(tokens+i, json_chunk);
+			switch (type)
+			{
+			case 34962:
+				type = cgltf_buffer_view_type_vertices;
+				break;
+			case 34963:
+				type = cgltf_buffer_view_type_indices;
+				break;
+			default:
+				type = cgltf_buffer_view_type_invalid;
+				break;
+			}
+			out_buffer_view->type = (cgltf_buffer_view_type)type;
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer_view->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if(out_buffer_view->extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			out_buffer_view->extensions_count = 0;
+			out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+
+			if (!out_buffer_view->extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			++i;
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0)
+				{
+					out_buffer_view->has_meshopt_compression = 1;
+					i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression);
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_meshopt_compression") == 0)
+				{
+					out_buffer_view->has_meshopt_compression = 1;
+					out_buffer_view->meshopt_compression.is_khr = 1;
+					i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression);
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j)
+	{
+		i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
+		{
+			++i;
+			out_buffer->size =
+					cgltf_json_to_size(tokens+i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_buffer->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->buffers_count; ++j)
+	{
+		i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_skin->joints_count; ++k)
+			{
+				out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
+				++i;
+			}
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+			out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+			out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_skin->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->skins_count; ++j)
+	{
+		i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int data_size = tokens[i].size;
+			++i;
+
+			if (out_camera->type != cgltf_camera_type_invalid)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			out_camera->type = cgltf_camera_type_perspective;
+
+			for (int k = 0; k < data_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0)
+				{
+					++i;
+					out_camera->data.perspective.has_aspect_ratio = 1;
+					out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0)
+				{
+					++i;
+					out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
+				{
+					++i;
+					out_camera->data.perspective.has_zfar = 1;
+					out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
+				{
+					++i;
+					out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+				{
+					i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int data_size = tokens[i].size;
+			++i;
+
+			if (out_camera->type != cgltf_camera_type_invalid)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			out_camera->type = cgltf_camera_type_orthographic;
+
+			for (int k = 0; k < data_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0)
+				{
+					++i;
+					out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0)
+				{
+					++i;
+					out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
+				{
+					++i;
+					out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
+				{
+					++i;
+					out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+				{
+					i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_camera->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->cameras_count; ++j)
+	{
+		i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	out_light->color[0] = 1.f;
+	out_light->color[1] = 1.f;
+	out_light->color[2] = 1.f;
+	out_light->intensity = 1.f;
+
+	out_light->spot_inner_cone_angle = 0.f;
+	out_light->spot_outer_cone_angle = 3.1415926535f / 4.0f;
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0)
+		{
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0)
+		{
+			++i;
+			out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0)
+			{
+				out_light->type = cgltf_light_type_directional;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0)
+			{
+				out_light->type = cgltf_light_type_point;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0)
+			{
+				out_light->type = cgltf_light_type_spot;
+			}
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0)
+		{
+			++i;
+			out_light->range = cgltf_json_to_float(tokens + i, json_chunk);
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int data_size = tokens[i].size;
+			++i;
+
+			for (int k = 0; k < data_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0)
+				{
+					++i;
+					out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0)
+				{
+					++i;
+					out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
+					++i;
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_light->extras);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->lights_count; ++j)
+	{
+		i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	out_node->rotation[3] = 1.0f;
+	out_node->scale[0] = 1.0f;
+	out_node->scale[1] = 1.0f;
+	out_node->scale[2] = 1.0f;
+	out_node->matrix[0] = 1.0f;
+	out_node->matrix[5] = 1.0f;
+	out_node->matrix[10] = 1.0f;
+	out_node->matrix[15] = 1.0f;
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_node->children_count; ++k)
+			{
+				out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
+				++i;
+			}
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+			out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+			out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0)
+		{
+			++i;
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+			out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
+		{
+			out_node->has_translation = 1;
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
+		{
+			out_node->has_rotation = 1;
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
+		{
+			out_node->has_scale = 1;
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0)
+		{
+			out_node->has_matrix = 1;
+			i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_node->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if(out_node->extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			out_node->extensions_count= 0;
+			out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+
+			if (!out_node->extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			++i;
+
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
+				{
+					++i;
+
+					CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+					int data_size = tokens[i].size;
+					++i;
+
+					for (int m = 0; m < data_size; ++m)
+					{
+						CGLTF_CHECK_KEY(tokens[i]);
+
+						if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0)
+						{
+							++i;
+							CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
+							out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk));
+							++i;
+						}
+						else
+						{
+							i = cgltf_skip_json(tokens, i + 1);
+						}
+
+						if (i < 0)
+						{
+							return i;
+						}
+					}
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_mesh_gpu_instancing") == 0)
+				{
+					out_node->has_mesh_gpu_instancing = 1;
+					i = cgltf_parse_json_mesh_gpu_instancing(options, tokens, i + 1, json_chunk, &out_node->mesh_gpu_instancing);
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->nodes_count; ++j)
+	{
+		i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_scene->nodes_count; ++k)
+			{
+				out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
+				++i;
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_scene->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->scenes_count; ++j)
+	{
+		i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler)
+{
+	(void)options;
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0)
+		{
+			++i;
+			out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0)
+		{
+			++i;
+			out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0)
+		{
+			++i;
+			if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0)
+			{
+				out_sampler->interpolation = cgltf_interpolation_type_linear;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0)
+			{
+				out_sampler->interpolation = cgltf_interpolation_type_step;
+			}
+			else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0)
+			{
+				out_sampler->interpolation = cgltf_interpolation_type_cubic_spline;
+			}
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_sampler->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel)
+{
+	(void)options;
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0)
+		{
+			++i;
+			out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+			int target_size = tokens[i].size;
+			++i;
+
+			for (int k = 0; k < target_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0)
+				{
+					++i;
+					out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0)
+				{
+					++i;
+					if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
+					{
+						out_channel->target_path = cgltf_animation_path_type_translation;
+					}
+					else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
+					{
+						out_channel->target_path = cgltf_animation_path_type_rotation;
+					}
+					else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
+					{
+						out_channel->target_path = cgltf_animation_path_type_scale;
+					}
+					else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0)
+					{
+						out_channel->target_path = cgltf_animation_path_type_weights;
+					}
+					++i;
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+				{
+					i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_channel->extras);
+				}
+				else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+				{
+					i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions);
+				}
+				else
+				{
+					i = cgltf_skip_json(tokens, i+1);
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_animation->samplers_count; ++k)
+			{
+				i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]);
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0)
+		{
+			i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count);
+			if (i < 0)
+			{
+				return i;
+			}
+
+			for (cgltf_size k = 0; k < out_animation->channels_count; ++k)
+			{
+				i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]);
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_animation->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->animations_count; ++j)
+	{
+		i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_variant* out_variant)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_variant->name);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_variant->extras);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+static int cgltf_parse_json_variants(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material_variant), (void**)&out_data->variants, &out_data->variants_count);
+	if (i < 0)
+	{
+		return i;
+	}
+
+	for (cgltf_size j = 0; j < out_data->variants_count; ++j)
+	{
+		i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data->variants[j]);
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+	return i;
+}
+
+static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0)
+		{
+			i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_asset->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i+1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2)
+	{
+		return CGLTF_ERROR_LEGACY;
+	}
+
+	return i;
+}
+
+cgltf_size cgltf_num_components(cgltf_type type) {
+	switch (type)
+	{
+	case cgltf_type_vec2:
+		return 2;
+	case cgltf_type_vec3:
+		return 3;
+	case cgltf_type_vec4:
+		return 4;
+	case cgltf_type_mat2:
+		return 4;
+	case cgltf_type_mat3:
+		return 9;
+	case cgltf_type_mat4:
+		return 16;
+	case cgltf_type_invalid:
+	case cgltf_type_scalar:
+	default:
+		return 1;
+	}
+}
+
+cgltf_size cgltf_component_size(cgltf_component_type component_type) {
+	switch (component_type)
+	{
+	case cgltf_component_type_r_8:
+	case cgltf_component_type_r_8u:
+		return 1;
+	case cgltf_component_type_r_16:
+	case cgltf_component_type_r_16u:
+		return 2;
+	case cgltf_component_type_r_32u:
+	case cgltf_component_type_r_32f:
+		return 4;
+	case cgltf_component_type_invalid:
+	default:
+		return 0;
+	}
+}
+
+cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
+{
+	cgltf_size component_size = cgltf_component_size(component_type);
+	if (type == cgltf_type_mat2 && component_size == 1)
+	{
+		return 8 * component_size;
+	}
+	else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2))
+	{
+		return 12 * component_size;
+	}
+	return component_size * cgltf_num_components(type);
+}
+
+static int cgltf_fixup_pointers(cgltf_data* out_data);
+
+static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
+{
+	CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+	int size = tokens[i].size;
+	++i;
+
+	for (int j = 0; j < size; ++j)
+	{
+		CGLTF_CHECK_KEY(tokens[i]);
+
+		if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0)
+		{
+			i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0)
+		{
+			i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0)
+		{
+			i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0)
+		{
+			i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0)
+		{
+			i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0)
+		{
+			i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0)
+		{
+			i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0)
+		{
+			i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0)
+		{
+			i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0)
+		{
+			i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0)
+		{
+			i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0)
+		{
+			i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0)
+		{
+			i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
+		{
+			++i;
+			out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk));
+			++i;
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
+		{
+			i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data);
+		}
+		else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
+		{
+			i = cgltf_parse_json_extras(options, tokens, i + 1, json_chunk, &out_data->extras);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
+		{
+			++i;
+
+			CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+			if(out_data->data_extensions)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			int extensions_size = tokens[i].size;
+			out_data->data_extensions_count = 0;
+			out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
+
+			if (!out_data->data_extensions)
+			{
+				return CGLTF_ERROR_NOMEM;
+			}
+
+			++i;
+
+			for (int k = 0; k < extensions_size; ++k)
+			{
+				CGLTF_CHECK_KEY(tokens[i]);
+
+				if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
+				{
+					++i;
+
+					CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+					int data_size = tokens[i].size;
+					++i;
+
+					for (int m = 0; m < data_size; ++m)
+					{
+						CGLTF_CHECK_KEY(tokens[i]);
+
+						if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0)
+						{
+							i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data);
+						}
+						else
+						{
+							i = cgltf_skip_json(tokens, i + 1);
+						}
+
+						if (i < 0)
+						{
+							return i;
+						}
+					}
+				}
+				else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
+				{
+					++i;
+
+					CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
+
+					int data_size = tokens[i].size;
+					++i;
+
+					for (int m = 0; m < data_size; ++m)
+					{
+						CGLTF_CHECK_KEY(tokens[i]);
+
+						if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
+						{
+							i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, out_data);
+						}
+						else
+						{
+							i = cgltf_skip_json(tokens, i + 1);
+						}
+
+						if (i < 0)
+						{
+							return i;
+						}
+					}
+				}
+				else
+				{
+					i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++]));
+				}
+
+				if (i < 0)
+				{
+					return i;
+				}
+			}
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0)
+		{
+			i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count);
+		}
+		else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0)
+		{
+			i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count);
+		}
+		else
+		{
+			i = cgltf_skip_json(tokens, i + 1);
+		}
+
+		if (i < 0)
+		{
+			return i;
+		}
+	}
+
+	return i;
+}
+
+cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data)
+{
+	jsmn_parser parser = { 0, 0, 0 };
+
+	if (options->json_token_count == 0)
+	{
+		int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0);
+
+		if (token_count <= 0)
+		{
+			return cgltf_result_invalid_json;
+		}
+
+		options->json_token_count = token_count;
+	}
+
+	jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc_func(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1));
+
+	if (!tokens)
+	{
+		return cgltf_result_out_of_memory;
+	}
+
+	jsmn_init(&parser);
+
+	int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count);
+
+	if (token_count <= 0)
+	{
+		options->memory.free_func(options->memory.user_data, tokens);
+		return cgltf_result_invalid_json;
+	}
+
+	// this makes sure that we always have an UNDEFINED token at the end of the stream
+	// for invalid JSON inputs this makes sure we don't perform out of bound reads of token data
+	tokens[token_count].type = JSMN_UNDEFINED;
+
+	cgltf_data* data = (cgltf_data*)options->memory.alloc_func(options->memory.user_data, sizeof(cgltf_data));
+
+	if (!data)
+	{
+		options->memory.free_func(options->memory.user_data, tokens);
+		return cgltf_result_out_of_memory;
+	}
+
+	memset(data, 0, sizeof(cgltf_data));
+	data->memory = options->memory;
+	data->file = options->file;
+
+	int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data);
+
+	options->memory.free_func(options->memory.user_data, tokens);
+
+	if (i < 0)
+	{
+		cgltf_free(data);
+
+		switch (i)
+		{
+		case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory;
+		case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf;
+		default: return cgltf_result_invalid_gltf;
+		}
+	}
+
+	if (cgltf_fixup_pointers(data) < 0)
+	{
+		cgltf_free(data);
+		return cgltf_result_invalid_gltf;
+	}
+
+	data->json = (const char*)json_chunk;
+	data->json_size = size;
+
+	*out_data = data;
+
+	return cgltf_result_success;
+}
+
+static int cgltf_fixup_pointers(cgltf_data* data)
+{
+	for (cgltf_size i = 0; i < data->meshes_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
+		{
+			CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count);
+			CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count);
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
+			{
+				CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count);
+			}
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
+			{
+				for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
+				{
+					CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count);
+				}
+			}
+
+			if (data->meshes[i].primitives[j].has_draco_mesh_compression)
+			{
+				CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count);
+				for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m)
+				{
+					CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count);
+				}
+			}
+
+			for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
+			{
+				CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, data->materials, data->materials_count);
+			}
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->accessors_count; ++i)
+	{
+		CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count);
+
+		if (data->accessors[i].is_sparse)
+		{
+			CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count);
+			CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count);
+		}
+
+		if (data->accessors[i].buffer_view)
+		{
+			data->accessors[i].stride = data->accessors[i].buffer_view->stride;
+		}
+
+		if (data->accessors[i].stride == 0)
+		{
+			data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type);
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->textures_count; ++i)
+	{
+		CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count);
+		CGLTF_PTRFIXUP(data->textures[i].basisu_image, data->images, data->images_count);
+		CGLTF_PTRFIXUP(data->textures[i].webp_image, data->images, data->images_count);
+		CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count);
+	}
+
+	for (cgltf_size i = 0; i < data->images_count; ++i)
+	{
+		CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count);
+	}
+
+	for (cgltf_size i = 0; i < data->materials_count; ++i)
+	{
+		CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].iridescence.iridescence_thickness_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].diffuse_transmission.diffuse_transmission_texture.texture, data->textures, data->textures_count);
+		CGLTF_PTRFIXUP(data->materials[i].diffuse_transmission.diffuse_transmission_color_texture.texture, data->textures, data->textures_count);
+
+		CGLTF_PTRFIXUP(data->materials[i].anisotropy.anisotropy_texture.texture, data->textures, data->textures_count);
+	}
+
+	for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
+	{
+		CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count);
+
+		if (data->buffer_views[i].has_meshopt_compression)
+		{
+			CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count);
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->skins_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j)
+		{
+			CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count);
+		}
+
+		CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count);
+		CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count);
+	}
+
+	for (cgltf_size i = 0; i < data->nodes_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j)
+		{
+			CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count);
+
+			if (data->nodes[i].children[j]->parent)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+
+			data->nodes[i].children[j]->parent = &data->nodes[i];
+		}
+
+		CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count);
+		CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count);
+		CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count);
+		CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count);
+
+		if (data->nodes[i].has_mesh_gpu_instancing)
+		{
+			for (cgltf_size m = 0; m < data->nodes[i].mesh_gpu_instancing.attributes_count; ++m)
+			{
+				CGLTF_PTRFIXUP_REQ(data->nodes[i].mesh_gpu_instancing.attributes[m].data, data->accessors, data->accessors_count);
+			}
+		}
+	}
+
+	for (cgltf_size i = 0; i < data->scenes_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
+		{
+			CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count);
+
+			if (data->scenes[i].nodes[j]->parent)
+			{
+				return CGLTF_ERROR_JSON;
+			}
+		}
+	}
+
+	CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count);
+
+	for (cgltf_size i = 0; i < data->animations_count; ++i)
+	{
+		for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
+		{
+			CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count);
+			CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count);
+		}
+
+		for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
+		{
+			CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count);
+			CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count);
+		}
+	}
+
+	return 0;
+}
+
+/*
+ * -- jsmn.c start --
+ * Source: https://github.com/zserge/jsmn
+ * License: MIT
+ *
+ * Copyright (c) 2010 Serge A. Zaitsev
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * Allocates a fresh unused token from the token pull.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+				   jsmntok_t *tokens, size_t num_tokens) {
+	jsmntok_t *tok;
+	if (parser->toknext >= num_tokens) {
+		return NULL;
+	}
+	tok = &tokens[parser->toknext++];
+	tok->start = tok->end = -1;
+	tok->size = 0;
+#ifdef JSMN_PARENT_LINKS
+	tok->parent = -1;
+#endif
+	return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+				ptrdiff_t start, ptrdiff_t end) {
+	token->type = type;
+	token->start = start;
+	token->end = end;
+	token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+				size_t len, jsmntok_t *tokens, size_t num_tokens) {
+	jsmntok_t *token;
+	ptrdiff_t start;
+
+	start = parser->pos;
+
+	for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+		switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+		/* In strict mode primitive must be followed by "," or "}" or "]" */
+		case ':':
+#endif
+		case '\t' : case '\r' : case '\n' : case ' ' :
+		case ','  : case ']'  : case '}' :
+			goto found;
+		}
+		if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+			parser->pos = start;
+			return JSMN_ERROR_INVAL;
+		}
+	}
+#ifdef JSMN_STRICT
+	/* In strict mode primitive must be followed by a comma/object/array */
+	parser->pos = start;
+	return JSMN_ERROR_PART;
+#endif
+
+found:
+	if (tokens == NULL) {
+		parser->pos--;
+		return 0;
+	}
+	token = jsmn_alloc_token(parser, tokens, num_tokens);
+	if (token == NULL) {
+		parser->pos = start;
+		return JSMN_ERROR_NOMEM;
+	}
+	jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+	token->parent = parser->toksuper;
+#endif
+	parser->pos--;
+	return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+				 size_t len, jsmntok_t *tokens, size_t num_tokens) {
+	jsmntok_t *token;
+
+	ptrdiff_t start = parser->pos;
+
+	parser->pos++;
+
+	/* Skip starting quote */
+	for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+		char c = js[parser->pos];
+
+		/* Quote: end of string */
+		if (c == '\"') {
+			if (tokens == NULL) {
+				return 0;
+			}
+			token = jsmn_alloc_token(parser, tokens, num_tokens);
+			if (token == NULL) {
+				parser->pos = start;
+				return JSMN_ERROR_NOMEM;
+			}
+			jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+			token->parent = parser->toksuper;
+#endif
+			return 0;
+		}
+
+		/* Backslash: Quoted symbol expected */
+		if (c == '\\' && parser->pos + 1 < len) {
+			int i;
+			parser->pos++;
+			switch (js[parser->pos]) {
+			/* Allowed escaped symbols */
+			case '\"': case '/' : case '\\' : case 'b' :
+			case 'f' : case 'r' : case 'n'  : case 't' :
+				break;
+				/* Allows escaped symbol \uXXXX */
+			case 'u':
+				parser->pos++;
+				for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
+					/* If it isn't a hex character we have an error */
+					if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
+						 (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
+						 (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+						parser->pos = start;
+						return JSMN_ERROR_INVAL;
+					}
+					parser->pos++;
+				}
+				parser->pos--;
+				break;
+				/* Unexpected symbol */
+			default:
+				parser->pos = start;
+				return JSMN_ERROR_INVAL;
+			}
+		}
+	}
+	parser->pos = start;
+	return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
+		   jsmntok_t *tokens, size_t num_tokens) {
+	int r;
+	int i;
+	jsmntok_t *token;
+	int count = parser->toknext;
+
+	for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+		char c;
+		jsmntype_t type;
+
+		c = js[parser->pos];
+		switch (c) {
+		case '{': case '[':
+			count++;
+			if (tokens == NULL) {
+				break;
+			}
+			token = jsmn_alloc_token(parser, tokens, num_tokens);
+			if (token == NULL)
+				return JSMN_ERROR_NOMEM;
+			if (parser->toksuper != -1) {
+				tokens[parser->toksuper].size++;
+#ifdef JSMN_PARENT_LINKS
+				token->parent = parser->toksuper;
+#endif
+			}
+			token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+			token->start = parser->pos;
+			parser->toksuper = parser->toknext - 1;
+			break;
+		case '}': case ']':
+			if (tokens == NULL)
+				break;
+			type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+#ifdef JSMN_PARENT_LINKS
+			if (parser->toknext < 1) {
+				return JSMN_ERROR_INVAL;
+			}
+			token = &tokens[parser->toknext - 1];
+			for (;;) {
+				if (token->start != -1 && token->end == -1) {
+					if (token->type != type) {
+						return JSMN_ERROR_INVAL;
+					}
+					token->end = parser->pos + 1;
+					parser->toksuper = token->parent;
+					break;
+				}
+				if (token->parent == -1) {
+					if(token->type != type || parser->toksuper == -1) {
+						return JSMN_ERROR_INVAL;
+					}
+					break;
+				}
+				token = &tokens[token->parent];
+			}
+#else
+			for (i = parser->toknext - 1; i >= 0; i--) {
+				token = &tokens[i];
+				if (token->start != -1 && token->end == -1) {
+					if (token->type != type) {
+						return JSMN_ERROR_INVAL;
+					}
+					parser->toksuper = -1;
+					token->end = parser->pos + 1;
+					break;
+				}
+			}
+			/* Error if unmatched closing bracket */
+			if (i == -1) return JSMN_ERROR_INVAL;
+			for (; i >= 0; i--) {
+				token = &tokens[i];
+				if (token->start != -1 && token->end == -1) {
+					parser->toksuper = i;
+					break;
+				}
+			}
+#endif
+			break;
+		case '\"':
+			r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+			if (r < 0) return r;
+			count++;
+			if (parser->toksuper != -1 && tokens != NULL)
+				tokens[parser->toksuper].size++;
+			break;
+		case '\t' : case '\r' : case '\n' : case ' ':
+			break;
+		case ':':
+			parser->toksuper = parser->toknext - 1;
+			break;
+		case ',':
+			if (tokens != NULL && parser->toksuper != -1 &&
+					tokens[parser->toksuper].type != JSMN_ARRAY &&
+					tokens[parser->toksuper].type != JSMN_OBJECT) {
+#ifdef JSMN_PARENT_LINKS
+				parser->toksuper = tokens[parser->toksuper].parent;
+#else
+				for (i = parser->toknext - 1; i >= 0; i--) {
+					if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+						if (tokens[i].start != -1 && tokens[i].end == -1) {
+							parser->toksuper = i;
+							break;
+						}
+					}
+				}
+#endif
+			}
+			break;
+#ifdef JSMN_STRICT
+			/* In strict mode primitives are: numbers and booleans */
+		case '-': case '0': case '1' : case '2': case '3' : case '4':
+		case '5': case '6': case '7' : case '8': case '9':
+		case 't': case 'f': case 'n' :
+			/* And they must not be keys of the object */
+			if (tokens != NULL && parser->toksuper != -1) {
+				jsmntok_t *t = &tokens[parser->toksuper];
+				if (t->type == JSMN_OBJECT ||
+						(t->type == JSMN_STRING && t->size != 0)) {
+					return JSMN_ERROR_INVAL;
+				}
+			}
+#else
+			/* In non-strict mode every unquoted value is a primitive */
+		default:
+#endif
+			r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+			if (r < 0) return r;
+			count++;
+			if (parser->toksuper != -1 && tokens != NULL)
+				tokens[parser->toksuper].size++;
+			break;
+
+#ifdef JSMN_STRICT
+			/* Unexpected char in strict mode */
+		default:
+			return JSMN_ERROR_INVAL;
+#endif
+		}
+	}
+
+	if (tokens != NULL) {
+		for (i = parser->toknext - 1; i >= 0; i--) {
+			/* Unmatched opened object or array */
+			if (tokens[i].start != -1 && tokens[i].end == -1) {
+				return JSMN_ERROR_PART;
+			}
+		}
+	}
+
+	return count;
+}
+
+/**
+ * Creates a new parser based over a given  buffer with an array of tokens
+ * available.
+ */
+static void jsmn_init(jsmn_parser *parser) {
+	parser->pos = 0;
+	parser->toknext = 0;
+	parser->toksuper = -1;
+}
+/*
+ * -- jsmn.c end --
+ */
+
+#endif /* #ifdef CGLTF_IMPLEMENTATION */
+
+/* cgltf is distributed under MIT license:
+ *
+ * Copyright (c) 2018-2021 Johannes Kuhlmann
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
ADD · third-party/glfw +1 -0
--- a/third-party/glfw
+++ b/third-party/glfw
@@ -0,0 +1 @@
+Subproject commit d9d6f0f1f967807ffade6598ea9a631ebaf37a56
ADD · third-party/imgui +1 -0
--- a/third-party/imgui
+++ b/third-party/imgui
@@ -0,0 +1 @@
+Subproject commit b48d1afbe8ee8b238e2961dc363a949dd7304e23
ADD · third-party/json.hpp +26753 -0
--- a/third-party/json.hpp
+++ b/third-party/json.hpp
@@ -0,0 +1,26753 @@
+/*
+    __ _____ _____ _____
+ __|  |   __|     |   | |  JSON for Modern C++
+|  |  |__   |  |  | | | |  version 3.10.4
+|_____|_____|_____|_|___|  https://github.com/nlohmann/json
+
+Licensed under the MIT License <http://opensource.org/licenses/MIT>.
+SPDX-License-Identifier: MIT
+Copyright (c) 2013-2019 Niels Lohmann <http://nlohmann.me>.
+
+Permission is hereby  granted, free of charge, to any  person obtaining a copy
+of this software and associated  documentation files (the "Software"), to deal
+in the Software  without restriction, including without  limitation the rights
+to  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell
+copies  of  the Software,  and  to  permit persons  to  whom  the Software  is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE  IS PROVIDED "AS  IS", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR
+IMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,
+FITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE
+AUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER
+LIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#ifndef INCLUDE_NLOHMANN_JSON_HPP_
+#define INCLUDE_NLOHMANN_JSON_HPP_
+
+#define NLOHMANN_JSON_VERSION_MAJOR 3
+#define NLOHMANN_JSON_VERSION_MINOR 10
+#define NLOHMANN_JSON_VERSION_PATCH 4
+
+#include <algorithm> // all_of, find, for_each
+#include <cstddef> // nullptr_t, ptrdiff_t, size_t
+#include <functional> // hash, less
+#include <initializer_list> // initializer_list
+#ifndef JSON_NO_IO
+    #include <iosfwd> // istream, ostream
+#endif  // JSON_NO_IO
+#include <iterator> // random_access_iterator_tag
+#include <memory> // unique_ptr
+#include <numeric> // accumulate
+#include <string> // string, stoi, to_string
+#include <utility> // declval, forward, move, pair, swap
+#include <vector> // vector
+
+// #include <nlohmann/adl_serializer.hpp>
+
+
+#include <type_traits>
+#include <utility>
+
+// #include <nlohmann/detail/conversions/from_json.hpp>
+
+
+#include <algorithm> // transform
+#include <array> // array
+#include <forward_list> // forward_list
+#include <iterator> // inserter, front_inserter, end
+#include <map> // map
+#include <string> // string
+#include <tuple> // tuple, make_tuple
+#include <type_traits> // is_arithmetic, is_same, is_enum, underlying_type, is_convertible
+#include <unordered_map> // unordered_map
+#include <utility> // pair, declval
+#include <valarray> // valarray
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+
+#include <exception> // exception
+#include <stdexcept> // runtime_error
+#include <string> // to_string
+#include <vector> // vector
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+#include <array> // array
+#include <cstddef> // size_t
+#include <cstdint> // uint8_t
+#include <string> // string
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////////////
+// JSON type enumeration //
+///////////////////////////
+
+/*!
+@brief the JSON type enumeration
+
+This enumeration collects the different JSON types. It is internally used to
+distinguish the stored values, and the functions @ref basic_json::is_null(),
+@ref basic_json::is_object(), @ref basic_json::is_array(),
+@ref basic_json::is_string(), @ref basic_json::is_boolean(),
+@ref basic_json::is_number() (with @ref basic_json::is_number_integer(),
+@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()),
+@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and
+@ref basic_json::is_structured() rely on it.
+
+@note There are three enumeration entries (number_integer, number_unsigned, and
+number_float), because the library distinguishes these three types for numbers:
+@ref basic_json::number_unsigned_t is used for unsigned integers,
+@ref basic_json::number_integer_t is used for signed integers, and
+@ref basic_json::number_float_t is used for floating-point numbers or to
+approximate integers which do not fit in the limits of their respective type.
+
+@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON
+value with the default value for a given type
+
+@since version 1.0.0
+*/
+enum class value_t : std::uint8_t
+{
+    null,             ///< null value
+    object,           ///< object (unordered set of name/value pairs)
+    array,            ///< array (ordered collection of values)
+    string,           ///< string value
+    boolean,          ///< boolean value
+    number_integer,   ///< number value (signed integer)
+    number_unsigned,  ///< number value (unsigned integer)
+    number_float,     ///< number value (floating-point)
+    binary,           ///< binary array (ordered collection of bytes)
+    discarded         ///< discarded by the parser callback function
+};
+
+/*!
+@brief comparison operator for JSON types
+
+Returns an ordering that is similar to Python:
+- order: null < boolean < number < object < array < string < binary
+- furthermore, each type is not smaller than itself
+- discarded values are not comparable
+- binary is represented as a b"" string in python and directly comparable to a
+  string; however, making a binary array directly comparable with a string would
+  be surprising behavior in a JSON file.
+
+@since version 1.0.0
+*/
+inline bool operator<(const value_t lhs, const value_t rhs) noexcept
+{
+    static constexpr std::array<std::uint8_t, 9> order = {{
+            0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
+            1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */,
+            6 /* binary */
+        }
+    };
+
+    const auto l_index = static_cast<std::size_t>(lhs);
+    const auto r_index = static_cast<std::size_t>(rhs);
+    return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
+}
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/string_escape.hpp>
+
+
+#include <string>
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+#include <utility> // declval, pair
+// #include <nlohmann/thirdparty/hedley/hedley.hpp>
+
+
+/* Hedley - https://nemequ.github.io/hedley
+ * Created by Evan Nemerson <evan@nemerson.com>
+ *
+ * To the extent possible under law, the author(s) have dedicated all
+ * copyright and related and neighboring rights to this software to
+ * the public domain worldwide. This software is distributed without
+ * any warranty.
+ *
+ * For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
+ * SPDX-License-Identifier: CC0-1.0
+ */
+
+#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
+#if defined(JSON_HEDLEY_VERSION)
+    #undef JSON_HEDLEY_VERSION
+#endif
+#define JSON_HEDLEY_VERSION 15
+
+#if defined(JSON_HEDLEY_STRINGIFY_EX)
+    #undef JSON_HEDLEY_STRINGIFY_EX
+#endif
+#define JSON_HEDLEY_STRINGIFY_EX(x) #x
+
+#if defined(JSON_HEDLEY_STRINGIFY)
+    #undef JSON_HEDLEY_STRINGIFY
+#endif
+#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
+
+#if defined(JSON_HEDLEY_CONCAT_EX)
+    #undef JSON_HEDLEY_CONCAT_EX
+#endif
+#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
+
+#if defined(JSON_HEDLEY_CONCAT)
+    #undef JSON_HEDLEY_CONCAT
+#endif
+#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
+
+#if defined(JSON_HEDLEY_CONCAT3_EX)
+    #undef JSON_HEDLEY_CONCAT3_EX
+#endif
+#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
+
+#if defined(JSON_HEDLEY_CONCAT3)
+    #undef JSON_HEDLEY_CONCAT3
+#endif
+#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
+
+#if defined(JSON_HEDLEY_VERSION_ENCODE)
+    #undef JSON_HEDLEY_VERSION_ENCODE
+#endif
+#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
+
+#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
+    #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
+#endif
+#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
+
+#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
+    #undef JSON_HEDLEY_VERSION_DECODE_MINOR
+#endif
+#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
+
+#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
+    #undef JSON_HEDLEY_VERSION_DECODE_REVISION
+#endif
+#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
+
+#if defined(JSON_HEDLEY_GNUC_VERSION)
+    #undef JSON_HEDLEY_GNUC_VERSION
+#endif
+#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
+    #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
+#elif defined(__GNUC__)
+    #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
+    #undef JSON_HEDLEY_GNUC_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_GNUC_VERSION)
+    #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_MSVC_VERSION)
+    #undef JSON_HEDLEY_MSVC_VERSION
+#endif
+#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
+    #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
+#elif defined(_MSC_FULL_VER) && !defined(__ICL)
+    #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
+#elif defined(_MSC_VER) && !defined(__ICL)
+    #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
+#endif
+
+#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
+    #undef JSON_HEDLEY_MSVC_VERSION_CHECK
+#endif
+#if !defined(JSON_HEDLEY_MSVC_VERSION)
+    #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
+#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
+    #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
+    #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
+#else
+    #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
+#endif
+
+#if defined(JSON_HEDLEY_INTEL_VERSION)
+    #undef JSON_HEDLEY_INTEL_VERSION
+#endif
+#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
+    #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
+#elif defined(__INTEL_COMPILER) && !defined(__ICL)
+    #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
+#endif
+
+#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
+    #undef JSON_HEDLEY_INTEL_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_INTEL_VERSION)
+    #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
+    #undef JSON_HEDLEY_INTEL_CL_VERSION
+#endif
+#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
+    #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
+#endif
+
+#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
+    #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
+    #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_PGI_VERSION)
+    #undef JSON_HEDLEY_PGI_VERSION
+#endif
+#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
+    #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
+#endif
+
+#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
+    #undef JSON_HEDLEY_PGI_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_PGI_VERSION)
+    #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_SUNPRO_VERSION)
+    #undef JSON_HEDLEY_SUNPRO_VERSION
+#endif
+#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
+    #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
+#elif defined(__SUNPRO_C)
+    #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
+#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
+    #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
+#elif defined(__SUNPRO_CC)
+    #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
+#endif
+
+#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
+    #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_SUNPRO_VERSION)
+    #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
+    #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
+#endif
+#if defined(__EMSCRIPTEN__)
+    #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
+#endif
+
+#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
+    #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
+    #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_ARM_VERSION)
+    #undef JSON_HEDLEY_ARM_VERSION
+#endif
+#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
+    #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
+#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
+    #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
+#endif
+
+#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
+    #undef JSON_HEDLEY_ARM_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_ARM_VERSION)
+    #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_IBM_VERSION)
+    #undef JSON_HEDLEY_IBM_VERSION
+#endif
+#if defined(__ibmxl__)
+    #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
+#elif defined(__xlC__) && defined(__xlC_ver__)
+    #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
+#elif defined(__xlC__)
+    #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
+#endif
+
+#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
+    #undef JSON_HEDLEY_IBM_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_IBM_VERSION)
+    #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_VERSION)
+    #undef JSON_HEDLEY_TI_VERSION
+#endif
+#if \
+    defined(__TI_COMPILER_VERSION__) && \
+    ( \
+      defined(__TMS470__) || defined(__TI_ARM__) || \
+      defined(__MSP430__) || \
+      defined(__TMS320C2000__) \
+    )
+#if (__TI_COMPILER_VERSION__ >= 16000000)
+    #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+#endif
+
+#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_VERSION)
+    #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
+    #undef JSON_HEDLEY_TI_CL2000_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
+    #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
+    #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL430_VERSION)
+    #undef JSON_HEDLEY_TI_CL430_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
+    #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_CL430_VERSION)
+    #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
+    #undef JSON_HEDLEY_TI_ARMCL_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
+    #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
+    #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
+    #undef JSON_HEDLEY_TI_CL6X_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
+    #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
+    #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
+    #undef JSON_HEDLEY_TI_CL7X_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
+    #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
+    #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
+    #undef JSON_HEDLEY_TI_CLPRU_VERSION
+#endif
+#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
+    #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
+#endif
+
+#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
+    #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
+    #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_CRAY_VERSION)
+    #undef JSON_HEDLEY_CRAY_VERSION
+#endif
+#if defined(_CRAYC)
+    #if defined(_RELEASE_PATCHLEVEL)
+        #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
+    #else
+        #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
+    #endif
+#endif
+
+#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
+    #undef JSON_HEDLEY_CRAY_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_CRAY_VERSION)
+    #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_IAR_VERSION)
+    #undef JSON_HEDLEY_IAR_VERSION
+#endif
+#if defined(__IAR_SYSTEMS_ICC__)
+    #if __VER__ > 1000
+        #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
+    #else
+        #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
+    #endif
+#endif
+
+#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
+    #undef JSON_HEDLEY_IAR_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_IAR_VERSION)
+    #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_TINYC_VERSION)
+    #undef JSON_HEDLEY_TINYC_VERSION
+#endif
+#if defined(__TINYC__)
+    #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
+#endif
+
+#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
+    #undef JSON_HEDLEY_TINYC_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_TINYC_VERSION)
+    #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_DMC_VERSION)
+    #undef JSON_HEDLEY_DMC_VERSION
+#endif
+#if defined(__DMC__)
+    #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
+#endif
+
+#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
+    #undef JSON_HEDLEY_DMC_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_DMC_VERSION)
+    #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_COMPCERT_VERSION)
+    #undef JSON_HEDLEY_COMPCERT_VERSION
+#endif
+#if defined(__COMPCERT_VERSION__)
+    #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
+#endif
+
+#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
+    #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_COMPCERT_VERSION)
+    #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_PELLES_VERSION)
+    #undef JSON_HEDLEY_PELLES_VERSION
+#endif
+#if defined(__POCC__)
+    #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
+#endif
+
+#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
+    #undef JSON_HEDLEY_PELLES_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_PELLES_VERSION)
+    #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
+    #undef JSON_HEDLEY_MCST_LCC_VERSION
+#endif
+#if defined(__LCC__) && defined(__LCC_MINOR__)
+    #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
+#endif
+
+#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
+    #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
+    #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_VERSION)
+    #undef JSON_HEDLEY_GCC_VERSION
+#endif
+#if \
+    defined(JSON_HEDLEY_GNUC_VERSION) && \
+    !defined(__clang__) && \
+    !defined(JSON_HEDLEY_INTEL_VERSION) && \
+    !defined(JSON_HEDLEY_PGI_VERSION) && \
+    !defined(JSON_HEDLEY_ARM_VERSION) && \
+    !defined(JSON_HEDLEY_CRAY_VERSION) && \
+    !defined(JSON_HEDLEY_TI_VERSION) && \
+    !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
+    !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
+    !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
+    !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
+    !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
+    !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
+    !defined(__COMPCERT__) && \
+    !defined(JSON_HEDLEY_MCST_LCC_VERSION)
+    #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
+#endif
+
+#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
+    #undef JSON_HEDLEY_GCC_VERSION_CHECK
+#endif
+#if defined(JSON_HEDLEY_GCC_VERSION)
+    #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
+#else
+    #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
+    #undef JSON_HEDLEY_HAS_ATTRIBUTE
+#endif
+#if \
+  defined(__has_attribute) && \
+  ( \
+    (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
+  )
+#  define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
+#else
+#  define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
+    #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
+#endif
+#if defined(__has_attribute)
+    #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
+    #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
+#endif
+#if defined(__has_attribute)
+    #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
+#else
+    #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
+    #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
+#endif
+#if \
+    defined(__has_cpp_attribute) && \
+    defined(__cplusplus) && \
+    (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
+    #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
+#else
+    #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
+    #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
+#endif
+#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
+    #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
+#elif \
+    !defined(JSON_HEDLEY_PGI_VERSION) && \
+    !defined(JSON_HEDLEY_IAR_VERSION) && \
+    (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
+    (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
+    #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
+#else
+    #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
+    #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
+#endif
+#if defined(__has_cpp_attribute) && defined(__cplusplus)
+    #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
+    #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
+#endif
+#if defined(__has_cpp_attribute) && defined(__cplusplus)
+    #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
+#else
+    #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_BUILTIN)
+    #undef JSON_HEDLEY_HAS_BUILTIN
+#endif
+#if defined(__has_builtin)
+    #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
+#else
+    #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
+    #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
+#endif
+#if defined(__has_builtin)
+    #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
+    #undef JSON_HEDLEY_GCC_HAS_BUILTIN
+#endif
+#if defined(__has_builtin)
+    #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
+#else
+    #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_FEATURE)
+    #undef JSON_HEDLEY_HAS_FEATURE
+#endif
+#if defined(__has_feature)
+    #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
+#else
+    #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
+    #undef JSON_HEDLEY_GNUC_HAS_FEATURE
+#endif
+#if defined(__has_feature)
+    #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
+    #undef JSON_HEDLEY_GCC_HAS_FEATURE
+#endif
+#if defined(__has_feature)
+    #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
+#else
+    #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_EXTENSION)
+    #undef JSON_HEDLEY_HAS_EXTENSION
+#endif
+#if defined(__has_extension)
+    #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
+#else
+    #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
+    #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
+#endif
+#if defined(__has_extension)
+    #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
+    #undef JSON_HEDLEY_GCC_HAS_EXTENSION
+#endif
+#if defined(__has_extension)
+    #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
+#else
+    #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
+    #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
+#endif
+#if defined(__has_declspec_attribute)
+    #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
+#else
+    #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
+    #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
+#endif
+#if defined(__has_declspec_attribute)
+    #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
+    #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
+#endif
+#if defined(__has_declspec_attribute)
+    #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
+#else
+    #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_HAS_WARNING)
+    #undef JSON_HEDLEY_HAS_WARNING
+#endif
+#if defined(__has_warning)
+    #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
+#else
+    #define JSON_HEDLEY_HAS_WARNING(warning) (0)
+#endif
+
+#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
+    #undef JSON_HEDLEY_GNUC_HAS_WARNING
+#endif
+#if defined(__has_warning)
+    #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
+#else
+    #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
+    #undef JSON_HEDLEY_GCC_HAS_WARNING
+#endif
+#if defined(__has_warning)
+    #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
+#else
+    #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if \
+    (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
+    defined(__clang__) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
+    JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
+    (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
+    #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
+#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
+    #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
+#else
+    #define JSON_HEDLEY_PRAGMA(value)
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
+    #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
+#endif
+#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
+    #undef JSON_HEDLEY_DIAGNOSTIC_POP
+#endif
+#if defined(__clang__)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
+#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
+    #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
+#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
+#elif \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
+    #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_PUSH
+    #define JSON_HEDLEY_DIAGNOSTIC_POP
+#endif
+
+/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for
+   HEDLEY INTERNAL USE ONLY.  API subject to change without notice. */
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
+#endif
+#if defined(__cplusplus)
+#  if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
+#    if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
+#      if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
+#        define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
+    _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
+    _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
+    xpr \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#      else
+#        define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
+    _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
+    xpr \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#      endif
+#    else
+#      define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
+    xpr \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#    endif
+#  endif
+#endif
+#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
+#endif
+
+#if defined(JSON_HEDLEY_CONST_CAST)
+    #undef JSON_HEDLEY_CONST_CAST
+#endif
+#if defined(__cplusplus)
+#  define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
+#elif \
+  JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
+  JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+#  define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
+        JSON_HEDLEY_DIAGNOSTIC_PUSH \
+        JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
+        ((T) (expr)); \
+        JSON_HEDLEY_DIAGNOSTIC_POP \
+    }))
+#else
+#  define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
+#endif
+
+#if defined(JSON_HEDLEY_REINTERPRET_CAST)
+    #undef JSON_HEDLEY_REINTERPRET_CAST
+#endif
+#if defined(__cplusplus)
+    #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
+#else
+    #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
+#endif
+
+#if defined(JSON_HEDLEY_STATIC_CAST)
+    #undef JSON_HEDLEY_STATIC_CAST
+#endif
+#if defined(__cplusplus)
+    #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
+#else
+    #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
+#endif
+
+#if defined(JSON_HEDLEY_CPP_CAST)
+    #undef JSON_HEDLEY_CPP_CAST
+#endif
+#if defined(__cplusplus)
+#  if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
+#    define JSON_HEDLEY_CPP_CAST(T, expr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
+    ((T) (expr)) \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#  elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
+#    define JSON_HEDLEY_CPP_CAST(T, expr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("diag_suppress=Pe137") \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#  else
+#    define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
+#  endif
+#else
+#  define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
+#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
+#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
+#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
+#elif \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
+#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
+#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
+#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
+#elif \
+    JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
+#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
+#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
+#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
+#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
+#elif \
+    JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
+#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
+#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
+#endif
+
+#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
+    #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
+#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
+#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
+#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
+#else
+    #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
+#endif
+
+#if defined(JSON_HEDLEY_DEPRECATED)
+    #undef JSON_HEDLEY_DEPRECATED
+#endif
+#if defined(JSON_HEDLEY_DEPRECATED_FOR)
+    #undef JSON_HEDLEY_DEPRECATED_FOR
+#endif
+#if \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
+#elif \
+    (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
+#elif defined(__cplusplus) && (__cplusplus >= 201402L)
+    #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
+#elif \
+    JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
+    JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
+    #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
+    JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
+#else
+    #define JSON_HEDLEY_DEPRECATED(since)
+    #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
+#endif
+
+#if defined(JSON_HEDLEY_UNAVAILABLE)
+    #undef JSON_HEDLEY_UNAVAILABLE
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
+#else
+    #define JSON_HEDLEY_UNAVAILABLE(available_since)
+#endif
+
+#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
+    #undef JSON_HEDLEY_WARN_UNUSED_RESULT
+#endif
+#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
+    #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
+#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
+#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
+#elif defined(_Check_return_) /* SAL */
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
+#else
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT
+    #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
+#endif
+
+#if defined(JSON_HEDLEY_SENTINEL)
+    #undef JSON_HEDLEY_SENTINEL
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
+#else
+    #define JSON_HEDLEY_SENTINEL(position)
+#endif
+
+#if defined(JSON_HEDLEY_NO_RETURN)
+    #undef JSON_HEDLEY_NO_RETURN
+#endif
+#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_NO_RETURN __noreturn
+#elif \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+    #define JSON_HEDLEY_NO_RETURN _Noreturn
+#elif defined(__cplusplus) && (__cplusplus >= 201103L)
+    #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
+#elif \
+    JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
+    #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
+    #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
+#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
+    #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
+#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
+    #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
+    #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
+#else
+    #define JSON_HEDLEY_NO_RETURN
+#endif
+
+#if defined(JSON_HEDLEY_NO_ESCAPE)
+    #undef JSON_HEDLEY_NO_ESCAPE
+#endif
+#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
+    #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
+#else
+    #define JSON_HEDLEY_NO_ESCAPE
+#endif
+
+#if defined(JSON_HEDLEY_UNREACHABLE)
+    #undef JSON_HEDLEY_UNREACHABLE
+#endif
+#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
+    #undef JSON_HEDLEY_UNREACHABLE_RETURN
+#endif
+#if defined(JSON_HEDLEY_ASSUME)
+    #undef JSON_HEDLEY_ASSUME
+#endif
+#if \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
+#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
+    #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
+#elif \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
+    #if defined(__cplusplus)
+        #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
+    #else
+        #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
+    #endif
+#endif
+#if \
+    (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
+    JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
+#elif defined(JSON_HEDLEY_ASSUME)
+    #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
+#endif
+#if !defined(JSON_HEDLEY_ASSUME)
+    #if defined(JSON_HEDLEY_UNREACHABLE)
+        #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
+    #else
+        #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
+    #endif
+#endif
+#if defined(JSON_HEDLEY_UNREACHABLE)
+    #if  \
+        JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
+        JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
+        #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
+    #else
+        #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
+    #endif
+#else
+    #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
+#endif
+#if !defined(JSON_HEDLEY_UNREACHABLE)
+    #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
+#endif
+
+JSON_HEDLEY_DIAGNOSTIC_PUSH
+#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
+    #pragma clang diagnostic ignored "-Wpedantic"
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
+    #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
+#endif
+#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
+    #if defined(__clang__)
+        #pragma clang diagnostic ignored "-Wvariadic-macros"
+    #elif defined(JSON_HEDLEY_GCC_VERSION)
+        #pragma GCC diagnostic ignored "-Wvariadic-macros"
+    #endif
+#endif
+#if defined(JSON_HEDLEY_NON_NULL)
+    #undef JSON_HEDLEY_NON_NULL
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
+    #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
+#else
+    #define JSON_HEDLEY_NON_NULL(...)
+#endif
+JSON_HEDLEY_DIAGNOSTIC_POP
+
+#if defined(JSON_HEDLEY_PRINTF_FORMAT)
+    #undef JSON_HEDLEY_PRINTF_FORMAT
+#endif
+#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
+    #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
+#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
+    #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
+#elif \
+    JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
+    #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
+#else
+    #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
+#endif
+
+#if defined(JSON_HEDLEY_CONSTEXPR)
+    #undef JSON_HEDLEY_CONSTEXPR
+#endif
+#if defined(__cplusplus)
+    #if __cplusplus >= 201103L
+        #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
+    #endif
+#endif
+#if !defined(JSON_HEDLEY_CONSTEXPR)
+    #define JSON_HEDLEY_CONSTEXPR
+#endif
+
+#if defined(JSON_HEDLEY_PREDICT)
+    #undef JSON_HEDLEY_PREDICT
+#endif
+#if defined(JSON_HEDLEY_LIKELY)
+    #undef JSON_HEDLEY_LIKELY
+#endif
+#if defined(JSON_HEDLEY_UNLIKELY)
+    #undef JSON_HEDLEY_UNLIKELY
+#endif
+#if defined(JSON_HEDLEY_UNPREDICTABLE)
+    #undef JSON_HEDLEY_UNPREDICTABLE
+#endif
+#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
+    #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
+#endif
+#if \
+  (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
+  JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
+  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+#  define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(  (expr), (value), (probability))
+#  define JSON_HEDLEY_PREDICT_TRUE(expr, probability)   __builtin_expect_with_probability(!!(expr),    1   , (probability))
+#  define JSON_HEDLEY_PREDICT_FALSE(expr, probability)  __builtin_expect_with_probability(!!(expr),    0   , (probability))
+#  define JSON_HEDLEY_LIKELY(expr)                      __builtin_expect                 (!!(expr),    1                  )
+#  define JSON_HEDLEY_UNLIKELY(expr)                    __builtin_expect                 (!!(expr),    0                  )
+#elif \
+  (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
+  JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+  (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
+  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
+  JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
+  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
+  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
+  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+  JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
+  JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
+  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+#  define JSON_HEDLEY_PREDICT(expr, expected, probability) \
+    (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
+#  define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
+    (__extension__ ({ \
+        double hedley_probability_ = (probability); \
+        ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
+    }))
+#  define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
+    (__extension__ ({ \
+        double hedley_probability_ = (probability); \
+        ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
+    }))
+#  define JSON_HEDLEY_LIKELY(expr)   __builtin_expect(!!(expr), 1)
+#  define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
+#else
+#  define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
+#  define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
+#  define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
+#  define JSON_HEDLEY_LIKELY(expr) (!!(expr))
+#  define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
+#endif
+#if !defined(JSON_HEDLEY_UNPREDICTABLE)
+    #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
+#endif
+
+#if defined(JSON_HEDLEY_MALLOC)
+    #undef JSON_HEDLEY_MALLOC
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
+    #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_MALLOC __declspec(restrict)
+#else
+    #define JSON_HEDLEY_MALLOC
+#endif
+
+#if defined(JSON_HEDLEY_PURE)
+    #undef JSON_HEDLEY_PURE
+#endif
+#if \
+  JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
+  JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+  JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
+  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+#  define JSON_HEDLEY_PURE __attribute__((__pure__))
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
+#  define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
+#elif defined(__cplusplus) && \
+    ( \
+      JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
+      JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
+      JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
+    )
+#  define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
+#else
+#  define JSON_HEDLEY_PURE
+#endif
+
+#if defined(JSON_HEDLEY_CONST)
+    #undef JSON_HEDLEY_CONST
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_CONST __attribute__((__const__))
+#elif \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
+    #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
+#else
+    #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
+#endif
+
+#if defined(JSON_HEDLEY_RESTRICT)
+    #undef JSON_HEDLEY_RESTRICT
+#endif
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
+    #define JSON_HEDLEY_RESTRICT restrict
+#elif \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+    JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
+    JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
+    defined(__clang__) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_RESTRICT __restrict
+#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
+    #define JSON_HEDLEY_RESTRICT _Restrict
+#else
+    #define JSON_HEDLEY_RESTRICT
+#endif
+
+#if defined(JSON_HEDLEY_INLINE)
+    #undef JSON_HEDLEY_INLINE
+#endif
+#if \
+    (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
+    (defined(__cplusplus) && (__cplusplus >= 199711L))
+    #define JSON_HEDLEY_INLINE inline
+#elif \
+    defined(JSON_HEDLEY_GCC_VERSION) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
+    #define JSON_HEDLEY_INLINE __inline__
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_INLINE __inline
+#else
+    #define JSON_HEDLEY_INLINE
+#endif
+
+#if defined(JSON_HEDLEY_ALWAYS_INLINE)
+    #undef JSON_HEDLEY_ALWAYS_INLINE
+#endif
+#if \
+  JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
+  JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+  JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+  JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+  JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+  JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+  (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+  (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+  (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+  (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+  JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+  JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+  JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+  JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
+  JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
+#  define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
+#elif \
+  JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
+  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+#  define JSON_HEDLEY_ALWAYS_INLINE __forceinline
+#elif defined(__cplusplus) && \
+    ( \
+      JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+      JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+      JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+      JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
+      JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+      JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
+    )
+#  define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+#  define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
+#else
+#  define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
+#endif
+
+#if defined(JSON_HEDLEY_NEVER_INLINE)
+    #undef JSON_HEDLEY_NEVER_INLINE
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
+    JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
+    (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
+    (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
+    (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
+    (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
+    JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
+    JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
+    JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
+    #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
+#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
+    #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
+#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
+    #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+    #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
+#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
+    #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
+    #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
+#else
+    #define JSON_HEDLEY_NEVER_INLINE
+#endif
+
+#if defined(JSON_HEDLEY_PRIVATE)
+    #undef JSON_HEDLEY_PRIVATE
+#endif
+#if defined(JSON_HEDLEY_PUBLIC)
+    #undef JSON_HEDLEY_PUBLIC
+#endif
+#if defined(JSON_HEDLEY_IMPORT)
+    #undef JSON_HEDLEY_IMPORT
+#endif
+#if defined(_WIN32) || defined(__CYGWIN__)
+#  define JSON_HEDLEY_PRIVATE
+#  define JSON_HEDLEY_PUBLIC   __declspec(dllexport)
+#  define JSON_HEDLEY_IMPORT   __declspec(dllimport)
+#else
+#  if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
+    JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
+    ( \
+      defined(__TI_EABI__) && \
+      ( \
+        (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
+        JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
+      ) \
+    ) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+#    define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
+#    define JSON_HEDLEY_PUBLIC  __attribute__((__visibility__("default")))
+#  else
+#    define JSON_HEDLEY_PRIVATE
+#    define JSON_HEDLEY_PUBLIC
+#  endif
+#  define JSON_HEDLEY_IMPORT    extern
+#endif
+
+#if defined(JSON_HEDLEY_NO_THROW)
+    #undef JSON_HEDLEY_NO_THROW
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
+#elif \
+    JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
+    #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
+#else
+    #define JSON_HEDLEY_NO_THROW
+#endif
+
+#if defined(JSON_HEDLEY_FALL_THROUGH)
+    #undef JSON_HEDLEY_FALL_THROUGH
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
+#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
+    #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
+#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
+    #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
+#elif defined(__fallthrough) /* SAL */
+    #define JSON_HEDLEY_FALL_THROUGH __fallthrough
+#else
+    #define JSON_HEDLEY_FALL_THROUGH
+#endif
+
+#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
+    #undef JSON_HEDLEY_RETURNS_NON_NULL
+#endif
+#if \
+    JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
+#elif defined(_Ret_notnull_) /* SAL */
+    #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
+#else
+    #define JSON_HEDLEY_RETURNS_NON_NULL
+#endif
+
+#if defined(JSON_HEDLEY_ARRAY_PARAM)
+    #undef JSON_HEDLEY_ARRAY_PARAM
+#endif
+#if \
+    defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
+    !defined(__STDC_NO_VLA__) && \
+    !defined(__cplusplus) && \
+    !defined(JSON_HEDLEY_PGI_VERSION) && \
+    !defined(JSON_HEDLEY_TINYC_VERSION)
+    #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
+#else
+    #define JSON_HEDLEY_ARRAY_PARAM(name)
+#endif
+
+#if defined(JSON_HEDLEY_IS_CONSTANT)
+    #undef JSON_HEDLEY_IS_CONSTANT
+#endif
+#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
+    #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
+#endif
+/* JSON_HEDLEY_IS_CONSTEXPR_ is for
+   HEDLEY INTERNAL USE ONLY.  API subject to change without notice. */
+#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
+    #undef JSON_HEDLEY_IS_CONSTEXPR_
+#endif
+#if \
+    JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
+    JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
+    JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+    JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
+    JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
+    JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
+    JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
+    (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
+    JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
+    JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
+    #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
+#endif
+#if !defined(__cplusplus)
+#  if \
+       JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
+       JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
+       JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+       JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
+       JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
+       JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
+       JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
+#if defined(__INTPTR_TYPE__)
+    #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
+#else
+    #include <stdint.h>
+    #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
+#endif
+#  elif \
+       ( \
+          defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
+          !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
+          !defined(JSON_HEDLEY_PGI_VERSION) && \
+          !defined(JSON_HEDLEY_IAR_VERSION)) || \
+       (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
+       JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
+       JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
+       JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
+       JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
+#if defined(__INTPTR_TYPE__)
+    #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
+#else
+    #include <stdint.h>
+    #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
+#endif
+#  elif \
+       defined(JSON_HEDLEY_GCC_VERSION) || \
+       defined(JSON_HEDLEY_INTEL_VERSION) || \
+       defined(JSON_HEDLEY_TINYC_VERSION) || \
+       defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
+       JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
+       defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
+       defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
+       defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
+       defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
+       defined(__clang__)
+#    define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
+        sizeof(void) != \
+        sizeof(*( \
+                  1 ? \
+                  ((void*) ((expr) * 0L) ) : \
+((struct { char v[sizeof(void) * 2]; } *) 1) \
+                ) \
+              ) \
+                                            )
+#  endif
+#endif
+#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
+    #if !defined(JSON_HEDLEY_IS_CONSTANT)
+        #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
+    #endif
+    #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
+#else
+    #if !defined(JSON_HEDLEY_IS_CONSTANT)
+        #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
+    #endif
+    #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
+#endif
+
+#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
+    #undef JSON_HEDLEY_BEGIN_C_DECLS
+#endif
+#if defined(JSON_HEDLEY_END_C_DECLS)
+    #undef JSON_HEDLEY_END_C_DECLS
+#endif
+#if defined(JSON_HEDLEY_C_DECL)
+    #undef JSON_HEDLEY_C_DECL
+#endif
+#if defined(__cplusplus)
+    #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
+    #define JSON_HEDLEY_END_C_DECLS }
+    #define JSON_HEDLEY_C_DECL extern "C"
+#else
+    #define JSON_HEDLEY_BEGIN_C_DECLS
+    #define JSON_HEDLEY_END_C_DECLS
+    #define JSON_HEDLEY_C_DECL
+#endif
+
+#if defined(JSON_HEDLEY_STATIC_ASSERT)
+    #undef JSON_HEDLEY_STATIC_ASSERT
+#endif
+#if \
+  !defined(__cplusplus) && ( \
+      (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
+      (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
+      JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
+      JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
+      defined(_Static_assert) \
+    )
+#  define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
+#elif \
+  (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
+  JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
+  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+#  define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
+#else
+#  define JSON_HEDLEY_STATIC_ASSERT(expr, message)
+#endif
+
+#if defined(JSON_HEDLEY_NULL)
+    #undef JSON_HEDLEY_NULL
+#endif
+#if defined(__cplusplus)
+    #if __cplusplus >= 201103L
+        #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
+    #elif defined(NULL)
+        #define JSON_HEDLEY_NULL NULL
+    #else
+        #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
+    #endif
+#elif defined(NULL)
+    #define JSON_HEDLEY_NULL NULL
+#else
+    #define JSON_HEDLEY_NULL ((void*) 0)
+#endif
+
+#if defined(JSON_HEDLEY_MESSAGE)
+    #undef JSON_HEDLEY_MESSAGE
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
+#  define JSON_HEDLEY_MESSAGE(msg) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
+    JSON_HEDLEY_PRAGMA(message msg) \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#elif \
+  JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+#  define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
+#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
+#  define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
+#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
+#  define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
+#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
+#  define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
+#else
+#  define JSON_HEDLEY_MESSAGE(msg)
+#endif
+
+#if defined(JSON_HEDLEY_WARNING)
+    #undef JSON_HEDLEY_WARNING
+#endif
+#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
+#  define JSON_HEDLEY_WARNING(msg) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
+    JSON_HEDLEY_PRAGMA(clang warning msg) \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#elif \
+  JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
+  JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
+  JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
+#  define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
+#elif \
+  JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
+  JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+#  define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
+#else
+#  define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
+#endif
+
+#if defined(JSON_HEDLEY_REQUIRE)
+    #undef JSON_HEDLEY_REQUIRE
+#endif
+#if defined(JSON_HEDLEY_REQUIRE_MSG)
+    #undef JSON_HEDLEY_REQUIRE_MSG
+#endif
+#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
+#  if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
+#    define JSON_HEDLEY_REQUIRE(expr) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
+    __attribute__((diagnose_if(!(expr), #expr, "error"))) \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#    define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
+    JSON_HEDLEY_DIAGNOSTIC_PUSH \
+    _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
+    __attribute__((diagnose_if(!(expr), msg, "error"))) \
+    JSON_HEDLEY_DIAGNOSTIC_POP
+#  else
+#    define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
+#    define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
+#  endif
+#else
+#  define JSON_HEDLEY_REQUIRE(expr)
+#  define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
+#endif
+
+#if defined(JSON_HEDLEY_FLAGS)
+    #undef JSON_HEDLEY_FLAGS
+#endif
+#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
+    #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
+#else
+    #define JSON_HEDLEY_FLAGS
+#endif
+
+#if defined(JSON_HEDLEY_FLAGS_CAST)
+    #undef JSON_HEDLEY_FLAGS_CAST
+#endif
+#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
+#  define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
+        JSON_HEDLEY_DIAGNOSTIC_PUSH \
+        _Pragma("warning(disable:188)") \
+        ((T) (expr)); \
+        JSON_HEDLEY_DIAGNOSTIC_POP \
+    }))
+#else
+#  define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
+#endif
+
+#if defined(JSON_HEDLEY_EMPTY_BASES)
+    #undef JSON_HEDLEY_EMPTY_BASES
+#endif
+#if \
+    (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
+    JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
+    #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
+#else
+    #define JSON_HEDLEY_EMPTY_BASES
+#endif
+
+/* Remaining macros are deprecated. */
+
+#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
+    #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
+#endif
+#if defined(__clang__)
+    #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
+#else
+    #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
+#endif
+
+#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
+    #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
+#endif
+#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
+    #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
+#endif
+#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
+    #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
+#endif
+#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
+    #undef JSON_HEDLEY_CLANG_HAS_FEATURE
+#endif
+#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
+    #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
+#endif
+#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
+    #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
+#endif
+#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
+
+#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
+    #undef JSON_HEDLEY_CLANG_HAS_WARNING
+#endif
+#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
+
+#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */
+
+// #include <nlohmann/detail/meta/detected.hpp>
+
+
+#include <type_traits>
+
+// #include <nlohmann/detail/meta/void_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename ...Ts> struct make_void
+{
+    using type = void;
+};
+template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
+} // namespace detail
+}  // namespace nlohmann
+
+
+// https://en.cppreference.com/w/cpp/experimental/is_detected
+namespace nlohmann
+{
+namespace detail
+{
+struct nonesuch
+{
+    nonesuch() = delete;
+    ~nonesuch() = delete;
+    nonesuch(nonesuch const&) = delete;
+    nonesuch(nonesuch const&&) = delete;
+    void operator=(nonesuch const&) = delete;
+    void operator=(nonesuch&&) = delete;
+};
+
+template<class Default,
+         class AlwaysVoid,
+         template<class...> class Op,
+         class... Args>
+struct detector
+{
+    using value_t = std::false_type;
+    using type = Default;
+};
+
+template<class Default, template<class...> class Op, class... Args>
+struct detector<Default, void_t<Op<Args...>>, Op, Args...>
+{
+    using value_t = std::true_type;
+    using type = Op<Args...>;
+};
+
+template<template<class...> class Op, class... Args>
+using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
+
+template<template<class...> class Op, class... Args>
+struct is_detected_lazy : is_detected<Op, Args...> { };
+
+template<template<class...> class Op, class... Args>
+using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
+
+template<class Default, template<class...> class Op, class... Args>
+using detected_or = detector<Default, void, Op, Args...>;
+
+template<class Default, template<class...> class Op, class... Args>
+using detected_or_t = typename detected_or<Default, Op, Args...>::type;
+
+template<class Expected, template<class...> class Op, class... Args>
+using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
+
+template<class To, template<class...> class Op, class... Args>
+using is_detected_convertible =
+    std::is_convertible<detected_t<Op, Args...>, To>;
+}  // namespace detail
+}  // namespace nlohmann
+
+
+// This file contains all internal macro definitions
+// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
+
+// exclude unsupported compilers
+#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
+    #if defined(__clang__)
+        #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
+            #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
+        #endif
+    #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
+        #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
+            #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
+        #endif
+    #endif
+#endif
+
+// C++ language standard detection
+// if the user manually specified the used c++ version this is skipped
+#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
+    #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
+        #define JSON_HAS_CPP_20
+        #define JSON_HAS_CPP_17
+        #define JSON_HAS_CPP_14
+    #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
+        #define JSON_HAS_CPP_17
+        #define JSON_HAS_CPP_14
+    #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
+        #define JSON_HAS_CPP_14
+    #endif
+    // the cpp 11 flag is always specified because it is the minimal required version
+    #define JSON_HAS_CPP_11
+#endif
+
+// disable documentation warnings on clang
+#if defined(__clang__)
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wdocumentation"
+    #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
+#endif
+
+// allow to disable exceptions
+#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
+    #define JSON_THROW(exception) throw exception
+    #define JSON_TRY try
+    #define JSON_CATCH(exception) catch(exception)
+    #define JSON_INTERNAL_CATCH(exception) catch(exception)
+#else
+    #include <cstdlib>
+    #define JSON_THROW(exception) std::abort()
+    #define JSON_TRY if(true)
+    #define JSON_CATCH(exception) if(false)
+    #define JSON_INTERNAL_CATCH(exception) if(false)
+#endif
+
+// override exception macros
+#if defined(JSON_THROW_USER)
+    #undef JSON_THROW
+    #define JSON_THROW JSON_THROW_USER
+#endif
+#if defined(JSON_TRY_USER)
+    #undef JSON_TRY
+    #define JSON_TRY JSON_TRY_USER
+#endif
+#if defined(JSON_CATCH_USER)
+    #undef JSON_CATCH
+    #define JSON_CATCH JSON_CATCH_USER
+    #undef JSON_INTERNAL_CATCH
+    #define JSON_INTERNAL_CATCH JSON_CATCH_USER
+#endif
+#if defined(JSON_INTERNAL_CATCH_USER)
+    #undef JSON_INTERNAL_CATCH
+    #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
+#endif
+
+// allow to override assert
+#if !defined(JSON_ASSERT)
+    #include <cassert> // assert
+    #define JSON_ASSERT(x) assert(x)
+#endif
+
+// allow to access some private functions (needed by the test suite)
+#if defined(JSON_TESTS_PRIVATE)
+    #define JSON_PRIVATE_UNLESS_TESTED public
+#else
+    #define JSON_PRIVATE_UNLESS_TESTED private
+#endif
+
+/*!
+@brief macro to briefly define a mapping between an enum and JSON
+@def NLOHMANN_JSON_SERIALIZE_ENUM
+@since version 3.4.0
+*/
+#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...)                                            \
+    template<typename BasicJsonType>                                                            \
+    inline void to_json(BasicJsonType& j, const ENUM_TYPE& e)                                   \
+    {                                                                                           \
+        static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!");          \
+        static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__;                     \
+        auto it = std::find_if(std::begin(m), std::end(m),                                      \
+                               [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool  \
+        {                                                                                       \
+            return ej_pair.first == e;                                                          \
+        });                                                                                     \
+        j = ((it != std::end(m)) ? it : std::begin(m))->second;                                 \
+    }                                                                                           \
+    template<typename BasicJsonType>                                                            \
+    inline void from_json(const BasicJsonType& j, ENUM_TYPE& e)                                 \
+    {                                                                                           \
+        static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!");          \
+        static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__;                     \
+        auto it = std::find_if(std::begin(m), std::end(m),                                      \
+                               [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
+        {                                                                                       \
+            return ej_pair.second == j;                                                         \
+        });                                                                                     \
+        e = ((it != std::end(m)) ? it : std::begin(m))->first;                                  \
+    }
+
+// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
+// may be removed in the future once the class is split.
+
+#define NLOHMANN_BASIC_JSON_TPL_DECLARATION                                \
+    template<template<typename, typename, typename...> class ObjectType,   \
+             template<typename, typename...> class ArrayType,              \
+             class StringType, class BooleanType, class NumberIntegerType, \
+             class NumberUnsignedType, class NumberFloatType,              \
+             template<typename> class AllocatorType,                       \
+             template<typename, typename = void> class JSONSerializer,     \
+             class BinaryType>
+
+#define NLOHMANN_BASIC_JSON_TPL                                            \
+    basic_json<ObjectType, ArrayType, StringType, BooleanType,             \
+    NumberIntegerType, NumberUnsignedType, NumberFloatType,                \
+    AllocatorType, JSONSerializer, BinaryType>
+
+// Macros to simplify conversion from/to types
+
+#define NLOHMANN_JSON_EXPAND( x ) x
+#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
+#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
+        NLOHMANN_JSON_PASTE64, \
+        NLOHMANN_JSON_PASTE63, \
+        NLOHMANN_JSON_PASTE62, \
+        NLOHMANN_JSON_PASTE61, \
+        NLOHMANN_JSON_PASTE60, \
+        NLOHMANN_JSON_PASTE59, \
+        NLOHMANN_JSON_PASTE58, \
+        NLOHMANN_JSON_PASTE57, \
+        NLOHMANN_JSON_PASTE56, \
+        NLOHMANN_JSON_PASTE55, \
+        NLOHMANN_JSON_PASTE54, \
+        NLOHMANN_JSON_PASTE53, \
+        NLOHMANN_JSON_PASTE52, \
+        NLOHMANN_JSON_PASTE51, \
+        NLOHMANN_JSON_PASTE50, \
+        NLOHMANN_JSON_PASTE49, \
+        NLOHMANN_JSON_PASTE48, \
+        NLOHMANN_JSON_PASTE47, \
+        NLOHMANN_JSON_PASTE46, \
+        NLOHMANN_JSON_PASTE45, \
+        NLOHMANN_JSON_PASTE44, \
+        NLOHMANN_JSON_PASTE43, \
+        NLOHMANN_JSON_PASTE42, \
+        NLOHMANN_JSON_PASTE41, \
+        NLOHMANN_JSON_PASTE40, \
+        NLOHMANN_JSON_PASTE39, \
+        NLOHMANN_JSON_PASTE38, \
+        NLOHMANN_JSON_PASTE37, \
+        NLOHMANN_JSON_PASTE36, \
+        NLOHMANN_JSON_PASTE35, \
+        NLOHMANN_JSON_PASTE34, \
+        NLOHMANN_JSON_PASTE33, \
+        NLOHMANN_JSON_PASTE32, \
+        NLOHMANN_JSON_PASTE31, \
+        NLOHMANN_JSON_PASTE30, \
+        NLOHMANN_JSON_PASTE29, \
+        NLOHMANN_JSON_PASTE28, \
+        NLOHMANN_JSON_PASTE27, \
+        NLOHMANN_JSON_PASTE26, \
+        NLOHMANN_JSON_PASTE25, \
+        NLOHMANN_JSON_PASTE24, \
+        NLOHMANN_JSON_PASTE23, \
+        NLOHMANN_JSON_PASTE22, \
+        NLOHMANN_JSON_PASTE21, \
+        NLOHMANN_JSON_PASTE20, \
+        NLOHMANN_JSON_PASTE19, \
+        NLOHMANN_JSON_PASTE18, \
+        NLOHMANN_JSON_PASTE17, \
+        NLOHMANN_JSON_PASTE16, \
+        NLOHMANN_JSON_PASTE15, \
+        NLOHMANN_JSON_PASTE14, \
+        NLOHMANN_JSON_PASTE13, \
+        NLOHMANN_JSON_PASTE12, \
+        NLOHMANN_JSON_PASTE11, \
+        NLOHMANN_JSON_PASTE10, \
+        NLOHMANN_JSON_PASTE9, \
+        NLOHMANN_JSON_PASTE8, \
+        NLOHMANN_JSON_PASTE7, \
+        NLOHMANN_JSON_PASTE6, \
+        NLOHMANN_JSON_PASTE5, \
+        NLOHMANN_JSON_PASTE4, \
+        NLOHMANN_JSON_PASTE3, \
+        NLOHMANN_JSON_PASTE2, \
+        NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
+#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
+#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
+#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
+#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
+#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
+#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
+#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
+#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
+#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
+#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
+#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
+#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
+#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
+#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
+#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
+#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
+#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
+#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
+#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
+#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
+#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
+#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
+#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
+#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
+#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
+#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
+#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
+#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
+#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
+#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
+#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
+#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
+#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
+#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
+#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
+#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
+#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
+#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
+#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
+#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
+#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
+#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
+#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
+#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
+#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
+#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
+#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
+#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
+#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
+#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
+#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
+#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
+#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
+#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
+#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
+#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
+#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
+#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
+#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
+#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
+#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
+#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
+#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
+
+#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
+#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
+
+/*!
+@brief macro
+@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
+@since version 3.9.0
+*/
+#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...)  \
+    friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
+    friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
+
+/*!
+@brief macro
+@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
+@since version 3.9.0
+*/
+#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...)  \
+    inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
+    inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
+
+
+// inspired from https://stackoverflow.com/a/26745591
+// allows to call any std function as if (e.g. with begin):
+// using std::begin; begin(x);
+//
+// it allows using the detected idiom to retrieve the return type
+// of such an expression
+#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)                                 \
+    namespace detail {                                                            \
+    using std::std_name;                                                          \
+    \
+    template<typename... T>                                                       \
+    using result_of_##std_name = decltype(std_name(std::declval<T>()...));        \
+    }                                                                             \
+    \
+    namespace detail2 {                                                           \
+    struct std_name##_tag                                                         \
+    {                                                                             \
+    };                                                                            \
+    \
+    template<typename... T>                                                       \
+    std_name##_tag std_name(T&&...);                                              \
+    \
+    template<typename... T>                                                       \
+    using result_of_##std_name = decltype(std_name(std::declval<T>()...));        \
+    \
+    template<typename... T>                                                       \
+    struct would_call_std_##std_name                                              \
+    {                                                                             \
+        static constexpr auto const value = ::nlohmann::detail::                  \
+                                            is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
+    };                                                                            \
+    } /* namespace detail2 */ \
+    \
+    template<typename... T>                                                       \
+    struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...>   \
+    {                                                                             \
+    }
+
+#ifndef JSON_USE_IMPLICIT_CONVERSIONS
+    #define JSON_USE_IMPLICIT_CONVERSIONS 1
+#endif
+
+#if JSON_USE_IMPLICIT_CONVERSIONS
+    #define JSON_EXPLICIT
+#else
+    #define JSON_EXPLICIT explicit
+#endif
+
+#ifndef JSON_DIAGNOSTICS
+    #define JSON_DIAGNOSTICS 0
+#endif
+
+
+namespace nlohmann
+{
+namespace detail
+{
+
+/*!
+@brief replace all occurrences of a substring by another string
+
+@param[in,out] s  the string to manipulate; changed so that all
+               occurrences of @a f are replaced with @a t
+@param[in]     f  the substring to replace with @a t
+@param[in]     t  the string to replace @a f
+
+@pre The search string @a f must not be empty. **This precondition is
+enforced with an assertion.**
+
+@since version 2.0.0
+*/
+inline void replace_substring(std::string& s, const std::string& f,
+                              const std::string& t)
+{
+    JSON_ASSERT(!f.empty());
+    for (auto pos = s.find(f);                // find first occurrence of f
+            pos != std::string::npos;         // make sure f was found
+            s.replace(pos, f.size(), t),      // replace with t, and
+            pos = s.find(f, pos + t.size()))  // find next occurrence of f
+    {}
+}
+
+/*!
+ * @brief string escaping as described in RFC 6901 (Sect. 4)
+ * @param[in] s string to escape
+ * @return    escaped string
+ *
+ * Note the order of escaping "~" to "~0" and "/" to "~1" is important.
+ */
+inline std::string escape(std::string s)
+{
+    replace_substring(s, "~", "~0");
+    replace_substring(s, "/", "~1");
+    return s;
+}
+
+/*!
+ * @brief string unescaping as described in RFC 6901 (Sect. 4)
+ * @param[in] s string to unescape
+ * @return    unescaped string
+ *
+ * Note the order of escaping "~1" to "/" and "~0" to "~" is important.
+ */
+static void unescape(std::string& s)
+{
+    replace_substring(s, "~1", "/");
+    replace_substring(s, "~0", "~");
+}
+
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/input/position_t.hpp>
+
+
+#include <cstddef> // size_t
+
+namespace nlohmann
+{
+namespace detail
+{
+/// struct to capture the start position of the current token
+struct position_t
+{
+    /// the total number of characters read
+    std::size_t chars_read_total = 0;
+    /// the number of characters read in the current line
+    std::size_t chars_read_current_line = 0;
+    /// the number of lines read
+    std::size_t lines_read = 0;
+
+    /// conversion to size_t to preserve SAX interface
+    constexpr operator size_t() const
+    {
+        return chars_read_total;
+    }
+};
+
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+////////////////
+// exceptions //
+////////////////
+
+/*!
+@brief general exception of the @ref basic_json class
+
+This class is an extension of `std::exception` objects with a member @a id for
+exception ids. It is used as the base class for all exceptions thrown by the
+@ref basic_json class. This class can hence be used as "wildcard" to catch
+exceptions.
+
+Subclasses:
+- @ref parse_error for exceptions indicating a parse error
+- @ref invalid_iterator for exceptions indicating errors with iterators
+- @ref type_error for exceptions indicating executing a member function with
+                  a wrong type
+- @ref out_of_range for exceptions indicating access out of the defined range
+- @ref other_error for exceptions indicating other library errors
+
+@internal
+@note To have nothrow-copy-constructible exceptions, we internally use
+      `std::runtime_error` which can cope with arbitrary-length error messages.
+      Intermediate strings are built with static functions and then passed to
+      the actual constructor.
+@endinternal
+
+@liveexample{The following code shows how arbitrary library exceptions can be
+caught.,exception}
+
+@since version 3.0.0
+*/
+class exception : public std::exception
+{
+  public:
+    /// returns the explanatory string
+    const char* what() const noexcept override
+    {
+        return m.what();
+    }
+
+    /// the id of the exception
+    const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes)
+
+  protected:
+    JSON_HEDLEY_NON_NULL(3)
+    exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
+
+    static std::string name(const std::string& ename, int id_)
+    {
+        return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
+    }
+
+    template<typename BasicJsonType>
+    static std::string diagnostics(const BasicJsonType& leaf_element)
+    {
+#if JSON_DIAGNOSTICS
+        std::vector<std::string> tokens;
+        for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent)
+        {
+            switch (current->m_parent->type())
+            {
+                case value_t::array:
+                {
+                    for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
+                    {
+                        if (&current->m_parent->m_value.array->operator[](i) == current)
+                        {
+                            tokens.emplace_back(std::to_string(i));
+                            break;
+                        }
+                    }
+                    break;
+                }
+
+                case value_t::object:
+                {
+                    for (const auto& element : *current->m_parent->m_value.object)
+                    {
+                        if (&element.second == current)
+                        {
+                            tokens.emplace_back(element.first.c_str());
+                            break;
+                        }
+                    }
+                    break;
+                }
+
+                case value_t::null: // LCOV_EXCL_LINE
+                case value_t::string: // LCOV_EXCL_LINE
+                case value_t::boolean: // LCOV_EXCL_LINE
+                case value_t::number_integer: // LCOV_EXCL_LINE
+                case value_t::number_unsigned: // LCOV_EXCL_LINE
+                case value_t::number_float: // LCOV_EXCL_LINE
+                case value_t::binary: // LCOV_EXCL_LINE
+                case value_t::discarded: // LCOV_EXCL_LINE
+                default:   // LCOV_EXCL_LINE
+                    break; // LCOV_EXCL_LINE
+            }
+        }
+
+        if (tokens.empty())
+        {
+            return "";
+        }
+
+        return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
+                                     [](const std::string & a, const std::string & b)
+        {
+            return a + "/" + detail::escape(b);
+        }) + ") ";
+#else
+        static_cast<void>(leaf_element);
+        return "";
+#endif
+    }
+
+  private:
+    /// an exception object as storage for error messages
+    std::runtime_error m;
+};
+
+/*!
+@brief exception indicating a parse error
+
+This exception is thrown by the library when a parse error occurs. Parse errors
+can occur during the deserialization of JSON text, CBOR, MessagePack, as well
+as when using JSON Patch.
+
+Member @a byte holds the byte index of the last read character in the input
+file.
+
+Exceptions have ids 1xx.
+
+name / id                      | example message | description
+------------------------------ | --------------- | -------------------------
+json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position.
+json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.
+json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid.
+json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects.
+json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.
+json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`.
+json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character.
+json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences.
+json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number.
+json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read.
+json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read.
+json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read.
+json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet).
+json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed.
+
+@note For an input with n bytes, 1 is the index of the first character and n+1
+      is the index of the terminating null byte or the end of file. This also
+      holds true when reading a byte vector (CBOR or MessagePack).
+
+@liveexample{The following code shows how a `parse_error` exception can be
+caught.,parse_error}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+                    a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class parse_error : public exception
+{
+  public:
+    /*!
+    @brief create a parse error exception
+    @param[in] id_       the id of the exception
+    @param[in] pos       the position where the error occurred (or with
+                         chars_read_total=0 if the position cannot be
+                         determined)
+    @param[in] what_arg  the explanatory string
+    @return parse_error object
+    */
+    template<typename BasicJsonType>
+    static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("parse_error", id_) + "parse error" +
+                        position_string(pos) + ": " + exception::diagnostics(context) + what_arg;
+        return parse_error(id_, pos.chars_read_total, w.c_str());
+    }
+
+    template<typename BasicJsonType>
+    static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("parse_error", id_) + "parse error" +
+                        (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
+                        ": " + exception::diagnostics(context) + what_arg;
+        return parse_error(id_, byte_, w.c_str());
+    }
+
+    /*!
+    @brief byte index of the parse error
+
+    The byte index of the last read character in the input file.
+
+    @note For an input with n bytes, 1 is the index of the first character and
+          n+1 is the index of the terminating null byte or the end of file.
+          This also holds true when reading a byte vector (CBOR or MessagePack).
+    */
+    const std::size_t byte;
+
+  private:
+    parse_error(int id_, std::size_t byte_, const char* what_arg)
+        : exception(id_, what_arg), byte(byte_) {}
+
+    static std::string position_string(const position_t& pos)
+    {
+        return " at line " + std::to_string(pos.lines_read + 1) +
+               ", column " + std::to_string(pos.chars_read_current_line);
+    }
+};
+
+/*!
+@brief exception indicating errors with iterators
+
+This exception is thrown if iterators passed to a library function do not match
+the expected semantics.
+
+Exceptions have ids 2xx.
+
+name / id                           | example message | description
+----------------------------------- | --------------- | -------------------------
+json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
+json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
+json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
+json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid.
+json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid.
+json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range.
+json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.
+json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
+json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
+json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
+json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to.
+json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container.
+json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered.
+json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin().
+
+@liveexample{The following code shows how an `invalid_iterator` exception can be
+caught.,invalid_iterator}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref type_error for exceptions indicating executing a member function with
+                    a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class invalid_iterator : public exception
+{
+  public:
+    template<typename BasicJsonType>
+    static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg;
+        return invalid_iterator(id_, w.c_str());
+    }
+
+  private:
+    JSON_HEDLEY_NON_NULL(3)
+    invalid_iterator(int id_, const char* what_arg)
+        : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating executing a member function with a wrong type
+
+This exception is thrown in case of a type error; that is, a library function is
+executed on a JSON value whose type does not match the expected semantics.
+
+Exceptions have ids 3xx.
+
+name / id                     | example message | description
+----------------------------- | --------------- | -------------------------
+json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
+json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
+json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &.
+json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types.
+json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types.
+json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types.
+json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types.
+json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
+json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types.
+json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types.
+json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types.
+json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types.
+json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
+json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers.
+json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
+json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. |
+json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) |
+
+@liveexample{The following code shows how a `type_error` exception can be
+caught.,type_error}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class type_error : public exception
+{
+  public:
+    template<typename BasicJsonType>
+    static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg;
+        return type_error(id_, w.c_str());
+    }
+
+  private:
+    JSON_HEDLEY_NON_NULL(3)
+    type_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating access out of the defined range
+
+This exception is thrown in case a library function is called on an input
+parameter that exceeds the expected range, for instance in case of array
+indices or nonexisting object keys.
+
+Exceptions have ids 4xx.
+
+name / id                       | example message | description
+------------------------------- | --------------- | -------------------------
+json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1.
+json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.
+json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object.
+json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
+json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
+json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
+json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) |
+json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. |
+json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string |
+
+@liveexample{The following code shows how an `out_of_range` exception can be
+caught.,out_of_range}
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+                    a wrong type
+@sa - @ref other_error for exceptions indicating other library errors
+
+@since version 3.0.0
+*/
+class out_of_range : public exception
+{
+  public:
+    template<typename BasicJsonType>
+    static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg;
+        return out_of_range(id_, w.c_str());
+    }
+
+  private:
+    JSON_HEDLEY_NON_NULL(3)
+    out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+
+/*!
+@brief exception indicating other library errors
+
+This exception is thrown in case of errors that cannot be classified with the
+other exception types.
+
+Exceptions have ids 5xx.
+
+name / id                      | example message | description
+------------------------------ | --------------- | -------------------------
+json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
+
+@sa - @ref exception for the base class of the library exceptions
+@sa - @ref parse_error for exceptions indicating a parse error
+@sa - @ref invalid_iterator for exceptions indicating errors with iterators
+@sa - @ref type_error for exceptions indicating executing a member function with
+                    a wrong type
+@sa - @ref out_of_range for exceptions indicating access out of the defined range
+
+@liveexample{The following code shows how an `other_error` exception can be
+caught.,other_error}
+
+@since version 3.0.0
+*/
+class other_error : public exception
+{
+  public:
+    template<typename BasicJsonType>
+    static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context)
+    {
+        std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg;
+        return other_error(id_, w.c_str());
+    }
+
+  private:
+    JSON_HEDLEY_NON_NULL(3)
+    other_error(int id_, const char* what_arg) : exception(id_, what_arg) {}
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+
+#include <cstddef> // size_t
+#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
+#include <utility> // index_sequence, make_index_sequence, index_sequence_for
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+
+template<typename T>
+using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+
+#ifdef JSON_HAS_CPP_14
+
+// the following utilities are natively available in C++14
+using std::enable_if_t;
+using std::index_sequence;
+using std::make_index_sequence;
+using std::index_sequence_for;
+
+#else
+
+// alias templates to reduce boilerplate
+template<bool B, typename T = void>
+using enable_if_t = typename std::enable_if<B, T>::type;
+
+// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h
+// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0.
+
+//// START OF CODE FROM GOOGLE ABSEIL
+
+// integer_sequence
+//
+// Class template representing a compile-time integer sequence. An instantiation
+// of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its
+// type through its template arguments (which is a common need when
+// working with C++11 variadic templates). `absl::integer_sequence` is designed
+// to be a drop-in replacement for C++14's `std::integer_sequence`.
+//
+// Example:
+//
+//   template< class T, T... Ints >
+//   void user_function(integer_sequence<T, Ints...>);
+//
+//   int main()
+//   {
+//     // user_function's `T` will be deduced to `int` and `Ints...`
+//     // will be deduced to `0, 1, 2, 3, 4`.
+//     user_function(make_integer_sequence<int, 5>());
+//   }
+template <typename T, T... Ints>
+struct integer_sequence
+{
+    using value_type = T;
+    static constexpr std::size_t size() noexcept
+    {
+        return sizeof...(Ints);
+    }
+};
+
+// index_sequence
+//
+// A helper template for an `integer_sequence` of `size_t`,
+// `absl::index_sequence` is designed to be a drop-in replacement for C++14's
+// `std::index_sequence`.
+template <size_t... Ints>
+using index_sequence = integer_sequence<size_t, Ints...>;
+
+namespace utility_internal
+{
+
+template <typename Seq, size_t SeqSize, size_t Rem>
+struct Extend;
+
+// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
+template <typename T, T... Ints, size_t SeqSize>
+struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
+{
+    using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
+};
+
+template <typename T, T... Ints, size_t SeqSize>
+struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
+{
+    using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
+};
+
+// Recursion helper for 'make_integer_sequence<T, N>'.
+// 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
+template <typename T, size_t N>
+struct Gen
+{
+    using type =
+        typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
+};
+
+template <typename T>
+struct Gen<T, 0>
+{
+    using type = integer_sequence<T>;
+};
+
+}  // namespace utility_internal
+
+// Compile-time sequences of integers
+
+// make_integer_sequence
+//
+// This template alias is equivalent to
+// `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
+// replacement for C++14's `std::make_integer_sequence`.
+template <typename T, T N>
+using make_integer_sequence = typename utility_internal::Gen<T, N>::type;
+
+// make_index_sequence
+//
+// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`,
+// and is designed to be a drop-in replacement for C++14's
+// `std::make_index_sequence`.
+template <size_t N>
+using make_index_sequence = make_integer_sequence<size_t, N>;
+
+// index_sequence_for
+//
+// Converts a typename pack into an index sequence of the same length, and
+// is designed to be a drop-in replacement for C++14's
+// `std::index_sequence_for()`
+template <typename... Ts>
+using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
+
+//// END OF CODE FROM GOOGLE ABSEIL
+
+#endif
+
+// dispatch utility (taken from ranges-v3)
+template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
+template<> struct priority_tag<0> {};
+
+// taken from ranges-v3
+template<typename T>
+struct static_const
+{
+    static constexpr T value{};
+};
+
+template<typename T>
+constexpr T static_const<T>::value;
+
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/meta/identity_tag.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+// dispatching helper struct
+template <class T> struct identity_tag {};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+#include <limits> // numeric_limits
+#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
+#include <utility> // declval
+#include <tuple> // tuple
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+// #include <nlohmann/detail/iterators/iterator_traits.hpp>
+
+
+#include <iterator> // random_access_iterator_tag
+
+// #include <nlohmann/detail/meta/void_t.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename It, typename = void>
+struct iterator_types {};
+
+template<typename It>
+struct iterator_types <
+    It,
+    void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
+    typename It::reference, typename It::iterator_category >>
+{
+    using difference_type = typename It::difference_type;
+    using value_type = typename It::value_type;
+    using pointer = typename It::pointer;
+    using reference = typename It::reference;
+    using iterator_category = typename It::iterator_category;
+};
+
+// This is required as some compilers implement std::iterator_traits in a way that
+// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
+template<typename T, typename = void>
+struct iterator_traits
+{
+};
+
+template<typename T>
+struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
+            : iterator_types<T>
+{
+};
+
+template<typename T>
+struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
+{
+    using iterator_category = std::random_access_iterator_tag;
+    using value_type = T;
+    using difference_type = ptrdiff_t;
+    using pointer = T*;
+    using reference = T&;
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/meta/call_std/begin.hpp>
+
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin);
+} // namespace nlohmann
+
+// #include <nlohmann/detail/meta/call_std/end.hpp>
+
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end);
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/detected.hpp>
+
+// #include <nlohmann/json_fwd.hpp>
+#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
+#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
+
+#include <cstdint> // int64_t, uint64_t
+#include <map> // map
+#include <memory> // allocator
+#include <string> // string
+#include <vector> // vector
+
+/*!
+@brief namespace for Niels Lohmann
+@see https://github.com/nlohmann
+@since version 1.0.0
+*/
+namespace nlohmann
+{
+/*!
+@brief default JSONSerializer template argument
+
+This serializer ignores the template arguments and uses ADL
+([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
+for serialization.
+*/
+template<typename T = void, typename SFINAE = void>
+struct adl_serializer;
+
+template<template<typename U, typename V, typename... Args> class ObjectType =
+         std::map,
+         template<typename U, typename... Args> class ArrayType = std::vector,
+         class StringType = std::string, class BooleanType = bool,
+         class NumberIntegerType = std::int64_t,
+         class NumberUnsignedType = std::uint64_t,
+         class NumberFloatType = double,
+         template<typename U> class AllocatorType = std::allocator,
+         template<typename T, typename SFINAE = void> class JSONSerializer =
+         adl_serializer,
+         class BinaryType = std::vector<std::uint8_t>>
+class basic_json;
+
+/*!
+@brief JSON Pointer
+
+A JSON pointer defines a string syntax for identifying a specific value
+within a JSON document. It can be used with functions `at` and
+`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
+
+@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
+
+@since version 2.0.0
+*/
+template<typename BasicJsonType>
+class json_pointer;
+
+/*!
+@brief default JSON class
+
+This type is the default specialization of the @ref basic_json class which
+uses the standard template types.
+
+@since version 1.0.0
+*/
+using json = basic_json<>;
+
+template<class Key, class T, class IgnoredLess, class Allocator>
+struct ordered_map;
+
+/*!
+@brief ordered JSON class
+
+This type preserves the insertion order of object keys.
+
+@since version 3.9.0
+*/
+using ordered_json = basic_json<nlohmann::ordered_map>;
+
+}  // namespace nlohmann
+
+#endif  // INCLUDE_NLOHMANN_JSON_FWD_HPP_
+
+
+namespace nlohmann
+{
+/*!
+@brief detail namespace with internal helper functions
+
+This namespace collects functions that should not be exposed,
+implementations of some @ref basic_json methods, and meta-programming helpers.
+
+@since version 2.1.0
+*/
+namespace detail
+{
+/////////////
+// helpers //
+/////////////
+
+// Note to maintainers:
+//
+// Every trait in this file expects a non CV-qualified type.
+// The only exceptions are in the 'aliases for detected' section
+// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
+//
+// In this case, T has to be properly CV-qualified to constraint the function arguments
+// (e.g. to_json(BasicJsonType&, const T&))
+
+template<typename> struct is_basic_json : std::false_type {};
+
+NLOHMANN_BASIC_JSON_TPL_DECLARATION
+struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
+
+//////////////////////
+// json_ref helpers //
+//////////////////////
+
+template<typename>
+class json_ref;
+
+template<typename>
+struct is_json_ref : std::false_type {};
+
+template<typename T>
+struct is_json_ref<json_ref<T>> : std::true_type {};
+
+//////////////////////////
+// aliases for detected //
+//////////////////////////
+
+template<typename T>
+using mapped_type_t = typename T::mapped_type;
+
+template<typename T>
+using key_type_t = typename T::key_type;
+
+template<typename T>
+using value_type_t = typename T::value_type;
+
+template<typename T>
+using difference_type_t = typename T::difference_type;
+
+template<typename T>
+using pointer_t = typename T::pointer;
+
+template<typename T>
+using reference_t = typename T::reference;
+
+template<typename T>
+using iterator_category_t = typename T::iterator_category;
+
+template<typename T, typename... Args>
+using to_json_function = decltype(T::to_json(std::declval<Args>()...));
+
+template<typename T, typename... Args>
+using from_json_function = decltype(T::from_json(std::declval<Args>()...));
+
+template<typename T, typename U>
+using get_template_function = decltype(std::declval<T>().template get<U>());
+
+// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
+template<typename BasicJsonType, typename T, typename = void>
+struct has_from_json : std::false_type {};
+
+// trait checking if j.get<T> is valid
+// use this trait instead of std::is_constructible or std::is_convertible,
+// both rely on, or make use of implicit conversions, and thus fail when T
+// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958)
+template <typename BasicJsonType, typename T>
+struct is_getable
+{
+    static constexpr bool value = is_detected<get_template_function, const BasicJsonType&, T>::value;
+};
+
+template<typename BasicJsonType, typename T>
+struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
+{
+    using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+    static constexpr bool value =
+        is_detected_exact<void, from_json_function, serializer,
+        const BasicJsonType&, T&>::value;
+};
+
+// This trait checks if JSONSerializer<T>::from_json(json const&) exists
+// this overload is used for non-default-constructible user-defined-types
+template<typename BasicJsonType, typename T, typename = void>
+struct has_non_default_from_json : std::false_type {};
+
+template<typename BasicJsonType, typename T>
+struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
+{
+    using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+    static constexpr bool value =
+        is_detected_exact<T, from_json_function, serializer,
+        const BasicJsonType&>::value;
+};
+
+// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
+// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
+template<typename BasicJsonType, typename T, typename = void>
+struct has_to_json : std::false_type {};
+
+template<typename BasicJsonType, typename T>
+struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
+{
+    using serializer = typename BasicJsonType::template json_serializer<T, void>;
+
+    static constexpr bool value =
+        is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
+        T>::value;
+};
+
+
+///////////////////
+// is_ functions //
+///////////////////
+
+// https://en.cppreference.com/w/cpp/types/conjunction
+template<class...> struct conjunction : std::true_type { };
+template<class B1> struct conjunction<B1> : B1 { };
+template<class B1, class... Bn>
+struct conjunction<B1, Bn...>
+: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
+
+// https://en.cppreference.com/w/cpp/types/negation
+template<class B> struct negation : std::integral_constant < bool, !B::value > { };
+
+// Reimplementation of is_constructible and is_default_constructible, due to them being broken for
+// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
+// This causes compile errors in e.g. clang 3.5 or gcc 4.9.
+template <typename T>
+struct is_default_constructible : std::is_default_constructible<T> {};
+
+template <typename T1, typename T2>
+struct is_default_constructible<std::pair<T1, T2>>
+            : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
+
+template <typename T1, typename T2>
+struct is_default_constructible<const std::pair<T1, T2>>
+            : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
+
+template <typename... Ts>
+struct is_default_constructible<std::tuple<Ts...>>
+            : conjunction<is_default_constructible<Ts>...> {};
+
+template <typename... Ts>
+struct is_default_constructible<const std::tuple<Ts...>>
+            : conjunction<is_default_constructible<Ts>...> {};
+
+
+template <typename T, typename... Args>
+struct is_constructible : std::is_constructible<T, Args...> {};
+
+template <typename T1, typename T2>
+struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
+
+template <typename T1, typename T2>
+struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
+
+template <typename... Ts>
+struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
+
+template <typename... Ts>
+struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
+
+
+template<typename T, typename = void>
+struct is_iterator_traits : std::false_type {};
+
+template<typename T>
+struct is_iterator_traits<iterator_traits<T>>
+{
+  private:
+    using traits = iterator_traits<T>;
+
+  public:
+    static constexpr auto value =
+        is_detected<value_type_t, traits>::value &&
+        is_detected<difference_type_t, traits>::value &&
+        is_detected<pointer_t, traits>::value &&
+        is_detected<iterator_category_t, traits>::value &&
+        is_detected<reference_t, traits>::value;
+};
+
+template<typename T>
+struct is_range
+{
+  private:
+    using t_ref = typename std::add_lvalue_reference<T>::type;
+
+    using iterator = detected_t<result_of_begin, t_ref>;
+    using sentinel = detected_t<result_of_end, t_ref>;
+
+    // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator
+    // and https://en.cppreference.com/w/cpp/iterator/sentinel_for
+    // but reimplementing these would be too much work, as a lot of other concepts are used underneath
+    static constexpr auto is_iterator_begin =
+        is_iterator_traits<iterator_traits<iterator>>::value;
+
+  public:
+    static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
+};
+
+template<typename R>
+using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>;
+
+template<typename T>
+using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>;
+
+// The following implementation of is_complete_type is taken from
+// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
+// and is written by Xiang Fan who agreed to using it in this library.
+
+template<typename T, typename = void>
+struct is_complete_type : std::false_type {};
+
+template<typename T>
+struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
+
+template<typename BasicJsonType, typename CompatibleObjectType,
+         typename = void>
+struct is_compatible_object_type_impl : std::false_type {};
+
+template<typename BasicJsonType, typename CompatibleObjectType>
+struct is_compatible_object_type_impl <
+    BasicJsonType, CompatibleObjectType,
+    enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
+    is_detected<key_type_t, CompatibleObjectType>::value >>
+{
+    using object_t = typename BasicJsonType::object_t;
+
+    // macOS's is_constructible does not play well with nonesuch...
+    static constexpr bool value =
+        is_constructible<typename object_t::key_type,
+        typename CompatibleObjectType::key_type>::value &&
+        is_constructible<typename object_t::mapped_type,
+        typename CompatibleObjectType::mapped_type>::value;
+};
+
+template<typename BasicJsonType, typename CompatibleObjectType>
+struct is_compatible_object_type
+    : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
+
+template<typename BasicJsonType, typename ConstructibleObjectType,
+         typename = void>
+struct is_constructible_object_type_impl : std::false_type {};
+
+template<typename BasicJsonType, typename ConstructibleObjectType>
+struct is_constructible_object_type_impl <
+    BasicJsonType, ConstructibleObjectType,
+    enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&&
+    is_detected<key_type_t, ConstructibleObjectType>::value >>
+{
+    using object_t = typename BasicJsonType::object_t;
+
+    static constexpr bool value =
+        (is_default_constructible<ConstructibleObjectType>::value &&
+         (std::is_move_assignable<ConstructibleObjectType>::value ||
+          std::is_copy_assignable<ConstructibleObjectType>::value) &&
+         (is_constructible<typename ConstructibleObjectType::key_type,
+          typename object_t::key_type>::value &&
+          std::is_same <
+          typename object_t::mapped_type,
+          typename ConstructibleObjectType::mapped_type >::value)) ||
+        (has_from_json<BasicJsonType,
+         typename ConstructibleObjectType::mapped_type>::value ||
+         has_non_default_from_json <
+         BasicJsonType,
+         typename ConstructibleObjectType::mapped_type >::value);
+};
+
+template<typename BasicJsonType, typename ConstructibleObjectType>
+struct is_constructible_object_type
+    : is_constructible_object_type_impl<BasicJsonType,
+      ConstructibleObjectType> {};
+
+template<typename BasicJsonType, typename CompatibleStringType>
+struct is_compatible_string_type
+{
+    static constexpr auto value =
+        is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
+};
+
+template<typename BasicJsonType, typename ConstructibleStringType>
+struct is_constructible_string_type
+{
+    static constexpr auto value =
+        is_constructible<ConstructibleStringType,
+        typename BasicJsonType::string_t>::value;
+};
+
+template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
+struct is_compatible_array_type_impl : std::false_type {};
+
+template<typename BasicJsonType, typename CompatibleArrayType>
+struct is_compatible_array_type_impl <
+    BasicJsonType, CompatibleArrayType,
+    enable_if_t <
+    is_detected<iterator_t, CompatibleArrayType>::value&&
+    is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
+// special case for types like std::filesystem::path whose iterator's value_type are themselves
+// c.f. https://github.com/nlohmann/json/pull/3073
+    !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
+{
+    static constexpr bool value =
+        is_constructible<BasicJsonType,
+        range_value_t<CompatibleArrayType>>::value;
+};
+
+template<typename BasicJsonType, typename CompatibleArrayType>
+struct is_compatible_array_type
+    : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
+
+template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
+struct is_constructible_array_type_impl : std::false_type {};
+
+template<typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type_impl <
+    BasicJsonType, ConstructibleArrayType,
+    enable_if_t<std::is_same<ConstructibleArrayType,
+    typename BasicJsonType::value_type>::value >>
+            : std::true_type {};
+
+template<typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type_impl <
+    BasicJsonType, ConstructibleArrayType,
+    enable_if_t < !std::is_same<ConstructibleArrayType,
+    typename BasicJsonType::value_type>::value&&
+    !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
+    is_default_constructible<ConstructibleArrayType>::value&&
+(std::is_move_assignable<ConstructibleArrayType>::value ||
+ std::is_copy_assignable<ConstructibleArrayType>::value)&&
+is_detected<iterator_t, ConstructibleArrayType>::value&&
+is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
+is_detected<range_value_t, ConstructibleArrayType>::value&&
+// special case for types like std::filesystem::path whose iterator's value_type are themselves
+// c.f. https://github.com/nlohmann/json/pull/3073
+!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
+        is_complete_type <
+        detected_t<range_value_t, ConstructibleArrayType >>::value >>
+{
+    using value_type = range_value_t<ConstructibleArrayType>;
+
+    static constexpr bool value =
+        std::is_same<value_type,
+        typename BasicJsonType::array_t::value_type>::value ||
+        has_from_json<BasicJsonType,
+        value_type>::value ||
+        has_non_default_from_json <
+        BasicJsonType,
+        value_type >::value;
+};
+
+template<typename BasicJsonType, typename ConstructibleArrayType>
+struct is_constructible_array_type
+    : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
+
+template<typename RealIntegerType, typename CompatibleNumberIntegerType,
+         typename = void>
+struct is_compatible_integer_type_impl : std::false_type {};
+
+template<typename RealIntegerType, typename CompatibleNumberIntegerType>
+struct is_compatible_integer_type_impl <
+    RealIntegerType, CompatibleNumberIntegerType,
+    enable_if_t < std::is_integral<RealIntegerType>::value&&
+    std::is_integral<CompatibleNumberIntegerType>::value&&
+    !std::is_same<bool, CompatibleNumberIntegerType>::value >>
+{
+    // is there an assert somewhere on overflows?
+    using RealLimits = std::numeric_limits<RealIntegerType>;
+    using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
+
+    static constexpr auto value =
+        is_constructible<RealIntegerType,
+        CompatibleNumberIntegerType>::value &&
+        CompatibleLimits::is_integer &&
+        RealLimits::is_signed == CompatibleLimits::is_signed;
+};
+
+template<typename RealIntegerType, typename CompatibleNumberIntegerType>
+struct is_compatible_integer_type
+    : is_compatible_integer_type_impl<RealIntegerType,
+      CompatibleNumberIntegerType> {};
+
+template<typename BasicJsonType, typename CompatibleType, typename = void>
+struct is_compatible_type_impl: std::false_type {};
+
+template<typename BasicJsonType, typename CompatibleType>
+struct is_compatible_type_impl <
+    BasicJsonType, CompatibleType,
+    enable_if_t<is_complete_type<CompatibleType>::value >>
+{
+    static constexpr bool value =
+        has_to_json<BasicJsonType, CompatibleType>::value;
+};
+
+template<typename BasicJsonType, typename CompatibleType>
+struct is_compatible_type
+    : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
+
+template<typename T1, typename T2>
+struct is_constructible_tuple : std::false_type {};
+
+template<typename T1, typename... Args>
+struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
+
+// a naive helper to check if a type is an ordered_map (exploits the fact that
+// ordered_map inherits capacity() from std::vector)
+template <typename T>
+struct is_ordered_map
+{
+    using one = char;
+
+    struct two
+    {
+        char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+    };
+
+    template <typename C> static one test( decltype(&C::capacity) ) ;
+    template <typename C> static two test(...);
+
+    enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+};
+
+// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
+template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 >
+T conditional_static_cast(U value)
+{
+    return static_cast<T>(value);
+}
+
+template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
+T conditional_static_cast(U value)
+{
+    return value;
+}
+
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+#ifdef JSON_HAS_CPP_17
+    #include <filesystem>
+#endif
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_null()))
+    {
+        JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j));
+    }
+    n = nullptr;
+}
+
+// overloads for basic_json template parameters
+template < typename BasicJsonType, typename ArithmeticType,
+           enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
+                         !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
+                         int > = 0 >
+void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
+{
+    switch (static_cast<value_t>(j))
+    {
+        case value_t::number_unsigned:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
+            break;
+        }
+        case value_t::number_integer:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
+            break;
+        }
+        case value_t::number_float:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
+            break;
+        }
+
+        case value_t::null:
+        case value_t::object:
+        case value_t::array:
+        case value_t::string:
+        case value_t::boolean:
+        case value_t::binary:
+        case value_t::discarded:
+        default:
+            JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
+    }
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_boolean()))
+    {
+        JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j));
+    }
+    b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
+    {
+        JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
+    }
+    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
+}
+
+template <
+    typename BasicJsonType, typename ConstructibleStringType,
+    enable_if_t <
+        is_constructible_string_type<BasicJsonType, ConstructibleStringType>::value&&
+        !std::is_same<typename BasicJsonType::string_t,
+                      ConstructibleStringType>::value,
+        int > = 0 >
+void from_json(const BasicJsonType& j, ConstructibleStringType& s)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
+    {
+        JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
+    }
+
+    s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val)
+{
+    get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val)
+{
+    get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val)
+{
+    get_arithmetic_value(j, val);
+}
+
+template<typename BasicJsonType, typename EnumType,
+         enable_if_t<std::is_enum<EnumType>::value, int> = 0>
+void from_json(const BasicJsonType& j, EnumType& e)
+{
+    typename std::underlying_type<EnumType>::type val;
+    get_arithmetic_value(j, val);
+    e = static_cast<EnumType>(val);
+}
+
+// forward_list doesn't have an insert method
+template<typename BasicJsonType, typename T, typename Allocator,
+         enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
+void from_json(const BasicJsonType& j, std::forward_list<T, Allocator>& l)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+    l.clear();
+    std::transform(j.rbegin(), j.rend(),
+                   std::front_inserter(l), [](const BasicJsonType & i)
+    {
+        return i.template get<T>();
+    });
+}
+
+// valarray doesn't have an insert method
+template<typename BasicJsonType, typename T,
+         enable_if_t<is_getable<BasicJsonType, T>::value, int> = 0>
+void from_json(const BasicJsonType& j, std::valarray<T>& l)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+    l.resize(j.size());
+    std::transform(j.begin(), j.end(), std::begin(l),
+                   [](const BasicJsonType & elem)
+    {
+        return elem.template get<T>();
+    });
+}
+
+template<typename BasicJsonType, typename T, std::size_t N>
+auto from_json(const BasicJsonType& j, T (&arr)[N])  // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+-> decltype(j.template get<T>(), void())
+{
+    for (std::size_t i = 0; i < N; ++i)
+    {
+        arr[i] = j.at(i).template get<T>();
+    }
+}
+
+template<typename BasicJsonType>
+void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/)
+{
+    arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
+}
+
+template<typename BasicJsonType, typename T, std::size_t N>
+auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr,
+                          priority_tag<2> /*unused*/)
+-> decltype(j.template get<T>(), void())
+{
+    for (std::size_t i = 0; i < N; ++i)
+    {
+        arr[i] = j.at(i).template get<T>();
+    }
+}
+
+template<typename BasicJsonType, typename ConstructibleArrayType,
+         enable_if_t<
+             std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
+             int> = 0>
+auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
+-> decltype(
+    arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
+    j.template get<typename ConstructibleArrayType::value_type>(),
+    void())
+{
+    using std::end;
+
+    ConstructibleArrayType ret;
+    ret.reserve(j.size());
+    std::transform(j.begin(), j.end(),
+                   std::inserter(ret, end(ret)), [](const BasicJsonType & i)
+    {
+        // get<BasicJsonType>() returns *this, this won't call a from_json
+        // method when value_type is BasicJsonType
+        return i.template get<typename ConstructibleArrayType::value_type>();
+    });
+    arr = std::move(ret);
+}
+
+template<typename BasicJsonType, typename ConstructibleArrayType,
+         enable_if_t<
+             std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
+             int> = 0>
+void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr,
+                          priority_tag<0> /*unused*/)
+{
+    using std::end;
+
+    ConstructibleArrayType ret;
+    std::transform(
+        j.begin(), j.end(), std::inserter(ret, end(ret)),
+        [](const BasicJsonType & i)
+    {
+        // get<BasicJsonType>() returns *this, this won't call a from_json
+        // method when value_type is BasicJsonType
+        return i.template get<typename ConstructibleArrayType::value_type>();
+    });
+    arr = std::move(ret);
+}
+
+template < typename BasicJsonType, typename ConstructibleArrayType,
+           enable_if_t <
+               is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
+               !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
+               !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
+               !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
+               !is_basic_json<ConstructibleArrayType>::value,
+               int > = 0 >
+auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
+-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
+j.template get<typename ConstructibleArrayType::value_type>(),
+void())
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+
+    from_json_array_impl(j, arr, priority_tag<3> {});
+}
+
+template < typename BasicJsonType, typename T, std::size_t... Idx >
+std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
+        identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
+{
+    return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
+}
+
+template < typename BasicJsonType, typename T, std::size_t N >
+auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
+-> decltype(from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {}))
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+
+    return from_json_inplace_array_impl(std::forward<BasicJsonType>(j), tag, make_index_sequence<N> {});
+}
+
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_binary()))
+    {
+        JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j));
+    }
+
+    bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
+}
+
+template<typename BasicJsonType, typename ConstructibleObjectType,
+         enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
+void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
+    {
+        JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j));
+    }
+
+    ConstructibleObjectType ret;
+    const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
+    using value_type = typename ConstructibleObjectType::value_type;
+    std::transform(
+        inner_object->begin(), inner_object->end(),
+        std::inserter(ret, ret.begin()),
+        [](typename BasicJsonType::object_t::value_type const & p)
+    {
+        return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
+    });
+    obj = std::move(ret);
+}
+
+// overload for arithmetic types, not chosen for basic_json template arguments
+// (BooleanType, etc..); note: Is it really necessary to provide explicit
+// overloads for boolean_t etc. in case of a custom BooleanType which is not
+// an arithmetic type?
+template < typename BasicJsonType, typename ArithmeticType,
+           enable_if_t <
+               std::is_arithmetic<ArithmeticType>::value&&
+               !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
+               !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
+               !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
+               !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
+               int > = 0 >
+void from_json(const BasicJsonType& j, ArithmeticType& val)
+{
+    switch (static_cast<value_t>(j))
+    {
+        case value_t::number_unsigned:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
+            break;
+        }
+        case value_t::number_integer:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
+            break;
+        }
+        case value_t::number_float:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
+            break;
+        }
+        case value_t::boolean:
+        {
+            val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
+            break;
+        }
+
+        case value_t::null:
+        case value_t::object:
+        case value_t::array:
+        case value_t::string:
+        case value_t::binary:
+        case value_t::discarded:
+        default:
+            JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
+    }
+}
+
+template<typename BasicJsonType, typename... Args, std::size_t... Idx>
+std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
+{
+    return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...);
+}
+
+template < typename BasicJsonType, class A1, class A2 >
+std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
+{
+    return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
+            std::forward<BasicJsonType>(j).at(1).template get<A2>()};
+}
+
+template<typename BasicJsonType, typename A1, typename A2>
+void from_json_tuple_impl(BasicJsonType&& j, std::pair<A1, A2>& p, priority_tag<1> /*unused*/)
+{
+    p = from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
+}
+
+template<typename BasicJsonType, typename... Args>
+std::tuple<Args...> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::tuple<Args...>> /*unused*/, priority_tag<2> /*unused*/)
+{
+    return from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
+}
+
+template<typename BasicJsonType, typename... Args>
+void from_json_tuple_impl(BasicJsonType&& j, std::tuple<Args...>& t, priority_tag<3> /*unused*/)
+{
+    t = from_json_tuple_impl_base<BasicJsonType, Args...>(std::forward<BasicJsonType>(j), index_sequence_for<Args...> {});
+}
+
+template<typename BasicJsonType, typename TupleRelated>
+auto from_json(BasicJsonType&& j, TupleRelated&& t)
+-> decltype(from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+
+    return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
+}
+
+template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
+           typename = enable_if_t < !std::is_constructible <
+                                        typename BasicJsonType::string_t, Key >::value >>
+void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+    m.clear();
+    for (const auto& p : j)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
+        {
+            JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
+        }
+        m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
+    }
+}
+
+template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator,
+           typename = enable_if_t < !std::is_constructible <
+                                        typename BasicJsonType::string_t, Key >::value >>
+void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
+    {
+        JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j));
+    }
+    m.clear();
+    for (const auto& p : j)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!p.is_array()))
+        {
+            JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j));
+        }
+        m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
+    }
+}
+
+#ifdef JSON_HAS_CPP_17
+template<typename BasicJsonType>
+void from_json(const BasicJsonType& j, std::filesystem::path& p)
+{
+    if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
+    {
+        JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j));
+    }
+    p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
+}
+#endif
+
+struct from_json_fn
+{
+    template<typename BasicJsonType, typename T>
+    auto operator()(const BasicJsonType& j, T&& val) const
+    noexcept(noexcept(from_json(j, std::forward<T>(val))))
+    -> decltype(from_json(j, std::forward<T>(val)))
+    {
+        return from_json(j, std::forward<T>(val));
+    }
+};
+}  // namespace detail
+
+/// namespace to hold default `from_json` function
+/// to see why this is required:
+/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
+namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
+{
+constexpr const auto& from_json = detail::static_const<detail::from_json_fn>::value; // NOLINT(misc-definitions-in-headers)
+} // namespace
+} // namespace nlohmann
+
+// #include <nlohmann/detail/conversions/to_json.hpp>
+
+
+#include <algorithm> // copy
+#include <iterator> // begin, end
+#include <string> // string
+#include <tuple> // tuple, get
+#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
+#include <utility> // move, forward, declval, pair
+#include <valarray> // valarray
+#include <vector> // vector
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
+
+
+#include <cstddef> // size_t
+#include <iterator> // input_iterator_tag
+#include <string> // string, to_string
+#include <tuple> // tuple_size, get, tuple_element
+#include <utility> // move
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename string_type>
+void int_to_string( string_type& target, std::size_t value )
+{
+    // For ADL
+    using std::to_string;
+    target = to_string(value);
+}
+template<typename IteratorType> class iteration_proxy_value
+{
+  public:
+    using difference_type = std::ptrdiff_t;
+    using value_type = iteration_proxy_value;
+    using pointer = value_type * ;
+    using reference = value_type & ;
+    using iterator_category = std::input_iterator_tag;
+    using string_type = typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().key() ) >::type >::type;
+
+  private:
+    /// the iterator
+    IteratorType anchor;
+    /// an index for arrays (used to create key names)
+    std::size_t array_index = 0;
+    /// last stringified array index
+    mutable std::size_t array_index_last = 0;
+    /// a string representation of the array index
+    mutable string_type array_index_str = "0";
+    /// an empty string (to return a reference for primitive values)
+    const string_type empty_str{};
+
+  public:
+    explicit iteration_proxy_value(IteratorType it) noexcept
+        : anchor(std::move(it))
+    {}
+
+    /// dereference operator (needed for range-based for)
+    iteration_proxy_value& operator*()
+    {
+        return *this;
+    }
+
+    /// increment operator (needed for range-based for)
+    iteration_proxy_value& operator++()
+    {
+        ++anchor;
+        ++array_index;
+
+        return *this;
+    }
+
+    /// equality operator (needed for InputIterator)
+    bool operator==(const iteration_proxy_value& o) const
+    {
+        return anchor == o.anchor;
+    }
+
+    /// inequality operator (needed for range-based for)
+    bool operator!=(const iteration_proxy_value& o) const
+    {
+        return anchor != o.anchor;
+    }
+
+    /// return key of the iterator
+    const string_type& key() const
+    {
+        JSON_ASSERT(anchor.m_object != nullptr);
+
+        switch (anchor.m_object->type())
+        {
+            // use integer array index as key
+            case value_t::array:
+            {
+                if (array_index != array_index_last)
+                {
+                    int_to_string( array_index_str, array_index );
+                    array_index_last = array_index;
+                }
+                return array_index_str;
+            }
+
+            // use key from the object
+            case value_t::object:
+                return anchor.key();
+
+            // use an empty key for all primitive types
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                return empty_str;
+        }
+    }
+
+    /// return value of the iterator
+    typename IteratorType::reference value() const
+    {
+        return anchor.value();
+    }
+};
+
+/// proxy class for the items() function
+template<typename IteratorType> class iteration_proxy
+{
+  private:
+    /// the container to iterate
+    typename IteratorType::reference container;
+
+  public:
+    /// construct iteration proxy from a container
+    explicit iteration_proxy(typename IteratorType::reference cont) noexcept
+        : container(cont) {}
+
+    /// return iterator begin (needed for range-based for)
+    iteration_proxy_value<IteratorType> begin() noexcept
+    {
+        return iteration_proxy_value<IteratorType>(container.begin());
+    }
+
+    /// return iterator end (needed for range-based for)
+    iteration_proxy_value<IteratorType> end() noexcept
+    {
+        return iteration_proxy_value<IteratorType>(container.end());
+    }
+};
+// Structured Bindings Support
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
+auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
+{
+    return i.key();
+}
+// Structured Bindings Support
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
+auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
+{
+    return i.value();
+}
+}  // namespace detail
+}  // namespace nlohmann
+
+// The Addition to the STD Namespace is required to add
+// Structured Bindings Support to the iteration_proxy_value class
+// For further reference see https://blog.tartanllama.xyz/structured-bindings/
+// And see https://github.com/nlohmann/json/pull/1391
+namespace std
+{
+#if defined(__clang__)
+    // Fix: https://github.com/nlohmann/json/issues/1401
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wmismatched-tags"
+#endif
+template<typename IteratorType>
+class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
+            : public std::integral_constant<std::size_t, 2> {};
+
+template<std::size_t N, typename IteratorType>
+class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
+{
+  public:
+    using type = decltype(
+                     get<N>(std::declval <
+                            ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
+};
+#if defined(__clang__)
+    #pragma clang diagnostic pop
+#endif
+} // namespace std
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+#ifdef JSON_HAS_CPP_17
+    #include <filesystem>
+#endif
+
+namespace nlohmann
+{
+namespace detail
+{
+//////////////////
+// constructors //
+//////////////////
+
+/*
+ * Note all external_constructor<>::construct functions need to call
+ * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an
+ * allocated value (e.g., a string). See bug issue
+ * https://github.com/nlohmann/json/issues/2865 for more information.
+ */
+
+template<value_t> struct external_constructor;
+
+template<>
+struct external_constructor<value_t::boolean>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::boolean;
+        j.m_value = b;
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::string>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::string;
+        j.m_value = s;
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::string;
+        j.m_value = std::move(s);
+        j.assert_invariant();
+    }
+
+    template < typename BasicJsonType, typename CompatibleStringType,
+               enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
+                             int > = 0 >
+    static void construct(BasicJsonType& j, const CompatibleStringType& str)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::string;
+        j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::binary>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::binary;
+        j.m_value = typename BasicJsonType::binary_t(b);
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::binary;
+        j.m_value = typename BasicJsonType::binary_t(std::move(b));
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::number_float>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::number_float;
+        j.m_value = val;
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::number_unsigned>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::number_unsigned;
+        j.m_value = val;
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::number_integer>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::number_integer;
+        j.m_value = val;
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::array>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::array;
+        j.m_value = arr;
+        j.set_parents();
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::array;
+        j.m_value = std::move(arr);
+        j.set_parents();
+        j.assert_invariant();
+    }
+
+    template < typename BasicJsonType, typename CompatibleArrayType,
+               enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
+                             int > = 0 >
+    static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
+    {
+        using std::begin;
+        using std::end;
+
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::array;
+        j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
+        j.set_parents();
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, const std::vector<bool>& arr)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::array;
+        j.m_value = value_t::array;
+        j.m_value.array->reserve(arr.size());
+        for (const bool x : arr)
+        {
+            j.m_value.array->push_back(x);
+            j.set_parent(j.m_value.array->back());
+        }
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType, typename T,
+             enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
+    static void construct(BasicJsonType& j, const std::valarray<T>& arr)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::array;
+        j.m_value = value_t::array;
+        j.m_value.array->resize(arr.size());
+        if (arr.size() > 0)
+        {
+            std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
+        }
+        j.set_parents();
+        j.assert_invariant();
+    }
+};
+
+template<>
+struct external_constructor<value_t::object>
+{
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::object;
+        j.m_value = obj;
+        j.set_parents();
+        j.assert_invariant();
+    }
+
+    template<typename BasicJsonType>
+    static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
+    {
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::object;
+        j.m_value = std::move(obj);
+        j.set_parents();
+        j.assert_invariant();
+    }
+
+    template < typename BasicJsonType, typename CompatibleObjectType,
+               enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int > = 0 >
+    static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
+    {
+        using std::begin;
+        using std::end;
+
+        j.m_value.destroy(j.m_type);
+        j.m_type = value_t::object;
+        j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
+        j.set_parents();
+        j.assert_invariant();
+    }
+};
+
+/////////////
+// to_json //
+/////////////
+
+template<typename BasicJsonType, typename T,
+         enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value, int> = 0>
+void to_json(BasicJsonType& j, T b) noexcept
+{
+    external_constructor<value_t::boolean>::construct(j, b);
+}
+
+template<typename BasicJsonType, typename CompatibleString,
+         enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
+void to_json(BasicJsonType& j, const CompatibleString& s)
+{
+    external_constructor<value_t::string>::construct(j, s);
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
+{
+    external_constructor<value_t::string>::construct(j, std::move(s));
+}
+
+template<typename BasicJsonType, typename FloatType,
+         enable_if_t<std::is_floating_point<FloatType>::value, int> = 0>
+void to_json(BasicJsonType& j, FloatType val) noexcept
+{
+    external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
+}
+
+template<typename BasicJsonType, typename CompatibleNumberUnsignedType,
+         enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
+void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
+{
+    external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
+}
+
+template<typename BasicJsonType, typename CompatibleNumberIntegerType,
+         enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
+void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
+{
+    external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
+}
+
+template<typename BasicJsonType, typename EnumType,
+         enable_if_t<std::is_enum<EnumType>::value, int> = 0>
+void to_json(BasicJsonType& j, EnumType e) noexcept
+{
+    using underlying_type = typename std::underlying_type<EnumType>::type;
+    external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, const std::vector<bool>& e)
+{
+    external_constructor<value_t::array>::construct(j, e);
+}
+
+template < typename BasicJsonType, typename CompatibleArrayType,
+           enable_if_t < is_compatible_array_type<BasicJsonType,
+                         CompatibleArrayType>::value&&
+                         !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
+                         !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&&
+                         !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
+                         !is_basic_json<CompatibleArrayType>::value,
+                         int > = 0 >
+void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
+{
+    external_constructor<value_t::array>::construct(j, arr);
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
+{
+    external_constructor<value_t::binary>::construct(j, bin);
+}
+
+template<typename BasicJsonType, typename T,
+         enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
+void to_json(BasicJsonType& j, const std::valarray<T>& arr)
+{
+    external_constructor<value_t::array>::construct(j, std::move(arr));
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
+{
+    external_constructor<value_t::array>::construct(j, std::move(arr));
+}
+
+template < typename BasicJsonType, typename CompatibleObjectType,
+           enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value, int > = 0 >
+void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
+{
+    external_constructor<value_t::object>::construct(j, obj);
+}
+
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
+{
+    external_constructor<value_t::object>::construct(j, std::move(obj));
+}
+
+template <
+    typename BasicJsonType, typename T, std::size_t N,
+    enable_if_t < !std::is_constructible<typename BasicJsonType::string_t,
+                  const T(&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+                  int > = 0 >
+void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+{
+    external_constructor<value_t::array>::construct(j, arr);
+}
+
+template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value, int > = 0 >
+void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
+{
+    j = { p.first, p.second };
+}
+
+// for https://github.com/nlohmann/json/pull/1134
+template<typename BasicJsonType, typename T,
+         enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
+void to_json(BasicJsonType& j, const T& b)
+{
+    j = { {b.key(), b.value()} };
+}
+
+template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
+void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/)
+{
+    j = { std::get<Idx>(t)... };
+}
+
+template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value, int > = 0>
+void to_json(BasicJsonType& j, const T& t)
+{
+    to_json_tuple_impl(j, t, make_index_sequence<std::tuple_size<T>::value> {});
+}
+
+#ifdef JSON_HAS_CPP_17
+template<typename BasicJsonType>
+void to_json(BasicJsonType& j, const std::filesystem::path& p)
+{
+    j = p.string();
+}
+#endif
+
+struct to_json_fn
+{
+    template<typename BasicJsonType, typename T>
+    auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
+    -> decltype(to_json(j, std::forward<T>(val)), void())
+    {
+        return to_json(j, std::forward<T>(val));
+    }
+};
+}  // namespace detail
+
+/// namespace to hold default `to_json` function
+/// to see why this is required:
+/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html
+namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces)
+{
+constexpr const auto& to_json = detail::static_const<detail::to_json_fn>::value; // NOLINT(misc-definitions-in-headers)
+} // namespace
+} // namespace nlohmann
+
+// #include <nlohmann/detail/meta/identity_tag.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+namespace nlohmann
+{
+
+template<typename ValueType, typename>
+struct adl_serializer
+{
+    /*!
+    @brief convert a JSON value to any value type
+
+    This function is usually called by the `get()` function of the
+    @ref basic_json class (either explicit or via conversion operators).
+
+    @note This function is chosen for default-constructible value types.
+
+    @param[in] j        JSON value to read from
+    @param[in,out] val  value to write to
+    */
+    template<typename BasicJsonType, typename TargetType = ValueType>
+    static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
+        noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
+    -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
+    {
+        ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
+    }
+
+    /*!
+    @brief convert a JSON value to any value type
+
+    This function is usually called by the `get()` function of the
+    @ref basic_json class (either explicit or via conversion operators).
+
+    @note This function is chosen for value types which are not default-constructible.
+
+    @param[in] j  JSON value to read from
+
+    @return copy of the JSON value, converted to @a ValueType
+    */
+    template<typename BasicJsonType, typename TargetType = ValueType>
+    static auto from_json(BasicJsonType && j) noexcept(
+    noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
+    -> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
+    {
+        return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
+    }
+
+    /*!
+    @brief convert any value type to a JSON value
+
+    This function is usually called by the constructors of the @ref basic_json
+    class.
+
+    @param[in,out] j  JSON value to write to
+    @param[in] val    value to read from
+    */
+    template<typename BasicJsonType, typename TargetType = ValueType>
+    static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
+        noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
+    -> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
+    {
+        ::nlohmann::to_json(j, std::forward<TargetType>(val));
+    }
+};
+}  // namespace nlohmann
+
+// #include <nlohmann/byte_container_with_subtype.hpp>
+
+
+#include <cstdint> // uint8_t, uint64_t
+#include <tuple> // tie
+#include <utility> // move
+
+namespace nlohmann
+{
+
+/*!
+@brief an internal type for a backed binary type
+
+This type extends the template parameter @a BinaryType provided to `basic_json`
+with a subtype used by BSON and MessagePack. This type exists so that the user
+does not have to specify a type themselves with a specific naming scheme in
+order to override the binary type.
+
+@tparam BinaryType container to store bytes (`std::vector<std::uint8_t>` by
+                   default)
+
+@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.10.0.
+*/
+template<typename BinaryType>
+class byte_container_with_subtype : public BinaryType
+{
+  public:
+    /// the type of the underlying container
+    using container_type = BinaryType;
+    /// the type of the subtype
+    using subtype_type = std::uint64_t;
+
+    byte_container_with_subtype() noexcept(noexcept(container_type()))
+        : container_type()
+    {}
+
+    byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b)))
+        : container_type(b)
+    {}
+
+    byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
+        : container_type(std::move(b))
+    {}
+
+    byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
+        : container_type(b)
+        , m_subtype(subtype_)
+        , m_has_subtype(true)
+    {}
+
+    byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
+        : container_type(std::move(b))
+        , m_subtype(subtype_)
+        , m_has_subtype(true)
+    {}
+
+    bool operator==(const byte_container_with_subtype& rhs) const
+    {
+        return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
+               std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
+    }
+
+    bool operator!=(const byte_container_with_subtype& rhs) const
+    {
+        return !(rhs == *this);
+    }
+
+    /*!
+    @brief sets the binary subtype
+
+    Sets the binary subtype of the value, also flags a binary JSON value as
+    having a subtype, which has implications for serialization.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @sa see @ref subtype() -- return the binary subtype
+    @sa see @ref clear_subtype() -- clears the binary subtype
+    @sa see @ref has_subtype() -- returns whether or not the binary value has a
+    subtype
+
+    @since version 3.8.0
+    */
+    void set_subtype(subtype_type subtype_) noexcept
+    {
+        m_subtype = subtype_;
+        m_has_subtype = true;
+    }
+
+    /*!
+    @brief return the binary subtype
+
+    Returns the numerical subtype of the value if it has a subtype. If it does
+    not have a subtype, this function will return subtype_type(-1) as a sentinel
+    value.
+
+    @return the numerical subtype of the binary value
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @sa see @ref set_subtype() -- sets the binary subtype
+    @sa see @ref clear_subtype() -- clears the binary subtype
+    @sa see @ref has_subtype() -- returns whether or not the binary value has a
+    subtype
+
+    @since version 3.8.0; fixed return value to properly return
+           subtype_type(-1) as documented in version 3.10.0
+    */
+    constexpr subtype_type subtype() const noexcept
+    {
+        return m_has_subtype ? m_subtype : subtype_type(-1);
+    }
+
+    /*!
+    @brief return whether the value has a subtype
+
+    @return whether the value has a subtype
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @sa see @ref subtype() -- return the binary subtype
+    @sa see @ref set_subtype() -- sets the binary subtype
+    @sa see @ref clear_subtype() -- clears the binary subtype
+
+    @since version 3.8.0
+    */
+    constexpr bool has_subtype() const noexcept
+    {
+        return m_has_subtype;
+    }
+
+    /*!
+    @brief clears the binary subtype
+
+    Clears the binary subtype and flags the value as not having a subtype, which
+    has implications for serialization; for instance MessagePack will prefer the
+    bin family over the ext family.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @sa see @ref subtype() -- return the binary subtype
+    @sa see @ref set_subtype() -- sets the binary subtype
+    @sa see @ref has_subtype() -- returns whether or not the binary value has a
+    subtype
+
+    @since version 3.8.0
+    */
+    void clear_subtype() noexcept
+    {
+        m_subtype = 0;
+        m_has_subtype = false;
+    }
+
+  private:
+    subtype_type m_subtype = 0;
+    bool m_has_subtype = false;
+};
+
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/conversions/from_json.hpp>
+
+// #include <nlohmann/detail/conversions/to_json.hpp>
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/hash.hpp>
+
+
+#include <cstdint> // uint8_t
+#include <cstddef> // size_t
+#include <functional> // hash
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+
+// boost::hash_combine
+inline std::size_t combine(std::size_t seed, std::size_t h) noexcept
+{
+    seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
+    return seed;
+}
+
+/*!
+@brief hash a JSON value
+
+The hash function tries to rely on std::hash where possible. Furthermore, the
+type of the JSON value is taken into account to have different hash values for
+null, 0, 0U, and false, etc.
+
+@tparam BasicJsonType basic_json specialization
+@param j JSON value to hash
+@return hash value of j
+*/
+template<typename BasicJsonType>
+std::size_t hash(const BasicJsonType& j)
+{
+    using string_t = typename BasicJsonType::string_t;
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+
+    const auto type = static_cast<std::size_t>(j.type());
+    switch (j.type())
+    {
+        case BasicJsonType::value_t::null:
+        case BasicJsonType::value_t::discarded:
+        {
+            return combine(type, 0);
+        }
+
+        case BasicJsonType::value_t::object:
+        {
+            auto seed = combine(type, j.size());
+            for (const auto& element : j.items())
+            {
+                const auto h = std::hash<string_t> {}(element.key());
+                seed = combine(seed, h);
+                seed = combine(seed, hash(element.value()));
+            }
+            return seed;
+        }
+
+        case BasicJsonType::value_t::array:
+        {
+            auto seed = combine(type, j.size());
+            for (const auto& element : j)
+            {
+                seed = combine(seed, hash(element));
+            }
+            return seed;
+        }
+
+        case BasicJsonType::value_t::string:
+        {
+            const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
+            return combine(type, h);
+        }
+
+        case BasicJsonType::value_t::boolean:
+        {
+            const auto h = std::hash<bool> {}(j.template get<bool>());
+            return combine(type, h);
+        }
+
+        case BasicJsonType::value_t::number_integer:
+        {
+            const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
+            return combine(type, h);
+        }
+
+        case BasicJsonType::value_t::number_unsigned:
+        {
+            const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
+            return combine(type, h);
+        }
+
+        case BasicJsonType::value_t::number_float:
+        {
+            const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
+            return combine(type, h);
+        }
+
+        case BasicJsonType::value_t::binary:
+        {
+            auto seed = combine(type, j.get_binary().size());
+            const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
+            seed = combine(seed, h);
+            seed = combine(seed, static_cast<std::size_t>(j.get_binary().subtype()));
+            for (const auto byte : j.get_binary())
+            {
+                seed = combine(seed, std::hash<std::uint8_t> {}(byte));
+            }
+            return seed;
+        }
+
+        default:                   // LCOV_EXCL_LINE
+            JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+            return 0;              // LCOV_EXCL_LINE
+    }
+}
+
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/input/binary_reader.hpp>
+
+
+#include <algorithm> // generate_n
+#include <array> // array
+#include <cmath> // ldexp
+#include <cstddef> // size_t
+#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
+#include <cstdio> // snprintf
+#include <cstring> // memcpy
+#include <iterator> // back_inserter
+#include <limits> // numeric_limits
+#include <string> // char_traits, string
+#include <utility> // make_pair, move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+
+#include <array> // array
+#include <cstddef> // size_t
+#include <cstring> // strlen
+#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
+#include <memory> // shared_ptr, make_shared, addressof
+#include <numeric> // accumulate
+#include <string> // string, char_traits
+#include <type_traits> // enable_if, is_base_of, is_pointer, is_integral, remove_pointer
+#include <utility> // pair, declval
+
+#ifndef JSON_NO_IO
+    #include <cstdio>   // FILE *
+    #include <istream>  // istream
+#endif                  // JSON_NO_IO
+
+// #include <nlohmann/detail/iterators/iterator_traits.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/// the supported input formats
+enum class input_format_t { json, cbor, msgpack, ubjson, bson };
+
+////////////////////
+// input adapters //
+////////////////////
+
+#ifndef JSON_NO_IO
+/*!
+Input adapter for stdio file access. This adapter read only 1 byte and do not use any
+ buffer. This adapter is a very low level adapter.
+*/
+class file_input_adapter
+{
+  public:
+    using char_type = char;
+
+    JSON_HEDLEY_NON_NULL(2)
+    explicit file_input_adapter(std::FILE* f) noexcept
+        : m_file(f)
+    {}
+
+    // make class move-only
+    file_input_adapter(const file_input_adapter&) = delete;
+    file_input_adapter(file_input_adapter&&) noexcept = default;
+    file_input_adapter& operator=(const file_input_adapter&) = delete;
+    file_input_adapter& operator=(file_input_adapter&&) = delete;
+    ~file_input_adapter() = default;
+
+    std::char_traits<char>::int_type get_character() noexcept
+    {
+        return std::fgetc(m_file);
+    }
+
+  private:
+    /// the file pointer to read from
+    std::FILE* m_file;
+};
+
+
+/*!
+Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at
+beginning of input. Does not support changing the underlying std::streambuf
+in mid-input. Maintains underlying std::istream and std::streambuf to support
+subsequent use of standard std::istream operations to process any input
+characters following those used in parsing the JSON input.  Clears the
+std::istream flags; any input errors (e.g., EOF) will be detected by the first
+subsequent call for input from the std::istream.
+*/
+class input_stream_adapter
+{
+  public:
+    using char_type = char;
+
+    ~input_stream_adapter()
+    {
+        // clear stream flags; we use underlying streambuf I/O, do not
+        // maintain ifstream flags, except eof
+        if (is != nullptr)
+        {
+            is->clear(is->rdstate() & std::ios::eofbit);
+        }
+    }
+
+    explicit input_stream_adapter(std::istream& i)
+        : is(&i), sb(i.rdbuf())
+    {}
+
+    // delete because of pointer members
+    input_stream_adapter(const input_stream_adapter&) = delete;
+    input_stream_adapter& operator=(input_stream_adapter&) = delete;
+    input_stream_adapter& operator=(input_stream_adapter&&) = delete;
+
+    input_stream_adapter(input_stream_adapter&& rhs) noexcept
+        : is(rhs.is), sb(rhs.sb)
+    {
+        rhs.is = nullptr;
+        rhs.sb = nullptr;
+    }
+
+    // std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
+    // ensure that std::char_traits<char>::eof() and the character 0xFF do not
+    // end up as the same value, eg. 0xFFFFFFFF.
+    std::char_traits<char>::int_type get_character()
+    {
+        auto res = sb->sbumpc();
+        // set eof manually, as we don't use the istream interface.
+        if (JSON_HEDLEY_UNLIKELY(res == std::char_traits<char>::eof()))
+        {
+            is->clear(is->rdstate() | std::ios::eofbit);
+        }
+        return res;
+    }
+
+  private:
+    /// the associated input stream
+    std::istream* is = nullptr;
+    std::streambuf* sb = nullptr;
+};
+#endif  // JSON_NO_IO
+
+// General-purpose iterator-based adapter. It might not be as fast as
+// theoretically possible for some containers, but it is extremely versatile.
+template<typename IteratorType>
+class iterator_input_adapter
+{
+  public:
+    using char_type = typename std::iterator_traits<IteratorType>::value_type;
+
+    iterator_input_adapter(IteratorType first, IteratorType last)
+        : current(std::move(first)), end(std::move(last))
+    {}
+
+    typename std::char_traits<char_type>::int_type get_character()
+    {
+        if (JSON_HEDLEY_LIKELY(current != end))
+        {
+            auto result = std::char_traits<char_type>::to_int_type(*current);
+            std::advance(current, 1);
+            return result;
+        }
+
+        return std::char_traits<char_type>::eof();
+    }
+
+  private:
+    IteratorType current;
+    IteratorType end;
+
+    template<typename BaseInputAdapter, size_t T>
+    friend struct wide_string_input_helper;
+
+    bool empty() const
+    {
+        return current == end;
+    }
+};
+
+
+template<typename BaseInputAdapter, size_t T>
+struct wide_string_input_helper;
+
+template<typename BaseInputAdapter>
+struct wide_string_input_helper<BaseInputAdapter, 4>
+{
+    // UTF-32
+    static void fill_buffer(BaseInputAdapter& input,
+                            std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
+                            size_t& utf8_bytes_index,
+                            size_t& utf8_bytes_filled)
+    {
+        utf8_bytes_index = 0;
+
+        if (JSON_HEDLEY_UNLIKELY(input.empty()))
+        {
+            utf8_bytes[0] = std::char_traits<char>::eof();
+            utf8_bytes_filled = 1;
+        }
+        else
+        {
+            // get the current character
+            const auto wc = input.get_character();
+
+            // UTF-32 to UTF-8 encoding
+            if (wc < 0x80)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+                utf8_bytes_filled = 1;
+            }
+            else if (wc <= 0x7FF)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
+                utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
+                utf8_bytes_filled = 2;
+            }
+            else if (wc <= 0xFFFF)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
+                utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
+                utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
+                utf8_bytes_filled = 3;
+            }
+            else if (wc <= 0x10FFFF)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((static_cast<unsigned int>(wc) >> 18u) & 0x07u));
+                utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
+                utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
+                utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
+                utf8_bytes_filled = 4;
+            }
+            else
+            {
+                // unknown character
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+                utf8_bytes_filled = 1;
+            }
+        }
+    }
+};
+
+template<typename BaseInputAdapter>
+struct wide_string_input_helper<BaseInputAdapter, 2>
+{
+    // UTF-16
+    static void fill_buffer(BaseInputAdapter& input,
+                            std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
+                            size_t& utf8_bytes_index,
+                            size_t& utf8_bytes_filled)
+    {
+        utf8_bytes_index = 0;
+
+        if (JSON_HEDLEY_UNLIKELY(input.empty()))
+        {
+            utf8_bytes[0] = std::char_traits<char>::eof();
+            utf8_bytes_filled = 1;
+        }
+        else
+        {
+            // get the current character
+            const auto wc = input.get_character();
+
+            // UTF-16 to UTF-8 encoding
+            if (wc < 0x80)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+                utf8_bytes_filled = 1;
+            }
+            else if (wc <= 0x7FF)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((static_cast<unsigned int>(wc) >> 6u)));
+                utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
+                utf8_bytes_filled = 2;
+            }
+            else if (0xD800 > wc || wc >= 0xE000)
+            {
+                utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((static_cast<unsigned int>(wc) >> 12u)));
+                utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
+                utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (static_cast<unsigned int>(wc) & 0x3Fu));
+                utf8_bytes_filled = 3;
+            }
+            else
+            {
+                if (JSON_HEDLEY_UNLIKELY(!input.empty()))
+                {
+                    const auto wc2 = static_cast<unsigned int>(input.get_character());
+                    const auto charcode = 0x10000u + (((static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
+                    utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | (charcode >> 18u));
+                    utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu));
+                    utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu));
+                    utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (charcode & 0x3Fu));
+                    utf8_bytes_filled = 4;
+                }
+                else
+                {
+                    utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
+                    utf8_bytes_filled = 1;
+                }
+            }
+        }
+    }
+};
+
+// Wraps another input apdater to convert wide character types into individual bytes.
+template<typename BaseInputAdapter, typename WideCharType>
+class wide_string_input_adapter
+{
+  public:
+    using char_type = char;
+
+    wide_string_input_adapter(BaseInputAdapter base)
+        : base_adapter(base) {}
+
+    typename std::char_traits<char>::int_type get_character() noexcept
+    {
+        // check if buffer needs to be filled
+        if (utf8_bytes_index == utf8_bytes_filled)
+        {
+            fill_buffer<sizeof(WideCharType)>();
+
+            JSON_ASSERT(utf8_bytes_filled > 0);
+            JSON_ASSERT(utf8_bytes_index == 0);
+        }
+
+        // use buffer
+        JSON_ASSERT(utf8_bytes_filled > 0);
+        JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled);
+        return utf8_bytes[utf8_bytes_index++];
+    }
+
+  private:
+    BaseInputAdapter base_adapter;
+
+    template<size_t T>
+    void fill_buffer()
+    {
+        wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
+    }
+
+    /// a buffer for UTF-8 bytes
+    std::array<std::char_traits<char>::int_type, 4> utf8_bytes = {{0, 0, 0, 0}};
+
+    /// index to the utf8_codes array for the next valid byte
+    std::size_t utf8_bytes_index = 0;
+    /// number of valid bytes in the utf8_codes array
+    std::size_t utf8_bytes_filled = 0;
+};
+
+
+template<typename IteratorType, typename Enable = void>
+struct iterator_input_adapter_factory
+{
+    using iterator_type = IteratorType;
+    using char_type = typename std::iterator_traits<iterator_type>::value_type;
+    using adapter_type = iterator_input_adapter<iterator_type>;
+
+    static adapter_type create(IteratorType first, IteratorType last)
+    {
+        return adapter_type(std::move(first), std::move(last));
+    }
+};
+
+template<typename T>
+struct is_iterator_of_multibyte
+{
+    using value_type = typename std::iterator_traits<T>::value_type;
+    enum
+    {
+        value = sizeof(value_type) > 1
+    };
+};
+
+template<typename IteratorType>
+struct iterator_input_adapter_factory<IteratorType, enable_if_t<is_iterator_of_multibyte<IteratorType>::value>>
+{
+    using iterator_type = IteratorType;
+    using char_type = typename std::iterator_traits<iterator_type>::value_type;
+    using base_adapter_type = iterator_input_adapter<iterator_type>;
+    using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
+
+    static adapter_type create(IteratorType first, IteratorType last)
+    {
+        return adapter_type(base_adapter_type(std::move(first), std::move(last)));
+    }
+};
+
+// General purpose iterator-based input
+template<typename IteratorType>
+typename iterator_input_adapter_factory<IteratorType>::adapter_type input_adapter(IteratorType first, IteratorType last)
+{
+    using factory_type = iterator_input_adapter_factory<IteratorType>;
+    return factory_type::create(first, last);
+}
+
+// Convenience shorthand from container to iterator
+// Enables ADL on begin(container) and end(container)
+// Encloses the using declarations in namespace for not to leak them to outside scope
+
+namespace container_input_adapter_factory_impl
+{
+
+using std::begin;
+using std::end;
+
+template<typename ContainerType, typename Enable = void>
+struct container_input_adapter_factory {};
+
+template<typename ContainerType>
+struct container_input_adapter_factory< ContainerType,
+       void_t<decltype(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
+       {
+           using adapter_type = decltype(input_adapter(begin(std::declval<ContainerType>()), end(std::declval<ContainerType>())));
+
+           static adapter_type create(const ContainerType& container)
+{
+    return input_adapter(begin(container), end(container));
+}
+       };
+
+} // namespace container_input_adapter_factory_impl
+
+template<typename ContainerType>
+typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType& container)
+{
+    return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
+}
+
+#ifndef JSON_NO_IO
+// Special cases with fast paths
+inline file_input_adapter input_adapter(std::FILE* file)
+{
+    return file_input_adapter(file);
+}
+
+inline input_stream_adapter input_adapter(std::istream& stream)
+{
+    return input_stream_adapter(stream);
+}
+
+inline input_stream_adapter input_adapter(std::istream&& stream)
+{
+    return input_stream_adapter(stream);
+}
+#endif  // JSON_NO_IO
+
+using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval<const char*>(), std::declval<const char*>()));
+
+// Null-delimited strings, and the like.
+template < typename CharT,
+           typename std::enable_if <
+               std::is_pointer<CharT>::value&&
+               !std::is_array<CharT>::value&&
+               std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
+               sizeof(typename std::remove_pointer<CharT>::type) == 1,
+               int >::type = 0 >
+contiguous_bytes_input_adapter input_adapter(CharT b)
+{
+    auto length = std::strlen(reinterpret_cast<const char*>(b));
+    const auto* ptr = reinterpret_cast<const char*>(b);
+    return input_adapter(ptr, ptr + length);
+}
+
+template<typename T, std::size_t N>
+auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+{
+    return input_adapter(array, array + N);
+}
+
+// This class only handles inputs of input_buffer_adapter type.
+// It's required so that expressions like {ptr, len} can be implicitely casted
+// to the correct adapter.
+class span_input_adapter
+{
+  public:
+    template < typename CharT,
+               typename std::enable_if <
+                   std::is_pointer<CharT>::value&&
+                   std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
+                   sizeof(typename std::remove_pointer<CharT>::type) == 1,
+                   int >::type = 0 >
+    span_input_adapter(CharT b, std::size_t l)
+        : ia(reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(b) + l) {}
+
+    template<class IteratorType,
+             typename std::enable_if<
+                 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>::value,
+                 int>::type = 0>
+    span_input_adapter(IteratorType first, IteratorType last)
+        : ia(input_adapter(first, last)) {}
+
+    contiguous_bytes_input_adapter&& get()
+    {
+        return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg)
+    }
+
+  private:
+    contiguous_bytes_input_adapter ia;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/input/json_sax.hpp>
+
+
+#include <cstddef>
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+
+/*!
+@brief SAX interface
+
+This class describes the SAX interface used by @ref nlohmann::json::sax_parse.
+Each function is called in different situations while the input is parsed. The
+boolean return value informs the parser whether to continue processing the
+input.
+*/
+template<typename BasicJsonType>
+struct json_sax
+{
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+
+    /*!
+    @brief a null value was read
+    @return whether parsing should proceed
+    */
+    virtual bool null() = 0;
+
+    /*!
+    @brief a boolean value was read
+    @param[in] val  boolean value
+    @return whether parsing should proceed
+    */
+    virtual bool boolean(bool val) = 0;
+
+    /*!
+    @brief an integer number was read
+    @param[in] val  integer value
+    @return whether parsing should proceed
+    */
+    virtual bool number_integer(number_integer_t val) = 0;
+
+    /*!
+    @brief an unsigned integer number was read
+    @param[in] val  unsigned integer value
+    @return whether parsing should proceed
+    */
+    virtual bool number_unsigned(number_unsigned_t val) = 0;
+
+    /*!
+    @brief an floating-point number was read
+    @param[in] val  floating-point value
+    @param[in] s    raw token value
+    @return whether parsing should proceed
+    */
+    virtual bool number_float(number_float_t val, const string_t& s) = 0;
+
+    /*!
+    @brief a string was read
+    @param[in] val  string value
+    @return whether parsing should proceed
+    @note It is safe to move the passed string.
+    */
+    virtual bool string(string_t& val) = 0;
+
+    /*!
+    @brief a binary string was read
+    @param[in] val  binary value
+    @return whether parsing should proceed
+    @note It is safe to move the passed binary.
+    */
+    virtual bool binary(binary_t& val) = 0;
+
+    /*!
+    @brief the beginning of an object was read
+    @param[in] elements  number of object elements or -1 if unknown
+    @return whether parsing should proceed
+    @note binary formats may report the number of elements
+    */
+    virtual bool start_object(std::size_t elements) = 0;
+
+    /*!
+    @brief an object key was read
+    @param[in] val  object key
+    @return whether parsing should proceed
+    @note It is safe to move the passed string.
+    */
+    virtual bool key(string_t& val) = 0;
+
+    /*!
+    @brief the end of an object was read
+    @return whether parsing should proceed
+    */
+    virtual bool end_object() = 0;
+
+    /*!
+    @brief the beginning of an array was read
+    @param[in] elements  number of array elements or -1 if unknown
+    @return whether parsing should proceed
+    @note binary formats may report the number of elements
+    */
+    virtual bool start_array(std::size_t elements) = 0;
+
+    /*!
+    @brief the end of an array was read
+    @return whether parsing should proceed
+    */
+    virtual bool end_array() = 0;
+
+    /*!
+    @brief a parse error occurred
+    @param[in] position    the position in the input where the error occurs
+    @param[in] last_token  the last read token
+    @param[in] ex          an exception object describing the error
+    @return whether parsing should proceed (must return false)
+    */
+    virtual bool parse_error(std::size_t position,
+                             const std::string& last_token,
+                             const detail::exception& ex) = 0;
+
+    json_sax() = default;
+    json_sax(const json_sax&) = default;
+    json_sax(json_sax&&) noexcept = default;
+    json_sax& operator=(const json_sax&) = default;
+    json_sax& operator=(json_sax&&) noexcept = default;
+    virtual ~json_sax() = default;
+};
+
+
+namespace detail
+{
+/*!
+@brief SAX implementation to create a JSON value from SAX events
+
+This class implements the @ref json_sax interface and processes the SAX events
+to create a JSON value which makes it basically a DOM parser. The structure or
+hierarchy of the JSON value is managed by the stack `ref_stack` which contains
+a pointer to the respective array or object for each recursion depth.
+
+After successful parsing, the value that is passed by reference to the
+constructor contains the parsed value.
+
+@tparam BasicJsonType  the JSON type
+*/
+template<typename BasicJsonType>
+class json_sax_dom_parser
+{
+  public:
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+
+    /*!
+    @param[in,out] r  reference to a JSON value that is manipulated while
+                       parsing
+    @param[in] allow_exceptions_  whether parse errors yield exceptions
+    */
+    explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true)
+        : root(r), allow_exceptions(allow_exceptions_)
+    {}
+
+    // make class move-only
+    json_sax_dom_parser(const json_sax_dom_parser&) = delete;
+    json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
+    json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    ~json_sax_dom_parser() = default;
+
+    bool null()
+    {
+        handle_value(nullptr);
+        return true;
+    }
+
+    bool boolean(bool val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_integer(number_integer_t val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_unsigned(number_unsigned_t val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_float(number_float_t val, const string_t& /*unused*/)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool string(string_t& val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool binary(binary_t& val)
+    {
+        handle_value(std::move(val));
+        return true;
+    }
+
+    bool start_object(std::size_t len)
+    {
+        ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
+
+        if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
+        {
+            JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
+        }
+
+        return true;
+    }
+
+    bool key(string_t& val)
+    {
+        // add null at given key and store the reference for later
+        object_element = &(ref_stack.back()->m_value.object->operator[](val));
+        return true;
+    }
+
+    bool end_object()
+    {
+        ref_stack.back()->set_parents();
+        ref_stack.pop_back();
+        return true;
+    }
+
+    bool start_array(std::size_t len)
+    {
+        ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
+
+        if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
+        {
+            JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
+        }
+
+        return true;
+    }
+
+    bool end_array()
+    {
+        ref_stack.back()->set_parents();
+        ref_stack.pop_back();
+        return true;
+    }
+
+    template<class Exception>
+    bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
+                     const Exception& ex)
+    {
+        errored = true;
+        static_cast<void>(ex);
+        if (allow_exceptions)
+        {
+            JSON_THROW(ex);
+        }
+        return false;
+    }
+
+    constexpr bool is_errored() const
+    {
+        return errored;
+    }
+
+  private:
+    /*!
+    @invariant If the ref stack is empty, then the passed value will be the new
+               root.
+    @invariant If the ref stack contains a value, then it is an array or an
+               object to which we can add elements
+    */
+    template<typename Value>
+    JSON_HEDLEY_RETURNS_NON_NULL
+    BasicJsonType* handle_value(Value&& v)
+    {
+        if (ref_stack.empty())
+        {
+            root = BasicJsonType(std::forward<Value>(v));
+            return &root;
+        }
+
+        JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
+
+        if (ref_stack.back()->is_array())
+        {
+            ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
+            return &(ref_stack.back()->m_value.array->back());
+        }
+
+        JSON_ASSERT(ref_stack.back()->is_object());
+        JSON_ASSERT(object_element);
+        *object_element = BasicJsonType(std::forward<Value>(v));
+        return object_element;
+    }
+
+    /// the parsed JSON value
+    BasicJsonType& root;
+    /// stack to model hierarchy of values
+    std::vector<BasicJsonType*> ref_stack {};
+    /// helper to hold the reference for the next object element
+    BasicJsonType* object_element = nullptr;
+    /// whether a syntax error occurred
+    bool errored = false;
+    /// whether to throw exceptions in case of errors
+    const bool allow_exceptions = true;
+};
+
+template<typename BasicJsonType>
+class json_sax_dom_callback_parser
+{
+  public:
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+    using parser_callback_t = typename BasicJsonType::parser_callback_t;
+    using parse_event_t = typename BasicJsonType::parse_event_t;
+
+    json_sax_dom_callback_parser(BasicJsonType& r,
+                                 const parser_callback_t cb,
+                                 const bool allow_exceptions_ = true)
+        : root(r), callback(cb), allow_exceptions(allow_exceptions_)
+    {
+        keep_stack.push_back(true);
+    }
+
+    // make class move-only
+    json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete;
+    json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete;
+    json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    ~json_sax_dom_callback_parser() = default;
+
+    bool null()
+    {
+        handle_value(nullptr);
+        return true;
+    }
+
+    bool boolean(bool val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_integer(number_integer_t val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_unsigned(number_unsigned_t val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool number_float(number_float_t val, const string_t& /*unused*/)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool string(string_t& val)
+    {
+        handle_value(val);
+        return true;
+    }
+
+    bool binary(binary_t& val)
+    {
+        handle_value(std::move(val));
+        return true;
+    }
+
+    bool start_object(std::size_t len)
+    {
+        // check callback for object start
+        const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::object_start, discarded);
+        keep_stack.push_back(keep);
+
+        auto val = handle_value(BasicJsonType::value_t::object, true);
+        ref_stack.push_back(val.second);
+
+        // check object limit
+        if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
+        {
+            JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back()));
+        }
+
+        return true;
+    }
+
+    bool key(string_t& val)
+    {
+        BasicJsonType k = BasicJsonType(val);
+
+        // check callback for key
+        const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
+        key_keep_stack.push_back(keep);
+
+        // add discarded value at given key and store the reference for later
+        if (keep && ref_stack.back())
+        {
+            object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
+        }
+
+        return true;
+    }
+
+    bool end_object()
+    {
+        if (ref_stack.back())
+        {
+            if (!callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
+            {
+                // discard object
+                *ref_stack.back() = discarded;
+            }
+            else
+            {
+                ref_stack.back()->set_parents();
+            }
+        }
+
+        JSON_ASSERT(!ref_stack.empty());
+        JSON_ASSERT(!keep_stack.empty());
+        ref_stack.pop_back();
+        keep_stack.pop_back();
+
+        if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
+        {
+            // remove discarded value
+            for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
+            {
+                if (it->is_discarded())
+                {
+                    ref_stack.back()->erase(it);
+                    break;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    bool start_array(std::size_t len)
+    {
+        const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::array_start, discarded);
+        keep_stack.push_back(keep);
+
+        auto val = handle_value(BasicJsonType::value_t::array, true);
+        ref_stack.push_back(val.second);
+
+        // check array limit
+        if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
+        {
+            JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back()));
+        }
+
+        return true;
+    }
+
+    bool end_array()
+    {
+        bool keep = true;
+
+        if (ref_stack.back())
+        {
+            keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
+            if (keep)
+            {
+                ref_stack.back()->set_parents();
+            }
+            else
+            {
+                // discard array
+                *ref_stack.back() = discarded;
+            }
+        }
+
+        JSON_ASSERT(!ref_stack.empty());
+        JSON_ASSERT(!keep_stack.empty());
+        ref_stack.pop_back();
+        keep_stack.pop_back();
+
+        // remove discarded value
+        if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
+        {
+            ref_stack.back()->m_value.array->pop_back();
+        }
+
+        return true;
+    }
+
+    template<class Exception>
+    bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/,
+                     const Exception& ex)
+    {
+        errored = true;
+        static_cast<void>(ex);
+        if (allow_exceptions)
+        {
+            JSON_THROW(ex);
+        }
+        return false;
+    }
+
+    constexpr bool is_errored() const
+    {
+        return errored;
+    }
+
+  private:
+    /*!
+    @param[in] v  value to add to the JSON value we build during parsing
+    @param[in] skip_callback  whether we should skip calling the callback
+               function; this is required after start_array() and
+               start_object() SAX events, because otherwise we would call the
+               callback function with an empty array or object, respectively.
+
+    @invariant If the ref stack is empty, then the passed value will be the new
+               root.
+    @invariant If the ref stack contains a value, then it is an array or an
+               object to which we can add elements
+
+    @return pair of boolean (whether value should be kept) and pointer (to the
+            passed value in the ref_stack hierarchy; nullptr if not kept)
+    */
+    template<typename Value>
+    std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
+    {
+        JSON_ASSERT(!keep_stack.empty());
+
+        // do not handle this value if we know it would be added to a discarded
+        // container
+        if (!keep_stack.back())
+        {
+            return {false, nullptr};
+        }
+
+        // create value
+        auto value = BasicJsonType(std::forward<Value>(v));
+
+        // check callback
+        const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
+
+        // do not handle this value if we just learnt it shall be discarded
+        if (!keep)
+        {
+            return {false, nullptr};
+        }
+
+        if (ref_stack.empty())
+        {
+            root = std::move(value);
+            return {true, &root};
+        }
+
+        // skip this value if we already decided to skip the parent
+        // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
+        if (!ref_stack.back())
+        {
+            return {false, nullptr};
+        }
+
+        // we now only expect arrays and objects
+        JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
+
+        // array
+        if (ref_stack.back()->is_array())
+        {
+            ref_stack.back()->m_value.array->emplace_back(std::move(value));
+            return {true, &(ref_stack.back()->m_value.array->back())};
+        }
+
+        // object
+        JSON_ASSERT(ref_stack.back()->is_object());
+        // check if we should store an element for the current key
+        JSON_ASSERT(!key_keep_stack.empty());
+        const bool store_element = key_keep_stack.back();
+        key_keep_stack.pop_back();
+
+        if (!store_element)
+        {
+            return {false, nullptr};
+        }
+
+        JSON_ASSERT(object_element);
+        *object_element = std::move(value);
+        return {true, object_element};
+    }
+
+    /// the parsed JSON value
+    BasicJsonType& root;
+    /// stack to model hierarchy of values
+    std::vector<BasicJsonType*> ref_stack {};
+    /// stack to manage which values to keep
+    std::vector<bool> keep_stack {};
+    /// stack to manage which object keys to keep
+    std::vector<bool> key_keep_stack {};
+    /// helper to hold the reference for the next object element
+    BasicJsonType* object_element = nullptr;
+    /// whether a syntax error occurred
+    bool errored = false;
+    /// callback function
+    const parser_callback_t callback = nullptr;
+    /// whether to throw exceptions in case of errors
+    const bool allow_exceptions = true;
+    /// a discarded value for the callback
+    BasicJsonType discarded = BasicJsonType::value_t::discarded;
+};
+
+template<typename BasicJsonType>
+class json_sax_acceptor
+{
+  public:
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+
+    bool null()
+    {
+        return true;
+    }
+
+    bool boolean(bool /*unused*/)
+    {
+        return true;
+    }
+
+    bool number_integer(number_integer_t /*unused*/)
+    {
+        return true;
+    }
+
+    bool number_unsigned(number_unsigned_t /*unused*/)
+    {
+        return true;
+    }
+
+    bool number_float(number_float_t /*unused*/, const string_t& /*unused*/)
+    {
+        return true;
+    }
+
+    bool string(string_t& /*unused*/)
+    {
+        return true;
+    }
+
+    bool binary(binary_t& /*unused*/)
+    {
+        return true;
+    }
+
+    bool start_object(std::size_t /*unused*/ = std::size_t(-1))
+    {
+        return true;
+    }
+
+    bool key(string_t& /*unused*/)
+    {
+        return true;
+    }
+
+    bool end_object()
+    {
+        return true;
+    }
+
+    bool start_array(std::size_t /*unused*/ = std::size_t(-1))
+    {
+        return true;
+    }
+
+    bool end_array()
+    {
+        return true;
+    }
+
+    bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/)
+    {
+        return false;
+    }
+};
+}  // namespace detail
+
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/input/lexer.hpp>
+
+
+#include <array> // array
+#include <clocale> // localeconv
+#include <cstddef> // size_t
+#include <cstdio> // snprintf
+#include <cstdlib> // strtof, strtod, strtold, strtoll, strtoull
+#include <initializer_list> // initializer_list
+#include <string> // char_traits, string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/position_t.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////
+// lexer //
+///////////
+
+template<typename BasicJsonType>
+class lexer_base
+{
+  public:
+    /// token types for the parser
+    enum class token_type
+    {
+        uninitialized,    ///< indicating the scanner is uninitialized
+        literal_true,     ///< the `true` literal
+        literal_false,    ///< the `false` literal
+        literal_null,     ///< the `null` literal
+        value_string,     ///< a string -- use get_string() for actual value
+        value_unsigned,   ///< an unsigned integer -- use get_number_unsigned() for actual value
+        value_integer,    ///< a signed integer -- use get_number_integer() for actual value
+        value_float,      ///< an floating point number -- use get_number_float() for actual value
+        begin_array,      ///< the character for array begin `[`
+        begin_object,     ///< the character for object begin `{`
+        end_array,        ///< the character for array end `]`
+        end_object,       ///< the character for object end `}`
+        name_separator,   ///< the name separator `:`
+        value_separator,  ///< the value separator `,`
+        parse_error,      ///< indicating a parse error
+        end_of_input,     ///< indicating the end of the input buffer
+        literal_or_value  ///< a literal or the begin of a value (only for diagnostics)
+    };
+
+    /// return name of values of type token_type (only used for errors)
+    JSON_HEDLEY_RETURNS_NON_NULL
+    JSON_HEDLEY_CONST
+    static const char* token_type_name(const token_type t) noexcept
+    {
+        switch (t)
+        {
+            case token_type::uninitialized:
+                return "<uninitialized>";
+            case token_type::literal_true:
+                return "true literal";
+            case token_type::literal_false:
+                return "false literal";
+            case token_type::literal_null:
+                return "null literal";
+            case token_type::value_string:
+                return "string literal";
+            case token_type::value_unsigned:
+            case token_type::value_integer:
+            case token_type::value_float:
+                return "number literal";
+            case token_type::begin_array:
+                return "'['";
+            case token_type::begin_object:
+                return "'{'";
+            case token_type::end_array:
+                return "']'";
+            case token_type::end_object:
+                return "'}'";
+            case token_type::name_separator:
+                return "':'";
+            case token_type::value_separator:
+                return "','";
+            case token_type::parse_error:
+                return "<parse error>";
+            case token_type::end_of_input:
+                return "end of input";
+            case token_type::literal_or_value:
+                return "'[', '{', or a literal";
+            // LCOV_EXCL_START
+            default: // catch non-enum values
+                return "unknown token";
+                // LCOV_EXCL_STOP
+        }
+    }
+};
+/*!
+@brief lexical analysis
+
+This class organizes the lexical analysis during JSON deserialization.
+*/
+template<typename BasicJsonType, typename InputAdapterType>
+class lexer : public lexer_base<BasicJsonType>
+{
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using char_type = typename InputAdapterType::char_type;
+    using char_int_type = typename std::char_traits<char_type>::int_type;
+
+  public:
+    using token_type = typename lexer_base<BasicJsonType>::token_type;
+
+    explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept
+        : ia(std::move(adapter))
+        , ignore_comments(ignore_comments_)
+        , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
+    {}
+
+    // delete because of pointer members
+    lexer(const lexer&) = delete;
+    lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    lexer& operator=(lexer&) = delete;
+    lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    ~lexer() = default;
+
+  private:
+    /////////////////////
+    // locales
+    /////////////////////
+
+    /// return the locale-dependent decimal point
+    JSON_HEDLEY_PURE
+    static char get_decimal_point() noexcept
+    {
+        const auto* loc = localeconv();
+        JSON_ASSERT(loc != nullptr);
+        return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
+    }
+
+    /////////////////////
+    // scan functions
+    /////////////////////
+
+    /*!
+    @brief get codepoint from 4 hex characters following `\u`
+
+    For input "\u c1 c2 c3 c4" the codepoint is:
+      (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4
+    = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0)
+
+    Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f'
+    must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The
+    conversion is done by subtracting the offset (0x30, 0x37, and 0x57)
+    between the ASCII value of the character and the desired integer value.
+
+    @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or
+            non-hex character)
+    */
+    int get_codepoint()
+    {
+        // this function only makes sense after reading `\u`
+        JSON_ASSERT(current == 'u');
+        int codepoint = 0;
+
+        const auto factors = { 12u, 8u, 4u, 0u };
+        for (const auto factor : factors)
+        {
+            get();
+
+            if (current >= '0' && current <= '9')
+            {
+                codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
+            }
+            else if (current >= 'A' && current <= 'F')
+            {
+                codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
+            }
+            else if (current >= 'a' && current <= 'f')
+            {
+                codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
+            }
+            else
+            {
+                return -1;
+            }
+        }
+
+        JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
+        return codepoint;
+    }
+
+    /*!
+    @brief check if the next byte(s) are inside a given range
+
+    Adds the current byte and, for each passed range, reads a new byte and
+    checks if it is inside the range. If a violation was detected, set up an
+    error message and return false. Otherwise, return true.
+
+    @param[in] ranges  list of integers; interpreted as list of pairs of
+                       inclusive lower and upper bound, respectively
+
+    @pre The passed list @a ranges must have 2, 4, or 6 elements; that is,
+         1, 2, or 3 pairs. This precondition is enforced by an assertion.
+
+    @return true if and only if no range violation was detected
+    */
+    bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
+    {
+        JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
+        add(current);
+
+        for (auto range = ranges.begin(); range != ranges.end(); ++range)
+        {
+            get();
+            if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
+            {
+                add(current);
+            }
+            else
+            {
+                error_message = "invalid string: ill-formed UTF-8 byte";
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /*!
+    @brief scan a string literal
+
+    This function scans a string according to Sect. 7 of RFC 8259. While
+    scanning, bytes are escaped and copied into buffer token_buffer. Then the
+    function returns successfully, token_buffer is *not* null-terminated (as it
+    may contain \0 bytes), and token_buffer.size() is the number of bytes in the
+    string.
+
+    @return token_type::value_string if string could be successfully scanned,
+            token_type::parse_error otherwise
+
+    @note In case of errors, variable error_message contains a textual
+          description.
+    */
+    token_type scan_string()
+    {
+        // reset token_buffer (ignore opening quote)
+        reset();
+
+        // we entered the function by reading an open quote
+        JSON_ASSERT(current == '\"');
+
+        while (true)
+        {
+            // get next character
+            switch (get())
+            {
+                // end of file while parsing string
+                case std::char_traits<char_type>::eof():
+                {
+                    error_message = "invalid string: missing closing quote";
+                    return token_type::parse_error;
+                }
+
+                // closing quote
+                case '\"':
+                {
+                    return token_type::value_string;
+                }
+
+                // escapes
+                case '\\':
+                {
+                    switch (get())
+                    {
+                        // quotation mark
+                        case '\"':
+                            add('\"');
+                            break;
+                        // reverse solidus
+                        case '\\':
+                            add('\\');
+                            break;
+                        // solidus
+                        case '/':
+                            add('/');
+                            break;
+                        // backspace
+                        case 'b':
+                            add('\b');
+                            break;
+                        // form feed
+                        case 'f':
+                            add('\f');
+                            break;
+                        // line feed
+                        case 'n':
+                            add('\n');
+                            break;
+                        // carriage return
+                        case 'r':
+                            add('\r');
+                            break;
+                        // tab
+                        case 't':
+                            add('\t');
+                            break;
+
+                        // unicode escapes
+                        case 'u':
+                        {
+                            const int codepoint1 = get_codepoint();
+                            int codepoint = codepoint1; // start with codepoint1
+
+                            if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1))
+                            {
+                                error_message = "invalid string: '\\u' must be followed by 4 hex digits";
+                                return token_type::parse_error;
+                            }
+
+                            // check if code point is a high surrogate
+                            if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
+                            {
+                                // expect next \uxxxx entry
+                                if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u'))
+                                {
+                                    const int codepoint2 = get_codepoint();
+
+                                    if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1))
+                                    {
+                                        error_message = "invalid string: '\\u' must be followed by 4 hex digits";
+                                        return token_type::parse_error;
+                                    }
+
+                                    // check if codepoint2 is a low surrogate
+                                    if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF))
+                                    {
+                                        // overwrite codepoint
+                                        codepoint = static_cast<int>(
+                                                        // high surrogate occupies the most significant 22 bits
+                                                        (static_cast<unsigned int>(codepoint1) << 10u)
+                                                        // low surrogate occupies the least significant 15 bits
+                                                        + static_cast<unsigned int>(codepoint2)
+                                                        // there is still the 0xD800, 0xDC00 and 0x10000 noise
+                                                        // in the result so we have to subtract with:
+                                                        // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
+                                                        - 0x35FDC00u);
+                                    }
+                                    else
+                                    {
+                                        error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
+                                        return token_type::parse_error;
+                                    }
+                                }
+                                else
+                                {
+                                    error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
+                                    return token_type::parse_error;
+                                }
+                            }
+                            else
+                            {
+                                if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF))
+                                {
+                                    error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
+                                    return token_type::parse_error;
+                                }
+                            }
+
+                            // result of the above calculation yields a proper codepoint
+                            JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
+
+                            // translate codepoint into bytes
+                            if (codepoint < 0x80)
+                            {
+                                // 1-byte characters: 0xxxxxxx (ASCII)
+                                add(static_cast<char_int_type>(codepoint));
+                            }
+                            else if (codepoint <= 0x7FF)
+                            {
+                                // 2-byte characters: 110xxxxx 10xxxxxx
+                                add(static_cast<char_int_type>(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u)));
+                                add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+                            }
+                            else if (codepoint <= 0xFFFF)
+                            {
+                                // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
+                                add(static_cast<char_int_type>(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u)));
+                                add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
+                                add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+                            }
+                            else
+                            {
+                                // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+                                add(static_cast<char_int_type>(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u)));
+                                add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
+                                add(static_cast<char_int_type>(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
+                                add(static_cast<char_int_type>(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu)));
+                            }
+
+                            break;
+                        }
+
+                        // other characters after escape
+                        default:
+                            error_message = "invalid string: forbidden character after backslash";
+                            return token_type::parse_error;
+                    }
+
+                    break;
+                }
+
+                // invalid control characters
+                case 0x00:
+                {
+                    error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
+                    return token_type::parse_error;
+                }
+
+                case 0x01:
+                {
+                    error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
+                    return token_type::parse_error;
+                }
+
+                case 0x02:
+                {
+                    error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002";
+                    return token_type::parse_error;
+                }
+
+                case 0x03:
+                {
+                    error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
+                    return token_type::parse_error;
+                }
+
+                case 0x04:
+                {
+                    error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
+                    return token_type::parse_error;
+                }
+
+                case 0x05:
+                {
+                    error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
+                    return token_type::parse_error;
+                }
+
+                case 0x06:
+                {
+                    error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
+                    return token_type::parse_error;
+                }
+
+                case 0x07:
+                {
+                    error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
+                    return token_type::parse_error;
+                }
+
+                case 0x08:
+                {
+                    error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
+                    return token_type::parse_error;
+                }
+
+                case 0x09:
+                {
+                    error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
+                    return token_type::parse_error;
+                }
+
+                case 0x0A:
+                {
+                    error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
+                    return token_type::parse_error;
+                }
+
+                case 0x0B:
+                {
+                    error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B";
+                    return token_type::parse_error;
+                }
+
+                case 0x0C:
+                {
+                    error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
+                    return token_type::parse_error;
+                }
+
+                case 0x0D:
+                {
+                    error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
+                    return token_type::parse_error;
+                }
+
+                case 0x0E:
+                {
+                    error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E";
+                    return token_type::parse_error;
+                }
+
+                case 0x0F:
+                {
+                    error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F";
+                    return token_type::parse_error;
+                }
+
+                case 0x10:
+                {
+                    error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
+                    return token_type::parse_error;
+                }
+
+                case 0x11:
+                {
+                    error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
+                    return token_type::parse_error;
+                }
+
+                case 0x12:
+                {
+                    error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
+                    return token_type::parse_error;
+                }
+
+                case 0x13:
+                {
+                    error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
+                    return token_type::parse_error;
+                }
+
+                case 0x14:
+                {
+                    error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
+                    return token_type::parse_error;
+                }
+
+                case 0x15:
+                {
+                    error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
+                    return token_type::parse_error;
+                }
+
+                case 0x16:
+                {
+                    error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
+                    return token_type::parse_error;
+                }
+
+                case 0x17:
+                {
+                    error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
+                    return token_type::parse_error;
+                }
+
+                case 0x18:
+                {
+                    error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
+                    return token_type::parse_error;
+                }
+
+                case 0x19:
+                {
+                    error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019";
+                    return token_type::parse_error;
+                }
+
+                case 0x1A:
+                {
+                    error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A";
+                    return token_type::parse_error;
+                }
+
+                case 0x1B:
+                {
+                    error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B";
+                    return token_type::parse_error;
+                }
+
+                case 0x1C:
+                {
+                    error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C";
+                    return token_type::parse_error;
+                }
+
+                case 0x1D:
+                {
+                    error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D";
+                    return token_type::parse_error;
+                }
+
+                case 0x1E:
+                {
+                    error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E";
+                    return token_type::parse_error;
+                }
+
+                case 0x1F:
+                {
+                    error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F";
+                    return token_type::parse_error;
+                }
+
+                // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace))
+                case 0x20:
+                case 0x21:
+                case 0x23:
+                case 0x24:
+                case 0x25:
+                case 0x26:
+                case 0x27:
+                case 0x28:
+                case 0x29:
+                case 0x2A:
+                case 0x2B:
+                case 0x2C:
+                case 0x2D:
+                case 0x2E:
+                case 0x2F:
+                case 0x30:
+                case 0x31:
+                case 0x32:
+                case 0x33:
+                case 0x34:
+                case 0x35:
+                case 0x36:
+                case 0x37:
+                case 0x38:
+                case 0x39:
+                case 0x3A:
+                case 0x3B:
+                case 0x3C:
+                case 0x3D:
+                case 0x3E:
+                case 0x3F:
+                case 0x40:
+                case 0x41:
+                case 0x42:
+                case 0x43:
+                case 0x44:
+                case 0x45:
+                case 0x46:
+                case 0x47:
+                case 0x48:
+                case 0x49:
+                case 0x4A:
+                case 0x4B:
+                case 0x4C:
+                case 0x4D:
+                case 0x4E:
+                case 0x4F:
+                case 0x50:
+                case 0x51:
+                case 0x52:
+                case 0x53:
+                case 0x54:
+                case 0x55:
+                case 0x56:
+                case 0x57:
+                case 0x58:
+                case 0x59:
+                case 0x5A:
+                case 0x5B:
+                case 0x5D:
+                case 0x5E:
+                case 0x5F:
+                case 0x60:
+                case 0x61:
+                case 0x62:
+                case 0x63:
+                case 0x64:
+                case 0x65:
+                case 0x66:
+                case 0x67:
+                case 0x68:
+                case 0x69:
+                case 0x6A:
+                case 0x6B:
+                case 0x6C:
+                case 0x6D:
+                case 0x6E:
+                case 0x6F:
+                case 0x70:
+                case 0x71:
+                case 0x72:
+                case 0x73:
+                case 0x74:
+                case 0x75:
+                case 0x76:
+                case 0x77:
+                case 0x78:
+                case 0x79:
+                case 0x7A:
+                case 0x7B:
+                case 0x7C:
+                case 0x7D:
+                case 0x7E:
+                case 0x7F:
+                {
+                    add(current);
+                    break;
+                }
+
+                // U+0080..U+07FF: bytes C2..DF 80..BF
+                case 0xC2:
+                case 0xC3:
+                case 0xC4:
+                case 0xC5:
+                case 0xC6:
+                case 0xC7:
+                case 0xC8:
+                case 0xC9:
+                case 0xCA:
+                case 0xCB:
+                case 0xCC:
+                case 0xCD:
+                case 0xCE:
+                case 0xCF:
+                case 0xD0:
+                case 0xD1:
+                case 0xD2:
+                case 0xD3:
+                case 0xD4:
+                case 0xD5:
+                case 0xD6:
+                case 0xD7:
+                case 0xD8:
+                case 0xD9:
+                case 0xDA:
+                case 0xDB:
+                case 0xDC:
+                case 0xDD:
+                case 0xDE:
+                case 0xDF:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+0800..U+0FFF: bytes E0 A0..BF 80..BF
+                case 0xE0:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF
+                // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF
+                case 0xE1:
+                case 0xE2:
+                case 0xE3:
+                case 0xE4:
+                case 0xE5:
+                case 0xE6:
+                case 0xE7:
+                case 0xE8:
+                case 0xE9:
+                case 0xEA:
+                case 0xEB:
+                case 0xEC:
+                case 0xEE:
+                case 0xEF:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+D000..U+D7FF: bytes ED 80..9F 80..BF
+                case 0xED:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
+                case 0xF0:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
+                case 0xF1:
+                case 0xF2:
+                case 0xF3:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
+                case 0xF4:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
+                    {
+                        return token_type::parse_error;
+                    }
+                    break;
+                }
+
+                // remaining bytes (80..C1 and F5..FF) are ill-formed
+                default:
+                {
+                    error_message = "invalid string: ill-formed UTF-8 byte";
+                    return token_type::parse_error;
+                }
+            }
+        }
+    }
+
+    /*!
+     * @brief scan a comment
+     * @return whether comment could be scanned successfully
+     */
+    bool scan_comment()
+    {
+        switch (get())
+        {
+            // single-line comments skip input until a newline or EOF is read
+            case '/':
+            {
+                while (true)
+                {
+                    switch (get())
+                    {
+                        case '\n':
+                        case '\r':
+                        case std::char_traits<char_type>::eof():
+                        case '\0':
+                            return true;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            // multi-line comments skip input until */ is read
+            case '*':
+            {
+                while (true)
+                {
+                    switch (get())
+                    {
+                        case std::char_traits<char_type>::eof():
+                        case '\0':
+                        {
+                            error_message = "invalid comment; missing closing '*/'";
+                            return false;
+                        }
+
+                        case '*':
+                        {
+                            switch (get())
+                            {
+                                case '/':
+                                    return true;
+
+                                default:
+                                {
+                                    unget();
+                                    continue;
+                                }
+                            }
+                        }
+
+                        default:
+                            continue;
+                    }
+                }
+            }
+
+            // unexpected character after reading '/'
+            default:
+            {
+                error_message = "invalid comment; expecting '/' or '*' after '/'";
+                return false;
+            }
+        }
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    static void strtof(float& f, const char* str, char** endptr) noexcept
+    {
+        f = std::strtof(str, endptr);
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    static void strtof(double& f, const char* str, char** endptr) noexcept
+    {
+        f = std::strtod(str, endptr);
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    static void strtof(long double& f, const char* str, char** endptr) noexcept
+    {
+        f = std::strtold(str, endptr);
+    }
+
+    /*!
+    @brief scan a number literal
+
+    This function scans a string according to Sect. 6 of RFC 8259.
+
+    The function is realized with a deterministic finite state machine derived
+    from the grammar described in RFC 8259. Starting in state "init", the
+    input is read and used to determined the next state. Only state "done"
+    accepts the number. State "error" is a trap state to model errors. In the
+    table below, "anything" means any character but the ones listed before.
+
+    state    | 0        | 1-9      | e E      | +       | -       | .        | anything
+    ---------|----------|----------|----------|---------|---------|----------|-----------
+    init     | zero     | any1     | [error]  | [error] | minus   | [error]  | [error]
+    minus    | zero     | any1     | [error]  | [error] | [error] | [error]  | [error]
+    zero     | done     | done     | exponent | done    | done    | decimal1 | done
+    any1     | any1     | any1     | exponent | done    | done    | decimal1 | done
+    decimal1 | decimal2 | decimal2 | [error]  | [error] | [error] | [error]  | [error]
+    decimal2 | decimal2 | decimal2 | exponent | done    | done    | done     | done
+    exponent | any2     | any2     | [error]  | sign    | sign    | [error]  | [error]
+    sign     | any2     | any2     | [error]  | [error] | [error] | [error]  | [error]
+    any2     | any2     | any2     | done     | done    | done    | done     | done
+
+    The state machine is realized with one label per state (prefixed with
+    "scan_number_") and `goto` statements between them. The state machine
+    contains cycles, but any cycle can be left when EOF is read. Therefore,
+    the function is guaranteed to terminate.
+
+    During scanning, the read bytes are stored in token_buffer. This string is
+    then converted to a signed integer, an unsigned integer, or a
+    floating-point number.
+
+    @return token_type::value_unsigned, token_type::value_integer, or
+            token_type::value_float if number could be successfully scanned,
+            token_type::parse_error otherwise
+
+    @note The scanner is independent of the current locale. Internally, the
+          locale's decimal point is used instead of `.` to work with the
+          locale-dependent converters.
+    */
+    token_type scan_number()  // lgtm [cpp/use-of-goto]
+    {
+        // reset token_buffer to store the number's bytes
+        reset();
+
+        // the type of the parsed number; initially set to unsigned; will be
+        // changed if minus sign, decimal point or exponent is read
+        token_type number_type = token_type::value_unsigned;
+
+        // state (init): we just found out we need to scan a number
+        switch (current)
+        {
+            case '-':
+            {
+                add(current);
+                goto scan_number_minus;
+            }
+
+            case '0':
+            {
+                add(current);
+                goto scan_number_zero;
+            }
+
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any1;
+            }
+
+            // all other characters are rejected outside scan_number()
+            default:            // LCOV_EXCL_LINE
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        }
+
+scan_number_minus:
+        // state: we just parsed a leading minus sign
+        number_type = token_type::value_integer;
+        switch (get())
+        {
+            case '0':
+            {
+                add(current);
+                goto scan_number_zero;
+            }
+
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any1;
+            }
+
+            default:
+            {
+                error_message = "invalid number; expected digit after '-'";
+                return token_type::parse_error;
+            }
+        }
+
+scan_number_zero:
+        // state: we just parse a zero (maybe with a leading minus sign)
+        switch (get())
+        {
+            case '.':
+            {
+                add(decimal_point_char);
+                goto scan_number_decimal1;
+            }
+
+            case 'e':
+            case 'E':
+            {
+                add(current);
+                goto scan_number_exponent;
+            }
+
+            default:
+                goto scan_number_done;
+        }
+
+scan_number_any1:
+        // state: we just parsed a number 0-9 (maybe with a leading minus sign)
+        switch (get())
+        {
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any1;
+            }
+
+            case '.':
+            {
+                add(decimal_point_char);
+                goto scan_number_decimal1;
+            }
+
+            case 'e':
+            case 'E':
+            {
+                add(current);
+                goto scan_number_exponent;
+            }
+
+            default:
+                goto scan_number_done;
+        }
+
+scan_number_decimal1:
+        // state: we just parsed a decimal point
+        number_type = token_type::value_float;
+        switch (get())
+        {
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_decimal2;
+            }
+
+            default:
+            {
+                error_message = "invalid number; expected digit after '.'";
+                return token_type::parse_error;
+            }
+        }
+
+scan_number_decimal2:
+        // we just parsed at least one number after a decimal point
+        switch (get())
+        {
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_decimal2;
+            }
+
+            case 'e':
+            case 'E':
+            {
+                add(current);
+                goto scan_number_exponent;
+            }
+
+            default:
+                goto scan_number_done;
+        }
+
+scan_number_exponent:
+        // we just parsed an exponent
+        number_type = token_type::value_float;
+        switch (get())
+        {
+            case '+':
+            case '-':
+            {
+                add(current);
+                goto scan_number_sign;
+            }
+
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any2;
+            }
+
+            default:
+            {
+                error_message =
+                    "invalid number; expected '+', '-', or digit after exponent";
+                return token_type::parse_error;
+            }
+        }
+
+scan_number_sign:
+        // we just parsed an exponent sign
+        switch (get())
+        {
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any2;
+            }
+
+            default:
+            {
+                error_message = "invalid number; expected digit after exponent sign";
+                return token_type::parse_error;
+            }
+        }
+
+scan_number_any2:
+        // we just parsed a number after the exponent or exponent sign
+        switch (get())
+        {
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+            {
+                add(current);
+                goto scan_number_any2;
+            }
+
+            default:
+                goto scan_number_done;
+        }
+
+scan_number_done:
+        // unget the character after the number (we only read it to know that
+        // we are done scanning a number)
+        unget();
+
+        char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+        errno = 0;
+
+        // try to parse integers first and fall back to floats
+        if (number_type == token_type::value_unsigned)
+        {
+            const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
+
+            // we checked the number format before
+            JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
+
+            if (errno == 0)
+            {
+                value_unsigned = static_cast<number_unsigned_t>(x);
+                if (value_unsigned == x)
+                {
+                    return token_type::value_unsigned;
+                }
+            }
+        }
+        else if (number_type == token_type::value_integer)
+        {
+            const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
+
+            // we checked the number format before
+            JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
+
+            if (errno == 0)
+            {
+                value_integer = static_cast<number_integer_t>(x);
+                if (value_integer == x)
+                {
+                    return token_type::value_integer;
+                }
+            }
+        }
+
+        // this code is reached if we parse a floating-point number or if an
+        // integer conversion above failed
+        strtof(value_float, token_buffer.data(), &endptr);
+
+        // we checked the number format before
+        JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
+
+        return token_type::value_float;
+    }
+
+    /*!
+    @param[in] literal_text  the literal text to expect
+    @param[in] length        the length of the passed literal text
+    @param[in] return_type   the token type to return on success
+    */
+    JSON_HEDLEY_NON_NULL(2)
+    token_type scan_literal(const char_type* literal_text, const std::size_t length,
+                            token_type return_type)
+    {
+        JSON_ASSERT(std::char_traits<char_type>::to_char_type(current) == literal_text[0]);
+        for (std::size_t i = 1; i < length; ++i)
+        {
+            if (JSON_HEDLEY_UNLIKELY(std::char_traits<char_type>::to_char_type(get()) != literal_text[i]))
+            {
+                error_message = "invalid literal";
+                return token_type::parse_error;
+            }
+        }
+        return return_type;
+    }
+
+    /////////////////////
+    // input management
+    /////////////////////
+
+    /// reset token_buffer; current character is beginning of token
+    void reset() noexcept
+    {
+        token_buffer.clear();
+        token_string.clear();
+        token_string.push_back(std::char_traits<char_type>::to_char_type(current));
+    }
+
+    /*
+    @brief get next character from the input
+
+    This function provides the interface to the used input adapter. It does
+    not throw in case the input reached EOF, but returns a
+    `std::char_traits<char>::eof()` in that case.  Stores the scanned characters
+    for use in error messages.
+
+    @return character read from the input
+    */
+    char_int_type get()
+    {
+        ++position.chars_read_total;
+        ++position.chars_read_current_line;
+
+        if (next_unget)
+        {
+            // just reset the next_unget variable and work with current
+            next_unget = false;
+        }
+        else
+        {
+            current = ia.get_character();
+        }
+
+        if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
+        {
+            token_string.push_back(std::char_traits<char_type>::to_char_type(current));
+        }
+
+        if (current == '\n')
+        {
+            ++position.lines_read;
+            position.chars_read_current_line = 0;
+        }
+
+        return current;
+    }
+
+    /*!
+    @brief unget current character (read it again on next get)
+
+    We implement unget by setting variable next_unget to true. The input is not
+    changed - we just simulate ungetting by modifying chars_read_total,
+    chars_read_current_line, and token_string. The next call to get() will
+    behave as if the unget character is read again.
+    */
+    void unget()
+    {
+        next_unget = true;
+
+        --position.chars_read_total;
+
+        // in case we "unget" a newline, we have to also decrement the lines_read
+        if (position.chars_read_current_line == 0)
+        {
+            if (position.lines_read > 0)
+            {
+                --position.lines_read;
+            }
+        }
+        else
+        {
+            --position.chars_read_current_line;
+        }
+
+        if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof()))
+        {
+            JSON_ASSERT(!token_string.empty());
+            token_string.pop_back();
+        }
+    }
+
+    /// add a character to token_buffer
+    void add(char_int_type c)
+    {
+        token_buffer.push_back(static_cast<typename string_t::value_type>(c));
+    }
+
+  public:
+    /////////////////////
+    // value getters
+    /////////////////////
+
+    /// return integer value
+    constexpr number_integer_t get_number_integer() const noexcept
+    {
+        return value_integer;
+    }
+
+    /// return unsigned integer value
+    constexpr number_unsigned_t get_number_unsigned() const noexcept
+    {
+        return value_unsigned;
+    }
+
+    /// return floating-point value
+    constexpr number_float_t get_number_float() const noexcept
+    {
+        return value_float;
+    }
+
+    /// return current string value (implicitly resets the token; useful only once)
+    string_t& get_string()
+    {
+        return token_buffer;
+    }
+
+    /////////////////////
+    // diagnostics
+    /////////////////////
+
+    /// return position of last read token
+    constexpr position_t get_position() const noexcept
+    {
+        return position;
+    }
+
+    /// return the last read token (for errors only).  Will never contain EOF
+    /// (an arbitrary value that is not a valid char value, often -1), because
+    /// 255 may legitimately occur.  May contain NUL, which should be escaped.
+    std::string get_token_string() const
+    {
+        // escape control characters
+        std::string result;
+        for (const auto c : token_string)
+        {
+            if (static_cast<unsigned char>(c) <= '\x1F')
+            {
+                // escape control characters
+                std::array<char, 9> cs{{}};
+                (std::snprintf)(cs.data(), cs.size(), "<U+%.4X>", static_cast<unsigned char>(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                result += cs.data();
+            }
+            else
+            {
+                // add character as is
+                result.push_back(static_cast<std::string::value_type>(c));
+            }
+        }
+
+        return result;
+    }
+
+    /// return syntax error message
+    JSON_HEDLEY_RETURNS_NON_NULL
+    constexpr const char* get_error_message() const noexcept
+    {
+        return error_message;
+    }
+
+    /////////////////////
+    // actual scanner
+    /////////////////////
+
+    /*!
+    @brief skip the UTF-8 byte order mark
+    @return true iff there is no BOM or the correct BOM has been skipped
+    */
+    bool skip_bom()
+    {
+        if (get() == 0xEF)
+        {
+            // check if we completely parse the BOM
+            return get() == 0xBB && get() == 0xBF;
+        }
+
+        // the first character is not the beginning of the BOM; unget it to
+        // process is later
+        unget();
+        return true;
+    }
+
+    void skip_whitespace()
+    {
+        do
+        {
+            get();
+        }
+        while (current == ' ' || current == '\t' || current == '\n' || current == '\r');
+    }
+
+    token_type scan()
+    {
+        // initially, skip the BOM
+        if (position.chars_read_total == 0 && !skip_bom())
+        {
+            error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given";
+            return token_type::parse_error;
+        }
+
+        // read next character and ignore whitespace
+        skip_whitespace();
+
+        // ignore comments
+        while (ignore_comments && current == '/')
+        {
+            if (!scan_comment())
+            {
+                return token_type::parse_error;
+            }
+
+            // skip following whitespace
+            skip_whitespace();
+        }
+
+        switch (current)
+        {
+            // structural characters
+            case '[':
+                return token_type::begin_array;
+            case ']':
+                return token_type::end_array;
+            case '{':
+                return token_type::begin_object;
+            case '}':
+                return token_type::end_object;
+            case ':':
+                return token_type::name_separator;
+            case ',':
+                return token_type::value_separator;
+
+            // literals
+            case 't':
+            {
+                std::array<char_type, 4> true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}};
+                return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
+            }
+            case 'f':
+            {
+                std::array<char_type, 5> false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}};
+                return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
+            }
+            case 'n':
+            {
+                std::array<char_type, 4> null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}};
+                return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
+            }
+
+            // string
+            case '\"':
+                return scan_string();
+
+            // number
+            case '-':
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
+                return scan_number();
+
+            // end of input (the null byte is needed when parsing from
+            // string literals)
+            case '\0':
+            case std::char_traits<char_type>::eof():
+                return token_type::end_of_input;
+
+            // error
+            default:
+                error_message = "invalid literal";
+                return token_type::parse_error;
+        }
+    }
+
+  private:
+    /// input adapter
+    InputAdapterType ia;
+
+    /// whether comments should be ignored (true) or signaled as errors (false)
+    const bool ignore_comments = false;
+
+    /// the current character
+    char_int_type current = std::char_traits<char_type>::eof();
+
+    /// whether the next get() call should just return current
+    bool next_unget = false;
+
+    /// the start position of the current token
+    position_t position {};
+
+    /// raw input token string (for error messages)
+    std::vector<char_type> token_string {};
+
+    /// buffer for variable-length tokens (numbers, strings)
+    string_t token_buffer {};
+
+    /// a description of occurred lexer errors
+    const char* error_message = "";
+
+    // number values
+    number_integer_t value_integer = 0;
+    number_unsigned_t value_unsigned = 0;
+    number_float_t value_float = 0;
+
+    /// the decimal point
+    const char_int_type decimal_point_char = '.';
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/is_sax.hpp>
+
+
+#include <cstdint> // size_t
+#include <utility> // declval
+#include <string> // string
+
+// #include <nlohmann/detail/meta/detected.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename T>
+using null_function_t = decltype(std::declval<T&>().null());
+
+template<typename T>
+using boolean_function_t =
+    decltype(std::declval<T&>().boolean(std::declval<bool>()));
+
+template<typename T, typename Integer>
+using number_integer_function_t =
+    decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
+
+template<typename T, typename Unsigned>
+using number_unsigned_function_t =
+    decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
+
+template<typename T, typename Float, typename String>
+using number_float_function_t = decltype(std::declval<T&>().number_float(
+                                    std::declval<Float>(), std::declval<const String&>()));
+
+template<typename T, typename String>
+using string_function_t =
+    decltype(std::declval<T&>().string(std::declval<String&>()));
+
+template<typename T, typename Binary>
+using binary_function_t =
+    decltype(std::declval<T&>().binary(std::declval<Binary&>()));
+
+template<typename T>
+using start_object_function_t =
+    decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
+
+template<typename T, typename String>
+using key_function_t =
+    decltype(std::declval<T&>().key(std::declval<String&>()));
+
+template<typename T>
+using end_object_function_t = decltype(std::declval<T&>().end_object());
+
+template<typename T>
+using start_array_function_t =
+    decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
+
+template<typename T>
+using end_array_function_t = decltype(std::declval<T&>().end_array());
+
+template<typename T, typename Exception>
+using parse_error_function_t = decltype(std::declval<T&>().parse_error(
+        std::declval<std::size_t>(), std::declval<const std::string&>(),
+        std::declval<const Exception&>()));
+
+template<typename SAX, typename BasicJsonType>
+struct is_sax
+{
+  private:
+    static_assert(is_basic_json<BasicJsonType>::value,
+                  "BasicJsonType must be of type basic_json<...>");
+
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+    using exception_t = typename BasicJsonType::exception;
+
+  public:
+    static constexpr bool value =
+        is_detected_exact<bool, null_function_t, SAX>::value &&
+        is_detected_exact<bool, boolean_function_t, SAX>::value &&
+        is_detected_exact<bool, number_integer_function_t, SAX, number_integer_t>::value &&
+        is_detected_exact<bool, number_unsigned_function_t, SAX, number_unsigned_t>::value &&
+        is_detected_exact<bool, number_float_function_t, SAX, number_float_t, string_t>::value &&
+        is_detected_exact<bool, string_function_t, SAX, string_t>::value &&
+        is_detected_exact<bool, binary_function_t, SAX, binary_t>::value &&
+        is_detected_exact<bool, start_object_function_t, SAX>::value &&
+        is_detected_exact<bool, key_function_t, SAX, string_t>::value &&
+        is_detected_exact<bool, end_object_function_t, SAX>::value &&
+        is_detected_exact<bool, start_array_function_t, SAX>::value &&
+        is_detected_exact<bool, end_array_function_t, SAX>::value &&
+        is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
+};
+
+template<typename SAX, typename BasicJsonType>
+struct is_sax_static_asserts
+{
+  private:
+    static_assert(is_basic_json<BasicJsonType>::value,
+                  "BasicJsonType must be of type basic_json<...>");
+
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+    using exception_t = typename BasicJsonType::exception;
+
+  public:
+    static_assert(is_detected_exact<bool, null_function_t, SAX>::value,
+                  "Missing/invalid function: bool null()");
+    static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
+                  "Missing/invalid function: bool boolean(bool)");
+    static_assert(is_detected_exact<bool, boolean_function_t, SAX>::value,
+                  "Missing/invalid function: bool boolean(bool)");
+    static_assert(
+        is_detected_exact<bool, number_integer_function_t, SAX,
+        number_integer_t>::value,
+        "Missing/invalid function: bool number_integer(number_integer_t)");
+    static_assert(
+        is_detected_exact<bool, number_unsigned_function_t, SAX,
+        number_unsigned_t>::value,
+        "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
+    static_assert(is_detected_exact<bool, number_float_function_t, SAX,
+                  number_float_t, string_t>::value,
+                  "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
+    static_assert(
+        is_detected_exact<bool, string_function_t, SAX, string_t>::value,
+        "Missing/invalid function: bool string(string_t&)");
+    static_assert(
+        is_detected_exact<bool, binary_function_t, SAX, binary_t>::value,
+        "Missing/invalid function: bool binary(binary_t&)");
+    static_assert(is_detected_exact<bool, start_object_function_t, SAX>::value,
+                  "Missing/invalid function: bool start_object(std::size_t)");
+    static_assert(is_detected_exact<bool, key_function_t, SAX, string_t>::value,
+                  "Missing/invalid function: bool key(string_t&)");
+    static_assert(is_detected_exact<bool, end_object_function_t, SAX>::value,
+                  "Missing/invalid function: bool end_object()");
+    static_assert(is_detected_exact<bool, start_array_function_t, SAX>::value,
+                  "Missing/invalid function: bool start_array(std::size_t)");
+    static_assert(is_detected_exact<bool, end_array_function_t, SAX>::value,
+                  "Missing/invalid function: bool end_array()");
+    static_assert(
+        is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value,
+        "Missing/invalid function: bool parse_error(std::size_t, const "
+        "std::string&, const exception&)");
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+
+/// how to treat CBOR tags
+enum class cbor_tag_handler_t
+{
+    error,   ///< throw a parse_error exception in case of a tag
+    ignore,  ///< ignore tags
+    store    ///< store tags as binary type
+};
+
+/*!
+@brief determine system byte order
+
+@return true if and only if system's byte order is little endian
+
+@note from https://stackoverflow.com/a/1001328/266378
+*/
+static inline bool little_endianess(int num = 1) noexcept
+{
+    return *reinterpret_cast<char*>(&num) == 1;
+}
+
+
+///////////////////
+// binary reader //
+///////////////////
+
+/*!
+@brief deserialization of CBOR, MessagePack, and UBJSON values
+*/
+template<typename BasicJsonType, typename InputAdapterType, typename SAX = json_sax_dom_parser<BasicJsonType>>
+class binary_reader
+{
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+    using json_sax_t = SAX;
+    using char_type = typename InputAdapterType::char_type;
+    using char_int_type = typename std::char_traits<char_type>::int_type;
+
+  public:
+    /*!
+    @brief create a binary reader
+
+    @param[in] adapter  input adapter to read from
+    */
+    explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter))
+    {
+        (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
+    }
+
+    // make class move-only
+    binary_reader(const binary_reader&) = delete;
+    binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    binary_reader& operator=(const binary_reader&) = delete;
+    binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
+    ~binary_reader() = default;
+
+    /*!
+    @param[in] format  the binary format to parse
+    @param[in] sax_    a SAX event processor
+    @param[in] strict  whether to expect the input to be consumed completed
+    @param[in] tag_handler  how to treat CBOR tags
+
+    @return whether parsing was successful
+    */
+    JSON_HEDLEY_NON_NULL(3)
+    bool sax_parse(const input_format_t format,
+                   json_sax_t* sax_,
+                   const bool strict = true,
+                   const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
+    {
+        sax = sax_;
+        bool result = false;
+
+        switch (format)
+        {
+            case input_format_t::bson:
+                result = parse_bson_internal();
+                break;
+
+            case input_format_t::cbor:
+                result = parse_cbor_internal(true, tag_handler);
+                break;
+
+            case input_format_t::msgpack:
+                result = parse_msgpack_internal();
+                break;
+
+            case input_format_t::ubjson:
+                result = parse_ubjson_internal();
+                break;
+
+            case input_format_t::json: // LCOV_EXCL_LINE
+            default:            // LCOV_EXCL_LINE
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        }
+
+        // strict mode: next byte must be EOF
+        if (result && strict)
+        {
+            if (format == input_format_t::ubjson)
+            {
+                get_ignore_noop();
+            }
+            else
+            {
+                get();
+            }
+
+            if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
+            {
+                return sax->parse_error(chars_read, get_token_string(),
+                                        parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType()));
+            }
+        }
+
+        return result;
+    }
+
+  private:
+    //////////
+    // BSON //
+    //////////
+
+    /*!
+    @brief Reads in a BSON-object and passes it to the SAX-parser.
+    @return whether a valid BSON-value was passed to the SAX parser
+    */
+    bool parse_bson_internal()
+    {
+        std::int32_t document_size{};
+        get_number<std::int32_t, true>(input_format_t::bson, document_size);
+
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
+        {
+            return false;
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false)))
+        {
+            return false;
+        }
+
+        return sax->end_object();
+    }
+
+    /*!
+    @brief Parses a C-style string from the BSON input.
+    @param[in,out] result  A reference to the string variable where the read
+                            string is to be stored.
+    @return `true` if the \x00-byte indicating the end of the string was
+             encountered before the EOF; false` indicates an unexpected EOF.
+    */
+    bool get_bson_cstr(string_t& result)
+    {
+        auto out = std::back_inserter(result);
+        while (true)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring")))
+            {
+                return false;
+            }
+            if (current == 0x00)
+            {
+                return true;
+            }
+            *out++ = static_cast<typename string_t::value_type>(current);
+        }
+    }
+
+    /*!
+    @brief Parses a zero-terminated string of length @a len from the BSON
+           input.
+    @param[in] len  The length (including the zero-byte at the end) of the
+                    string to be read.
+    @param[in,out] result  A reference to the string variable where the read
+                            string is to be stored.
+    @tparam NumberType The type of the length @a len
+    @pre len >= 1
+    @return `true` if the string was successfully parsed
+    */
+    template<typename NumberType>
+    bool get_bson_string(const NumberType len, string_t& result)
+    {
+        if (JSON_HEDLEY_UNLIKELY(len < 1))
+        {
+            auto last_token = get_token_string();
+            return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType()));
+        }
+
+        return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) && get() != std::char_traits<char_type>::eof();
+    }
+
+    /*!
+    @brief Parses a byte array input of length @a len from the BSON input.
+    @param[in] len  The length of the byte array to be read.
+    @param[in,out] result  A reference to the binary variable where the read
+                            array is to be stored.
+    @tparam NumberType The type of the length @a len
+    @pre len >= 0
+    @return `true` if the byte array was successfully parsed
+    */
+    template<typename NumberType>
+    bool get_bson_binary(const NumberType len, binary_t& result)
+    {
+        if (JSON_HEDLEY_UNLIKELY(len < 0))
+        {
+            auto last_token = get_token_string();
+            return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType()));
+        }
+
+        // All BSON binary values have a subtype
+        std::uint8_t subtype{};
+        get_number<std::uint8_t>(input_format_t::bson, subtype);
+        result.set_subtype(subtype);
+
+        return get_binary(input_format_t::bson, len, result);
+    }
+
+    /*!
+    @brief Read a BSON document element of the given @a element_type.
+    @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html
+    @param[in] element_type_parse_position The position in the input stream,
+               where the `element_type` was read.
+    @warning Not all BSON element types are supported yet. An unsupported
+             @a element_type will give rise to a parse_error.114:
+             Unsupported BSON record type 0x...
+    @return whether a valid BSON-object/array was passed to the SAX parser
+    */
+    bool parse_bson_element_internal(const char_int_type element_type,
+                                     const std::size_t element_type_parse_position)
+    {
+        switch (element_type)
+        {
+            case 0x01: // double
+            {
+                double number{};
+                return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 0x02: // string
+            {
+                std::int32_t len{};
+                string_t value;
+                return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value);
+            }
+
+            case 0x03: // object
+            {
+                return parse_bson_internal();
+            }
+
+            case 0x04: // array
+            {
+                return parse_bson_array();
+            }
+
+            case 0x05: // binary
+            {
+                std::int32_t len{};
+                binary_t value;
+                return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value);
+            }
+
+            case 0x08: // boolean
+            {
+                return sax->boolean(get() != 0);
+            }
+
+            case 0x0A: // null
+            {
+                return sax->null();
+            }
+
+            case 0x10: // int32
+            {
+                std::int32_t value{};
+                return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value);
+            }
+
+            case 0x12: // int64
+            {
+                std::int64_t value{};
+                return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value);
+            }
+
+            default: // anything else not supported (yet)
+            {
+                std::array<char, 3> cr{{}};
+                (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief Read a BSON element list (as specified in the BSON-spec)
+
+    The same binary layout is used for objects and arrays, hence it must be
+    indicated with the argument @a is_array which one is expected
+    (true --> array, false --> object).
+
+    @param[in] is_array Determines if the element list being read is to be
+                        treated as an object (@a is_array == false), or as an
+                        array (@a is_array == true).
+    @return whether a valid BSON-object/array was passed to the SAX parser
+    */
+    bool parse_bson_element_list(const bool is_array)
+    {
+        string_t key;
+
+        while (auto element_type = get())
+        {
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list")))
+            {
+                return false;
+            }
+
+            const std::size_t element_type_parse_position = chars_read;
+            if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key)))
+            {
+                return false;
+            }
+
+            if (!is_array && !sax->key(key))
+            {
+                return false;
+            }
+
+            if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
+            {
+                return false;
+            }
+
+            // get_bson_cstr only appends
+            key.clear();
+        }
+
+        return true;
+    }
+
+    /*!
+    @brief Reads an array from the BSON input and passes it to the SAX-parser.
+    @return whether a valid BSON-array was passed to the SAX parser
+    */
+    bool parse_bson_array()
+    {
+        std::int32_t document_size{};
+        get_number<std::int32_t, true>(input_format_t::bson, document_size);
+
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
+        {
+            return false;
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true)))
+        {
+            return false;
+        }
+
+        return sax->end_array();
+    }
+
+    //////////
+    // CBOR //
+    //////////
+
+    /*!
+    @param[in] get_char  whether a new character should be retrieved from the
+                         input (true) or whether the last read character should
+                         be considered instead (false)
+    @param[in] tag_handler how CBOR tags should be treated
+
+    @return whether a valid CBOR value was passed to the SAX parser
+    */
+    bool parse_cbor_internal(const bool get_char,
+                             const cbor_tag_handler_t tag_handler)
+    {
+        switch (get_char ? get() : current)
+        {
+            // EOF
+            case std::char_traits<char_type>::eof():
+                return unexpect_eof(input_format_t::cbor, "value");
+
+            // Integer 0x00..0x17 (0..23)
+            case 0x00:
+            case 0x01:
+            case 0x02:
+            case 0x03:
+            case 0x04:
+            case 0x05:
+            case 0x06:
+            case 0x07:
+            case 0x08:
+            case 0x09:
+            case 0x0A:
+            case 0x0B:
+            case 0x0C:
+            case 0x0D:
+            case 0x0E:
+            case 0x0F:
+            case 0x10:
+            case 0x11:
+            case 0x12:
+            case 0x13:
+            case 0x14:
+            case 0x15:
+            case 0x16:
+            case 0x17:
+                return sax->number_unsigned(static_cast<number_unsigned_t>(current));
+
+            case 0x18: // Unsigned integer (one-byte uint8_t follows)
+            {
+                std::uint8_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
+            }
+
+            case 0x19: // Unsigned integer (two-byte uint16_t follows)
+            {
+                std::uint16_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
+            }
+
+            case 0x1A: // Unsigned integer (four-byte uint32_t follows)
+            {
+                std::uint32_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
+            }
+
+            case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
+            {
+                std::uint64_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
+            }
+
+            // Negative integer -1-0x00..-1-0x17 (-1..-24)
+            case 0x20:
+            case 0x21:
+            case 0x22:
+            case 0x23:
+            case 0x24:
+            case 0x25:
+            case 0x26:
+            case 0x27:
+            case 0x28:
+            case 0x29:
+            case 0x2A:
+            case 0x2B:
+            case 0x2C:
+            case 0x2D:
+            case 0x2E:
+            case 0x2F:
+            case 0x30:
+            case 0x31:
+            case 0x32:
+            case 0x33:
+            case 0x34:
+            case 0x35:
+            case 0x36:
+            case 0x37:
+                return sax->number_integer(static_cast<std::int8_t>(0x20 - 1 - current));
+
+            case 0x38: // Negative integer (one-byte uint8_t follows)
+            {
+                std::uint8_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
+            }
+
+            case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
+            {
+                std::uint16_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
+            }
+
+            case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
+            {
+                std::uint32_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1) - number);
+            }
+
+            case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
+            {
+                std::uint64_t number{};
+                return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast<number_integer_t>(-1)
+                        - static_cast<number_integer_t>(number));
+            }
+
+            // Binary data (0x00..0x17 bytes follow)
+            case 0x40:
+            case 0x41:
+            case 0x42:
+            case 0x43:
+            case 0x44:
+            case 0x45:
+            case 0x46:
+            case 0x47:
+            case 0x48:
+            case 0x49:
+            case 0x4A:
+            case 0x4B:
+            case 0x4C:
+            case 0x4D:
+            case 0x4E:
+            case 0x4F:
+            case 0x50:
+            case 0x51:
+            case 0x52:
+            case 0x53:
+            case 0x54:
+            case 0x55:
+            case 0x56:
+            case 0x57:
+            case 0x58: // Binary data (one-byte uint8_t for n follows)
+            case 0x59: // Binary data (two-byte uint16_t for n follow)
+            case 0x5A: // Binary data (four-byte uint32_t for n follow)
+            case 0x5B: // Binary data (eight-byte uint64_t for n follow)
+            case 0x5F: // Binary data (indefinite length)
+            {
+                binary_t b;
+                return get_cbor_binary(b) && sax->binary(b);
+            }
+
+            // UTF-8 string (0x00..0x17 bytes follow)
+            case 0x60:
+            case 0x61:
+            case 0x62:
+            case 0x63:
+            case 0x64:
+            case 0x65:
+            case 0x66:
+            case 0x67:
+            case 0x68:
+            case 0x69:
+            case 0x6A:
+            case 0x6B:
+            case 0x6C:
+            case 0x6D:
+            case 0x6E:
+            case 0x6F:
+            case 0x70:
+            case 0x71:
+            case 0x72:
+            case 0x73:
+            case 0x74:
+            case 0x75:
+            case 0x76:
+            case 0x77:
+            case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
+            case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
+            case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
+            case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
+            case 0x7F: // UTF-8 string (indefinite length)
+            {
+                string_t s;
+                return get_cbor_string(s) && sax->string(s);
+            }
+
+            // array (0x00..0x17 data items follow)
+            case 0x80:
+            case 0x81:
+            case 0x82:
+            case 0x83:
+            case 0x84:
+            case 0x85:
+            case 0x86:
+            case 0x87:
+            case 0x88:
+            case 0x89:
+            case 0x8A:
+            case 0x8B:
+            case 0x8C:
+            case 0x8D:
+            case 0x8E:
+            case 0x8F:
+            case 0x90:
+            case 0x91:
+            case 0x92:
+            case 0x93:
+            case 0x94:
+            case 0x95:
+            case 0x96:
+            case 0x97:
+                return get_cbor_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
+
+            case 0x98: // array (one-byte uint8_t for n follows)
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0x99: // array (two-byte uint16_t for n follow)
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0x9A: // array (four-byte uint32_t for n follow)
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0x9B: // array (eight-byte uint64_t for n follow)
+            {
+                std::uint64_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0x9F: // array (indefinite length)
+                return get_cbor_array(std::size_t(-1), tag_handler);
+
+            // map (0x00..0x17 pairs of data items follow)
+            case 0xA0:
+            case 0xA1:
+            case 0xA2:
+            case 0xA3:
+            case 0xA4:
+            case 0xA5:
+            case 0xA6:
+            case 0xA7:
+            case 0xA8:
+            case 0xA9:
+            case 0xAA:
+            case 0xAB:
+            case 0xAC:
+            case 0xAD:
+            case 0xAE:
+            case 0xAF:
+            case 0xB0:
+            case 0xB1:
+            case 0xB2:
+            case 0xB3:
+            case 0xB4:
+            case 0xB5:
+            case 0xB6:
+            case 0xB7:
+                return get_cbor_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
+
+            case 0xB8: // map (one-byte uint8_t for n follows)
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0xB9: // map (two-byte uint16_t for n follow)
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0xBA: // map (four-byte uint32_t for n follow)
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0xBB: // map (eight-byte uint64_t for n follow)
+            {
+                std::uint64_t len{};
+                return get_number(input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast<std::size_t>(len), tag_handler);
+            }
+
+            case 0xBF: // map (indefinite length)
+                return get_cbor_object(std::size_t(-1), tag_handler);
+
+            case 0xC6: // tagged item
+            case 0xC7:
+            case 0xC8:
+            case 0xC9:
+            case 0xCA:
+            case 0xCB:
+            case 0xCC:
+            case 0xCD:
+            case 0xCE:
+            case 0xCF:
+            case 0xD0:
+            case 0xD1:
+            case 0xD2:
+            case 0xD3:
+            case 0xD4:
+            case 0xD8: // tagged item (1 bytes follow)
+            case 0xD9: // tagged item (2 bytes follow)
+            case 0xDA: // tagged item (4 bytes follow)
+            case 0xDB: // tagged item (8 bytes follow)
+            {
+                switch (tag_handler)
+                {
+                    case cbor_tag_handler_t::error:
+                    {
+                        auto last_token = get_token_string();
+                        return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
+                    }
+
+                    case cbor_tag_handler_t::ignore:
+                    {
+                        // ignore binary subtype
+                        switch (current)
+                        {
+                            case 0xD8:
+                            {
+                                std::uint8_t subtype_to_ignore{};
+                                get_number(input_format_t::cbor, subtype_to_ignore);
+                                break;
+                            }
+                            case 0xD9:
+                            {
+                                std::uint16_t subtype_to_ignore{};
+                                get_number(input_format_t::cbor, subtype_to_ignore);
+                                break;
+                            }
+                            case 0xDA:
+                            {
+                                std::uint32_t subtype_to_ignore{};
+                                get_number(input_format_t::cbor, subtype_to_ignore);
+                                break;
+                            }
+                            case 0xDB:
+                            {
+                                std::uint64_t subtype_to_ignore{};
+                                get_number(input_format_t::cbor, subtype_to_ignore);
+                                break;
+                            }
+                            default:
+                                break;
+                        }
+                        return parse_cbor_internal(true, tag_handler);
+                    }
+
+                    case cbor_tag_handler_t::store:
+                    {
+                        binary_t b;
+                        // use binary subtype and store in binary container
+                        switch (current)
+                        {
+                            case 0xD8:
+                            {
+                                std::uint8_t subtype{};
+                                get_number(input_format_t::cbor, subtype);
+                                b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
+                                break;
+                            }
+                            case 0xD9:
+                            {
+                                std::uint16_t subtype{};
+                                get_number(input_format_t::cbor, subtype);
+                                b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
+                                break;
+                            }
+                            case 0xDA:
+                            {
+                                std::uint32_t subtype{};
+                                get_number(input_format_t::cbor, subtype);
+                                b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
+                                break;
+                            }
+                            case 0xDB:
+                            {
+                                std::uint64_t subtype{};
+                                get_number(input_format_t::cbor, subtype);
+                                b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
+                                break;
+                            }
+                            default:
+                                return parse_cbor_internal(true, tag_handler);
+                        }
+                        get();
+                        return get_cbor_binary(b) && sax->binary(b);
+                    }
+
+                    default:                 // LCOV_EXCL_LINE
+                        JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+                        return false;        // LCOV_EXCL_LINE
+                }
+            }
+
+            case 0xF4: // false
+                return sax->boolean(false);
+
+            case 0xF5: // true
+                return sax->boolean(true);
+
+            case 0xF6: // null
+                return sax->null();
+
+            case 0xF9: // Half-Precision Float (two-byte IEEE 754)
+            {
+                const auto byte1_raw = get();
+                if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number")))
+                {
+                    return false;
+                }
+                const auto byte2_raw = get();
+                if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number")))
+                {
+                    return false;
+                }
+
+                const auto byte1 = static_cast<unsigned char>(byte1_raw);
+                const auto byte2 = static_cast<unsigned char>(byte2_raw);
+
+                // code from RFC 7049, Appendix D, Figure 3:
+                // As half-precision floating-point numbers were only added
+                // to IEEE 754 in 2008, today's programming platforms often
+                // still only have limited support for them. It is very
+                // easy to include at least decoding support for them even
+                // without such support. An example of a small decoder for
+                // half-precision floating-point numbers in the C language
+                // is shown in Fig. 3.
+                const auto half = static_cast<unsigned int>((byte1 << 8u) + byte2);
+                const double val = [&half]
+                {
+                    const int exp = (half >> 10u) & 0x1Fu;
+                    const unsigned int mant = half & 0x3FFu;
+                    JSON_ASSERT(0 <= exp&& exp <= 32);
+                    JSON_ASSERT(mant <= 1024);
+                    switch (exp)
+                    {
+                        case 0:
+                            return std::ldexp(mant, -24);
+                        case 31:
+                            return (mant == 0)
+                            ? std::numeric_limits<double>::infinity()
+                            : std::numeric_limits<double>::quiet_NaN();
+                        default:
+                            return std::ldexp(mant + 1024, exp - 25);
+                    }
+                }();
+                return sax->number_float((half & 0x8000u) != 0
+                                         ? static_cast<number_float_t>(-val)
+                                         : static_cast<number_float_t>(val), "");
+            }
+
+            case 0xFA: // Single-Precision Float (four-byte IEEE 754)
+            {
+                float number{};
+                return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
+            {
+                double number{};
+                return get_number(input_format_t::cbor, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            default: // anything else (0xFF is handled inside the other types)
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief reads a CBOR string
+
+    This function first reads starting bytes to determine the expected
+    string length and then copies this number of bytes into a string.
+    Additionally, CBOR's strings with indefinite lengths are supported.
+
+    @param[out] result  created string
+
+    @return whether string creation completed
+    */
+    bool get_cbor_string(string_t& result)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string")))
+        {
+            return false;
+        }
+
+        switch (current)
+        {
+            // UTF-8 string (0x00..0x17 bytes follow)
+            case 0x60:
+            case 0x61:
+            case 0x62:
+            case 0x63:
+            case 0x64:
+            case 0x65:
+            case 0x66:
+            case 0x67:
+            case 0x68:
+            case 0x69:
+            case 0x6A:
+            case 0x6B:
+            case 0x6C:
+            case 0x6D:
+            case 0x6E:
+            case 0x6F:
+            case 0x70:
+            case 0x71:
+            case 0x72:
+            case 0x73:
+            case 0x74:
+            case 0x75:
+            case 0x76:
+            case 0x77:
+            {
+                return get_string(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
+            }
+
+            case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
+            }
+
+            case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
+            }
+
+            case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
+            }
+
+            case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
+            {
+                std::uint64_t len{};
+                return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
+            }
+
+            case 0x7F: // UTF-8 string (indefinite length)
+            {
+                while (get() != 0xFF)
+                {
+                    string_t chunk;
+                    if (!get_cbor_string(chunk))
+                    {
+                        return false;
+                    }
+                    result.append(chunk);
+                }
+                return true;
+            }
+
+            default:
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief reads a CBOR byte array
+
+    This function first reads starting bytes to determine the expected
+    byte array length and then copies this number of bytes into the byte array.
+    Additionally, CBOR's byte arrays with indefinite lengths are supported.
+
+    @param[out] result  created byte array
+
+    @return whether byte array creation completed
+    */
+    bool get_cbor_binary(binary_t& result)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary")))
+        {
+            return false;
+        }
+
+        switch (current)
+        {
+            // Binary data (0x00..0x17 bytes follow)
+            case 0x40:
+            case 0x41:
+            case 0x42:
+            case 0x43:
+            case 0x44:
+            case 0x45:
+            case 0x46:
+            case 0x47:
+            case 0x48:
+            case 0x49:
+            case 0x4A:
+            case 0x4B:
+            case 0x4C:
+            case 0x4D:
+            case 0x4E:
+            case 0x4F:
+            case 0x50:
+            case 0x51:
+            case 0x52:
+            case 0x53:
+            case 0x54:
+            case 0x55:
+            case 0x56:
+            case 0x57:
+            {
+                return get_binary(input_format_t::cbor, static_cast<unsigned int>(current) & 0x1Fu, result);
+            }
+
+            case 0x58: // Binary data (one-byte uint8_t for n follows)
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::cbor, len) &&
+                       get_binary(input_format_t::cbor, len, result);
+            }
+
+            case 0x59: // Binary data (two-byte uint16_t for n follow)
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::cbor, len) &&
+                       get_binary(input_format_t::cbor, len, result);
+            }
+
+            case 0x5A: // Binary data (four-byte uint32_t for n follow)
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::cbor, len) &&
+                       get_binary(input_format_t::cbor, len, result);
+            }
+
+            case 0x5B: // Binary data (eight-byte uint64_t for n follow)
+            {
+                std::uint64_t len{};
+                return get_number(input_format_t::cbor, len) &&
+                       get_binary(input_format_t::cbor, len, result);
+            }
+
+            case 0x5F: // Binary data (indefinite length)
+            {
+                while (get() != 0xFF)
+                {
+                    binary_t chunk;
+                    if (!get_cbor_binary(chunk))
+                    {
+                        return false;
+                    }
+                    result.insert(result.end(), chunk.begin(), chunk.end());
+                }
+                return true;
+            }
+
+            default:
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @param[in] len  the length of the array or std::size_t(-1) for an
+                    array of indefinite size
+    @param[in] tag_handler how CBOR tags should be treated
+    @return whether array creation completed
+    */
+    bool get_cbor_array(const std::size_t len,
+                        const cbor_tag_handler_t tag_handler)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
+        {
+            return false;
+        }
+
+        if (len != std::size_t(-1))
+        {
+            for (std::size_t i = 0; i < len; ++i)
+            {
+                if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
+                {
+                    return false;
+                }
+            }
+        }
+        else
+        {
+            while (get() != 0xFF)
+            {
+                if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler)))
+                {
+                    return false;
+                }
+            }
+        }
+
+        return sax->end_array();
+    }
+
+    /*!
+    @param[in] len  the length of the object or std::size_t(-1) for an
+                    object of indefinite size
+    @param[in] tag_handler how CBOR tags should be treated
+    @return whether object creation completed
+    */
+    bool get_cbor_object(const std::size_t len,
+                         const cbor_tag_handler_t tag_handler)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
+        {
+            return false;
+        }
+
+        if (len != 0)
+        {
+            string_t key;
+            if (len != std::size_t(-1))
+            {
+                for (std::size_t i = 0; i < len; ++i)
+                {
+                    get();
+                    if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
+                    {
+                        return false;
+                    }
+
+                    if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
+                    {
+                        return false;
+                    }
+                    key.clear();
+                }
+            }
+            else
+            {
+                while (get() != 0xFF)
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key)))
+                    {
+                        return false;
+                    }
+
+                    if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler)))
+                    {
+                        return false;
+                    }
+                    key.clear();
+                }
+            }
+        }
+
+        return sax->end_object();
+    }
+
+    /////////////
+    // MsgPack //
+    /////////////
+
+    /*!
+    @return whether a valid MessagePack value was passed to the SAX parser
+    */
+    bool parse_msgpack_internal()
+    {
+        switch (get())
+        {
+            // EOF
+            case std::char_traits<char_type>::eof():
+                return unexpect_eof(input_format_t::msgpack, "value");
+
+            // positive fixint
+            case 0x00:
+            case 0x01:
+            case 0x02:
+            case 0x03:
+            case 0x04:
+            case 0x05:
+            case 0x06:
+            case 0x07:
+            case 0x08:
+            case 0x09:
+            case 0x0A:
+            case 0x0B:
+            case 0x0C:
+            case 0x0D:
+            case 0x0E:
+            case 0x0F:
+            case 0x10:
+            case 0x11:
+            case 0x12:
+            case 0x13:
+            case 0x14:
+            case 0x15:
+            case 0x16:
+            case 0x17:
+            case 0x18:
+            case 0x19:
+            case 0x1A:
+            case 0x1B:
+            case 0x1C:
+            case 0x1D:
+            case 0x1E:
+            case 0x1F:
+            case 0x20:
+            case 0x21:
+            case 0x22:
+            case 0x23:
+            case 0x24:
+            case 0x25:
+            case 0x26:
+            case 0x27:
+            case 0x28:
+            case 0x29:
+            case 0x2A:
+            case 0x2B:
+            case 0x2C:
+            case 0x2D:
+            case 0x2E:
+            case 0x2F:
+            case 0x30:
+            case 0x31:
+            case 0x32:
+            case 0x33:
+            case 0x34:
+            case 0x35:
+            case 0x36:
+            case 0x37:
+            case 0x38:
+            case 0x39:
+            case 0x3A:
+            case 0x3B:
+            case 0x3C:
+            case 0x3D:
+            case 0x3E:
+            case 0x3F:
+            case 0x40:
+            case 0x41:
+            case 0x42:
+            case 0x43:
+            case 0x44:
+            case 0x45:
+            case 0x46:
+            case 0x47:
+            case 0x48:
+            case 0x49:
+            case 0x4A:
+            case 0x4B:
+            case 0x4C:
+            case 0x4D:
+            case 0x4E:
+            case 0x4F:
+            case 0x50:
+            case 0x51:
+            case 0x52:
+            case 0x53:
+            case 0x54:
+            case 0x55:
+            case 0x56:
+            case 0x57:
+            case 0x58:
+            case 0x59:
+            case 0x5A:
+            case 0x5B:
+            case 0x5C:
+            case 0x5D:
+            case 0x5E:
+            case 0x5F:
+            case 0x60:
+            case 0x61:
+            case 0x62:
+            case 0x63:
+            case 0x64:
+            case 0x65:
+            case 0x66:
+            case 0x67:
+            case 0x68:
+            case 0x69:
+            case 0x6A:
+            case 0x6B:
+            case 0x6C:
+            case 0x6D:
+            case 0x6E:
+            case 0x6F:
+            case 0x70:
+            case 0x71:
+            case 0x72:
+            case 0x73:
+            case 0x74:
+            case 0x75:
+            case 0x76:
+            case 0x77:
+            case 0x78:
+            case 0x79:
+            case 0x7A:
+            case 0x7B:
+            case 0x7C:
+            case 0x7D:
+            case 0x7E:
+            case 0x7F:
+                return sax->number_unsigned(static_cast<number_unsigned_t>(current));
+
+            // fixmap
+            case 0x80:
+            case 0x81:
+            case 0x82:
+            case 0x83:
+            case 0x84:
+            case 0x85:
+            case 0x86:
+            case 0x87:
+            case 0x88:
+            case 0x89:
+            case 0x8A:
+            case 0x8B:
+            case 0x8C:
+            case 0x8D:
+            case 0x8E:
+            case 0x8F:
+                return get_msgpack_object(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
+
+            // fixarray
+            case 0x90:
+            case 0x91:
+            case 0x92:
+            case 0x93:
+            case 0x94:
+            case 0x95:
+            case 0x96:
+            case 0x97:
+            case 0x98:
+            case 0x99:
+            case 0x9A:
+            case 0x9B:
+            case 0x9C:
+            case 0x9D:
+            case 0x9E:
+            case 0x9F:
+                return get_msgpack_array(static_cast<std::size_t>(static_cast<unsigned int>(current) & 0x0Fu));
+
+            // fixstr
+            case 0xA0:
+            case 0xA1:
+            case 0xA2:
+            case 0xA3:
+            case 0xA4:
+            case 0xA5:
+            case 0xA6:
+            case 0xA7:
+            case 0xA8:
+            case 0xA9:
+            case 0xAA:
+            case 0xAB:
+            case 0xAC:
+            case 0xAD:
+            case 0xAE:
+            case 0xAF:
+            case 0xB0:
+            case 0xB1:
+            case 0xB2:
+            case 0xB3:
+            case 0xB4:
+            case 0xB5:
+            case 0xB6:
+            case 0xB7:
+            case 0xB8:
+            case 0xB9:
+            case 0xBA:
+            case 0xBB:
+            case 0xBC:
+            case 0xBD:
+            case 0xBE:
+            case 0xBF:
+            case 0xD9: // str 8
+            case 0xDA: // str 16
+            case 0xDB: // str 32
+            {
+                string_t s;
+                return get_msgpack_string(s) && sax->string(s);
+            }
+
+            case 0xC0: // nil
+                return sax->null();
+
+            case 0xC2: // false
+                return sax->boolean(false);
+
+            case 0xC3: // true
+                return sax->boolean(true);
+
+            case 0xC4: // bin 8
+            case 0xC5: // bin 16
+            case 0xC6: // bin 32
+            case 0xC7: // ext 8
+            case 0xC8: // ext 16
+            case 0xC9: // ext 32
+            case 0xD4: // fixext 1
+            case 0xD5: // fixext 2
+            case 0xD6: // fixext 4
+            case 0xD7: // fixext 8
+            case 0xD8: // fixext 16
+            {
+                binary_t b;
+                return get_msgpack_binary(b) && sax->binary(b);
+            }
+
+            case 0xCA: // float 32
+            {
+                float number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 0xCB: // float 64
+            {
+                double number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 0xCC: // uint 8
+            {
+                std::uint8_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
+            }
+
+            case 0xCD: // uint 16
+            {
+                std::uint16_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
+            }
+
+            case 0xCE: // uint 32
+            {
+                std::uint32_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
+            }
+
+            case 0xCF: // uint 64
+            {
+                std::uint64_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
+            }
+
+            case 0xD0: // int 8
+            {
+                std::int8_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
+            }
+
+            case 0xD1: // int 16
+            {
+                std::int16_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
+            }
+
+            case 0xD2: // int 32
+            {
+                std::int32_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
+            }
+
+            case 0xD3: // int 64
+            {
+                std::int64_t number{};
+                return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
+            }
+
+            case 0xDC: // array 16
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len));
+            }
+
+            case 0xDD: // array 32
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast<std::size_t>(len));
+            }
+
+            case 0xDE: // map 16
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len));
+            }
+
+            case 0xDF: // map 32
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast<std::size_t>(len));
+            }
+
+            // negative fixint
+            case 0xE0:
+            case 0xE1:
+            case 0xE2:
+            case 0xE3:
+            case 0xE4:
+            case 0xE5:
+            case 0xE6:
+            case 0xE7:
+            case 0xE8:
+            case 0xE9:
+            case 0xEA:
+            case 0xEB:
+            case 0xEC:
+            case 0xED:
+            case 0xEE:
+            case 0xEF:
+            case 0xF0:
+            case 0xF1:
+            case 0xF2:
+            case 0xF3:
+            case 0xF4:
+            case 0xF5:
+            case 0xF6:
+            case 0xF7:
+            case 0xF8:
+            case 0xF9:
+            case 0xFA:
+            case 0xFB:
+            case 0xFC:
+            case 0xFD:
+            case 0xFE:
+            case 0xFF:
+                return sax->number_integer(static_cast<std::int8_t>(current));
+
+            default: // anything else
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief reads a MessagePack string
+
+    This function first reads starting bytes to determine the expected
+    string length and then copies this number of bytes into a string.
+
+    @param[out] result  created string
+
+    @return whether string creation completed
+    */
+    bool get_msgpack_string(string_t& result)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string")))
+        {
+            return false;
+        }
+
+        switch (current)
+        {
+            // fixstr
+            case 0xA0:
+            case 0xA1:
+            case 0xA2:
+            case 0xA3:
+            case 0xA4:
+            case 0xA5:
+            case 0xA6:
+            case 0xA7:
+            case 0xA8:
+            case 0xA9:
+            case 0xAA:
+            case 0xAB:
+            case 0xAC:
+            case 0xAD:
+            case 0xAE:
+            case 0xAF:
+            case 0xB0:
+            case 0xB1:
+            case 0xB2:
+            case 0xB3:
+            case 0xB4:
+            case 0xB5:
+            case 0xB6:
+            case 0xB7:
+            case 0xB8:
+            case 0xB9:
+            case 0xBA:
+            case 0xBB:
+            case 0xBC:
+            case 0xBD:
+            case 0xBE:
+            case 0xBF:
+            {
+                return get_string(input_format_t::msgpack, static_cast<unsigned int>(current) & 0x1Fu, result);
+            }
+
+            case 0xD9: // str 8
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
+            }
+
+            case 0xDA: // str 16
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
+            }
+
+            case 0xDB: // str 32
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
+            }
+
+            default:
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief reads a MessagePack byte array
+
+    This function first reads starting bytes to determine the expected
+    byte array length and then copies this number of bytes into a byte array.
+
+    @param[out] result  created byte array
+
+    @return whether byte array creation completed
+    */
+    bool get_msgpack_binary(binary_t& result)
+    {
+        // helper function to set the subtype
+        auto assign_and_return_true = [&result](std::int8_t subtype)
+        {
+            result.set_subtype(static_cast<std::uint8_t>(subtype));
+            return true;
+        };
+
+        switch (current)
+        {
+            case 0xC4: // bin 8
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_binary(input_format_t::msgpack, len, result);
+            }
+
+            case 0xC5: // bin 16
+            {
+                std::uint16_t len{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_binary(input_format_t::msgpack, len, result);
+            }
+
+            case 0xC6: // bin 32
+            {
+                std::uint32_t len{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_binary(input_format_t::msgpack, len, result);
+            }
+
+            case 0xC7: // ext 8
+            {
+                std::uint8_t len{};
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, len, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xC8: // ext 16
+            {
+                std::uint16_t len{};
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, len, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xC9: // ext 32
+            {
+                std::uint32_t len{};
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, len) &&
+                       get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, len, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xD4: // fixext 1
+            {
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, 1, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xD5: // fixext 2
+            {
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, 2, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xD6: // fixext 4
+            {
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, 4, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xD7: // fixext 8
+            {
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, 8, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            case 0xD8: // fixext 16
+            {
+                std::int8_t subtype{};
+                return get_number(input_format_t::msgpack, subtype) &&
+                       get_binary(input_format_t::msgpack, 16, result) &&
+                       assign_and_return_true(subtype);
+            }
+
+            default:           // LCOV_EXCL_LINE
+                return false;  // LCOV_EXCL_LINE
+        }
+    }
+
+    /*!
+    @param[in] len  the length of the array
+    @return whether array creation completed
+    */
+    bool get_msgpack_array(const std::size_t len)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len)))
+        {
+            return false;
+        }
+
+        for (std::size_t i = 0; i < len; ++i)
+        {
+            if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal()))
+            {
+                return false;
+            }
+        }
+
+        return sax->end_array();
+    }
+
+    /*!
+    @param[in] len  the length of the object
+    @return whether object creation completed
+    */
+    bool get_msgpack_object(const std::size_t len)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len)))
+        {
+            return false;
+        }
+
+        string_t key;
+        for (std::size_t i = 0; i < len; ++i)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key)))
+            {
+                return false;
+            }
+
+            if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal()))
+            {
+                return false;
+            }
+            key.clear();
+        }
+
+        return sax->end_object();
+    }
+
+    ////////////
+    // UBJSON //
+    ////////////
+
+    /*!
+    @param[in] get_char  whether a new character should be retrieved from the
+                         input (true, default) or whether the last read
+                         character should be considered instead
+
+    @return whether a valid UBJSON value was passed to the SAX parser
+    */
+    bool parse_ubjson_internal(const bool get_char = true)
+    {
+        return get_ubjson_value(get_char ? get_ignore_noop() : current);
+    }
+
+    /*!
+    @brief reads a UBJSON string
+
+    This function is either called after reading the 'S' byte explicitly
+    indicating a string, or in case of an object key where the 'S' byte can be
+    left out.
+
+    @param[out] result   created string
+    @param[in] get_char  whether a new character should be retrieved from the
+                         input (true, default) or whether the last read
+                         character should be considered instead
+
+    @return whether string creation completed
+    */
+    bool get_ubjson_string(string_t& result, const bool get_char = true)
+    {
+        if (get_char)
+        {
+            get();  // TODO(niels): may we ignore N here?
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value")))
+        {
+            return false;
+        }
+
+        switch (current)
+        {
+            case 'U':
+            {
+                std::uint8_t len{};
+                return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
+            }
+
+            case 'i':
+            {
+                std::int8_t len{};
+                return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
+            }
+
+            case 'I':
+            {
+                std::int16_t len{};
+                return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
+            }
+
+            case 'l':
+            {
+                std::int32_t len{};
+                return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
+            }
+
+            case 'L':
+            {
+                std::int64_t len{};
+                return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result);
+            }
+
+            default:
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType()));
+        }
+    }
+
+    /*!
+    @param[out] result  determined size
+    @return whether size determination completed
+    */
+    bool get_ubjson_size_value(std::size_t& result)
+    {
+        switch (get_ignore_noop())
+        {
+            case 'U':
+            {
+                std::uint8_t number{};
+                if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
+                {
+                    return false;
+                }
+                result = static_cast<std::size_t>(number);
+                return true;
+            }
+
+            case 'i':
+            {
+                std::int8_t number{};
+                if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
+                {
+                    return false;
+                }
+                result = static_cast<std::size_t>(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char
+                return true;
+            }
+
+            case 'I':
+            {
+                std::int16_t number{};
+                if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
+                {
+                    return false;
+                }
+                result = static_cast<std::size_t>(number);
+                return true;
+            }
+
+            case 'l':
+            {
+                std::int32_t number{};
+                if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
+                {
+                    return false;
+                }
+                result = static_cast<std::size_t>(number);
+                return true;
+            }
+
+            case 'L':
+            {
+                std::int64_t number{};
+                if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number)))
+                {
+                    return false;
+                }
+                result = static_cast<std::size_t>(number);
+                return true;
+            }
+
+            default:
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @brief determine the type and size for a container
+
+    In the optimized UBJSON format, a type and a size can be provided to allow
+    for a more compact representation.
+
+    @param[out] result  pair of the size and the type
+
+    @return whether pair creation completed
+    */
+    bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
+    {
+        result.first = string_t::npos; // size
+        result.second = 0; // type
+
+        get_ignore_noop();
+
+        if (current == '$')
+        {
+            result.second = get();  // must not ignore 'N', because 'N' maybe the type
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type")))
+            {
+                return false;
+            }
+
+            get_ignore_noop();
+            if (JSON_HEDLEY_UNLIKELY(current != '#'))
+            {
+                if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value")))
+                {
+                    return false;
+                }
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType()));
+            }
+
+            return get_ubjson_size_value(result.first);
+        }
+
+        if (current == '#')
+        {
+            return get_ubjson_size_value(result.first);
+        }
+
+        return true;
+    }
+
+    /*!
+    @param prefix  the previously read or set type prefix
+    @return whether value creation completed
+    */
+    bool get_ubjson_value(const char_int_type prefix)
+    {
+        switch (prefix)
+        {
+            case std::char_traits<char_type>::eof():  // EOF
+                return unexpect_eof(input_format_t::ubjson, "value");
+
+            case 'T':  // true
+                return sax->boolean(true);
+            case 'F':  // false
+                return sax->boolean(false);
+
+            case 'Z':  // null
+                return sax->null();
+
+            case 'U':
+            {
+                std::uint8_t number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number);
+            }
+
+            case 'i':
+            {
+                std::int8_t number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
+            }
+
+            case 'I':
+            {
+                std::int16_t number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
+            }
+
+            case 'l':
+            {
+                std::int32_t number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
+            }
+
+            case 'L':
+            {
+                std::int64_t number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_integer(number);
+            }
+
+            case 'd':
+            {
+                float number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 'D':
+            {
+                double number{};
+                return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast<number_float_t>(number), "");
+            }
+
+            case 'H':
+            {
+                return get_ubjson_high_precision_number();
+            }
+
+            case 'C':  // char
+            {
+                get();
+                if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char")))
+                {
+                    return false;
+                }
+                if (JSON_HEDLEY_UNLIKELY(current > 127))
+                {
+                    auto last_token = get_token_string();
+                    return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType()));
+                }
+                string_t s(1, static_cast<typename string_t::value_type>(current));
+                return sax->string(s);
+            }
+
+            case 'S':  // string
+            {
+                string_t s;
+                return get_ubjson_string(s) && sax->string(s);
+            }
+
+            case '[':  // array
+                return get_ubjson_array();
+
+            case '{':  // object
+                return get_ubjson_object();
+
+            default: // anything else
+            {
+                auto last_token = get_token_string();
+                return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType()));
+            }
+        }
+    }
+
+    /*!
+    @return whether array creation completed
+    */
+    bool get_ubjson_array()
+    {
+        std::pair<std::size_t, char_int_type> size_and_type;
+        if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
+        {
+            return false;
+        }
+
+        if (size_and_type.first != string_t::npos)
+        {
+            if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first)))
+            {
+                return false;
+            }
+
+            if (size_and_type.second != 0)
+            {
+                if (size_and_type.second != 'N')
+                {
+                    for (std::size_t i = 0; i < size_and_type.first; ++i)
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
+                        {
+                            return false;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                for (std::size_t i = 0; i < size_and_type.first; ++i)
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+        else
+        {
+            if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
+            {
+                return false;
+            }
+
+            while (current != ']')
+            {
+                if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false)))
+                {
+                    return false;
+                }
+                get_ignore_noop();
+            }
+        }
+
+        return sax->end_array();
+    }
+
+    /*!
+    @return whether object creation completed
+    */
+    bool get_ubjson_object()
+    {
+        std::pair<std::size_t, char_int_type> size_and_type;
+        if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type)))
+        {
+            return false;
+        }
+
+        string_t key;
+        if (size_and_type.first != string_t::npos)
+        {
+            if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first)))
+            {
+                return false;
+            }
+
+            if (size_and_type.second != 0)
+            {
+                for (std::size_t i = 0; i < size_and_type.first; ++i)
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
+                    {
+                        return false;
+                    }
+                    if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second)))
+                    {
+                        return false;
+                    }
+                    key.clear();
+                }
+            }
+            else
+            {
+                for (std::size_t i = 0; i < size_and_type.first; ++i)
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key)))
+                    {
+                        return false;
+                    }
+                    if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
+                    {
+                        return false;
+                    }
+                    key.clear();
+                }
+            }
+        }
+        else
+        {
+            if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
+            {
+                return false;
+            }
+
+            while (current != '}')
+            {
+                if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key)))
+                {
+                    return false;
+                }
+                if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal()))
+                {
+                    return false;
+                }
+                get_ignore_noop();
+                key.clear();
+            }
+        }
+
+        return sax->end_object();
+    }
+
+    // Note, no reader for UBJSON binary types is implemented because they do
+    // not exist
+
+    bool get_ubjson_high_precision_number()
+    {
+        // get size of following number string
+        std::size_t size{};
+        auto res = get_ubjson_size_value(size);
+        if (JSON_HEDLEY_UNLIKELY(!res))
+        {
+            return res;
+        }
+
+        // get number string
+        std::vector<char> number_vector;
+        for (std::size_t i = 0; i < size; ++i)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number")))
+            {
+                return false;
+            }
+            number_vector.push_back(static_cast<char>(current));
+        }
+
+        // parse number string
+        using ia_type = decltype(detail::input_adapter(number_vector));
+        auto number_lexer = detail::lexer<BasicJsonType, ia_type>(detail::input_adapter(number_vector), false);
+        const auto result_number = number_lexer.scan();
+        const auto number_string = number_lexer.get_token_string();
+        const auto result_remainder = number_lexer.scan();
+
+        using token_type = typename detail::lexer_base<BasicJsonType>::token_type;
+
+        if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input))
+        {
+            return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType()));
+        }
+
+        switch (result_number)
+        {
+            case token_type::value_integer:
+                return sax->number_integer(number_lexer.get_number_integer());
+            case token_type::value_unsigned:
+                return sax->number_unsigned(number_lexer.get_number_unsigned());
+            case token_type::value_float:
+                return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
+            case token_type::uninitialized:
+            case token_type::literal_true:
+            case token_type::literal_false:
+            case token_type::literal_null:
+            case token_type::value_string:
+            case token_type::begin_array:
+            case token_type::begin_object:
+            case token_type::end_array:
+            case token_type::end_object:
+            case token_type::name_separator:
+            case token_type::value_separator:
+            case token_type::parse_error:
+            case token_type::end_of_input:
+            case token_type::literal_or_value:
+            default:
+                return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType()));
+        }
+    }
+
+    ///////////////////////
+    // Utility functions //
+    ///////////////////////
+
+    /*!
+    @brief get next character from the input
+
+    This function provides the interface to the used input adapter. It does
+    not throw in case the input reached EOF, but returns a -'ve valued
+    `std::char_traits<char_type>::eof()` in that case.
+
+    @return character read from the input
+    */
+    char_int_type get()
+    {
+        ++chars_read;
+        return current = ia.get_character();
+    }
+
+    /*!
+    @return character read from the input after ignoring all 'N' entries
+    */
+    char_int_type get_ignore_noop()
+    {
+        do
+        {
+            get();
+        }
+        while (current == 'N');
+
+        return current;
+    }
+
+    /*
+    @brief read a number from the input
+
+    @tparam NumberType the type of the number
+    @param[in] format   the current format (for diagnostics)
+    @param[out] result  number of type @a NumberType
+
+    @return whether conversion completed
+
+    @note This function needs to respect the system's endianess, because
+          bytes in CBOR, MessagePack, and UBJSON are stored in network order
+          (big endian) and therefore need reordering on little endian systems.
+    */
+    template<typename NumberType, bool InputIsLittleEndian = false>
+    bool get_number(const input_format_t format, NumberType& result)
+    {
+        // step 1: read input into array with system's byte order
+        std::array<std::uint8_t, sizeof(NumberType)> vec{};
+        for (std::size_t i = 0; i < sizeof(NumberType); ++i)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number")))
+            {
+                return false;
+            }
+
+            // reverse byte order prior to conversion if necessary
+            if (is_little_endian != InputIsLittleEndian)
+            {
+                vec[sizeof(NumberType) - i - 1] = static_cast<std::uint8_t>(current);
+            }
+            else
+            {
+                vec[i] = static_cast<std::uint8_t>(current); // LCOV_EXCL_LINE
+            }
+        }
+
+        // step 2: convert array into number of type T and return
+        std::memcpy(&result, vec.data(), sizeof(NumberType));
+        return true;
+    }
+
+    /*!
+    @brief create a string by reading characters from the input
+
+    @tparam NumberType the type of the number
+    @param[in] format the current format (for diagnostics)
+    @param[in] len number of characters to read
+    @param[out] result string created by reading @a len bytes
+
+    @return whether string creation completed
+
+    @note We can not reserve @a len bytes for the result, because @a len
+          may be too large. Usually, @ref unexpect_eof() detects the end of
+          the input before we run out of string memory.
+    */
+    template<typename NumberType>
+    bool get_string(const input_format_t format,
+                    const NumberType len,
+                    string_t& result)
+    {
+        bool success = true;
+        for (NumberType i = 0; i < len; i++)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string")))
+            {
+                success = false;
+                break;
+            }
+            result.push_back(static_cast<typename string_t::value_type>(current));
+        }
+        return success;
+    }
+
+    /*!
+    @brief create a byte array by reading bytes from the input
+
+    @tparam NumberType the type of the number
+    @param[in] format the current format (for diagnostics)
+    @param[in] len number of bytes to read
+    @param[out] result byte array created by reading @a len bytes
+
+    @return whether byte array creation completed
+
+    @note We can not reserve @a len bytes for the result, because @a len
+          may be too large. Usually, @ref unexpect_eof() detects the end of
+          the input before we run out of memory.
+    */
+    template<typename NumberType>
+    bool get_binary(const input_format_t format,
+                    const NumberType len,
+                    binary_t& result)
+    {
+        bool success = true;
+        for (NumberType i = 0; i < len; i++)
+        {
+            get();
+            if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary")))
+            {
+                success = false;
+                break;
+            }
+            result.push_back(static_cast<std::uint8_t>(current));
+        }
+        return success;
+    }
+
+    /*!
+    @param[in] format   the current format (for diagnostics)
+    @param[in] context  further context information (for diagnostics)
+    @return whether the last read character is not EOF
+    */
+    JSON_HEDLEY_NON_NULL(3)
+    bool unexpect_eof(const input_format_t format, const char* context) const
+    {
+        if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
+        {
+            return sax->parse_error(chars_read, "<end of file>",
+                                    parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType()));
+        }
+        return true;
+    }
+
+    /*!
+    @return a string representation of the last read byte
+    */
+    std::string get_token_string() const
+    {
+        std::array<char, 3> cr{{}};
+        (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+        return std::string{cr.data()};
+    }
+
+    /*!
+    @param[in] format   the current format
+    @param[in] detail   a detailed error message
+    @param[in] context  further context information
+    @return a message string to use in the parse_error exceptions
+    */
+    std::string exception_message(const input_format_t format,
+                                  const std::string& detail,
+                                  const std::string& context) const
+    {
+        std::string error_msg = "syntax error while parsing ";
+
+        switch (format)
+        {
+            case input_format_t::cbor:
+                error_msg += "CBOR";
+                break;
+
+            case input_format_t::msgpack:
+                error_msg += "MessagePack";
+                break;
+
+            case input_format_t::ubjson:
+                error_msg += "UBJSON";
+                break;
+
+            case input_format_t::bson:
+                error_msg += "BSON";
+                break;
+
+            case input_format_t::json: // LCOV_EXCL_LINE
+            default:            // LCOV_EXCL_LINE
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        }
+
+        return error_msg + " " + context + ": " + detail;
+    }
+
+  private:
+    /// input adapter
+    InputAdapterType ia;
+
+    /// the current character
+    char_int_type current = std::char_traits<char_type>::eof();
+
+    /// the number of characters read
+    std::size_t chars_read = 0;
+
+    /// whether we can assume little endianess
+    const bool is_little_endian = little_endianess();
+
+    /// the SAX parser
+    json_sax_t* sax = nullptr;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/lexer.hpp>
+
+// #include <nlohmann/detail/input/parser.hpp>
+
+
+#include <cmath> // isfinite
+#include <cstdint> // uint8_t
+#include <functional> // function
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/input/input_adapters.hpp>
+
+// #include <nlohmann/detail/input/json_sax.hpp>
+
+// #include <nlohmann/detail/input/lexer.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/is_sax.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+////////////
+// parser //
+////////////
+
+enum class parse_event_t : std::uint8_t
+{
+    /// the parser read `{` and started to process a JSON object
+    object_start,
+    /// the parser read `}` and finished processing a JSON object
+    object_end,
+    /// the parser read `[` and started to process a JSON array
+    array_start,
+    /// the parser read `]` and finished processing a JSON array
+    array_end,
+    /// the parser read a key of a value in an object
+    key,
+    /// the parser finished reading a JSON value
+    value
+};
+
+template<typename BasicJsonType>
+using parser_callback_t =
+    std::function<bool(int /*depth*/, parse_event_t /*event*/, BasicJsonType& /*parsed*/)>;
+
+/*!
+@brief syntax analysis
+
+This class implements a recursive descent parser.
+*/
+template<typename BasicJsonType, typename InputAdapterType>
+class parser
+{
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using string_t = typename BasicJsonType::string_t;
+    using lexer_t = lexer<BasicJsonType, InputAdapterType>;
+    using token_type = typename lexer_t::token_type;
+
+  public:
+    /// a parser reading from an input adapter
+    explicit parser(InputAdapterType&& adapter,
+                    const parser_callback_t<BasicJsonType> cb = nullptr,
+                    const bool allow_exceptions_ = true,
+                    const bool skip_comments = false)
+        : callback(cb)
+        , m_lexer(std::move(adapter), skip_comments)
+        , allow_exceptions(allow_exceptions_)
+    {
+        // read first token
+        get_token();
+    }
+
+    /*!
+    @brief public parser interface
+
+    @param[in] strict      whether to expect the last token to be EOF
+    @param[in,out] result  parsed JSON value
+
+    @throw parse_error.101 in case of an unexpected token
+    @throw parse_error.102 if to_unicode fails or surrogate error
+    @throw parse_error.103 if to_unicode fails
+    */
+    void parse(const bool strict, BasicJsonType& result)
+    {
+        if (callback)
+        {
+            json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
+            sax_parse_internal(&sdp);
+
+            // in strict mode, input must be completely read
+            if (strict && (get_token() != token_type::end_of_input))
+            {
+                sdp.parse_error(m_lexer.get_position(),
+                                m_lexer.get_token_string(),
+                                parse_error::create(101, m_lexer.get_position(),
+                                                    exception_message(token_type::end_of_input, "value"), BasicJsonType()));
+            }
+
+            // in case of an error, return discarded value
+            if (sdp.is_errored())
+            {
+                result = value_t::discarded;
+                return;
+            }
+
+            // set top-level value to null if it was discarded by the callback
+            // function
+            if (result.is_discarded())
+            {
+                result = nullptr;
+            }
+        }
+        else
+        {
+            json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
+            sax_parse_internal(&sdp);
+
+            // in strict mode, input must be completely read
+            if (strict && (get_token() != token_type::end_of_input))
+            {
+                sdp.parse_error(m_lexer.get_position(),
+                                m_lexer.get_token_string(),
+                                parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType()));
+            }
+
+            // in case of an error, return discarded value
+            if (sdp.is_errored())
+            {
+                result = value_t::discarded;
+                return;
+            }
+        }
+
+        result.assert_invariant();
+    }
+
+    /*!
+    @brief public accept interface
+
+    @param[in] strict  whether to expect the last token to be EOF
+    @return whether the input is a proper JSON text
+    */
+    bool accept(const bool strict = true)
+    {
+        json_sax_acceptor<BasicJsonType> sax_acceptor;
+        return sax_parse(&sax_acceptor, strict);
+    }
+
+    template<typename SAX>
+    JSON_HEDLEY_NON_NULL(2)
+    bool sax_parse(SAX* sax, const bool strict = true)
+    {
+        (void)detail::is_sax_static_asserts<SAX, BasicJsonType> {};
+        const bool result = sax_parse_internal(sax);
+
+        // strict mode: next byte must be EOF
+        if (result && strict && (get_token() != token_type::end_of_input))
+        {
+            return sax->parse_error(m_lexer.get_position(),
+                                    m_lexer.get_token_string(),
+                                    parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType()));
+        }
+
+        return result;
+    }
+
+  private:
+    template<typename SAX>
+    JSON_HEDLEY_NON_NULL(2)
+    bool sax_parse_internal(SAX* sax)
+    {
+        // stack to remember the hierarchy of structured values we are parsing
+        // true = array; false = object
+        std::vector<bool> states;
+        // value to avoid a goto (see comment where set to true)
+        bool skip_to_state_evaluation = false;
+
+        while (true)
+        {
+            if (!skip_to_state_evaluation)
+            {
+                // invariant: get_token() was called before each iteration
+                switch (last_token)
+                {
+                    case token_type::begin_object:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
+                        {
+                            return false;
+                        }
+
+                        // closing } -> we are done
+                        if (get_token() == token_type::end_object)
+                        {
+                            if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
+                            {
+                                return false;
+                            }
+                            break;
+                        }
+
+                        // parse key
+                        if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string))
+                        {
+                            return sax->parse_error(m_lexer.get_position(),
+                                                    m_lexer.get_token_string(),
+                                                    parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType()));
+                        }
+                        if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
+                        {
+                            return false;
+                        }
+
+                        // parse separator (:)
+                        if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
+                        {
+                            return sax->parse_error(m_lexer.get_position(),
+                                                    m_lexer.get_token_string(),
+                                                    parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType()));
+                        }
+
+                        // remember we are now inside an object
+                        states.push_back(false);
+
+                        // parse values
+                        get_token();
+                        continue;
+                    }
+
+                    case token_type::begin_array:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
+                        {
+                            return false;
+                        }
+
+                        // closing ] -> we are done
+                        if (get_token() == token_type::end_array)
+                        {
+                            if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
+                            {
+                                return false;
+                            }
+                            break;
+                        }
+
+                        // remember we are now inside an array
+                        states.push_back(true);
+
+                        // parse values (no need to call get_token)
+                        continue;
+                    }
+
+                    case token_type::value_float:
+                    {
+                        const auto res = m_lexer.get_number_float();
+
+                        if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res)))
+                        {
+                            return sax->parse_error(m_lexer.get_position(),
+                                                    m_lexer.get_token_string(),
+                                                    out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType()));
+                        }
+
+                        if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string())))
+                        {
+                            return false;
+                        }
+
+                        break;
+                    }
+
+                    case token_type::literal_false:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false)))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::literal_null:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->null()))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::literal_true:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true)))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::value_integer:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer())))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::value_string:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string())))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::value_unsigned:
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned())))
+                        {
+                            return false;
+                        }
+                        break;
+                    }
+
+                    case token_type::parse_error:
+                    {
+                        // using "uninitialized" to avoid "expected" message
+                        return sax->parse_error(m_lexer.get_position(),
+                                                m_lexer.get_token_string(),
+                                                parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType()));
+                    }
+
+                    case token_type::uninitialized:
+                    case token_type::end_array:
+                    case token_type::end_object:
+                    case token_type::name_separator:
+                    case token_type::value_separator:
+                    case token_type::end_of_input:
+                    case token_type::literal_or_value:
+                    default: // the last token was unexpected
+                    {
+                        return sax->parse_error(m_lexer.get_position(),
+                                                m_lexer.get_token_string(),
+                                                parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType()));
+                    }
+                }
+            }
+            else
+            {
+                skip_to_state_evaluation = false;
+            }
+
+            // we reached this line after we successfully parsed a value
+            if (states.empty())
+            {
+                // empty stack: we reached the end of the hierarchy: done
+                return true;
+            }
+
+            if (states.back())  // array
+            {
+                // comma -> next value
+                if (get_token() == token_type::value_separator)
+                {
+                    // parse a new value
+                    get_token();
+                    continue;
+                }
+
+                // closing ]
+                if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array))
+                {
+                    if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
+                    {
+                        return false;
+                    }
+
+                    // We are done with this array. Before we can parse a
+                    // new value, we need to evaluate the new state first.
+                    // By setting skip_to_state_evaluation to false, we
+                    // are effectively jumping to the beginning of this if.
+                    JSON_ASSERT(!states.empty());
+                    states.pop_back();
+                    skip_to_state_evaluation = true;
+                    continue;
+                }
+
+                return sax->parse_error(m_lexer.get_position(),
+                                        m_lexer.get_token_string(),
+                                        parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType()));
+            }
+
+            // states.back() is false -> object
+
+            // comma -> next value
+            if (get_token() == token_type::value_separator)
+            {
+                // parse key
+                if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string))
+                {
+                    return sax->parse_error(m_lexer.get_position(),
+                                            m_lexer.get_token_string(),
+                                            parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType()));
+                }
+
+                if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
+                {
+                    return false;
+                }
+
+                // parse separator (:)
+                if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator))
+                {
+                    return sax->parse_error(m_lexer.get_position(),
+                                            m_lexer.get_token_string(),
+                                            parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType()));
+                }
+
+                // parse values
+                get_token();
+                continue;
+            }
+
+            // closing }
+            if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
+            {
+                if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
+                {
+                    return false;
+                }
+
+                // We are done with this object. Before we can parse a
+                // new value, we need to evaluate the new state first.
+                // By setting skip_to_state_evaluation to false, we
+                // are effectively jumping to the beginning of this if.
+                JSON_ASSERT(!states.empty());
+                states.pop_back();
+                skip_to_state_evaluation = true;
+                continue;
+            }
+
+            return sax->parse_error(m_lexer.get_position(),
+                                    m_lexer.get_token_string(),
+                                    parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType()));
+        }
+    }
+
+    /// get next token from lexer
+    token_type get_token()
+    {
+        return last_token = m_lexer.scan();
+    }
+
+    std::string exception_message(const token_type expected, const std::string& context)
+    {
+        std::string error_msg = "syntax error ";
+
+        if (!context.empty())
+        {
+            error_msg += "while parsing " + context + " ";
+        }
+
+        error_msg += "- ";
+
+        if (last_token == token_type::parse_error)
+        {
+            error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" +
+                         m_lexer.get_token_string() + "'";
+        }
+        else
+        {
+            error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token));
+        }
+
+        if (expected != token_type::uninitialized)
+        {
+            error_msg += "; expected " + std::string(lexer_t::token_type_name(expected));
+        }
+
+        return error_msg;
+    }
+
+  private:
+    /// callback function
+    const parser_callback_t<BasicJsonType> callback = nullptr;
+    /// the type of the last read token
+    token_type last_token = token_type::uninitialized;
+    /// the lexer
+    lexer_t m_lexer;
+    /// whether to throw exceptions in case of errors
+    const bool allow_exceptions = true;
+};
+
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/internal_iterator.hpp>
+
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+
+#include <cstddef> // ptrdiff_t
+#include <limits>  // numeric_limits
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/*
+@brief an iterator for primitive JSON types
+
+This class models an iterator for primitive JSON types (boolean, number,
+string). It's only purpose is to allow the iterator/const_iterator classes
+to "iterate" over primitive values. Internally, the iterator is modeled by
+a `difference_type` variable. Value begin_value (`0`) models the begin,
+end_value (`1`) models past the end.
+*/
+class primitive_iterator_t
+{
+  private:
+    using difference_type = std::ptrdiff_t;
+    static constexpr difference_type begin_value = 0;
+    static constexpr difference_type end_value = begin_value + 1;
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    /// iterator as signed integer type
+    difference_type m_it = (std::numeric_limits<std::ptrdiff_t>::min)();
+
+  public:
+    constexpr difference_type get_value() const noexcept
+    {
+        return m_it;
+    }
+
+    /// set iterator to a defined beginning
+    void set_begin() noexcept
+    {
+        m_it = begin_value;
+    }
+
+    /// set iterator to a defined past the end
+    void set_end() noexcept
+    {
+        m_it = end_value;
+    }
+
+    /// return whether the iterator can be dereferenced
+    constexpr bool is_begin() const noexcept
+    {
+        return m_it == begin_value;
+    }
+
+    /// return whether the iterator is at end
+    constexpr bool is_end() const noexcept
+    {
+        return m_it == end_value;
+    }
+
+    friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+    {
+        return lhs.m_it == rhs.m_it;
+    }
+
+    friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+    {
+        return lhs.m_it < rhs.m_it;
+    }
+
+    primitive_iterator_t operator+(difference_type n) noexcept
+    {
+        auto result = *this;
+        result += n;
+        return result;
+    }
+
+    friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
+    {
+        return lhs.m_it - rhs.m_it;
+    }
+
+    primitive_iterator_t& operator++() noexcept
+    {
+        ++m_it;
+        return *this;
+    }
+
+    primitive_iterator_t const operator++(int) noexcept // NOLINT(readability-const-return-type)
+    {
+        auto result = *this;
+        ++m_it;
+        return result;
+    }
+
+    primitive_iterator_t& operator--() noexcept
+    {
+        --m_it;
+        return *this;
+    }
+
+    primitive_iterator_t const operator--(int) noexcept // NOLINT(readability-const-return-type)
+    {
+        auto result = *this;
+        --m_it;
+        return result;
+    }
+
+    primitive_iterator_t& operator+=(difference_type n) noexcept
+    {
+        m_it += n;
+        return *this;
+    }
+
+    primitive_iterator_t& operator-=(difference_type n) noexcept
+    {
+        m_it -= n;
+        return *this;
+    }
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/*!
+@brief an iterator value
+
+@note This structure could easily be a union, but MSVC currently does not allow
+unions members with complex constructors, see https://github.com/nlohmann/json/pull/105.
+*/
+template<typename BasicJsonType> struct internal_iterator
+{
+    /// iterator for JSON objects
+    typename BasicJsonType::object_t::iterator object_iterator {};
+    /// iterator for JSON arrays
+    typename BasicJsonType::array_t::iterator array_iterator {};
+    /// generic iterator for all other types
+    primitive_iterator_t primitive_iterator {};
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/iter_impl.hpp>
+
+
+#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
+#include <type_traits> // conditional, is_const, remove_const
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/iterators/internal_iterator.hpp>
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+// forward declare, to be able to friend it later on
+template<typename IteratorType> class iteration_proxy;
+template<typename IteratorType> class iteration_proxy_value;
+
+/*!
+@brief a template for a bidirectional iterator for the @ref basic_json class
+This class implements a both iterators (iterator and const_iterator) for the
+@ref basic_json class.
+@note An iterator is called *initialized* when a pointer to a JSON value has
+      been set (e.g., by a constructor or a copy assignment). If the iterator is
+      default-constructed, it is *uninitialized* and most methods are undefined.
+      **The library uses assertions to detect calls on uninitialized iterators.**
+@requirement The class satisfies the following concept requirements:
+-
+[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
+  The iterator that can be moved can be moved in both directions (i.e.
+  incremented and decremented).
+@since version 1.0.0, simplified in version 2.0.9, change to bidirectional
+       iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)
+*/
+template<typename BasicJsonType>
+class iter_impl
+{
+    /// the iterator with BasicJsonType of different const-ness
+    using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value, typename std::remove_const<BasicJsonType>::type, const BasicJsonType>::type>;
+    /// allow basic_json to access private members
+    friend other_iter_impl;
+    friend BasicJsonType;
+    friend iteration_proxy<iter_impl>;
+    friend iteration_proxy_value<iter_impl>;
+
+    using object_t = typename BasicJsonType::object_t;
+    using array_t = typename BasicJsonType::array_t;
+    // make sure BasicJsonType is basic_json or const basic_json
+    static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,
+                  "iter_impl only accepts (const) basic_json");
+
+  public:
+
+    /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
+    /// The C++ Standard has never required user-defined iterators to derive from std::iterator.
+    /// A user-defined iterator should provide publicly accessible typedefs named
+    /// iterator_category, value_type, difference_type, pointer, and reference.
+    /// Note that value_type is required to be non-const, even for constant iterators.
+    using iterator_category = std::bidirectional_iterator_tag;
+
+    /// the type of the values when the iterator is dereferenced
+    using value_type = typename BasicJsonType::value_type;
+    /// a type to represent differences between iterators
+    using difference_type = typename BasicJsonType::difference_type;
+    /// defines a pointer to the type iterated over (value_type)
+    using pointer = typename std::conditional<std::is_const<BasicJsonType>::value,
+          typename BasicJsonType::const_pointer,
+          typename BasicJsonType::pointer>::type;
+    /// defines a reference to the type iterated over (value_type)
+    using reference =
+        typename std::conditional<std::is_const<BasicJsonType>::value,
+        typename BasicJsonType::const_reference,
+        typename BasicJsonType::reference>::type;
+
+    iter_impl() = default;
+    ~iter_impl() = default;
+    iter_impl(iter_impl&&) noexcept = default;
+    iter_impl& operator=(iter_impl&&) noexcept = default;
+
+    /*!
+    @brief constructor for a given JSON instance
+    @param[in] object  pointer to a JSON object for this iterator
+    @pre object != nullptr
+    @post The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    explicit iter_impl(pointer object) noexcept : m_object(object)
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                m_it.object_iterator = typename object_t::iterator();
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_it.array_iterator = typename array_t::iterator();
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                m_it.primitive_iterator = primitive_iterator_t();
+                break;
+            }
+        }
+    }
+
+    /*!
+    @note The conventional copy constructor and copy assignment are implicitly
+          defined. Combined with the following converting constructor and
+          assignment, they support: (1) copy from iterator to iterator, (2)
+          copy from const iterator to const iterator, and (3) conversion from
+          iterator to const iterator. However conversion from const iterator
+          to iterator is not defined.
+    */
+
+    /*!
+    @brief const copy constructor
+    @param[in] other const iterator to copy from
+    @note This copy constructor had to be defined explicitly to circumvent a bug
+          occurring on msvc v19.0 compiler (VS 2015) debug build. For more
+          information refer to: https://github.com/nlohmann/json/issues/1608
+    */
+    iter_impl(const iter_impl<const BasicJsonType>& other) noexcept
+        : m_object(other.m_object), m_it(other.m_it)
+    {}
+
+    /*!
+    @brief converting assignment
+    @param[in] other const iterator to copy from
+    @return const/non-const iterator
+    @note It is not checked whether @a other is initialized.
+    */
+    iter_impl& operator=(const iter_impl<const BasicJsonType>& other) noexcept
+    {
+        if (&other != this)
+        {
+            m_object = other.m_object;
+            m_it = other.m_it;
+        }
+        return *this;
+    }
+
+    /*!
+    @brief converting constructor
+    @param[in] other  non-const iterator to copy from
+    @note It is not checked whether @a other is initialized.
+    */
+    iter_impl(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept
+        : m_object(other.m_object), m_it(other.m_it)
+    {}
+
+    /*!
+    @brief converting assignment
+    @param[in] other  non-const iterator to copy from
+    @return const/non-const iterator
+    @note It is not checked whether @a other is initialized.
+    */
+    iter_impl& operator=(const iter_impl<typename std::remove_const<BasicJsonType>::type>& other) noexcept // NOLINT(cert-oop54-cpp)
+    {
+        m_object = other.m_object;
+        m_it = other.m_it;
+        return *this;
+    }
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    /*!
+    @brief set the iterator to the first value
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    void set_begin() noexcept
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                m_it.object_iterator = m_object->m_value.object->begin();
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_it.array_iterator = m_object->m_value.array->begin();
+                break;
+            }
+
+            case value_t::null:
+            {
+                // set to end so begin()==end() is true: null is empty
+                m_it.primitive_iterator.set_end();
+                break;
+            }
+
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                m_it.primitive_iterator.set_begin();
+                break;
+            }
+        }
+    }
+
+    /*!
+    @brief set the iterator past the last value
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    void set_end() noexcept
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                m_it.object_iterator = m_object->m_value.object->end();
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_it.array_iterator = m_object->m_value.array->end();
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                m_it.primitive_iterator.set_end();
+                break;
+            }
+        }
+    }
+
+  public:
+    /*!
+    @brief return a reference to the value pointed to by the iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    reference operator*() const
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
+                return m_it.object_iterator->second;
+            }
+
+            case value_t::array:
+            {
+                JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
+                return *m_it.array_iterator;
+            }
+
+            case value_t::null:
+                JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
+
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin()))
+                {
+                    return *m_object;
+                }
+
+                JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
+            }
+        }
+    }
+
+    /*!
+    @brief dereference the iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    pointer operator->() const
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
+                return &(m_it.object_iterator->second);
+            }
+
+            case value_t::array:
+            {
+                JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
+                return &*m_it.array_iterator;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin()))
+                {
+                    return m_object;
+                }
+
+                JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
+            }
+        }
+    }
+
+    /*!
+    @brief post-increment (it++)
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl const operator++(int) // NOLINT(readability-const-return-type)
+    {
+        auto result = *this;
+        ++(*this);
+        return result;
+    }
+
+    /*!
+    @brief pre-increment (++it)
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl& operator++()
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                std::advance(m_it.object_iterator, 1);
+                break;
+            }
+
+            case value_t::array:
+            {
+                std::advance(m_it.array_iterator, 1);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                ++m_it.primitive_iterator;
+                break;
+            }
+        }
+
+        return *this;
+    }
+
+    /*!
+    @brief post-decrement (it--)
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl const operator--(int) // NOLINT(readability-const-return-type)
+    {
+        auto result = *this;
+        --(*this);
+        return result;
+    }
+
+    /*!
+    @brief pre-decrement (--it)
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl& operator--()
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+            {
+                std::advance(m_it.object_iterator, -1);
+                break;
+            }
+
+            case value_t::array:
+            {
+                std::advance(m_it.array_iterator, -1);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                --m_it.primitive_iterator;
+                break;
+            }
+        }
+
+        return *this;
+    }
+
+    /*!
+    @brief comparison: equal
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr >
+    bool operator==(const IterImpl& other) const
+    {
+        // if objects are not the same, the comparison is undefined
+        if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object));
+        }
+
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+                return (m_it.object_iterator == other.m_it.object_iterator);
+
+            case value_t::array:
+                return (m_it.array_iterator == other.m_it.array_iterator);
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                return (m_it.primitive_iterator == other.m_it.primitive_iterator);
+        }
+    }
+
+    /*!
+    @brief comparison: not equal
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    template < typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::nullptr_t > = nullptr >
+    bool operator!=(const IterImpl& other) const
+    {
+        return !operator==(other);
+    }
+
+    /*!
+    @brief comparison: smaller
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    bool operator<(const iter_impl& other) const
+    {
+        // if objects are not the same, the comparison is undefined
+        if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object));
+        }
+
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+                JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object));
+
+            case value_t::array:
+                return (m_it.array_iterator < other.m_it.array_iterator);
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                return (m_it.primitive_iterator < other.m_it.primitive_iterator);
+        }
+    }
+
+    /*!
+    @brief comparison: less than or equal
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    bool operator<=(const iter_impl& other) const
+    {
+        return !other.operator < (*this);
+    }
+
+    /*!
+    @brief comparison: greater than
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    bool operator>(const iter_impl& other) const
+    {
+        return !operator<=(other);
+    }
+
+    /*!
+    @brief comparison: greater than or equal
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    bool operator>=(const iter_impl& other) const
+    {
+        return !operator<(other);
+    }
+
+    /*!
+    @brief add to iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl& operator+=(difference_type i)
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+                JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object));
+
+            case value_t::array:
+            {
+                std::advance(m_it.array_iterator, i);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                m_it.primitive_iterator += i;
+                break;
+            }
+        }
+
+        return *this;
+    }
+
+    /*!
+    @brief subtract from iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl& operator-=(difference_type i)
+    {
+        return operator+=(-i);
+    }
+
+    /*!
+    @brief add to iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl operator+(difference_type i) const
+    {
+        auto result = *this;
+        result += i;
+        return result;
+    }
+
+    /*!
+    @brief addition of distance and iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    friend iter_impl operator+(difference_type i, const iter_impl& it)
+    {
+        auto result = it;
+        result += i;
+        return result;
+    }
+
+    /*!
+    @brief subtract from iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    iter_impl operator-(difference_type i) const
+    {
+        auto result = *this;
+        result -= i;
+        return result;
+    }
+
+    /*!
+    @brief return difference
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    difference_type operator-(const iter_impl& other) const
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+                JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object));
+
+            case value_t::array:
+                return m_it.array_iterator - other.m_it.array_iterator;
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                return m_it.primitive_iterator - other.m_it.primitive_iterator;
+        }
+    }
+
+    /*!
+    @brief access to successor
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    reference operator[](difference_type n) const
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        switch (m_object->m_type)
+        {
+            case value_t::object:
+                JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object));
+
+            case value_t::array:
+                return *std::next(m_it.array_iterator, n);
+
+            case value_t::null:
+                JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
+
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n))
+                {
+                    return *m_object;
+                }
+
+                JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
+            }
+        }
+    }
+
+    /*!
+    @brief return the key of an object iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    const typename object_t::key_type& key() const
+    {
+        JSON_ASSERT(m_object != nullptr);
+
+        if (JSON_HEDLEY_LIKELY(m_object->is_object()))
+        {
+            return m_it.object_iterator->first;
+        }
+
+        JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object));
+    }
+
+    /*!
+    @brief return the value of an iterator
+    @pre The iterator is initialized; i.e. `m_object != nullptr`.
+    */
+    reference value() const
+    {
+        return operator*();
+    }
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    /// associated JSON instance
+    pointer m_object = nullptr;
+    /// the actual iterator of the associated instance
+    internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
+};
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/iteration_proxy.hpp>
+
+// #include <nlohmann/detail/iterators/json_reverse_iterator.hpp>
+
+
+#include <cstddef> // ptrdiff_t
+#include <iterator> // reverse_iterator
+#include <utility> // declval
+
+namespace nlohmann
+{
+namespace detail
+{
+//////////////////////
+// reverse_iterator //
+//////////////////////
+
+/*!
+@brief a template for a reverse iterator class
+
+@tparam Base the base iterator type to reverse. Valid types are @ref
+iterator (to create @ref reverse_iterator) and @ref const_iterator (to
+create @ref const_reverse_iterator).
+
+@requirement The class satisfies the following concept requirements:
+-
+[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator):
+  The iterator that can be moved can be moved in both directions (i.e.
+  incremented and decremented).
+- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator):
+  It is possible to write to the pointed-to element (only if @a Base is
+  @ref iterator).
+
+@since version 1.0.0
+*/
+template<typename Base>
+class json_reverse_iterator : public std::reverse_iterator<Base>
+{
+  public:
+    using difference_type = std::ptrdiff_t;
+    /// shortcut to the reverse iterator adapter
+    using base_iterator = std::reverse_iterator<Base>;
+    /// the reference type for the pointed-to element
+    using reference = typename Base::reference;
+
+    /// create reverse iterator from iterator
+    explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
+        : base_iterator(it) {}
+
+    /// create reverse iterator from base class
+    explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}
+
+    /// post-increment (it++)
+    json_reverse_iterator const operator++(int) // NOLINT(readability-const-return-type)
+    {
+        return static_cast<json_reverse_iterator>(base_iterator::operator++(1));
+    }
+
+    /// pre-increment (++it)
+    json_reverse_iterator& operator++()
+    {
+        return static_cast<json_reverse_iterator&>(base_iterator::operator++());
+    }
+
+    /// post-decrement (it--)
+    json_reverse_iterator const operator--(int) // NOLINT(readability-const-return-type)
+    {
+        return static_cast<json_reverse_iterator>(base_iterator::operator--(1));
+    }
+
+    /// pre-decrement (--it)
+    json_reverse_iterator& operator--()
+    {
+        return static_cast<json_reverse_iterator&>(base_iterator::operator--());
+    }
+
+    /// add to iterator
+    json_reverse_iterator& operator+=(difference_type i)
+    {
+        return static_cast<json_reverse_iterator&>(base_iterator::operator+=(i));
+    }
+
+    /// add to iterator
+    json_reverse_iterator operator+(difference_type i) const
+    {
+        return static_cast<json_reverse_iterator>(base_iterator::operator+(i));
+    }
+
+    /// subtract from iterator
+    json_reverse_iterator operator-(difference_type i) const
+    {
+        return static_cast<json_reverse_iterator>(base_iterator::operator-(i));
+    }
+
+    /// return difference
+    difference_type operator-(const json_reverse_iterator& other) const
+    {
+        return base_iterator(*this) - base_iterator(other);
+    }
+
+    /// access to successor
+    reference operator[](difference_type n) const
+    {
+        return *(this->operator+(n));
+    }
+
+    /// return the key of an object iterator
+    auto key() const -> decltype(std::declval<Base>().key())
+    {
+        auto it = --this->base();
+        return it.key();
+    }
+
+    /// return the value of an iterator
+    reference value() const
+    {
+        auto it = --this->base();
+        return it.operator * ();
+    }
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
+
+// #include <nlohmann/detail/json_pointer.hpp>
+
+
+#include <algorithm> // all_of
+#include <cctype> // isdigit
+#include <limits> // max
+#include <numeric> // accumulate
+#include <string> // string
+#include <utility> // move
+#include <vector> // vector
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/string_escape.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+template<typename BasicJsonType>
+class json_pointer
+{
+    // allow basic_json to access private members
+    NLOHMANN_BASIC_JSON_TPL_DECLARATION
+    friend class basic_json;
+
+  public:
+    /*!
+    @brief create JSON pointer
+
+    Create a JSON pointer according to the syntax described in
+    [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
+
+    @param[in] s  string representing the JSON pointer; if omitted, the empty
+                  string is assumed which references the whole JSON value
+
+    @throw parse_error.107 if the given JSON pointer @a s is nonempty and does
+                           not begin with a slash (`/`); see example below
+
+    @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is
+    not followed by `0` (representing `~`) or `1` (representing `/`); see
+    example below
+
+    @liveexample{The example shows the construction several valid JSON pointers
+    as well as the exceptional behavior.,json_pointer}
+
+    @since version 2.0.0
+    */
+    explicit json_pointer(const std::string& s = "")
+        : reference_tokens(split(s))
+    {}
+
+    /*!
+    @brief return a string representation of the JSON pointer
+
+    @invariant For each JSON pointer `ptr`, it holds:
+    @code {.cpp}
+    ptr == json_pointer(ptr.to_string());
+    @endcode
+
+    @return a string representation of the JSON pointer
+
+    @liveexample{The example shows the result of `to_string`.,json_pointer__to_string}
+
+    @since version 2.0.0
+    */
+    std::string to_string() const
+    {
+        return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
+                               std::string{},
+                               [](const std::string & a, const std::string & b)
+        {
+            return a + "/" + detail::escape(b);
+        });
+    }
+
+    /// @copydoc to_string()
+    operator std::string() const
+    {
+        return to_string();
+    }
+
+    /*!
+    @brief append another JSON pointer at the end of this JSON pointer
+
+    @param[in] ptr  JSON pointer to append
+    @return JSON pointer with @a ptr appended
+
+    @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+    @complexity Linear in the length of @a ptr.
+
+    @sa see @ref operator/=(std::string) to append a reference token
+    @sa see @ref operator/=(std::size_t) to append an array index
+    @sa see @ref operator/(const json_pointer&, const json_pointer&) for a binary operator
+
+    @since version 3.6.0
+    */
+    json_pointer& operator/=(const json_pointer& ptr)
+    {
+        reference_tokens.insert(reference_tokens.end(),
+                                ptr.reference_tokens.begin(),
+                                ptr.reference_tokens.end());
+        return *this;
+    }
+
+    /*!
+    @brief append an unescaped reference token at the end of this JSON pointer
+
+    @param[in] token  reference token to append
+    @return JSON pointer with @a token appended without escaping @a token
+
+    @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+    @complexity Amortized constant.
+
+    @sa see @ref operator/=(const json_pointer&) to append a JSON pointer
+    @sa see @ref operator/=(std::size_t) to append an array index
+    @sa see @ref operator/(const json_pointer&, std::size_t) for a binary operator
+
+    @since version 3.6.0
+    */
+    json_pointer& operator/=(std::string token)
+    {
+        push_back(std::move(token));
+        return *this;
+    }
+
+    /*!
+    @brief append an array index at the end of this JSON pointer
+
+    @param[in] array_idx  array index to append
+    @return JSON pointer with @a array_idx appended
+
+    @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add}
+
+    @complexity Amortized constant.
+
+    @sa see @ref operator/=(const json_pointer&) to append a JSON pointer
+    @sa see @ref operator/=(std::string) to append a reference token
+    @sa see @ref operator/(const json_pointer&, std::string) for a binary operator
+
+    @since version 3.6.0
+    */
+    json_pointer& operator/=(std::size_t array_idx)
+    {
+        return *this /= std::to_string(array_idx);
+    }
+
+    /*!
+    @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
+
+    @param[in] lhs  JSON pointer
+    @param[in] rhs  JSON pointer
+    @return a new JSON pointer with @a rhs appended to @a lhs
+
+    @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+    @complexity Linear in the length of @a lhs and @a rhs.
+
+    @sa see @ref operator/=(const json_pointer&) to append a JSON pointer
+
+    @since version 3.6.0
+    */
+    friend json_pointer operator/(const json_pointer& lhs,
+                                  const json_pointer& rhs)
+    {
+        return json_pointer(lhs) /= rhs;
+    }
+
+    /*!
+    @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
+
+    @param[in] ptr  JSON pointer
+    @param[in] token  reference token
+    @return a new JSON pointer with unescaped @a token appended to @a ptr
+
+    @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+    @complexity Linear in the length of @a ptr.
+
+    @sa see @ref operator/=(std::string) to append a reference token
+
+    @since version 3.6.0
+    */
+    friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param)
+    {
+        return json_pointer(ptr) /= std::move(token);
+    }
+
+    /*!
+    @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
+
+    @param[in] ptr  JSON pointer
+    @param[in] array_idx  array index
+    @return a new JSON pointer with @a array_idx appended to @a ptr
+
+    @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary}
+
+    @complexity Linear in the length of @a ptr.
+
+    @sa see @ref operator/=(std::size_t) to append an array index
+
+    @since version 3.6.0
+    */
+    friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx)
+    {
+        return json_pointer(ptr) /= array_idx;
+    }
+
+    /*!
+    @brief returns the parent of this JSON pointer
+
+    @return parent of this JSON pointer; in case this JSON pointer is the root,
+            the root itself is returned
+
+    @complexity Linear in the length of the JSON pointer.
+
+    @liveexample{The example shows the result of `parent_pointer` for different
+    JSON Pointers.,json_pointer__parent_pointer}
+
+    @since version 3.6.0
+    */
+    json_pointer parent_pointer() const
+    {
+        if (empty())
+        {
+            return *this;
+        }
+
+        json_pointer res = *this;
+        res.pop_back();
+        return res;
+    }
+
+    /*!
+    @brief remove last reference token
+
+    @pre not `empty()`
+
+    @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back}
+
+    @complexity Constant.
+
+    @throw out_of_range.405 if JSON pointer has no parent
+
+    @since version 3.6.0
+    */
+    void pop_back()
+    {
+        if (JSON_HEDLEY_UNLIKELY(empty()))
+        {
+            JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
+        }
+
+        reference_tokens.pop_back();
+    }
+
+    /*!
+    @brief return last reference token
+
+    @pre not `empty()`
+    @return last reference token
+
+    @liveexample{The example shows the usage of `back`.,json_pointer__back}
+
+    @complexity Constant.
+
+    @throw out_of_range.405 if JSON pointer has no parent
+
+    @since version 3.6.0
+    */
+    const std::string& back() const
+    {
+        if (JSON_HEDLEY_UNLIKELY(empty()))
+        {
+            JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
+        }
+
+        return reference_tokens.back();
+    }
+
+    /*!
+    @brief append an unescaped token at the end of the reference pointer
+
+    @param[in] token  token to add
+
+    @complexity Amortized constant.
+
+    @liveexample{The example shows the result of `push_back` for different
+    JSON Pointers.,json_pointer__push_back}
+
+    @since version 3.6.0
+    */
+    void push_back(const std::string& token)
+    {
+        reference_tokens.push_back(token);
+    }
+
+    /// @copydoc push_back(const std::string&)
+    void push_back(std::string&& token)
+    {
+        reference_tokens.push_back(std::move(token));
+    }
+
+    /*!
+    @brief return whether pointer points to the root document
+
+    @return true iff the JSON pointer points to the root document
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example shows the result of `empty` for different JSON
+    Pointers.,json_pointer__empty}
+
+    @since version 3.6.0
+    */
+    bool empty() const noexcept
+    {
+        return reference_tokens.empty();
+    }
+
+  private:
+    /*!
+    @param[in] s  reference token to be converted into an array index
+
+    @return integer representation of @a s
+
+    @throw parse_error.106  if an array index begins with '0'
+    @throw parse_error.109  if an array index begins not with a digit
+    @throw out_of_range.404 if string @a s could not be converted to an integer
+    @throw out_of_range.410 if an array index exceeds size_type
+    */
+    static typename BasicJsonType::size_type array_index(const std::string& s)
+    {
+        using size_type = typename BasicJsonType::size_type;
+
+        // error condition (cf. RFC 6901, Sect. 4)
+        if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0'))
+        {
+            JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType()));
+        }
+
+        // error condition (cf. RFC 6901, Sect. 4)
+        if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9')))
+        {
+            JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType()));
+        }
+
+        std::size_t processed_chars = 0;
+        unsigned long long res = 0;  // NOLINT(runtime/int)
+        JSON_TRY
+        {
+            res = std::stoull(s, &processed_chars);
+        }
+        JSON_CATCH(std::out_of_range&)
+        {
+            JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType()));
+        }
+
+        // check if the string was completely read
+        if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size()))
+        {
+            JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType()));
+        }
+
+        // only triggered on special platforms (like 32bit), see also
+        // https://github.com/nlohmann/json/pull/2203
+        if (res >= static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))  // NOLINT(runtime/int)
+        {
+            JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE
+        }
+
+        return static_cast<size_type>(res);
+    }
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    json_pointer top() const
+    {
+        if (JSON_HEDLEY_UNLIKELY(empty()))
+        {
+            JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType()));
+        }
+
+        json_pointer result = *this;
+        result.reference_tokens = {reference_tokens[0]};
+        return result;
+    }
+
+  private:
+    /*!
+    @brief create and return a reference to the pointed to value
+
+    @complexity Linear in the number of reference tokens.
+
+    @throw parse_error.109 if array index is not a number
+    @throw type_error.313 if value cannot be unflattened
+    */
+    BasicJsonType& get_and_create(BasicJsonType& j) const
+    {
+        auto* result = &j;
+
+        // in case no reference tokens exist, return a reference to the JSON value
+        // j which will be overwritten by a primitive value
+        for (const auto& reference_token : reference_tokens)
+        {
+            switch (result->type())
+            {
+                case detail::value_t::null:
+                {
+                    if (reference_token == "0")
+                    {
+                        // start a new array if reference token is 0
+                        result = &result->operator[](0);
+                    }
+                    else
+                    {
+                        // start a new object otherwise
+                        result = &result->operator[](reference_token);
+                    }
+                    break;
+                }
+
+                case detail::value_t::object:
+                {
+                    // create an entry in the object
+                    result = &result->operator[](reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    // create an entry in the array
+                    result = &result->operator[](array_index(reference_token));
+                    break;
+                }
+
+                /*
+                The following code is only reached if there exists a reference
+                token _and_ the current value is primitive. In this case, we have
+                an error situation, because primitive values may only occur as
+                single value; that is, with an empty list of reference tokens.
+                */
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                    JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j));
+            }
+        }
+
+        return *result;
+    }
+
+    /*!
+    @brief return a reference to the pointed to value
+
+    @note This version does not throw if a value is not present, but tries to
+          create nested values instead. For instance, calling this function
+          with pointer `"/this/that"` on a null value is equivalent to calling
+          `operator[]("this").operator[]("that")` on that value, effectively
+          changing the null value to an object.
+
+    @param[in] ptr  a JSON value
+
+    @return reference to the JSON value pointed to by the JSON pointer
+
+    @complexity Linear in the length of the JSON pointer.
+
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+    */
+    BasicJsonType& get_unchecked(BasicJsonType* ptr) const
+    {
+        for (const auto& reference_token : reference_tokens)
+        {
+            // convert null values to arrays or objects before continuing
+            if (ptr->is_null())
+            {
+                // check if reference token is a number
+                const bool nums =
+                    std::all_of(reference_token.begin(), reference_token.end(),
+                                [](const unsigned char x)
+                {
+                    return std::isdigit(x);
+                });
+
+                // change value to array for numbers or "-" or to object otherwise
+                *ptr = (nums || reference_token == "-")
+                       ? detail::value_t::array
+                       : detail::value_t::object;
+            }
+
+            switch (ptr->type())
+            {
+                case detail::value_t::object:
+                {
+                    // use unchecked object access
+                    ptr = &ptr->operator[](reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    if (reference_token == "-")
+                    {
+                        // explicitly treat "-" as index beyond the end
+                        ptr = &ptr->operator[](ptr->m_value.array->size());
+                    }
+                    else
+                    {
+                        // convert array index to number; unchecked access
+                        ptr = &ptr->operator[](array_index(reference_token));
+                    }
+                    break;
+                }
+
+                case detail::value_t::null:
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                    JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
+            }
+        }
+
+        return *ptr;
+    }
+
+    /*!
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.402  if the array index '-' is used
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+    */
+    BasicJsonType& get_checked(BasicJsonType* ptr) const
+    {
+        for (const auto& reference_token : reference_tokens)
+        {
+            switch (ptr->type())
+            {
+                case detail::value_t::object:
+                {
+                    // note: at performs range check
+                    ptr = &ptr->at(reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
+                    {
+                        // "-" always fails the range check
+                        JSON_THROW(detail::out_of_range::create(402,
+                                                                "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
+                                                                ") is out of range", *ptr));
+                    }
+
+                    // note: at performs range check
+                    ptr = &ptr->at(array_index(reference_token));
+                    break;
+                }
+
+                case detail::value_t::null:
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                    JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
+            }
+        }
+
+        return *ptr;
+    }
+
+    /*!
+    @brief return a const reference to the pointed to value
+
+    @param[in] ptr  a JSON value
+
+    @return const reference to the JSON value pointed to by the JSON
+    pointer
+
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.402  if the array index '-' is used
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+    */
+    const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const
+    {
+        for (const auto& reference_token : reference_tokens)
+        {
+            switch (ptr->type())
+            {
+                case detail::value_t::object:
+                {
+                    // use unchecked object access
+                    ptr = &ptr->operator[](reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
+                    {
+                        // "-" cannot be used for const access
+                        JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr));
+                    }
+
+                    // use unchecked array access
+                    ptr = &ptr->operator[](array_index(reference_token));
+                    break;
+                }
+
+                case detail::value_t::null:
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                    JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
+            }
+        }
+
+        return *ptr;
+    }
+
+    /*!
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.402  if the array index '-' is used
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+    */
+    const BasicJsonType& get_checked(const BasicJsonType* ptr) const
+    {
+        for (const auto& reference_token : reference_tokens)
+        {
+            switch (ptr->type())
+            {
+                case detail::value_t::object:
+                {
+                    // note: at performs range check
+                    ptr = &ptr->at(reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
+                    {
+                        // "-" always fails the range check
+                        JSON_THROW(detail::out_of_range::create(402,
+                                                                "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
+                                                                ") is out of range", *ptr));
+                    }
+
+                    // note: at performs range check
+                    ptr = &ptr->at(array_index(reference_token));
+                    break;
+                }
+
+                case detail::value_t::null:
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                    JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
+            }
+        }
+
+        return *ptr;
+    }
+
+    /*!
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    */
+    bool contains(const BasicJsonType* ptr) const
+    {
+        for (const auto& reference_token : reference_tokens)
+        {
+            switch (ptr->type())
+            {
+                case detail::value_t::object:
+                {
+                    if (!ptr->contains(reference_token))
+                    {
+                        // we did not find the key in the object
+                        return false;
+                    }
+
+                    ptr = &ptr->operator[](reference_token);
+                    break;
+                }
+
+                case detail::value_t::array:
+                {
+                    if (JSON_HEDLEY_UNLIKELY(reference_token == "-"))
+                    {
+                        // "-" always fails the range check
+                        return false;
+                    }
+                    if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9")))
+                    {
+                        // invalid char
+                        return false;
+                    }
+                    if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
+                    {
+                        if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9')))
+                        {
+                            // first char should be between '1' and '9'
+                            return false;
+                        }
+                        for (std::size_t i = 1; i < reference_token.size(); i++)
+                        {
+                            if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9')))
+                            {
+                                // other char should be between '0' and '9'
+                                return false;
+                            }
+                        }
+                    }
+
+                    const auto idx = array_index(reference_token);
+                    if (idx >= ptr->size())
+                    {
+                        // index out of range
+                        return false;
+                    }
+
+                    ptr = &ptr->operator[](idx);
+                    break;
+                }
+
+                case detail::value_t::null:
+                case detail::value_t::string:
+                case detail::value_t::boolean:
+                case detail::value_t::number_integer:
+                case detail::value_t::number_unsigned:
+                case detail::value_t::number_float:
+                case detail::value_t::binary:
+                case detail::value_t::discarded:
+                default:
+                {
+                    // we do not expect primitive values if there is still a
+                    // reference token to process
+                    return false;
+                }
+            }
+        }
+
+        // no reference token left means we found a primitive value
+        return true;
+    }
+
+    /*!
+    @brief split the string input to reference tokens
+
+    @note This function is only called by the json_pointer constructor.
+          All exceptions below are documented there.
+
+    @throw parse_error.107  if the pointer is not empty or begins with '/'
+    @throw parse_error.108  if character '~' is not followed by '0' or '1'
+    */
+    static std::vector<std::string> split(const std::string& reference_string)
+    {
+        std::vector<std::string> result;
+
+        // special case: empty reference string -> no reference tokens
+        if (reference_string.empty())
+        {
+            return result;
+        }
+
+        // check if nonempty reference string begins with slash
+        if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/'))
+        {
+            JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType()));
+        }
+
+        // extract the reference tokens:
+        // - slash: position of the last read slash (or end of string)
+        // - start: position after the previous slash
+        for (
+            // search for the first slash after the first character
+            std::size_t slash = reference_string.find_first_of('/', 1),
+            // set the beginning of the first reference token
+            start = 1;
+            // we can stop if start == 0 (if slash == std::string::npos)
+            start != 0;
+            // set the beginning of the next reference token
+            // (will eventually be 0 if slash == std::string::npos)
+            start = (slash == std::string::npos) ? 0 : slash + 1,
+            // find next slash
+            slash = reference_string.find_first_of('/', start))
+        {
+            // use the text between the beginning of the reference token
+            // (start) and the last slash (slash).
+            auto reference_token = reference_string.substr(start, slash - start);
+
+            // check reference tokens are properly escaped
+            for (std::size_t pos = reference_token.find_first_of('~');
+                    pos != std::string::npos;
+                    pos = reference_token.find_first_of('~', pos + 1))
+            {
+                JSON_ASSERT(reference_token[pos] == '~');
+
+                // ~ must be followed by 0 or 1
+                if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 ||
+                                         (reference_token[pos + 1] != '0' &&
+                                          reference_token[pos + 1] != '1')))
+                {
+                    JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType()));
+                }
+            }
+
+            // finally, store the reference token
+            detail::unescape(reference_token);
+            result.push_back(reference_token);
+        }
+
+        return result;
+    }
+
+  private:
+    /*!
+    @param[in] reference_string  the reference string to the current value
+    @param[in] value             the value to consider
+    @param[in,out] result        the result object to insert values to
+
+    @note Empty objects or arrays are flattened to `null`.
+    */
+    static void flatten(const std::string& reference_string,
+                        const BasicJsonType& value,
+                        BasicJsonType& result)
+    {
+        switch (value.type())
+        {
+            case detail::value_t::array:
+            {
+                if (value.m_value.array->empty())
+                {
+                    // flatten empty array as null
+                    result[reference_string] = nullptr;
+                }
+                else
+                {
+                    // iterate array and use index as reference string
+                    for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
+                    {
+                        flatten(reference_string + "/" + std::to_string(i),
+                                value.m_value.array->operator[](i), result);
+                    }
+                }
+                break;
+            }
+
+            case detail::value_t::object:
+            {
+                if (value.m_value.object->empty())
+                {
+                    // flatten empty object as null
+                    result[reference_string] = nullptr;
+                }
+                else
+                {
+                    // iterate object and use keys as reference string
+                    for (const auto& element : *value.m_value.object)
+                    {
+                        flatten(reference_string + "/" + detail::escape(element.first), element.second, result);
+                    }
+                }
+                break;
+            }
+
+            case detail::value_t::null:
+            case detail::value_t::string:
+            case detail::value_t::boolean:
+            case detail::value_t::number_integer:
+            case detail::value_t::number_unsigned:
+            case detail::value_t::number_float:
+            case detail::value_t::binary:
+            case detail::value_t::discarded:
+            default:
+            {
+                // add primitive value with its reference string
+                result[reference_string] = value;
+                break;
+            }
+        }
+    }
+
+    /*!
+    @param[in] value  flattened JSON
+
+    @return unflattened JSON
+
+    @throw parse_error.109 if array index is not a number
+    @throw type_error.314  if value is not an object
+    @throw type_error.315  if object values are not primitive
+    @throw type_error.313  if value cannot be unflattened
+    */
+    static BasicJsonType
+    unflatten(const BasicJsonType& value)
+    {
+        if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
+        {
+            JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value));
+        }
+
+        BasicJsonType result;
+
+        // iterate the JSON object values
+        for (const auto& element : *value.m_value.object)
+        {
+            if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
+            {
+                JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second));
+            }
+
+            // assign value to reference pointed to by JSON pointer; Note that if
+            // the JSON pointer is "" (i.e., points to the whole value), function
+            // get_and_create returns a reference to result itself. An assignment
+            // will then create a primitive value.
+            json_pointer(element.first).get_and_create(result) = element.second;
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief compares two JSON pointers for equality
+
+    @param[in] lhs  JSON pointer to compare
+    @param[in] rhs  JSON pointer to compare
+    @return whether @a lhs is equal to @a rhs
+
+    @complexity Linear in the length of the JSON pointer
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+    */
+    friend bool operator==(json_pointer const& lhs,
+                           json_pointer const& rhs) noexcept
+    {
+        return lhs.reference_tokens == rhs.reference_tokens;
+    }
+
+    /*!
+    @brief compares two JSON pointers for inequality
+
+    @param[in] lhs  JSON pointer to compare
+    @param[in] rhs  JSON pointer to compare
+    @return whether @a lhs is not equal @a rhs
+
+    @complexity Linear in the length of the JSON pointer
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+    */
+    friend bool operator!=(json_pointer const& lhs,
+                           json_pointer const& rhs) noexcept
+    {
+        return !(lhs == rhs);
+    }
+
+    /// the reference tokens
+    std::vector<std::string> reference_tokens;
+};
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/json_ref.hpp>
+
+
+#include <initializer_list>
+#include <utility>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+template<typename BasicJsonType>
+class json_ref
+{
+  public:
+    using value_type = BasicJsonType;
+
+    json_ref(value_type&& value)
+        : owned_value(std::move(value))
+    {}
+
+    json_ref(const value_type& value)
+        : value_ref(&value)
+    {}
+
+    json_ref(std::initializer_list<json_ref> init)
+        : owned_value(init)
+    {}
+
+    template <
+        class... Args,
+        enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
+    json_ref(Args && ... args)
+        : owned_value(std::forward<Args>(args)...)
+    {}
+
+    // class should be movable only
+    json_ref(json_ref&&) noexcept = default;
+    json_ref(const json_ref&) = delete;
+    json_ref& operator=(const json_ref&) = delete;
+    json_ref& operator=(json_ref&&) = delete;
+    ~json_ref() = default;
+
+    value_type moved_or_copied() const
+    {
+        if (value_ref == nullptr)
+        {
+            return std::move(owned_value);
+        }
+        return *value_ref;
+    }
+
+    value_type const& operator*() const
+    {
+        return value_ref ? *value_ref : owned_value;
+    }
+
+    value_type const* operator->() const
+    {
+        return &** this;
+    }
+
+  private:
+    mutable value_type owned_value = nullptr;
+    value_type const* value_ref = nullptr;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/string_escape.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/meta/type_traits.hpp>
+
+// #include <nlohmann/detail/output/binary_writer.hpp>
+
+
+#include <algorithm> // reverse
+#include <array> // array
+#include <cmath> // isnan, isinf
+#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
+#include <cstring> // memcpy
+#include <limits> // numeric_limits
+#include <string> // string
+#include <utility> // move
+
+// #include <nlohmann/detail/input/binary_reader.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+
+#include <algorithm> // copy
+#include <cstddef> // size_t
+#include <iterator> // back_inserter
+#include <memory> // shared_ptr, make_shared
+#include <string> // basic_string
+#include <vector> // vector
+
+#ifndef JSON_NO_IO
+    #include <ios>      // streamsize
+    #include <ostream>  // basic_ostream
+#endif  // JSON_NO_IO
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+/// abstract output adapter interface
+template<typename CharType> struct output_adapter_protocol
+{
+    virtual void write_character(CharType c) = 0;
+    virtual void write_characters(const CharType* s, std::size_t length) = 0;
+    virtual ~output_adapter_protocol() = default;
+
+    output_adapter_protocol() = default;
+    output_adapter_protocol(const output_adapter_protocol&) = default;
+    output_adapter_protocol(output_adapter_protocol&&) noexcept = default;
+    output_adapter_protocol& operator=(const output_adapter_protocol&) = default;
+    output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default;
+};
+
+/// a type to simplify interfaces
+template<typename CharType>
+using output_adapter_t = std::shared_ptr<output_adapter_protocol<CharType>>;
+
+/// output adapter for byte vectors
+template<typename CharType, typename AllocatorType = std::allocator<CharType>>
+class output_vector_adapter : public output_adapter_protocol<CharType>
+{
+  public:
+    explicit output_vector_adapter(std::vector<CharType, AllocatorType>& vec) noexcept
+        : v(vec)
+    {}
+
+    void write_character(CharType c) override
+    {
+        v.push_back(c);
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    void write_characters(const CharType* s, std::size_t length) override
+    {
+        std::copy(s, s + length, std::back_inserter(v));
+    }
+
+  private:
+    std::vector<CharType, AllocatorType>& v;
+};
+
+#ifndef JSON_NO_IO
+/// output adapter for output streams
+template<typename CharType>
+class output_stream_adapter : public output_adapter_protocol<CharType>
+{
+  public:
+    explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept
+        : stream(s)
+    {}
+
+    void write_character(CharType c) override
+    {
+        stream.put(c);
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    void write_characters(const CharType* s, std::size_t length) override
+    {
+        stream.write(s, static_cast<std::streamsize>(length));
+    }
+
+  private:
+    std::basic_ostream<CharType>& stream;
+};
+#endif  // JSON_NO_IO
+
+/// output adapter for basic_string
+template<typename CharType, typename StringType = std::basic_string<CharType>>
+class output_string_adapter : public output_adapter_protocol<CharType>
+{
+  public:
+    explicit output_string_adapter(StringType& s) noexcept
+        : str(s)
+    {}
+
+    void write_character(CharType c) override
+    {
+        str.push_back(c);
+    }
+
+    JSON_HEDLEY_NON_NULL(2)
+    void write_characters(const CharType* s, std::size_t length) override
+    {
+        str.append(s, length);
+    }
+
+  private:
+    StringType& str;
+};
+
+template<typename CharType, typename StringType = std::basic_string<CharType>>
+class output_adapter
+{
+  public:
+    template<typename AllocatorType = std::allocator<CharType>>
+    output_adapter(std::vector<CharType, AllocatorType>& vec)
+        : oa(std::make_shared<output_vector_adapter<CharType, AllocatorType>>(vec)) {}
+
+#ifndef JSON_NO_IO
+    output_adapter(std::basic_ostream<CharType>& s)
+        : oa(std::make_shared<output_stream_adapter<CharType>>(s)) {}
+#endif  // JSON_NO_IO
+
+    output_adapter(StringType& s)
+        : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
+
+    operator output_adapter_t<CharType>()
+    {
+        return oa;
+    }
+
+  private:
+    output_adapter_t<CharType> oa = nullptr;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////
+// binary writer //
+///////////////////
+
+/*!
+@brief serialization to CBOR and MessagePack values
+*/
+template<typename BasicJsonType, typename CharType>
+class binary_writer
+{
+    using string_t = typename BasicJsonType::string_t;
+    using binary_t = typename BasicJsonType::binary_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+
+  public:
+    /*!
+    @brief create a binary writer
+
+    @param[in] adapter  output adapter to write to
+    */
+    explicit binary_writer(output_adapter_t<CharType> adapter) : oa(std::move(adapter))
+    {
+        JSON_ASSERT(oa);
+    }
+
+    /*!
+    @param[in] j  JSON value to serialize
+    @pre       j.type() == value_t::object
+    */
+    void write_bson(const BasicJsonType& j)
+    {
+        switch (j.type())
+        {
+            case value_t::object:
+            {
+                write_bson_object(*j.m_value.object);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::array:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));
+            }
+        }
+    }
+
+    /*!
+    @param[in] j  JSON value to serialize
+    */
+    void write_cbor(const BasicJsonType& j)
+    {
+        switch (j.type())
+        {
+            case value_t::null:
+            {
+                oa->write_character(to_char_type(0xF6));
+                break;
+            }
+
+            case value_t::boolean:
+            {
+                oa->write_character(j.m_value.boolean
+                                    ? to_char_type(0xF5)
+                                    : to_char_type(0xF4));
+                break;
+            }
+
+            case value_t::number_integer:
+            {
+                if (j.m_value.number_integer >= 0)
+                {
+                    // CBOR does not differentiate between positive signed
+                    // integers and unsigned integers. Therefore, we used the
+                    // code from the value_t::number_unsigned case here.
+                    if (j.m_value.number_integer <= 0x17)
+                    {
+                        write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x18));
+                        write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x19));
+                        write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x1A));
+                        write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+                    }
+                    else
+                    {
+                        oa->write_character(to_char_type(0x1B));
+                        write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+                    }
+                }
+                else
+                {
+                    // The conversions below encode the sign in the first
+                    // byte, and the value is converted to a positive number.
+                    const auto positive_number = -1 - j.m_value.number_integer;
+                    if (j.m_value.number_integer >= -24)
+                    {
+                        write_number(static_cast<std::uint8_t>(0x20 + positive_number));
+                    }
+                    else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x38));
+                        write_number(static_cast<std::uint8_t>(positive_number));
+                    }
+                    else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x39));
+                        write_number(static_cast<std::uint16_t>(positive_number));
+                    }
+                    else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
+                    {
+                        oa->write_character(to_char_type(0x3A));
+                        write_number(static_cast<std::uint32_t>(positive_number));
+                    }
+                    else
+                    {
+                        oa->write_character(to_char_type(0x3B));
+                        write_number(static_cast<std::uint64_t>(positive_number));
+                    }
+                }
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                if (j.m_value.number_unsigned <= 0x17)
+                {
+                    write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x18));
+                    write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x19));
+                    write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x1A));
+                    write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
+                }
+                else
+                {
+                    oa->write_character(to_char_type(0x1B));
+                    write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
+                }
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                if (std::isnan(j.m_value.number_float))
+                {
+                    // NaN is 0xf97e00 in CBOR
+                    oa->write_character(to_char_type(0xF9));
+                    oa->write_character(to_char_type(0x7E));
+                    oa->write_character(to_char_type(0x00));
+                }
+                else if (std::isinf(j.m_value.number_float))
+                {
+                    // Infinity is 0xf97c00, -Infinity is 0xf9fc00
+                    oa->write_character(to_char_type(0xf9));
+                    oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
+                    oa->write_character(to_char_type(0x00));
+                }
+                else
+                {
+                    write_compact_float(j.m_value.number_float, detail::input_format_t::cbor);
+                }
+                break;
+            }
+
+            case value_t::string:
+            {
+                // step 1: write control byte and the string length
+                const auto N = j.m_value.string->size();
+                if (N <= 0x17)
+                {
+                    write_number(static_cast<std::uint8_t>(0x60 + N));
+                }
+                else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x78));
+                    write_number(static_cast<std::uint8_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x79));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x7A));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+                // LCOV_EXCL_START
+                else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x7B));
+                    write_number(static_cast<std::uint64_t>(N));
+                }
+                // LCOV_EXCL_STOP
+
+                // step 2: write the string
+                oa->write_characters(
+                    reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+                    j.m_value.string->size());
+                break;
+            }
+
+            case value_t::array:
+            {
+                // step 1: write control byte and the array size
+                const auto N = j.m_value.array->size();
+                if (N <= 0x17)
+                {
+                    write_number(static_cast<std::uint8_t>(0x80 + N));
+                }
+                else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x98));
+                    write_number(static_cast<std::uint8_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x99));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x9A));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+                // LCOV_EXCL_START
+                else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x9B));
+                    write_number(static_cast<std::uint64_t>(N));
+                }
+                // LCOV_EXCL_STOP
+
+                // step 2: write each element
+                for (const auto& el : *j.m_value.array)
+                {
+                    write_cbor(el);
+                }
+                break;
+            }
+
+            case value_t::binary:
+            {
+                if (j.m_value.binary->has_subtype())
+                {
+                    if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
+                    {
+                        write_number(static_cast<std::uint8_t>(0xd8));
+                        write_number(static_cast<std::uint8_t>(j.m_value.binary->subtype()));
+                    }
+                    else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
+                    {
+                        write_number(static_cast<std::uint8_t>(0xd9));
+                        write_number(static_cast<std::uint16_t>(j.m_value.binary->subtype()));
+                    }
+                    else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
+                    {
+                        write_number(static_cast<std::uint8_t>(0xda));
+                        write_number(static_cast<std::uint32_t>(j.m_value.binary->subtype()));
+                    }
+                    else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
+                    {
+                        write_number(static_cast<std::uint8_t>(0xdb));
+                        write_number(static_cast<std::uint64_t>(j.m_value.binary->subtype()));
+                    }
+                }
+
+                // step 1: write control byte and the binary array size
+                const auto N = j.m_value.binary->size();
+                if (N <= 0x17)
+                {
+                    write_number(static_cast<std::uint8_t>(0x40 + N));
+                }
+                else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x58));
+                    write_number(static_cast<std::uint8_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x59));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x5A));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+                // LCOV_EXCL_START
+                else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+                {
+                    oa->write_character(to_char_type(0x5B));
+                    write_number(static_cast<std::uint64_t>(N));
+                }
+                // LCOV_EXCL_STOP
+
+                // step 2: write each element
+                oa->write_characters(
+                    reinterpret_cast<const CharType*>(j.m_value.binary->data()),
+                    N);
+
+                break;
+            }
+
+            case value_t::object:
+            {
+                // step 1: write control byte and the object size
+                const auto N = j.m_value.object->size();
+                if (N <= 0x17)
+                {
+                    write_number(static_cast<std::uint8_t>(0xA0 + N));
+                }
+                else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    oa->write_character(to_char_type(0xB8));
+                    write_number(static_cast<std::uint8_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    oa->write_character(to_char_type(0xB9));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    oa->write_character(to_char_type(0xBA));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+                // LCOV_EXCL_START
+                else if (N <= (std::numeric_limits<std::uint64_t>::max)())
+                {
+                    oa->write_character(to_char_type(0xBB));
+                    write_number(static_cast<std::uint64_t>(N));
+                }
+                // LCOV_EXCL_STOP
+
+                // step 2: write each element
+                for (const auto& el : *j.m_value.object)
+                {
+                    write_cbor(el.first);
+                    write_cbor(el.second);
+                }
+                break;
+            }
+
+            case value_t::discarded:
+            default:
+                break;
+        }
+    }
+
+    /*!
+    @param[in] j  JSON value to serialize
+    */
+    void write_msgpack(const BasicJsonType& j)
+    {
+        switch (j.type())
+        {
+            case value_t::null: // nil
+            {
+                oa->write_character(to_char_type(0xC0));
+                break;
+            }
+
+            case value_t::boolean: // true and false
+            {
+                oa->write_character(j.m_value.boolean
+                                    ? to_char_type(0xC3)
+                                    : to_char_type(0xC2));
+                break;
+            }
+
+            case value_t::number_integer:
+            {
+                if (j.m_value.number_integer >= 0)
+                {
+                    // MessagePack does not differentiate between positive
+                    // signed integers and unsigned integers. Therefore, we used
+                    // the code from the value_t::number_unsigned case here.
+                    if (j.m_value.number_unsigned < 128)
+                    {
+                        // positive fixnum
+                        write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+                    {
+                        // uint 8
+                        oa->write_character(to_char_type(0xCC));
+                        write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+                    {
+                        // uint 16
+                        oa->write_character(to_char_type(0xCD));
+                        write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+                    {
+                        // uint 32
+                        oa->write_character(to_char_type(0xCE));
+                        write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
+                    {
+                        // uint 64
+                        oa->write_character(to_char_type(0xCF));
+                        write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+                    }
+                }
+                else
+                {
+                    if (j.m_value.number_integer >= -32)
+                    {
+                        // negative fixnum
+                        write_number(static_cast<std::int8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
+                             j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
+                    {
+                        // int 8
+                        oa->write_character(to_char_type(0xD0));
+                        write_number(static_cast<std::int8_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
+                             j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
+                    {
+                        // int 16
+                        oa->write_character(to_char_type(0xD1));
+                        write_number(static_cast<std::int16_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
+                             j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
+                    {
+                        // int 32
+                        oa->write_character(to_char_type(0xD2));
+                        write_number(static_cast<std::int32_t>(j.m_value.number_integer));
+                    }
+                    else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
+                             j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
+                    {
+                        // int 64
+                        oa->write_character(to_char_type(0xD3));
+                        write_number(static_cast<std::int64_t>(j.m_value.number_integer));
+                    }
+                }
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                if (j.m_value.number_unsigned < 128)
+                {
+                    // positive fixnum
+                    write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    // uint 8
+                    oa->write_character(to_char_type(0xCC));
+                    write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    // uint 16
+                    oa->write_character(to_char_type(0xCD));
+                    write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    // uint 32
+                    oa->write_character(to_char_type(0xCE));
+                    write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
+                }
+                else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
+                {
+                    // uint 64
+                    oa->write_character(to_char_type(0xCF));
+                    write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
+                }
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack);
+                break;
+            }
+
+            case value_t::string:
+            {
+                // step 1: write control byte and the string length
+                const auto N = j.m_value.string->size();
+                if (N <= 31)
+                {
+                    // fixstr
+                    write_number(static_cast<std::uint8_t>(0xA0 | N));
+                }
+                else if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    // str 8
+                    oa->write_character(to_char_type(0xD9));
+                    write_number(static_cast<std::uint8_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    // str 16
+                    oa->write_character(to_char_type(0xDA));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    // str 32
+                    oa->write_character(to_char_type(0xDB));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+
+                // step 2: write the string
+                oa->write_characters(
+                    reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+                    j.m_value.string->size());
+                break;
+            }
+
+            case value_t::array:
+            {
+                // step 1: write control byte and the array size
+                const auto N = j.m_value.array->size();
+                if (N <= 15)
+                {
+                    // fixarray
+                    write_number(static_cast<std::uint8_t>(0x90 | N));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    // array 16
+                    oa->write_character(to_char_type(0xDC));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    // array 32
+                    oa->write_character(to_char_type(0xDD));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+
+                // step 2: write each element
+                for (const auto& el : *j.m_value.array)
+                {
+                    write_msgpack(el);
+                }
+                break;
+            }
+
+            case value_t::binary:
+            {
+                // step 0: determine if the binary type has a set subtype to
+                // determine whether or not to use the ext or fixext types
+                const bool use_ext = j.m_value.binary->has_subtype();
+
+                // step 1: write control byte and the byte string length
+                const auto N = j.m_value.binary->size();
+                if (N <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    std::uint8_t output_type{};
+                    bool fixed = true;
+                    if (use_ext)
+                    {
+                        switch (N)
+                        {
+                            case 1:
+                                output_type = 0xD4; // fixext 1
+                                break;
+                            case 2:
+                                output_type = 0xD5; // fixext 2
+                                break;
+                            case 4:
+                                output_type = 0xD6; // fixext 4
+                                break;
+                            case 8:
+                                output_type = 0xD7; // fixext 8
+                                break;
+                            case 16:
+                                output_type = 0xD8; // fixext 16
+                                break;
+                            default:
+                                output_type = 0xC7; // ext 8
+                                fixed = false;
+                                break;
+                        }
+
+                    }
+                    else
+                    {
+                        output_type = 0xC4; // bin 8
+                        fixed = false;
+                    }
+
+                    oa->write_character(to_char_type(output_type));
+                    if (!fixed)
+                    {
+                        write_number(static_cast<std::uint8_t>(N));
+                    }
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    std::uint8_t output_type = use_ext
+                                               ? 0xC8 // ext 16
+                                               : 0xC5; // bin 16
+
+                    oa->write_character(to_char_type(output_type));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    std::uint8_t output_type = use_ext
+                                               ? 0xC9 // ext 32
+                                               : 0xC6; // bin 32
+
+                    oa->write_character(to_char_type(output_type));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+
+                // step 1.5: if this is an ext type, write the subtype
+                if (use_ext)
+                {
+                    write_number(static_cast<std::int8_t>(j.m_value.binary->subtype()));
+                }
+
+                // step 2: write the byte string
+                oa->write_characters(
+                    reinterpret_cast<const CharType*>(j.m_value.binary->data()),
+                    N);
+
+                break;
+            }
+
+            case value_t::object:
+            {
+                // step 1: write control byte and the object size
+                const auto N = j.m_value.object->size();
+                if (N <= 15)
+                {
+                    // fixmap
+                    write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
+                }
+                else if (N <= (std::numeric_limits<std::uint16_t>::max)())
+                {
+                    // map 16
+                    oa->write_character(to_char_type(0xDE));
+                    write_number(static_cast<std::uint16_t>(N));
+                }
+                else if (N <= (std::numeric_limits<std::uint32_t>::max)())
+                {
+                    // map 32
+                    oa->write_character(to_char_type(0xDF));
+                    write_number(static_cast<std::uint32_t>(N));
+                }
+
+                // step 2: write each element
+                for (const auto& el : *j.m_value.object)
+                {
+                    write_msgpack(el.first);
+                    write_msgpack(el.second);
+                }
+                break;
+            }
+
+            case value_t::discarded:
+            default:
+                break;
+        }
+    }
+
+    /*!
+    @param[in] j  JSON value to serialize
+    @param[in] use_count   whether to use '#' prefixes (optimized format)
+    @param[in] use_type    whether to use '$' prefixes (optimized format)
+    @param[in] add_prefix  whether prefixes need to be used for this value
+    */
+    void write_ubjson(const BasicJsonType& j, const bool use_count,
+                      const bool use_type, const bool add_prefix = true)
+    {
+        switch (j.type())
+        {
+            case value_t::null:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(to_char_type('Z'));
+                }
+                break;
+            }
+
+            case value_t::boolean:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(j.m_value.boolean
+                                        ? to_char_type('T')
+                                        : to_char_type('F'));
+                }
+                break;
+            }
+
+            case value_t::number_integer:
+            {
+                write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
+                break;
+            }
+
+            case value_t::string:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(to_char_type('S'));
+                }
+                write_number_with_ubjson_prefix(j.m_value.string->size(), true);
+                oa->write_characters(
+                    reinterpret_cast<const CharType*>(j.m_value.string->c_str()),
+                    j.m_value.string->size());
+                break;
+            }
+
+            case value_t::array:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(to_char_type('['));
+                }
+
+                bool prefix_required = true;
+                if (use_type && !j.m_value.array->empty())
+                {
+                    JSON_ASSERT(use_count);
+                    const CharType first_prefix = ubjson_prefix(j.front());
+                    const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
+                                                         [this, first_prefix](const BasicJsonType & v)
+                    {
+                        return ubjson_prefix(v) == first_prefix;
+                    });
+
+                    if (same_prefix)
+                    {
+                        prefix_required = false;
+                        oa->write_character(to_char_type('$'));
+                        oa->write_character(first_prefix);
+                    }
+                }
+
+                if (use_count)
+                {
+                    oa->write_character(to_char_type('#'));
+                    write_number_with_ubjson_prefix(j.m_value.array->size(), true);
+                }
+
+                for (const auto& el : *j.m_value.array)
+                {
+                    write_ubjson(el, use_count, use_type, prefix_required);
+                }
+
+                if (!use_count)
+                {
+                    oa->write_character(to_char_type(']'));
+                }
+
+                break;
+            }
+
+            case value_t::binary:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(to_char_type('['));
+                }
+
+                if (use_type && !j.m_value.binary->empty())
+                {
+                    JSON_ASSERT(use_count);
+                    oa->write_character(to_char_type('$'));
+                    oa->write_character('U');
+                }
+
+                if (use_count)
+                {
+                    oa->write_character(to_char_type('#'));
+                    write_number_with_ubjson_prefix(j.m_value.binary->size(), true);
+                }
+
+                if (use_type)
+                {
+                    oa->write_characters(
+                        reinterpret_cast<const CharType*>(j.m_value.binary->data()),
+                        j.m_value.binary->size());
+                }
+                else
+                {
+                    for (size_t i = 0; i < j.m_value.binary->size(); ++i)
+                    {
+                        oa->write_character(to_char_type('U'));
+                        oa->write_character(j.m_value.binary->data()[i]);
+                    }
+                }
+
+                if (!use_count)
+                {
+                    oa->write_character(to_char_type(']'));
+                }
+
+                break;
+            }
+
+            case value_t::object:
+            {
+                if (add_prefix)
+                {
+                    oa->write_character(to_char_type('{'));
+                }
+
+                bool prefix_required = true;
+                if (use_type && !j.m_value.object->empty())
+                {
+                    JSON_ASSERT(use_count);
+                    const CharType first_prefix = ubjson_prefix(j.front());
+                    const bool same_prefix = std::all_of(j.begin(), j.end(),
+                                                         [this, first_prefix](const BasicJsonType & v)
+                    {
+                        return ubjson_prefix(v) == first_prefix;
+                    });
+
+                    if (same_prefix)
+                    {
+                        prefix_required = false;
+                        oa->write_character(to_char_type('$'));
+                        oa->write_character(first_prefix);
+                    }
+                }
+
+                if (use_count)
+                {
+                    oa->write_character(to_char_type('#'));
+                    write_number_with_ubjson_prefix(j.m_value.object->size(), true);
+                }
+
+                for (const auto& el : *j.m_value.object)
+                {
+                    write_number_with_ubjson_prefix(el.first.size(), true);
+                    oa->write_characters(
+                        reinterpret_cast<const CharType*>(el.first.c_str()),
+                        el.first.size());
+                    write_ubjson(el.second, use_count, use_type, prefix_required);
+                }
+
+                if (!use_count)
+                {
+                    oa->write_character(to_char_type('}'));
+                }
+
+                break;
+            }
+
+            case value_t::discarded:
+            default:
+                break;
+        }
+    }
+
+  private:
+    //////////
+    // BSON //
+    //////////
+
+    /*!
+    @return The size of a BSON document entry header, including the id marker
+            and the entry name size (and its null-terminator).
+    */
+    static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j)
+    {
+        const auto it = name.find(static_cast<typename string_t::value_type>(0));
+        if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
+        {
+            JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", j));
+            static_cast<void>(j);
+        }
+
+        return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
+    }
+
+    /*!
+    @brief Writes the given @a element_type and @a name to the output adapter
+    */
+    void write_bson_entry_header(const string_t& name,
+                                 const std::uint8_t element_type)
+    {
+        oa->write_character(to_char_type(element_type)); // boolean
+        oa->write_characters(
+            reinterpret_cast<const CharType*>(name.c_str()),
+            name.size() + 1u);
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and boolean value @a value
+    */
+    void write_bson_boolean(const string_t& name,
+                            const bool value)
+    {
+        write_bson_entry_header(name, 0x08);
+        oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and double value @a value
+    */
+    void write_bson_double(const string_t& name,
+                           const double value)
+    {
+        write_bson_entry_header(name, 0x01);
+        write_number<double, true>(value);
+    }
+
+    /*!
+    @return The size of the BSON-encoded string in @a value
+    */
+    static std::size_t calc_bson_string_size(const string_t& value)
+    {
+        return sizeof(std::int32_t) + value.size() + 1ul;
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and string value @a value
+    */
+    void write_bson_string(const string_t& name,
+                           const string_t& value)
+    {
+        write_bson_entry_header(name, 0x02);
+
+        write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size() + 1ul));
+        oa->write_characters(
+            reinterpret_cast<const CharType*>(value.c_str()),
+            value.size() + 1);
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and null value
+    */
+    void write_bson_null(const string_t& name)
+    {
+        write_bson_entry_header(name, 0x0A);
+    }
+
+    /*!
+    @return The size of the BSON-encoded integer @a value
+    */
+    static std::size_t calc_bson_integer_size(const std::int64_t value)
+    {
+        return (std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)()
+               ? sizeof(std::int32_t)
+               : sizeof(std::int64_t);
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and integer @a value
+    */
+    void write_bson_integer(const string_t& name,
+                            const std::int64_t value)
+    {
+        if ((std::numeric_limits<std::int32_t>::min)() <= value && value <= (std::numeric_limits<std::int32_t>::max)())
+        {
+            write_bson_entry_header(name, 0x10); // int32
+            write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
+        }
+        else
+        {
+            write_bson_entry_header(name, 0x12); // int64
+            write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
+        }
+    }
+
+    /*!
+    @return The size of the BSON-encoded unsigned integer in @a j
+    */
+    static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
+    {
+        return (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+               ? sizeof(std::int32_t)
+               : sizeof(std::int64_t);
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and unsigned @a value
+    */
+    void write_bson_unsigned(const string_t& name,
+                             const BasicJsonType& j)
+    {
+        if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+        {
+            write_bson_entry_header(name, 0x10 /* int32 */);
+            write_number<std::int32_t, true>(static_cast<std::int32_t>(j.m_value.number_unsigned));
+        }
+        else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
+        {
+            write_bson_entry_header(name, 0x12 /* int64 */);
+            write_number<std::int64_t, true>(static_cast<std::int64_t>(j.m_value.number_unsigned));
+        }
+        else
+        {
+            JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", j));
+        }
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and object @a value
+    */
+    void write_bson_object_entry(const string_t& name,
+                                 const typename BasicJsonType::object_t& value)
+    {
+        write_bson_entry_header(name, 0x03); // object
+        write_bson_object(value);
+    }
+
+    /*!
+    @return The size of the BSON-encoded array @a value
+    */
+    static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value)
+    {
+        std::size_t array_index = 0ul;
+
+        const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el)
+        {
+            return result + calc_bson_element_size(std::to_string(array_index++), el);
+        });
+
+        return sizeof(std::int32_t) + embedded_document_size + 1ul;
+    }
+
+    /*!
+    @return The size of the BSON-encoded binary array @a value
+    */
+    static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value)
+    {
+        return sizeof(std::int32_t) + value.size() + 1ul;
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and array @a value
+    */
+    void write_bson_array(const string_t& name,
+                          const typename BasicJsonType::array_t& value)
+    {
+        write_bson_entry_header(name, 0x04); // array
+        write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_array_size(value)));
+
+        std::size_t array_index = 0ul;
+
+        for (const auto& el : value)
+        {
+            write_bson_element(std::to_string(array_index++), el);
+        }
+
+        oa->write_character(to_char_type(0x00));
+    }
+
+    /*!
+    @brief Writes a BSON element with key @a name and binary value @a value
+    */
+    void write_bson_binary(const string_t& name,
+                           const binary_t& value)
+    {
+        write_bson_entry_header(name, 0x05);
+
+        write_number<std::int32_t, true>(static_cast<std::int32_t>(value.size()));
+        write_number(value.has_subtype() ? static_cast<std::uint8_t>(value.subtype()) : std::uint8_t(0x00));
+
+        oa->write_characters(reinterpret_cast<const CharType*>(value.data()), value.size());
+    }
+
+    /*!
+    @brief Calculates the size necessary to serialize the JSON value @a j with its @a name
+    @return The calculated size for the BSON document entry for @a j with the given @a name.
+    */
+    static std::size_t calc_bson_element_size(const string_t& name,
+            const BasicJsonType& j)
+    {
+        const auto header_size = calc_bson_entry_header_size(name, j);
+        switch (j.type())
+        {
+            case value_t::object:
+                return header_size + calc_bson_object_size(*j.m_value.object);
+
+            case value_t::array:
+                return header_size + calc_bson_array_size(*j.m_value.array);
+
+            case value_t::binary:
+                return header_size + calc_bson_binary_size(*j.m_value.binary);
+
+            case value_t::boolean:
+                return header_size + 1ul;
+
+            case value_t::number_float:
+                return header_size + 8ul;
+
+            case value_t::number_integer:
+                return header_size + calc_bson_integer_size(j.m_value.number_integer);
+
+            case value_t::number_unsigned:
+                return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
+
+            case value_t::string:
+                return header_size + calc_bson_string_size(*j.m_value.string);
+
+            case value_t::null:
+                return header_size + 0ul;
+
+            // LCOV_EXCL_START
+            case value_t::discarded:
+            default:
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
+                return 0ul;
+                // LCOV_EXCL_STOP
+        }
+    }
+
+    /*!
+    @brief Serializes the JSON value @a j to BSON and associates it with the
+           key @a name.
+    @param name The name to associate with the JSON entity @a j within the
+                current BSON document
+    */
+    void write_bson_element(const string_t& name,
+                            const BasicJsonType& j)
+    {
+        switch (j.type())
+        {
+            case value_t::object:
+                return write_bson_object_entry(name, *j.m_value.object);
+
+            case value_t::array:
+                return write_bson_array(name, *j.m_value.array);
+
+            case value_t::binary:
+                return write_bson_binary(name, *j.m_value.binary);
+
+            case value_t::boolean:
+                return write_bson_boolean(name, j.m_value.boolean);
+
+            case value_t::number_float:
+                return write_bson_double(name, j.m_value.number_float);
+
+            case value_t::number_integer:
+                return write_bson_integer(name, j.m_value.number_integer);
+
+            case value_t::number_unsigned:
+                return write_bson_unsigned(name, j);
+
+            case value_t::string:
+                return write_bson_string(name, *j.m_value.string);
+
+            case value_t::null:
+                return write_bson_null(name);
+
+            // LCOV_EXCL_START
+            case value_t::discarded:
+            default:
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
+                return;
+                // LCOV_EXCL_STOP
+        }
+    }
+
+    /*!
+    @brief Calculates the size of the BSON serialization of the given
+           JSON-object @a j.
+    @param[in] value  JSON value to serialize
+    @pre       value.type() == value_t::object
+    */
+    static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value)
+    {
+        std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0),
+                                    [](size_t result, const typename BasicJsonType::object_t::value_type & el)
+        {
+            return result += calc_bson_element_size(el.first, el.second);
+        });
+
+        return sizeof(std::int32_t) + document_size + 1ul;
+    }
+
+    /*!
+    @param[in] value  JSON value to serialize
+    @pre       value.type() == value_t::object
+    */
+    void write_bson_object(const typename BasicJsonType::object_t& value)
+    {
+        write_number<std::int32_t, true>(static_cast<std::int32_t>(calc_bson_object_size(value)));
+
+        for (const auto& el : value)
+        {
+            write_bson_element(el.first, el.second);
+        }
+
+        oa->write_character(to_char_type(0x00));
+    }
+
+    //////////
+    // CBOR //
+    //////////
+
+    static constexpr CharType get_cbor_float_prefix(float /*unused*/)
+    {
+        return to_char_type(0xFA);  // Single-Precision Float
+    }
+
+    static constexpr CharType get_cbor_float_prefix(double /*unused*/)
+    {
+        return to_char_type(0xFB);  // Double-Precision Float
+    }
+
+    /////////////
+    // MsgPack //
+    /////////////
+
+    static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
+    {
+        return to_char_type(0xCA);  // float 32
+    }
+
+    static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
+    {
+        return to_char_type(0xCB);  // float 64
+    }
+
+    ////////////
+    // UBJSON //
+    ////////////
+
+    // UBJSON: write number (floating point)
+    template<typename NumberType, typename std::enable_if<
+                 std::is_floating_point<NumberType>::value, int>::type = 0>
+    void write_number_with_ubjson_prefix(const NumberType n,
+                                         const bool add_prefix)
+    {
+        if (add_prefix)
+        {
+            oa->write_character(get_ubjson_float_prefix(n));
+        }
+        write_number(n);
+    }
+
+    // UBJSON: write number (unsigned integer)
+    template<typename NumberType, typename std::enable_if<
+                 std::is_unsigned<NumberType>::value, int>::type = 0>
+    void write_number_with_ubjson_prefix(const NumberType n,
+                                         const bool add_prefix)
+    {
+        if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('i'));  // int8
+            }
+            write_number(static_cast<std::uint8_t>(n));
+        }
+        else if (n <= (std::numeric_limits<std::uint8_t>::max)())
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('U'));  // uint8
+            }
+            write_number(static_cast<std::uint8_t>(n));
+        }
+        else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('I'));  // int16
+            }
+            write_number(static_cast<std::int16_t>(n));
+        }
+        else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('l'));  // int32
+            }
+            write_number(static_cast<std::int32_t>(n));
+        }
+        else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('L'));  // int64
+            }
+            write_number(static_cast<std::int64_t>(n));
+        }
+        else
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('H'));  // high-precision number
+            }
+
+            const auto number = BasicJsonType(n).dump();
+            write_number_with_ubjson_prefix(number.size(), true);
+            for (std::size_t i = 0; i < number.size(); ++i)
+            {
+                oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
+            }
+        }
+    }
+
+    // UBJSON: write number (signed integer)
+    template < typename NumberType, typename std::enable_if <
+                   std::is_signed<NumberType>::value&&
+                   !std::is_floating_point<NumberType>::value, int >::type = 0 >
+    void write_number_with_ubjson_prefix(const NumberType n,
+                                         const bool add_prefix)
+    {
+        if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('i'));  // int8
+            }
+            write_number(static_cast<std::int8_t>(n));
+        }
+        else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('U'));  // uint8
+            }
+            write_number(static_cast<std::uint8_t>(n));
+        }
+        else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('I'));  // int16
+            }
+            write_number(static_cast<std::int16_t>(n));
+        }
+        else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('l'));  // int32
+            }
+            write_number(static_cast<std::int32_t>(n));
+        }
+        else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('L'));  // int64
+            }
+            write_number(static_cast<std::int64_t>(n));
+        }
+        // LCOV_EXCL_START
+        else
+        {
+            if (add_prefix)
+            {
+                oa->write_character(to_char_type('H'));  // high-precision number
+            }
+
+            const auto number = BasicJsonType(n).dump();
+            write_number_with_ubjson_prefix(number.size(), true);
+            for (std::size_t i = 0; i < number.size(); ++i)
+            {
+                oa->write_character(to_char_type(static_cast<std::uint8_t>(number[i])));
+            }
+        }
+        // LCOV_EXCL_STOP
+    }
+
+    /*!
+    @brief determine the type prefix of container values
+    */
+    CharType ubjson_prefix(const BasicJsonType& j) const noexcept
+    {
+        switch (j.type())
+        {
+            case value_t::null:
+                return 'Z';
+
+            case value_t::boolean:
+                return j.m_value.boolean ? 'T' : 'F';
+
+            case value_t::number_integer:
+            {
+                if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
+                {
+                    return 'i';
+                }
+                if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
+                {
+                    return 'U';
+                }
+                if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
+                {
+                    return 'I';
+                }
+                if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
+                {
+                    return 'l';
+                }
+                if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
+                {
+                    return 'L';
+                }
+                // anything else is treated as high-precision number
+                return 'H'; // LCOV_EXCL_LINE
+            }
+
+            case value_t::number_unsigned:
+            {
+                if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
+                {
+                    return 'i';
+                }
+                if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
+                {
+                    return 'U';
+                }
+                if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
+                {
+                    return 'I';
+                }
+                if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
+                {
+                    return 'l';
+                }
+                if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
+                {
+                    return 'L';
+                }
+                // anything else is treated as high-precision number
+                return 'H'; // LCOV_EXCL_LINE
+            }
+
+            case value_t::number_float:
+                return get_ubjson_float_prefix(j.m_value.number_float);
+
+            case value_t::string:
+                return 'S';
+
+            case value_t::array: // fallthrough
+            case value_t::binary:
+                return '[';
+
+            case value_t::object:
+                return '{';
+
+            case value_t::discarded:
+            default:  // discarded values
+                return 'N';
+        }
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
+    {
+        return 'd';  // float 32
+    }
+
+    static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
+    {
+        return 'D';  // float 64
+    }
+
+    ///////////////////////
+    // Utility functions //
+    ///////////////////////
+
+    /*
+    @brief write a number to output input
+    @param[in] n number of type @a NumberType
+    @tparam NumberType the type of the number
+    @tparam OutputIsLittleEndian Set to true if output data is
+                                 required to be little endian
+
+    @note This function needs to respect the system's endianess, because bytes
+          in CBOR, MessagePack, and UBJSON are stored in network order (big
+          endian) and therefore need reordering on little endian systems.
+    */
+    template<typename NumberType, bool OutputIsLittleEndian = false>
+    void write_number(const NumberType n)
+    {
+        // step 1: write number to array of length NumberType
+        std::array<CharType, sizeof(NumberType)> vec{};
+        std::memcpy(vec.data(), &n, sizeof(NumberType));
+
+        // step 2: write array to output (with possible reordering)
+        if (is_little_endian != OutputIsLittleEndian)
+        {
+            // reverse byte order prior to conversion if necessary
+            std::reverse(vec.begin(), vec.end());
+        }
+
+        oa->write_characters(vec.data(), sizeof(NumberType));
+    }
+
+    void write_compact_float(const number_float_t n, detail::input_format_t format)
+    {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
+        if (static_cast<double>(n) >= static_cast<double>(std::numeric_limits<float>::lowest()) &&
+                static_cast<double>(n) <= static_cast<double>((std::numeric_limits<float>::max)()) &&
+                static_cast<double>(static_cast<float>(n)) == static_cast<double>(n))
+        {
+            oa->write_character(format == detail::input_format_t::cbor
+                                ? get_cbor_float_prefix(static_cast<float>(n))
+                                : get_msgpack_float_prefix(static_cast<float>(n)));
+            write_number(static_cast<float>(n));
+        }
+        else
+        {
+            oa->write_character(format == detail::input_format_t::cbor
+                                ? get_cbor_float_prefix(n)
+                                : get_msgpack_float_prefix(n));
+            write_number(n);
+        }
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+    }
+
+  public:
+    // The following to_char_type functions are implement the conversion
+    // between uint8_t and CharType. In case CharType is not unsigned,
+    // such a conversion is required to allow values greater than 128.
+    // See <https://github.com/nlohmann/json/issues/1286> for a discussion.
+    template < typename C = CharType,
+               enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * = nullptr >
+    static constexpr CharType to_char_type(std::uint8_t x) noexcept
+    {
+        return *reinterpret_cast<char*>(&x);
+    }
+
+    template < typename C = CharType,
+               enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * = nullptr >
+    static CharType to_char_type(std::uint8_t x) noexcept
+    {
+        static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
+        static_assert(std::is_trivial<CharType>::value, "CharType must be trivial");
+        CharType result;
+        std::memcpy(&result, &x, sizeof(x));
+        return result;
+    }
+
+    template<typename C = CharType,
+             enable_if_t<std::is_unsigned<C>::value>* = nullptr>
+    static constexpr CharType to_char_type(std::uint8_t x) noexcept
+    {
+        return x;
+    }
+
+    template < typename InputCharType, typename C = CharType,
+               enable_if_t <
+                   std::is_signed<C>::value &&
+                   std::is_signed<char>::value &&
+                   std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
+                   > * = nullptr >
+    static constexpr CharType to_char_type(InputCharType x) noexcept
+    {
+        return x;
+    }
+
+  private:
+    /// whether we can assume little endianess
+    const bool is_little_endian = little_endianess();
+
+    /// the output
+    output_adapter_t<CharType> oa = nullptr;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+// #include <nlohmann/detail/output/serializer.hpp>
+
+
+#include <algorithm> // reverse, remove, fill, find, none_of
+#include <array> // array
+#include <clocale> // localeconv, lconv
+#include <cmath> // labs, isfinite, isnan, signbit
+#include <cstddef> // size_t, ptrdiff_t
+#include <cstdint> // uint8_t
+#include <cstdio> // snprintf
+#include <limits> // numeric_limits
+#include <string> // string, char_traits
+#include <type_traits> // is_same
+#include <utility> // move
+
+// #include <nlohmann/detail/conversions/to_chars.hpp>
+
+
+#include <array> // array
+#include <cmath>   // signbit, isfinite
+#include <cstdint> // intN_t, uintN_t
+#include <cstring> // memcpy, memmove
+#include <limits> // numeric_limits
+#include <type_traits> // conditional
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+
+/*!
+@brief implements the Grisu2 algorithm for binary to decimal floating-point
+conversion.
+
+This implementation is a slightly modified version of the reference
+implementation which may be obtained from
+http://florian.loitsch.com/publications (bench.tar.gz).
+
+The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch.
+
+For a detailed description of the algorithm see:
+
+[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with
+    Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming
+    Language Design and Implementation, PLDI 2010
+[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately",
+    Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language
+    Design and Implementation, PLDI 1996
+*/
+namespace dtoa_impl
+{
+
+template<typename Target, typename Source>
+Target reinterpret_bits(const Source source)
+{
+    static_assert(sizeof(Target) == sizeof(Source), "size mismatch");
+
+    Target target;
+    std::memcpy(&target, &source, sizeof(Source));
+    return target;
+}
+
+struct diyfp // f * 2^e
+{
+    static constexpr int kPrecision = 64; // = q
+
+    std::uint64_t f = 0;
+    int e = 0;
+
+    constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
+
+    /*!
+    @brief returns x - y
+    @pre x.e == y.e and x.f >= y.f
+    */
+    static diyfp sub(const diyfp& x, const diyfp& y) noexcept
+    {
+        JSON_ASSERT(x.e == y.e);
+        JSON_ASSERT(x.f >= y.f);
+
+        return {x.f - y.f, x.e};
+    }
+
+    /*!
+    @brief returns x * y
+    @note The result is rounded. (Only the upper q bits are returned.)
+    */
+    static diyfp mul(const diyfp& x, const diyfp& y) noexcept
+    {
+        static_assert(kPrecision == 64, "internal error");
+
+        // Computes:
+        //  f = round((x.f * y.f) / 2^q)
+        //  e = x.e + y.e + q
+
+        // Emulate the 64-bit * 64-bit multiplication:
+        //
+        // p = u * v
+        //   = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi)
+        //   = (u_lo v_lo         ) + 2^32 ((u_lo v_hi         ) + (u_hi v_lo         )) + 2^64 (u_hi v_hi         )
+        //   = (p0                ) + 2^32 ((p1                ) + (p2                )) + 2^64 (p3                )
+        //   = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3                )
+        //   = (p0_lo             ) + 2^32 (p0_hi + p1_lo + p2_lo                      ) + 2^64 (p1_hi + p2_hi + p3)
+        //   = (p0_lo             ) + 2^32 (Q                                          ) + 2^64 (H                 )
+        //   = (p0_lo             ) + 2^32 (Q_lo + 2^32 Q_hi                           ) + 2^64 (H                 )
+        //
+        // (Since Q might be larger than 2^32 - 1)
+        //
+        //   = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H)
+        //
+        // (Q_hi + H does not overflow a 64-bit int)
+        //
+        //   = p_lo + 2^64 p_hi
+
+        const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
+        const std::uint64_t u_hi = x.f >> 32u;
+        const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
+        const std::uint64_t v_hi = y.f >> 32u;
+
+        const std::uint64_t p0 = u_lo * v_lo;
+        const std::uint64_t p1 = u_lo * v_hi;
+        const std::uint64_t p2 = u_hi * v_lo;
+        const std::uint64_t p3 = u_hi * v_hi;
+
+        const std::uint64_t p0_hi = p0 >> 32u;
+        const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
+        const std::uint64_t p1_hi = p1 >> 32u;
+        const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
+        const std::uint64_t p2_hi = p2 >> 32u;
+
+        std::uint64_t Q = p0_hi + p1_lo + p2_lo;
+
+        // The full product might now be computed as
+        //
+        // p_hi = p3 + p2_hi + p1_hi + (Q >> 32)
+        // p_lo = p0_lo + (Q << 32)
+        //
+        // But in this particular case here, the full p_lo is not required.
+        // Effectively we only need to add the highest bit in p_lo to p_hi (and
+        // Q_hi + 1 does not overflow).
+
+        Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
+
+        const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
+
+        return {h, x.e + y.e + 64};
+    }
+
+    /*!
+    @brief normalize x such that the significand is >= 2^(q-1)
+    @pre x.f != 0
+    */
+    static diyfp normalize(diyfp x) noexcept
+    {
+        JSON_ASSERT(x.f != 0);
+
+        while ((x.f >> 63u) == 0)
+        {
+            x.f <<= 1u;
+            x.e--;
+        }
+
+        return x;
+    }
+
+    /*!
+    @brief normalize x such that the result has the exponent E
+    @pre e >= x.e and the upper e - x.e bits of x.f must be zero.
+    */
+    static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept
+    {
+        const int delta = x.e - target_exponent;
+
+        JSON_ASSERT(delta >= 0);
+        JSON_ASSERT(((x.f << delta) >> delta) == x.f);
+
+        return {x.f << delta, target_exponent};
+    }
+};
+
+struct boundaries
+{
+    diyfp w;
+    diyfp minus;
+    diyfp plus;
+};
+
+/*!
+Compute the (normalized) diyfp representing the input number 'value' and its
+boundaries.
+
+@pre value must be finite and positive
+*/
+template<typename FloatType>
+boundaries compute_boundaries(FloatType value)
+{
+    JSON_ASSERT(std::isfinite(value));
+    JSON_ASSERT(value > 0);
+
+    // Convert the IEEE representation into a diyfp.
+    //
+    // If v is denormal:
+    //      value = 0.F * 2^(1 - bias) = (          F) * 2^(1 - bias - (p-1))
+    // If v is normalized:
+    //      value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
+
+    static_assert(std::numeric_limits<FloatType>::is_iec559,
+                  "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
+
+    constexpr int      kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
+    constexpr int      kBias      = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
+    constexpr int      kMinExp    = 1 - kBias;
+    constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
+
+    using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
+
+    const auto bits = static_cast<std::uint64_t>(reinterpret_bits<bits_type>(value));
+    const std::uint64_t E = bits >> (kPrecision - 1);
+    const std::uint64_t F = bits & (kHiddenBit - 1);
+
+    const bool is_denormal = E == 0;
+    const diyfp v = is_denormal
+                    ? diyfp(F, kMinExp)
+                    : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
+
+    // Compute the boundaries m- and m+ of the floating-point value
+    // v = f * 2^e.
+    //
+    // Determine v- and v+, the floating-point predecessor and successor if v,
+    // respectively.
+    //
+    //      v- = v - 2^e        if f != 2^(p-1) or e == e_min                (A)
+    //         = v - 2^(e-1)    if f == 2^(p-1) and e > e_min                (B)
+    //
+    //      v+ = v + 2^e
+    //
+    // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_
+    // between m- and m+ round to v, regardless of how the input rounding
+    // algorithm breaks ties.
+    //
+    //      ---+-------------+-------------+-------------+-------------+---  (A)
+    //         v-            m-            v             m+            v+
+    //
+    //      -----------------+------+------+-------------+-------------+---  (B)
+    //                       v-     m-     v             m+            v+
+
+    const bool lower_boundary_is_closer = F == 0 && E > 1;
+    const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
+    const diyfp m_minus = lower_boundary_is_closer
+                          ? diyfp(4 * v.f - 1, v.e - 2)  // (B)
+                          : diyfp(2 * v.f - 1, v.e - 1); // (A)
+
+    // Determine the normalized w+ = m+.
+    const diyfp w_plus = diyfp::normalize(m_plus);
+
+    // Determine w- = m- such that e_(w-) = e_(w+).
+    const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
+
+    return {diyfp::normalize(v), w_minus, w_plus};
+}
+
+// Given normalized diyfp w, Grisu needs to find a (normalized) cached
+// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies
+// within a certain range [alpha, gamma] (Definition 3.2 from [1])
+//
+//      alpha <= e = e_c + e_w + q <= gamma
+//
+// or
+//
+//      f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q
+//                          <= f_c * f_w * 2^gamma
+//
+// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies
+//
+//      2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma
+//
+// or
+//
+//      2^(q - 2 + alpha) <= c * w < 2^(q + gamma)
+//
+// The choice of (alpha,gamma) determines the size of the table and the form of
+// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well
+// in practice:
+//
+// The idea is to cut the number c * w = f * 2^e into two parts, which can be
+// processed independently: An integral part p1, and a fractional part p2:
+//
+//      f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e
+//              = (f div 2^-e) + (f mod 2^-e) * 2^e
+//              = p1 + p2 * 2^e
+//
+// The conversion of p1 into decimal form requires a series of divisions and
+// modulos by (a power of) 10. These operations are faster for 32-bit than for
+// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be
+// achieved by choosing
+//
+//      -e >= 32   or   e <= -32 := gamma
+//
+// In order to convert the fractional part
+//
+//      p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ...
+//
+// into decimal form, the fraction is repeatedly multiplied by 10 and the digits
+// d[-i] are extracted in order:
+//
+//      (10 * p2) div 2^-e = d[-1]
+//      (10 * p2) mod 2^-e = d[-2] / 10^1 + ...
+//
+// The multiplication by 10 must not overflow. It is sufficient to choose
+//
+//      10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64.
+//
+// Since p2 = f mod 2^-e < 2^-e,
+//
+//      -e <= 60   or   e >= -60 := alpha
+
+constexpr int kAlpha = -60;
+constexpr int kGamma = -32;
+
+struct cached_power // c = f * 2^e ~= 10^k
+{
+    std::uint64_t f;
+    int e;
+    int k;
+};
+
+/*!
+For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached
+power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c
+satisfies (Definition 3.2 from [1])
+
+     alpha <= e_c + e + q <= gamma.
+*/
+inline cached_power get_cached_power_for_binary_exponent(int e)
+{
+    // Now
+    //
+    //      alpha <= e_c + e + q <= gamma                                    (1)
+    //      ==> f_c * 2^alpha <= c * 2^e * 2^q
+    //
+    // and since the c's are normalized, 2^(q-1) <= f_c,
+    //
+    //      ==> 2^(q - 1 + alpha) <= c * 2^(e + q)
+    //      ==> 2^(alpha - e - 1) <= c
+    //
+    // If c were an exact power of ten, i.e. c = 10^k, one may determine k as
+    //
+    //      k = ceil( log_10( 2^(alpha - e - 1) ) )
+    //        = ceil( (alpha - e - 1) * log_10(2) )
+    //
+    // From the paper:
+    // "In theory the result of the procedure could be wrong since c is rounded,
+    //  and the computation itself is approximated [...]. In practice, however,
+    //  this simple function is sufficient."
+    //
+    // For IEEE double precision floating-point numbers converted into
+    // normalized diyfp's w = f * 2^e, with q = 64,
+    //
+    //      e >= -1022      (min IEEE exponent)
+    //           -52        (p - 1)
+    //           -52        (p - 1, possibly normalize denormal IEEE numbers)
+    //           -11        (normalize the diyfp)
+    //         = -1137
+    //
+    // and
+    //
+    //      e <= +1023      (max IEEE exponent)
+    //           -52        (p - 1)
+    //           -11        (normalize the diyfp)
+    //         = 960
+    //
+    // This binary exponent range [-1137,960] results in a decimal exponent
+    // range [-307,324]. One does not need to store a cached power for each
+    // k in this range. For each such k it suffices to find a cached power
+    // such that the exponent of the product lies in [alpha,gamma].
+    // This implies that the difference of the decimal exponents of adjacent
+    // table entries must be less than or equal to
+    //
+    //      floor( (gamma - alpha) * log_10(2) ) = 8.
+    //
+    // (A smaller distance gamma-alpha would require a larger table.)
+
+    // NB:
+    // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
+
+    constexpr int kCachedPowersMinDecExp = -300;
+    constexpr int kCachedPowersDecStep = 8;
+
+    static constexpr std::array<cached_power, 79> kCachedPowers =
+    {
+        {
+            { 0xAB70FE17C79AC6CA, -1060, -300 },
+            { 0xFF77B1FCBEBCDC4F, -1034, -292 },
+            { 0xBE5691EF416BD60C, -1007, -284 },
+            { 0x8DD01FAD907FFC3C,  -980, -276 },
+            { 0xD3515C2831559A83,  -954, -268 },
+            { 0x9D71AC8FADA6C9B5,  -927, -260 },
+            { 0xEA9C227723EE8BCB,  -901, -252 },
+            { 0xAECC49914078536D,  -874, -244 },
+            { 0x823C12795DB6CE57,  -847, -236 },
+            { 0xC21094364DFB5637,  -821, -228 },
+            { 0x9096EA6F3848984F,  -794, -220 },
+            { 0xD77485CB25823AC7,  -768, -212 },
+            { 0xA086CFCD97BF97F4,  -741, -204 },
+            { 0xEF340A98172AACE5,  -715, -196 },
+            { 0xB23867FB2A35B28E,  -688, -188 },
+            { 0x84C8D4DFD2C63F3B,  -661, -180 },
+            { 0xC5DD44271AD3CDBA,  -635, -172 },
+            { 0x936B9FCEBB25C996,  -608, -164 },
+            { 0xDBAC6C247D62A584,  -582, -156 },
+            { 0xA3AB66580D5FDAF6,  -555, -148 },
+            { 0xF3E2F893DEC3F126,  -529, -140 },
+            { 0xB5B5ADA8AAFF80B8,  -502, -132 },
+            { 0x87625F056C7C4A8B,  -475, -124 },
+            { 0xC9BCFF6034C13053,  -449, -116 },
+            { 0x964E858C91BA2655,  -422, -108 },
+            { 0xDFF9772470297EBD,  -396, -100 },
+            { 0xA6DFBD9FB8E5B88F,  -369,  -92 },
+            { 0xF8A95FCF88747D94,  -343,  -84 },
+            { 0xB94470938FA89BCF,  -316,  -76 },
+            { 0x8A08F0F8BF0F156B,  -289,  -68 },
+            { 0xCDB02555653131B6,  -263,  -60 },
+            { 0x993FE2C6D07B7FAC,  -236,  -52 },
+            { 0xE45C10C42A2B3B06,  -210,  -44 },
+            { 0xAA242499697392D3,  -183,  -36 },
+            { 0xFD87B5F28300CA0E,  -157,  -28 },
+            { 0xBCE5086492111AEB,  -130,  -20 },
+            { 0x8CBCCC096F5088CC,  -103,  -12 },
+            { 0xD1B71758E219652C,   -77,   -4 },
+            { 0x9C40000000000000,   -50,    4 },
+            { 0xE8D4A51000000000,   -24,   12 },
+            { 0xAD78EBC5AC620000,     3,   20 },
+            { 0x813F3978F8940984,    30,   28 },
+            { 0xC097CE7BC90715B3,    56,   36 },
+            { 0x8F7E32CE7BEA5C70,    83,   44 },
+            { 0xD5D238A4ABE98068,   109,   52 },
+            { 0x9F4F2726179A2245,   136,   60 },
+            { 0xED63A231D4C4FB27,   162,   68 },
+            { 0xB0DE65388CC8ADA8,   189,   76 },
+            { 0x83C7088E1AAB65DB,   216,   84 },
+            { 0xC45D1DF942711D9A,   242,   92 },
+            { 0x924D692CA61BE758,   269,  100 },
+            { 0xDA01EE641A708DEA,   295,  108 },
+            { 0xA26DA3999AEF774A,   322,  116 },
+            { 0xF209787BB47D6B85,   348,  124 },
+            { 0xB454E4A179DD1877,   375,  132 },
+            { 0x865B86925B9BC5C2,   402,  140 },
+            { 0xC83553C5C8965D3D,   428,  148 },
+            { 0x952AB45CFA97A0B3,   455,  156 },
+            { 0xDE469FBD99A05FE3,   481,  164 },
+            { 0xA59BC234DB398C25,   508,  172 },
+            { 0xF6C69A72A3989F5C,   534,  180 },
+            { 0xB7DCBF5354E9BECE,   561,  188 },
+            { 0x88FCF317F22241E2,   588,  196 },
+            { 0xCC20CE9BD35C78A5,   614,  204 },
+            { 0x98165AF37B2153DF,   641,  212 },
+            { 0xE2A0B5DC971F303A,   667,  220 },
+            { 0xA8D9D1535CE3B396,   694,  228 },
+            { 0xFB9B7CD9A4A7443C,   720,  236 },
+            { 0xBB764C4CA7A44410,   747,  244 },
+            { 0x8BAB8EEFB6409C1A,   774,  252 },
+            { 0xD01FEF10A657842C,   800,  260 },
+            { 0x9B10A4E5E9913129,   827,  268 },
+            { 0xE7109BFBA19C0C9D,   853,  276 },
+            { 0xAC2820D9623BF429,   880,  284 },
+            { 0x80444B5E7AA7CF85,   907,  292 },
+            { 0xBF21E44003ACDD2D,   933,  300 },
+            { 0x8E679C2F5E44FF8F,   960,  308 },
+            { 0xD433179D9C8CB841,   986,  316 },
+            { 0x9E19DB92B4E31BA9,  1013,  324 },
+        }
+    };
+
+    // This computation gives exactly the same results for k as
+    //      k = ceil((kAlpha - e - 1) * 0.30102999566398114)
+    // for |e| <= 1500, but doesn't require floating-point operations.
+    // NB: log_10(2) ~= 78913 / 2^18
+    JSON_ASSERT(e >= -1500);
+    JSON_ASSERT(e <=  1500);
+    const int f = kAlpha - e - 1;
+    const int k = (f * 78913) / (1 << 18) + static_cast<int>(f > 0);
+
+    const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
+    JSON_ASSERT(index >= 0);
+    JSON_ASSERT(static_cast<std::size_t>(index) < kCachedPowers.size());
+
+    const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)];
+    JSON_ASSERT(kAlpha <= cached.e + e + 64);
+    JSON_ASSERT(kGamma >= cached.e + e + 64);
+
+    return cached;
+}
+
+/*!
+For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
+For n == 0, returns 1 and sets pow10 := 1.
+*/
+inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
+{
+    // LCOV_EXCL_START
+    if (n >= 1000000000)
+    {
+        pow10 = 1000000000;
+        return 10;
+    }
+    // LCOV_EXCL_STOP
+    if (n >= 100000000)
+    {
+        pow10 = 100000000;
+        return  9;
+    }
+    if (n >= 10000000)
+    {
+        pow10 = 10000000;
+        return  8;
+    }
+    if (n >= 1000000)
+    {
+        pow10 = 1000000;
+        return  7;
+    }
+    if (n >= 100000)
+    {
+        pow10 = 100000;
+        return  6;
+    }
+    if (n >= 10000)
+    {
+        pow10 = 10000;
+        return  5;
+    }
+    if (n >= 1000)
+    {
+        pow10 = 1000;
+        return  4;
+    }
+    if (n >= 100)
+    {
+        pow10 = 100;
+        return  3;
+    }
+    if (n >= 10)
+    {
+        pow10 = 10;
+        return  2;
+    }
+
+    pow10 = 1;
+    return 1;
+}
+
+inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
+                         std::uint64_t rest, std::uint64_t ten_k)
+{
+    JSON_ASSERT(len >= 1);
+    JSON_ASSERT(dist <= delta);
+    JSON_ASSERT(rest <= delta);
+    JSON_ASSERT(ten_k > 0);
+
+    //               <--------------------------- delta ---->
+    //                                  <---- dist --------->
+    // --------------[------------------+-------------------]--------------
+    //               M-                 w                   M+
+    //
+    //                                  ten_k
+    //                                <------>
+    //                                       <---- rest ---->
+    // --------------[------------------+----+--------------]--------------
+    //                                  w    V
+    //                                       = buf * 10^k
+    //
+    // ten_k represents a unit-in-the-last-place in the decimal representation
+    // stored in buf.
+    // Decrement buf by ten_k while this takes buf closer to w.
+
+    // The tests are written in this order to avoid overflow in unsigned
+    // integer arithmetic.
+
+    while (rest < dist
+            && delta - rest >= ten_k
+            && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
+    {
+        JSON_ASSERT(buf[len - 1] != '0');
+        buf[len - 1]--;
+        rest += ten_k;
+    }
+}
+
+/*!
+Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+.
+M- and M+ must be normalized and share the same exponent -60 <= e <= -32.
+*/
+inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
+                             diyfp M_minus, diyfp w, diyfp M_plus)
+{
+    static_assert(kAlpha >= -60, "internal error");
+    static_assert(kGamma <= -32, "internal error");
+
+    // Generates the digits (and the exponent) of a decimal floating-point
+    // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's
+    // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma.
+    //
+    //               <--------------------------- delta ---->
+    //                                  <---- dist --------->
+    // --------------[------------------+-------------------]--------------
+    //               M-                 w                   M+
+    //
+    // Grisu2 generates the digits of M+ from left to right and stops as soon as
+    // V is in [M-,M+].
+
+    JSON_ASSERT(M_plus.e >= kAlpha);
+    JSON_ASSERT(M_plus.e <= kGamma);
+
+    std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
+    std::uint64_t dist  = diyfp::sub(M_plus, w      ).f; // (significand of (M+ - w ), implicit exponent is e)
+
+    // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0):
+    //
+    //      M+ = f * 2^e
+    //         = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e
+    //         = ((p1        ) * 2^-e + (p2        )) * 2^e
+    //         = p1 + p2 * 2^e
+
+    const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
+
+    auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
+    std::uint64_t p2 = M_plus.f & (one.f - 1);                    // p2 = f mod 2^-e
+
+    // 1)
+    //
+    // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0]
+
+    JSON_ASSERT(p1 > 0);
+
+    std::uint32_t pow10{};
+    const int k = find_largest_pow10(p1, pow10);
+
+    //      10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
+    //
+    //      p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1))
+    //         = (d[k-1]         ) * 10^(k-1) + (p1 mod 10^(k-1))
+    //
+    //      M+ = p1                                             + p2 * 2^e
+    //         = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1))          + p2 * 2^e
+    //         = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e
+    //         = d[k-1] * 10^(k-1) + (                         rest) * 2^e
+    //
+    // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0)
+    //
+    //      p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0]
+    //
+    // but stop as soon as
+    //
+    //      rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e
+
+    int n = k;
+    while (n > 0)
+    {
+        // Invariants:
+        //      M+ = buffer * 10^n + (p1 + p2 * 2^e)    (buffer = 0 for n = k)
+        //      pow10 = 10^(n-1) <= p1 < 10^n
+        //
+        const std::uint32_t d = p1 / pow10;  // d = p1 div 10^(n-1)
+        const std::uint32_t r = p1 % pow10;  // r = p1 mod 10^(n-1)
+        //
+        //      M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e
+        //         = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e)
+        //
+        JSON_ASSERT(d <= 9);
+        buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
+        //
+        //      M+ = buffer * 10^(n-1) + (r + p2 * 2^e)
+        //
+        p1 = r;
+        n--;
+        //
+        //      M+ = buffer * 10^n + (p1 + p2 * 2^e)
+        //      pow10 = 10^n
+        //
+
+        // Now check if enough digits have been generated.
+        // Compute
+        //
+        //      p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e
+        //
+        // Note:
+        // Since rest and delta share the same exponent e, it suffices to
+        // compare the significands.
+        const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
+        if (rest <= delta)
+        {
+            // V = buffer * 10^n, with M- <= V <= M+.
+
+            decimal_exponent += n;
+
+            // We may now just stop. But instead look if the buffer could be
+            // decremented to bring V closer to w.
+            //
+            // pow10 = 10^n is now 1 ulp in the decimal representation V.
+            // The rounding procedure works with diyfp's with an implicit
+            // exponent of e.
+            //
+            //      10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
+            //
+            const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
+            grisu2_round(buffer, length, dist, delta, rest, ten_n);
+
+            return;
+        }
+
+        pow10 /= 10;
+        //
+        //      pow10 = 10^(n-1) <= p1 < 10^n
+        // Invariants restored.
+    }
+
+    // 2)
+    //
+    // The digits of the integral part have been generated:
+    //
+    //      M+ = d[k-1]...d[1]d[0] + p2 * 2^e
+    //         = buffer            + p2 * 2^e
+    //
+    // Now generate the digits of the fractional part p2 * 2^e.
+    //
+    // Note:
+    // No decimal point is generated: the exponent is adjusted instead.
+    //
+    // p2 actually represents the fraction
+    //
+    //      p2 * 2^e
+    //          = p2 / 2^-e
+    //          = d[-1] / 10^1 + d[-2] / 10^2 + ...
+    //
+    // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...)
+    //
+    //      p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m
+    //                      + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...)
+    //
+    // using
+    //
+    //      10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e)
+    //                = (                   d) * 2^-e + (                   r)
+    //
+    // or
+    //      10^m * p2 * 2^e = d + r * 2^e
+    //
+    // i.e.
+    //
+    //      M+ = buffer + p2 * 2^e
+    //         = buffer + 10^-m * (d + r * 2^e)
+    //         = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e
+    //
+    // and stop as soon as 10^-m * r * 2^e <= delta * 2^e
+
+    JSON_ASSERT(p2 > delta);
+
+    int m = 0;
+    for (;;)
+    {
+        // Invariant:
+        //      M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e
+        //         = buffer * 10^-m + 10^-m * (p2                                 ) * 2^e
+        //         = buffer * 10^-m + 10^-m * (1/10 * (10 * p2)                   ) * 2^e
+        //         = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
+        //
+        JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
+        p2 *= 10;
+        const std::uint64_t d = p2 >> -one.e;     // d = (10 * p2) div 2^-e
+        const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e
+        //
+        //      M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e
+        //         = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e))
+        //         = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e
+        //
+        JSON_ASSERT(d <= 9);
+        buffer[length++] = static_cast<char>('0' + d); // buffer := buffer * 10 + d
+        //
+        //      M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e
+        //
+        p2 = r;
+        m++;
+        //
+        //      M+ = buffer * 10^-m + 10^-m * p2 * 2^e
+        // Invariant restored.
+
+        // Check if enough digits have been generated.
+        //
+        //      10^-m * p2 * 2^e <= delta * 2^e
+        //              p2 * 2^e <= 10^m * delta * 2^e
+        //                    p2 <= 10^m * delta
+        delta *= 10;
+        dist  *= 10;
+        if (p2 <= delta)
+        {
+            break;
+        }
+    }
+
+    // V = buffer * 10^-m, with M- <= V <= M+.
+
+    decimal_exponent -= m;
+
+    // 1 ulp in the decimal representation is now 10^-m.
+    // Since delta and dist are now scaled by 10^m, we need to do the
+    // same with ulp in order to keep the units in sync.
+    //
+    //      10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e
+    //
+    const std::uint64_t ten_m = one.f;
+    grisu2_round(buffer, length, dist, delta, p2, ten_m);
+
+    // By construction this algorithm generates the shortest possible decimal
+    // number (Loitsch, Theorem 6.2) which rounds back to w.
+    // For an input number of precision p, at least
+    //
+    //      N = 1 + ceil(p * log_10(2))
+    //
+    // decimal digits are sufficient to identify all binary floating-point
+    // numbers (Matula, "In-and-Out conversions").
+    // This implies that the algorithm does not produce more than N decimal
+    // digits.
+    //
+    //      N = 17 for p = 53 (IEEE double precision)
+    //      N = 9  for p = 24 (IEEE single precision)
+}
+
+/*!
+v = buf * 10^decimal_exponent
+len is the length of the buffer (number of decimal digits)
+The buffer must be large enough, i.e. >= max_digits10.
+*/
+JSON_HEDLEY_NON_NULL(1)
+inline void grisu2(char* buf, int& len, int& decimal_exponent,
+                   diyfp m_minus, diyfp v, diyfp m_plus)
+{
+    JSON_ASSERT(m_plus.e == m_minus.e);
+    JSON_ASSERT(m_plus.e == v.e);
+
+    //  --------(-----------------------+-----------------------)--------    (A)
+    //          m-                      v                       m+
+    //
+    //  --------------------(-----------+-----------------------)--------    (B)
+    //                      m-          v                       m+
+    //
+    // First scale v (and m- and m+) such that the exponent is in the range
+    // [alpha, gamma].
+
+    const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e);
+
+    const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k
+
+    // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma]
+    const diyfp w       = diyfp::mul(v,       c_minus_k);
+    const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
+    const diyfp w_plus  = diyfp::mul(m_plus,  c_minus_k);
+
+    //  ----(---+---)---------------(---+---)---------------(---+---)----
+    //          w-                      w                       w+
+    //          = c*m-                  = c*v                   = c*m+
+    //
+    // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and
+    // w+ are now off by a small amount.
+    // In fact:
+    //
+    //      w - v * 10^k < 1 ulp
+    //
+    // To account for this inaccuracy, add resp. subtract 1 ulp.
+    //
+    //  --------+---[---------------(---+---)---------------]---+--------
+    //          w-  M-                  w                   M+  w+
+    //
+    // Now any number in [M-, M+] (bounds included) will round to w when input,
+    // regardless of how the input rounding algorithm breaks ties.
+    //
+    // And digit_gen generates the shortest possible such number in [M-, M+].
+    // Note that this does not mean that Grisu2 always generates the shortest
+    // possible number in the interval (m-, m+).
+    const diyfp M_minus(w_minus.f + 1, w_minus.e);
+    const diyfp M_plus (w_plus.f  - 1, w_plus.e );
+
+    decimal_exponent = -cached.k; // = -(-k) = k
+
+    grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus);
+}
+
+/*!
+v = buf * 10^decimal_exponent
+len is the length of the buffer (number of decimal digits)
+The buffer must be large enough, i.e. >= max_digits10.
+*/
+template<typename FloatType>
+JSON_HEDLEY_NON_NULL(1)
+void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
+{
+    static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
+                  "internal error: not enough precision");
+
+    JSON_ASSERT(std::isfinite(value));
+    JSON_ASSERT(value > 0);
+
+    // If the neighbors (and boundaries) of 'value' are always computed for double-precision
+    // numbers, all float's can be recovered using strtod (and strtof). However, the resulting
+    // decimal representations are not exactly "short".
+    //
+    // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars)
+    // says "value is converted to a string as if by std::sprintf in the default ("C") locale"
+    // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars'
+    // does.
+    // On the other hand, the documentation for 'std::to_chars' requires that "parsing the
+    // representation using the corresponding std::from_chars function recovers value exactly". That
+    // indicates that single precision floating-point numbers should be recovered using
+    // 'std::strtof'.
+    //
+    // NB: If the neighbors are computed for single-precision numbers, there is a single float
+    //     (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision
+    //     value is off by 1 ulp.
+#if 0
+    const boundaries w = compute_boundaries(static_cast<double>(value));
+#else
+    const boundaries w = compute_boundaries(value);
+#endif
+
+    grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
+}
+
+/*!
+@brief appends a decimal representation of e to buf
+@return a pointer to the element following the exponent.
+@pre -1000 < e < 1000
+*/
+JSON_HEDLEY_NON_NULL(1)
+JSON_HEDLEY_RETURNS_NON_NULL
+inline char* append_exponent(char* buf, int e)
+{
+    JSON_ASSERT(e > -1000);
+    JSON_ASSERT(e <  1000);
+
+    if (e < 0)
+    {
+        e = -e;
+        *buf++ = '-';
+    }
+    else
+    {
+        *buf++ = '+';
+    }
+
+    auto k = static_cast<std::uint32_t>(e);
+    if (k < 10)
+    {
+        // Always print at least two digits in the exponent.
+        // This is for compatibility with printf("%g").
+        *buf++ = '0';
+        *buf++ = static_cast<char>('0' + k);
+    }
+    else if (k < 100)
+    {
+        *buf++ = static_cast<char>('0' + k / 10);
+        k %= 10;
+        *buf++ = static_cast<char>('0' + k);
+    }
+    else
+    {
+        *buf++ = static_cast<char>('0' + k / 100);
+        k %= 100;
+        *buf++ = static_cast<char>('0' + k / 10);
+        k %= 10;
+        *buf++ = static_cast<char>('0' + k);
+    }
+
+    return buf;
+}
+
+/*!
+@brief prettify v = buf * 10^decimal_exponent
+
+If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point
+notation. Otherwise it will be printed in exponential notation.
+
+@pre min_exp < 0
+@pre max_exp > 0
+*/
+JSON_HEDLEY_NON_NULL(1)
+JSON_HEDLEY_RETURNS_NON_NULL
+inline char* format_buffer(char* buf, int len, int decimal_exponent,
+                           int min_exp, int max_exp)
+{
+    JSON_ASSERT(min_exp < 0);
+    JSON_ASSERT(max_exp > 0);
+
+    const int k = len;
+    const int n = len + decimal_exponent;
+
+    // v = buf * 10^(n-k)
+    // k is the length of the buffer (number of decimal digits)
+    // n is the position of the decimal point relative to the start of the buffer.
+
+    if (k <= n && n <= max_exp)
+    {
+        // digits[000]
+        // len <= max_exp + 2
+
+        std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
+        // Make it look like a floating-point number (#362, #378)
+        buf[n + 0] = '.';
+        buf[n + 1] = '0';
+        return buf + (static_cast<size_t>(n) + 2);
+    }
+
+    if (0 < n && n <= max_exp)
+    {
+        // dig.its
+        // len <= max_digits10 + 1
+
+        JSON_ASSERT(k > n);
+
+        std::memmove(buf + (static_cast<size_t>(n) + 1), buf + n, static_cast<size_t>(k) - static_cast<size_t>(n));
+        buf[n] = '.';
+        return buf + (static_cast<size_t>(k) + 1U);
+    }
+
+    if (min_exp < n && n <= 0)
+    {
+        // 0.[000]digits
+        // len <= 2 + (-min_exp - 1) + max_digits10
+
+        std::memmove(buf + (2 + static_cast<size_t>(-n)), buf, static_cast<size_t>(k));
+        buf[0] = '0';
+        buf[1] = '.';
+        std::memset(buf + 2, '0', static_cast<size_t>(-n));
+        return buf + (2U + static_cast<size_t>(-n) + static_cast<size_t>(k));
+    }
+
+    if (k == 1)
+    {
+        // dE+123
+        // len <= 1 + 5
+
+        buf += 1;
+    }
+    else
+    {
+        // d.igitsE+123
+        // len <= max_digits10 + 1 + 5
+
+        std::memmove(buf + 2, buf + 1, static_cast<size_t>(k) - 1);
+        buf[1] = '.';
+        buf += 1 + static_cast<size_t>(k);
+    }
+
+    *buf++ = 'e';
+    return append_exponent(buf, n - 1);
+}
+
+} // namespace dtoa_impl
+
+/*!
+@brief generates a decimal representation of the floating-point number value in [first, last).
+
+The format of the resulting decimal representation is similar to printf's %g
+format. Returns an iterator pointing past-the-end of the decimal representation.
+
+@note The input number must be finite, i.e. NaN's and Inf's are not supported.
+@note The buffer must be large enough.
+@note The result is NOT null-terminated.
+*/
+template<typename FloatType>
+JSON_HEDLEY_NON_NULL(1, 2)
+JSON_HEDLEY_RETURNS_NON_NULL
+char* to_chars(char* first, const char* last, FloatType value)
+{
+    static_cast<void>(last); // maybe unused - fix warning
+    JSON_ASSERT(std::isfinite(value));
+
+    // Use signbit(value) instead of (value < 0) since signbit works for -0.
+    if (std::signbit(value))
+    {
+        value = -value;
+        *first++ = '-';
+    }
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
+    if (value == 0) // +-0
+    {
+        *first++ = '0';
+        // Make it look like a floating-point number (#362, #378)
+        *first++ = '.';
+        *first++ = '0';
+        return first;
+    }
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+    JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
+
+    // Compute v = buffer * 10^decimal_exponent.
+    // The decimal digits are stored in the buffer, which needs to be interpreted
+    // as an unsigned decimal integer.
+    // len is the length of the buffer, i.e. the number of decimal digits.
+    int len = 0;
+    int decimal_exponent = 0;
+    dtoa_impl::grisu2(first, len, decimal_exponent, value);
+
+    JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
+
+    // Format the buffer like printf("%.*g", prec, value)
+    constexpr int kMinExp = -4;
+    // Use digits10 here to increase compatibility with version 2.
+    constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
+
+    JSON_ASSERT(last - first >= kMaxExp + 2);
+    JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
+    JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
+
+    return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
+}
+
+} // namespace detail
+} // namespace nlohmann
+
+// #include <nlohmann/detail/exceptions.hpp>
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+// #include <nlohmann/detail/meta/cpp_future.hpp>
+
+// #include <nlohmann/detail/output/binary_writer.hpp>
+
+// #include <nlohmann/detail/output/output_adapters.hpp>
+
+// #include <nlohmann/detail/value_t.hpp>
+
+
+namespace nlohmann
+{
+namespace detail
+{
+///////////////////
+// serialization //
+///////////////////
+
+/// how to treat decoding errors
+enum class error_handler_t
+{
+    strict,  ///< throw a type_error exception in case of invalid UTF-8
+    replace, ///< replace invalid UTF-8 sequences with U+FFFD
+    ignore   ///< ignore invalid UTF-8 sequences
+};
+
+template<typename BasicJsonType>
+class serializer
+{
+    using string_t = typename BasicJsonType::string_t;
+    using number_float_t = typename BasicJsonType::number_float_t;
+    using number_integer_t = typename BasicJsonType::number_integer_t;
+    using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+    using binary_char_t = typename BasicJsonType::binary_t::value_type;
+    static constexpr std::uint8_t UTF8_ACCEPT = 0;
+    static constexpr std::uint8_t UTF8_REJECT = 1;
+
+  public:
+    /*!
+    @param[in] s  output stream to serialize to
+    @param[in] ichar  indentation character to use
+    @param[in] error_handler_  how to react on decoding errors
+    */
+    serializer(output_adapter_t<char> s, const char ichar,
+               error_handler_t error_handler_ = error_handler_t::strict)
+        : o(std::move(s))
+        , loc(std::localeconv())
+        , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
+        , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point)))
+        , indent_char(ichar)
+        , indent_string(512, indent_char)
+        , error_handler(error_handler_)
+    {}
+
+    // delete because of pointer members
+    serializer(const serializer&) = delete;
+    serializer& operator=(const serializer&) = delete;
+    serializer(serializer&&) = delete;
+    serializer& operator=(serializer&&) = delete;
+    ~serializer() = default;
+
+    /*!
+    @brief internal implementation of the serialization function
+
+    This function is called by the public member function dump and organizes
+    the serialization internally. The indentation level is propagated as
+    additional parameter. In case of arrays and objects, the function is
+    called recursively.
+
+    - strings and object keys are escaped using `escape_string()`
+    - integer numbers are converted implicitly via `operator<<`
+    - floating-point numbers are converted to a string using `"%g"` format
+    - binary values are serialized as objects containing the subtype and the
+      byte array
+
+    @param[in] val               value to serialize
+    @param[in] pretty_print      whether the output shall be pretty-printed
+    @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters
+    in the output are escaped with `\uXXXX` sequences, and the result consists
+    of ASCII characters only.
+    @param[in] indent_step       the indent level
+    @param[in] current_indent    the current indent level (only used internally)
+    */
+    void dump(const BasicJsonType& val,
+              const bool pretty_print,
+              const bool ensure_ascii,
+              const unsigned int indent_step,
+              const unsigned int current_indent = 0)
+    {
+        switch (val.m_type)
+        {
+            case value_t::object:
+            {
+                if (val.m_value.object->empty())
+                {
+                    o->write_characters("{}", 2);
+                    return;
+                }
+
+                if (pretty_print)
+                {
+                    o->write_characters("{\n", 2);
+
+                    // variable to hold indentation for recursive calls
+                    const auto new_indent = current_indent + indent_step;
+                    if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
+                    {
+                        indent_string.resize(indent_string.size() * 2, ' ');
+                    }
+
+                    // first n-1 elements
+                    auto i = val.m_value.object->cbegin();
+                    for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
+                    {
+                        o->write_characters(indent_string.c_str(), new_indent);
+                        o->write_character('\"');
+                        dump_escaped(i->first, ensure_ascii);
+                        o->write_characters("\": ", 3);
+                        dump(i->second, true, ensure_ascii, indent_step, new_indent);
+                        o->write_characters(",\n", 2);
+                    }
+
+                    // last element
+                    JSON_ASSERT(i != val.m_value.object->cend());
+                    JSON_ASSERT(std::next(i) == val.m_value.object->cend());
+                    o->write_characters(indent_string.c_str(), new_indent);
+                    o->write_character('\"');
+                    dump_escaped(i->first, ensure_ascii);
+                    o->write_characters("\": ", 3);
+                    dump(i->second, true, ensure_ascii, indent_step, new_indent);
+
+                    o->write_character('\n');
+                    o->write_characters(indent_string.c_str(), current_indent);
+                    o->write_character('}');
+                }
+                else
+                {
+                    o->write_character('{');
+
+                    // first n-1 elements
+                    auto i = val.m_value.object->cbegin();
+                    for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
+                    {
+                        o->write_character('\"');
+                        dump_escaped(i->first, ensure_ascii);
+                        o->write_characters("\":", 2);
+                        dump(i->second, false, ensure_ascii, indent_step, current_indent);
+                        o->write_character(',');
+                    }
+
+                    // last element
+                    JSON_ASSERT(i != val.m_value.object->cend());
+                    JSON_ASSERT(std::next(i) == val.m_value.object->cend());
+                    o->write_character('\"');
+                    dump_escaped(i->first, ensure_ascii);
+                    o->write_characters("\":", 2);
+                    dump(i->second, false, ensure_ascii, indent_step, current_indent);
+
+                    o->write_character('}');
+                }
+
+                return;
+            }
+
+            case value_t::array:
+            {
+                if (val.m_value.array->empty())
+                {
+                    o->write_characters("[]", 2);
+                    return;
+                }
+
+                if (pretty_print)
+                {
+                    o->write_characters("[\n", 2);
+
+                    // variable to hold indentation for recursive calls
+                    const auto new_indent = current_indent + indent_step;
+                    if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
+                    {
+                        indent_string.resize(indent_string.size() * 2, ' ');
+                    }
+
+                    // first n-1 elements
+                    for (auto i = val.m_value.array->cbegin();
+                            i != val.m_value.array->cend() - 1; ++i)
+                    {
+                        o->write_characters(indent_string.c_str(), new_indent);
+                        dump(*i, true, ensure_ascii, indent_step, new_indent);
+                        o->write_characters(",\n", 2);
+                    }
+
+                    // last element
+                    JSON_ASSERT(!val.m_value.array->empty());
+                    o->write_characters(indent_string.c_str(), new_indent);
+                    dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
+
+                    o->write_character('\n');
+                    o->write_characters(indent_string.c_str(), current_indent);
+                    o->write_character(']');
+                }
+                else
+                {
+                    o->write_character('[');
+
+                    // first n-1 elements
+                    for (auto i = val.m_value.array->cbegin();
+                            i != val.m_value.array->cend() - 1; ++i)
+                    {
+                        dump(*i, false, ensure_ascii, indent_step, current_indent);
+                        o->write_character(',');
+                    }
+
+                    // last element
+                    JSON_ASSERT(!val.m_value.array->empty());
+                    dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
+
+                    o->write_character(']');
+                }
+
+                return;
+            }
+
+            case value_t::string:
+            {
+                o->write_character('\"');
+                dump_escaped(*val.m_value.string, ensure_ascii);
+                o->write_character('\"');
+                return;
+            }
+
+            case value_t::binary:
+            {
+                if (pretty_print)
+                {
+                    o->write_characters("{\n", 2);
+
+                    // variable to hold indentation for recursive calls
+                    const auto new_indent = current_indent + indent_step;
+                    if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent))
+                    {
+                        indent_string.resize(indent_string.size() * 2, ' ');
+                    }
+
+                    o->write_characters(indent_string.c_str(), new_indent);
+
+                    o->write_characters("\"bytes\": [", 10);
+
+                    if (!val.m_value.binary->empty())
+                    {
+                        for (auto i = val.m_value.binary->cbegin();
+                                i != val.m_value.binary->cend() - 1; ++i)
+                        {
+                            dump_integer(*i);
+                            o->write_characters(", ", 2);
+                        }
+                        dump_integer(val.m_value.binary->back());
+                    }
+
+                    o->write_characters("],\n", 3);
+                    o->write_characters(indent_string.c_str(), new_indent);
+
+                    o->write_characters("\"subtype\": ", 11);
+                    if (val.m_value.binary->has_subtype())
+                    {
+                        dump_integer(val.m_value.binary->subtype());
+                    }
+                    else
+                    {
+                        o->write_characters("null", 4);
+                    }
+                    o->write_character('\n');
+                    o->write_characters(indent_string.c_str(), current_indent);
+                    o->write_character('}');
+                }
+                else
+                {
+                    o->write_characters("{\"bytes\":[", 10);
+
+                    if (!val.m_value.binary->empty())
+                    {
+                        for (auto i = val.m_value.binary->cbegin();
+                                i != val.m_value.binary->cend() - 1; ++i)
+                        {
+                            dump_integer(*i);
+                            o->write_character(',');
+                        }
+                        dump_integer(val.m_value.binary->back());
+                    }
+
+                    o->write_characters("],\"subtype\":", 12);
+                    if (val.m_value.binary->has_subtype())
+                    {
+                        dump_integer(val.m_value.binary->subtype());
+                        o->write_character('}');
+                    }
+                    else
+                    {
+                        o->write_characters("null}", 5);
+                    }
+                }
+                return;
+            }
+
+            case value_t::boolean:
+            {
+                if (val.m_value.boolean)
+                {
+                    o->write_characters("true", 4);
+                }
+                else
+                {
+                    o->write_characters("false", 5);
+                }
+                return;
+            }
+
+            case value_t::number_integer:
+            {
+                dump_integer(val.m_value.number_integer);
+                return;
+            }
+
+            case value_t::number_unsigned:
+            {
+                dump_integer(val.m_value.number_unsigned);
+                return;
+            }
+
+            case value_t::number_float:
+            {
+                dump_float(val.m_value.number_float);
+                return;
+            }
+
+            case value_t::discarded:
+            {
+                o->write_characters("<discarded>", 11);
+                return;
+            }
+
+            case value_t::null:
+            {
+                o->write_characters("null", 4);
+                return;
+            }
+
+            default:            // LCOV_EXCL_LINE
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        }
+    }
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    /*!
+    @brief dump escaped string
+
+    Escape a string by replacing certain special characters by a sequence of an
+    escape character (backslash) and another character and other control
+    characters by a sequence of "\u" followed by a four-digit hex
+    representation. The escaped string is written to output stream @a o.
+
+    @param[in] s  the string to escape
+    @param[in] ensure_ascii  whether to escape non-ASCII characters with
+                             \uXXXX sequences
+
+    @complexity Linear in the length of string @a s.
+    */
+    void dump_escaped(const string_t& s, const bool ensure_ascii)
+    {
+        std::uint32_t codepoint{};
+        std::uint8_t state = UTF8_ACCEPT;
+        std::size_t bytes = 0;  // number of bytes written to string_buffer
+
+        // number of bytes written at the point of the last valid byte
+        std::size_t bytes_after_last_accept = 0;
+        std::size_t undumped_chars = 0;
+
+        for (std::size_t i = 0; i < s.size(); ++i)
+        {
+            const auto byte = static_cast<std::uint8_t>(s[i]);
+
+            switch (decode(state, codepoint, byte))
+            {
+                case UTF8_ACCEPT:  // decode found a new code point
+                {
+                    switch (codepoint)
+                    {
+                        case 0x08: // backspace
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = 'b';
+                            break;
+                        }
+
+                        case 0x09: // horizontal tab
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = 't';
+                            break;
+                        }
+
+                        case 0x0A: // newline
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = 'n';
+                            break;
+                        }
+
+                        case 0x0C: // formfeed
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = 'f';
+                            break;
+                        }
+
+                        case 0x0D: // carriage return
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = 'r';
+                            break;
+                        }
+
+                        case 0x22: // quotation mark
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = '\"';
+                            break;
+                        }
+
+                        case 0x5C: // reverse solidus
+                        {
+                            string_buffer[bytes++] = '\\';
+                            string_buffer[bytes++] = '\\';
+                            break;
+                        }
+
+                        default:
+                        {
+                            // escape control characters (0x00..0x1F) or, if
+                            // ensure_ascii parameter is used, non-ASCII characters
+                            if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
+                            {
+                                if (codepoint <= 0xFFFF)
+                                {
+                                    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                                    (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
+                                                    static_cast<std::uint16_t>(codepoint));
+                                    bytes += 6;
+                                }
+                                else
+                                {
+                                    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                                    (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
+                                                    static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
+                                                    static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
+                                    bytes += 12;
+                                }
+                            }
+                            else
+                            {
+                                // copy byte to buffer (all previous bytes
+                                // been copied have in default case above)
+                                string_buffer[bytes++] = s[i];
+                            }
+                            break;
+                        }
+                    }
+
+                    // write buffer and reset index; there must be 13 bytes
+                    // left, as this is the maximal number of bytes to be
+                    // written ("\uxxxx\uxxxx\0") for one code point
+                    if (string_buffer.size() - bytes < 13)
+                    {
+                        o->write_characters(string_buffer.data(), bytes);
+                        bytes = 0;
+                    }
+
+                    // remember the byte position of this accept
+                    bytes_after_last_accept = bytes;
+                    undumped_chars = 0;
+                    break;
+                }
+
+                case UTF8_REJECT:  // decode found invalid UTF-8 byte
+                {
+                    switch (error_handler)
+                    {
+                        case error_handler_t::strict:
+                        {
+                            std::string sn(9, '\0');
+                            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                            (std::snprintf)(&sn[0], sn.size(), "%.2X", byte);
+                            JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn, BasicJsonType()));
+                        }
+
+                        case error_handler_t::ignore:
+                        case error_handler_t::replace:
+                        {
+                            // in case we saw this character the first time, we
+                            // would like to read it again, because the byte
+                            // may be OK for itself, but just not OK for the
+                            // previous sequence
+                            if (undumped_chars > 0)
+                            {
+                                --i;
+                            }
+
+                            // reset length buffer to the last accepted index;
+                            // thus removing/ignoring the invalid characters
+                            bytes = bytes_after_last_accept;
+
+                            if (error_handler == error_handler_t::replace)
+                            {
+                                // add a replacement character
+                                if (ensure_ascii)
+                                {
+                                    string_buffer[bytes++] = '\\';
+                                    string_buffer[bytes++] = 'u';
+                                    string_buffer[bytes++] = 'f';
+                                    string_buffer[bytes++] = 'f';
+                                    string_buffer[bytes++] = 'f';
+                                    string_buffer[bytes++] = 'd';
+                                }
+                                else
+                                {
+                                    string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xEF');
+                                    string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBF');
+                                    string_buffer[bytes++] = detail::binary_writer<BasicJsonType, char>::to_char_type('\xBD');
+                                }
+
+                                // write buffer and reset index; there must be 13 bytes
+                                // left, as this is the maximal number of bytes to be
+                                // written ("\uxxxx\uxxxx\0") for one code point
+                                if (string_buffer.size() - bytes < 13)
+                                {
+                                    o->write_characters(string_buffer.data(), bytes);
+                                    bytes = 0;
+                                }
+
+                                bytes_after_last_accept = bytes;
+                            }
+
+                            undumped_chars = 0;
+
+                            // continue processing the string
+                            state = UTF8_ACCEPT;
+                            break;
+                        }
+
+                        default:            // LCOV_EXCL_LINE
+                            JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+                    }
+                    break;
+                }
+
+                default:  // decode found yet incomplete multi-byte code point
+                {
+                    if (!ensure_ascii)
+                    {
+                        // code point will not be escaped - copy byte to buffer
+                        string_buffer[bytes++] = s[i];
+                    }
+                    ++undumped_chars;
+                    break;
+                }
+            }
+        }
+
+        // we finished processing the string
+        if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT))
+        {
+            // write buffer
+            if (bytes > 0)
+            {
+                o->write_characters(string_buffer.data(), bytes);
+            }
+        }
+        else
+        {
+            // we finish reading, but do not accept: string was incomplete
+            switch (error_handler)
+            {
+                case error_handler_t::strict:
+                {
+                    std::string sn(9, '\0');
+                    // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+                    (std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
+                    JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn, BasicJsonType()));
+                }
+
+                case error_handler_t::ignore:
+                {
+                    // write all accepted bytes
+                    o->write_characters(string_buffer.data(), bytes_after_last_accept);
+                    break;
+                }
+
+                case error_handler_t::replace:
+                {
+                    // write all accepted bytes
+                    o->write_characters(string_buffer.data(), bytes_after_last_accept);
+                    // add a replacement character
+                    if (ensure_ascii)
+                    {
+                        o->write_characters("\\ufffd", 6);
+                    }
+                    else
+                    {
+                        o->write_characters("\xEF\xBF\xBD", 3);
+                    }
+                    break;
+                }
+
+                default:            // LCOV_EXCL_LINE
+                    JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+            }
+        }
+    }
+
+  private:
+    /*!
+    @brief count digits
+
+    Count the number of decimal (base 10) digits for an input unsigned integer.
+
+    @param[in] x  unsigned integer number to count its digits
+    @return    number of decimal digits
+    */
+    inline unsigned int count_digits(number_unsigned_t x) noexcept
+    {
+        unsigned int n_digits = 1;
+        for (;;)
+        {
+            if (x < 10)
+            {
+                return n_digits;
+            }
+            if (x < 100)
+            {
+                return n_digits + 1;
+            }
+            if (x < 1000)
+            {
+                return n_digits + 2;
+            }
+            if (x < 10000)
+            {
+                return n_digits + 3;
+            }
+            x = x / 10000u;
+            n_digits += 4;
+        }
+    }
+
+    /*!
+    @brief dump an integer
+
+    Dump a given integer to output stream @a o. Works internally with
+    @a number_buffer.
+
+    @param[in] x  integer number (signed or unsigned) to dump
+    @tparam NumberType either @a number_integer_t or @a number_unsigned_t
+    */
+    template < typename NumberType, detail::enable_if_t <
+                   std::is_integral<NumberType>::value ||
+                   std::is_same<NumberType, number_unsigned_t>::value ||
+                   std::is_same<NumberType, number_integer_t>::value ||
+                   std::is_same<NumberType, binary_char_t>::value,
+                   int > = 0 >
+    void dump_integer(NumberType x)
+    {
+        static constexpr std::array<std::array<char, 2>, 100> digits_to_99
+        {
+            {
+                {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}},
+                {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}},
+                {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}},
+                {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}},
+                {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}},
+                {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}},
+                {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}},
+                {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}},
+                {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}},
+                {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}},
+            }
+        };
+
+        // special case for "0"
+        if (x == 0)
+        {
+            o->write_character('0');
+            return;
+        }
+
+        // use a pointer to fill the buffer
+        auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+
+        const bool is_negative = std::is_signed<NumberType>::value && !(x >= 0); // see issue #755
+        number_unsigned_t abs_value;
+
+        unsigned int n_chars{};
+
+        if (is_negative)
+        {
+            *buffer_ptr = '-';
+            abs_value = remove_sign(static_cast<number_integer_t>(x));
+
+            // account one more byte for the minus sign
+            n_chars = 1 + count_digits(abs_value);
+        }
+        else
+        {
+            abs_value = static_cast<number_unsigned_t>(x);
+            n_chars = count_digits(abs_value);
+        }
+
+        // spare 1 byte for '\0'
+        JSON_ASSERT(n_chars < number_buffer.size() - 1);
+
+        // jump to the end to generate the string from backward
+        // so we later avoid reversing the result
+        buffer_ptr += n_chars;
+
+        // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu
+        // See: https://www.youtube.com/watch?v=o4-CwDo2zpg
+        while (abs_value >= 100)
+        {
+            const auto digits_index = static_cast<unsigned>((abs_value % 100));
+            abs_value /= 100;
+            *(--buffer_ptr) = digits_to_99[digits_index][1];
+            *(--buffer_ptr) = digits_to_99[digits_index][0];
+        }
+
+        if (abs_value >= 10)
+        {
+            const auto digits_index = static_cast<unsigned>(abs_value);
+            *(--buffer_ptr) = digits_to_99[digits_index][1];
+            *(--buffer_ptr) = digits_to_99[digits_index][0];
+        }
+        else
+        {
+            *(--buffer_ptr) = static_cast<char>('0' + abs_value);
+        }
+
+        o->write_characters(number_buffer.data(), n_chars);
+    }
+
+    /*!
+    @brief dump a floating-point number
+
+    Dump a given floating-point number to output stream @a o. Works internally
+    with @a number_buffer.
+
+    @param[in] x  floating-point number to dump
+    */
+    void dump_float(number_float_t x)
+    {
+        // NaN / inf
+        if (!std::isfinite(x))
+        {
+            o->write_characters("null", 4);
+            return;
+        }
+
+        // If number_float_t is an IEEE-754 single or double precision number,
+        // use the Grisu2 algorithm to produce short numbers which are
+        // guaranteed to round-trip, using strtof and strtod, resp.
+        //
+        // NB: The test below works if <long double> == <double>.
+        static constexpr bool is_ieee_single_or_double
+            = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
+              (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
+
+        dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
+    }
+
+    void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/)
+    {
+        auto* begin = number_buffer.data();
+        auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
+
+        o->write_characters(begin, static_cast<size_t>(end - begin));
+    }
+
+    void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
+    {
+        // get number of digits for a float -> text -> float round-trip
+        static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
+
+        // the actual conversion
+        // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
+        std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x);
+
+        // negative value indicates an error
+        JSON_ASSERT(len > 0);
+        // check if buffer was large enough
+        JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
+
+        // erase thousands separator
+        if (thousands_sep != '\0')
+        {
+            // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081
+            const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
+            std::fill(end, number_buffer.end(), '\0');
+            JSON_ASSERT((end - number_buffer.begin()) <= len);
+            len = (end - number_buffer.begin());
+        }
+
+        // convert decimal point to '.'
+        if (decimal_point != '\0' && decimal_point != '.')
+        {
+            // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081
+            const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
+            if (dec_pos != number_buffer.end())
+            {
+                *dec_pos = '.';
+            }
+        }
+
+        o->write_characters(number_buffer.data(), static_cast<std::size_t>(len));
+
+        // determine if need to append ".0"
+        const bool value_is_int_like =
+            std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
+                         [](char c)
+        {
+            return c == '.' || c == 'e';
+        });
+
+        if (value_is_int_like)
+        {
+            o->write_characters(".0", 2);
+        }
+    }
+
+    /*!
+    @brief check whether a string is UTF-8 encoded
+
+    The function checks each byte of a string whether it is UTF-8 encoded. The
+    result of the check is stored in the @a state parameter. The function must
+    be called initially with state 0 (accept). State 1 means the string must
+    be rejected, because the current byte is not allowed. If the string is
+    completely processed, but the state is non-zero, the string ended
+    prematurely; that is, the last byte indicated more bytes should have
+    followed.
+
+    @param[in,out] state  the state of the decoding
+    @param[in,out] codep  codepoint (valid only if resulting state is UTF8_ACCEPT)
+    @param[in] byte       next byte to decode
+    @return               new state
+
+    @note The function has been edited: a std::array is used.
+
+    @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
+    @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
+    */
+    static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
+    {
+        static const std::array<std::uint8_t, 400> utf8d =
+        {
+            {
+                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F
+                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F
+                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F
+                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F
+                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F
+                7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF
+                8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF
+                0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF
+                0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF
+                0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0
+                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2
+                1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4
+                1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6
+                1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8
+            }
+        };
+
+        JSON_ASSERT(byte < utf8d.size());
+        const std::uint8_t type = utf8d[byte];
+
+        codep = (state != UTF8_ACCEPT)
+                ? (byte & 0x3fu) | (codep << 6u)
+                : (0xFFu >> type) & (byte);
+
+        std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
+        JSON_ASSERT(index < 400);
+        state = utf8d[index];
+        return state;
+    }
+
+    /*
+     * Overload to make the compiler happy while it is instantiating
+     * dump_integer for number_unsigned_t.
+     * Must never be called.
+     */
+    number_unsigned_t remove_sign(number_unsigned_t x)
+    {
+        JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        return x; // LCOV_EXCL_LINE
+    }
+
+    /*
+     * Helper function for dump_integer
+     *
+     * This function takes a negative signed integer and returns its absolute
+     * value as unsigned integer. The plus/minus shuffling is necessary as we can
+     * not directly remove the sign of an arbitrary signed integer as the
+     * absolute values of INT_MIN and INT_MAX are usually not the same. See
+     * #1708 for details.
+     */
+    inline number_unsigned_t remove_sign(number_integer_t x) noexcept
+    {
+        JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)()); // NOLINT(misc-redundant-expression)
+        return static_cast<number_unsigned_t>(-(x + 1)) + 1;
+    }
+
+  private:
+    /// the output of the serializer
+    output_adapter_t<char> o = nullptr;
+
+    /// a (hopefully) large enough character buffer
+    std::array<char, 64> number_buffer{{}};
+
+    /// the locale
+    const std::lconv* loc = nullptr;
+    /// the locale's thousand separator character
+    const char thousands_sep = '\0';
+    /// the locale's decimal point character
+    const char decimal_point = '\0';
+
+    /// string buffer
+    std::array<char, 512> string_buffer{{}};
+
+    /// the indentation character
+    const char indent_char;
+    /// the indentation string
+    string_t indent_string;
+
+    /// error_handler how to react on decoding errors
+    const error_handler_t error_handler;
+};
+}  // namespace detail
+}  // namespace nlohmann
+
+// #include <nlohmann/detail/value_t.hpp>
+
+// #include <nlohmann/json_fwd.hpp>
+
+// #include <nlohmann/ordered_map.hpp>
+
+
+#include <functional> // less
+#include <initializer_list> // initializer_list
+#include <iterator> // input_iterator_tag, iterator_traits
+#include <memory> // allocator
+#include <stdexcept> // for out_of_range
+#include <type_traits> // enable_if, is_convertible
+#include <utility> // pair
+#include <vector> // vector
+
+// #include <nlohmann/detail/macro_scope.hpp>
+
+
+namespace nlohmann
+{
+
+/// ordered_map: a minimal map-like container that preserves insertion order
+/// for use within nlohmann::basic_json<ordered_map>
+template <class Key, class T, class IgnoredLess = std::less<Key>,
+          class Allocator = std::allocator<std::pair<const Key, T>>>
+                  struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
+{
+    using key_type = Key;
+    using mapped_type = T;
+    using Container = std::vector<std::pair<const Key, T>, Allocator>;
+    using typename Container::iterator;
+    using typename Container::const_iterator;
+    using typename Container::size_type;
+    using typename Container::value_type;
+
+    // Explicit constructors instead of `using Container::Container`
+    // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4)
+    ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {}
+    template <class It>
+    ordered_map(It first, It last, const Allocator& alloc = Allocator())
+        : Container{first, last, alloc} {}
+    ordered_map(std::initializer_list<T> init, const Allocator& alloc = Allocator() )
+        : Container{init, alloc} {}
+
+    std::pair<iterator, bool> emplace(const key_type& key, T&& t)
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return {it, false};
+            }
+        }
+        Container::emplace_back(key, t);
+        return {--this->end(), true};
+    }
+
+    T& operator[](const Key& key)
+    {
+        return emplace(key, T{}).first->second;
+    }
+
+    const T& operator[](const Key& key) const
+    {
+        return at(key);
+    }
+
+    T& at(const Key& key)
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return it->second;
+            }
+        }
+
+        JSON_THROW(std::out_of_range("key not found"));
+    }
+
+    const T& at(const Key& key) const
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return it->second;
+            }
+        }
+
+        JSON_THROW(std::out_of_range("key not found"));
+    }
+
+    size_type erase(const Key& key)
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                // Since we cannot move const Keys, re-construct them in place
+                for (auto next = it; ++next != this->end(); ++it)
+                {
+                    it->~value_type(); // Destroy but keep allocation
+                    new (&*it) value_type{std::move(*next)};
+                }
+                Container::pop_back();
+                return 1;
+            }
+        }
+        return 0;
+    }
+
+    iterator erase(iterator pos)
+    {
+        auto it = pos;
+
+        // Since we cannot move const Keys, re-construct them in place
+        for (auto next = it; ++next != this->end(); ++it)
+        {
+            it->~value_type(); // Destroy but keep allocation
+            new (&*it) value_type{std::move(*next)};
+        }
+        Container::pop_back();
+        return pos;
+    }
+
+    size_type count(const Key& key) const
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return 1;
+            }
+        }
+        return 0;
+    }
+
+    iterator find(const Key& key)
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return it;
+            }
+        }
+        return Container::end();
+    }
+
+    const_iterator find(const Key& key) const
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == key)
+            {
+                return it;
+            }
+        }
+        return Container::end();
+    }
+
+    std::pair<iterator, bool> insert( value_type&& value )
+    {
+        return emplace(value.first, std::move(value.second));
+    }
+
+    std::pair<iterator, bool> insert( const value_type& value )
+    {
+        for (auto it = this->begin(); it != this->end(); ++it)
+        {
+            if (it->first == value.first)
+            {
+                return {it, false};
+            }
+        }
+        Container::push_back(value);
+        return {--this->end(), true};
+    }
+
+    template<typename InputIt>
+    using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
+            std::input_iterator_tag>::value>::type;
+
+    template<typename InputIt, typename = require_input_iter<InputIt>>
+    void insert(InputIt first, InputIt last)
+    {
+        for (auto it = first; it != last; ++it)
+        {
+            insert(*it);
+        }
+    }
+};
+
+}  // namespace nlohmann
+
+
+#if defined(JSON_HAS_CPP_17)
+    #include <string_view>
+#endif
+
+/*!
+@brief namespace for Niels Lohmann
+@see https://github.com/nlohmann
+@since version 1.0.0
+*/
+namespace nlohmann
+{
+
+/*!
+@brief a class to store JSON values
+
+@tparam ObjectType type for JSON objects (`std::map` by default; will be used
+in @ref object_t)
+@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used
+in @ref array_t)
+@tparam StringType type for JSON strings and object keys (`std::string` by
+default; will be used in @ref string_t)
+@tparam BooleanType type for JSON booleans (`bool` by default; will be used
+in @ref boolean_t)
+@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by
+default; will be used in @ref number_integer_t)
+@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c
+`uint64_t` by default; will be used in @ref number_unsigned_t)
+@tparam NumberFloatType type for JSON floating-point numbers (`double` by
+default; will be used in @ref number_float_t)
+@tparam BinaryType type for packed binary data for compatibility with binary
+serialization formats (`std::vector<std::uint8_t>` by default; will be used in
+@ref binary_t)
+@tparam AllocatorType type of the allocator to use (`std::allocator` by
+default)
+@tparam JSONSerializer the serializer to resolve internal calls to `to_json()`
+and `from_json()` (@ref adl_serializer by default)
+
+@requirement The class satisfies the following concept requirements:
+- Basic
+ - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible):
+   JSON values can be default constructed. The result will be a JSON null
+   value.
+ - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible):
+   A JSON value can be constructed from an rvalue argument.
+ - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible):
+   A JSON value can be copy-constructed from an lvalue expression.
+ - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable):
+   A JSON value van be assigned from an rvalue argument.
+ - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable):
+   A JSON value can be copy-assigned from an lvalue expression.
+ - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible):
+   JSON values can be destructed.
+- Layout
+ - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType):
+   JSON values have
+   [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout):
+   All non-static data members are private and standard layout types, the
+   class has no virtual functions or (virtual) base classes.
+- Library-wide
+ - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable):
+   JSON values can be compared with `==`, see @ref
+   operator==(const_reference,const_reference).
+ - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable):
+   JSON values can be compared with `<`, see @ref
+   operator<(const_reference,const_reference).
+ - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable):
+   Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of
+   other compatible types, using unqualified function call @ref swap().
+ - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer):
+   JSON values can be compared against `std::nullptr_t` objects which are used
+   to model the `null` value.
+- Container
+ - [Container](https://en.cppreference.com/w/cpp/named_req/Container):
+   JSON values can be used like STL containers and provide iterator access.
+ - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer);
+   JSON values can be used like STL containers and provide reverse iterator
+   access.
+
+@invariant The member variables @a m_value and @a m_type have the following
+relationship:
+- If `m_type == value_t::object`, then `m_value.object != nullptr`.
+- If `m_type == value_t::array`, then `m_value.array != nullptr`.
+- If `m_type == value_t::string`, then `m_value.string != nullptr`.
+The invariants are checked by member function assert_invariant().
+
+@internal
+@note ObjectType trick from https://stackoverflow.com/a/9860911
+@endinternal
+
+@see [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange
+Format](https://tools.ietf.org/html/rfc8259)
+
+@since version 1.0.0
+
+@nosubgrouping
+*/
+NLOHMANN_BASIC_JSON_TPL_DECLARATION
+class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
+{
+  private:
+    template<detail::value_t> friend struct detail::external_constructor;
+    friend ::nlohmann::json_pointer<basic_json>;
+
+    template<typename BasicJsonType, typename InputType>
+    friend class ::nlohmann::detail::parser;
+    friend ::nlohmann::detail::serializer<basic_json>;
+    template<typename BasicJsonType>
+    friend class ::nlohmann::detail::iter_impl;
+    template<typename BasicJsonType, typename CharType>
+    friend class ::nlohmann::detail::binary_writer;
+    template<typename BasicJsonType, typename InputType, typename SAX>
+    friend class ::nlohmann::detail::binary_reader;
+    template<typename BasicJsonType>
+    friend class ::nlohmann::detail::json_sax_dom_parser;
+    template<typename BasicJsonType>
+    friend class ::nlohmann::detail::json_sax_dom_callback_parser;
+    friend class ::nlohmann::detail::exception;
+
+    /// workaround type for MSVC
+    using basic_json_t = NLOHMANN_BASIC_JSON_TPL;
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    // convenience aliases for types residing in namespace detail;
+    using lexer = ::nlohmann::detail::lexer_base<basic_json>;
+
+    template<typename InputAdapterType>
+    static ::nlohmann::detail::parser<basic_json, InputAdapterType> parser(
+        InputAdapterType adapter,
+        detail::parser_callback_t<basic_json>cb = nullptr,
+        const bool allow_exceptions = true,
+        const bool ignore_comments = false
+                                 )
+    {
+        return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
+                std::move(cb), allow_exceptions, ignore_comments);
+    }
+
+  private:
+    using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t;
+    template<typename BasicJsonType>
+    using internal_iterator = ::nlohmann::detail::internal_iterator<BasicJsonType>;
+    template<typename BasicJsonType>
+    using iter_impl = ::nlohmann::detail::iter_impl<BasicJsonType>;
+    template<typename Iterator>
+    using iteration_proxy = ::nlohmann::detail::iteration_proxy<Iterator>;
+    template<typename Base> using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator<Base>;
+
+    template<typename CharType>
+    using output_adapter_t = ::nlohmann::detail::output_adapter_t<CharType>;
+
+    template<typename InputType>
+    using binary_reader = ::nlohmann::detail::binary_reader<basic_json, InputType>;
+    template<typename CharType> using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    using serializer = ::nlohmann::detail::serializer<basic_json>;
+
+  public:
+    using value_t = detail::value_t;
+    /// JSON Pointer, see @ref nlohmann::json_pointer
+    using json_pointer = ::nlohmann::json_pointer<basic_json>;
+    template<typename T, typename SFINAE>
+    using json_serializer = JSONSerializer<T, SFINAE>;
+    /// how to treat decoding errors
+    using error_handler_t = detail::error_handler_t;
+    /// how to treat CBOR tags
+    using cbor_tag_handler_t = detail::cbor_tag_handler_t;
+    /// helper type for initializer lists of basic_json values
+    using initializer_list_t = std::initializer_list<detail::json_ref<basic_json>>;
+
+    using input_format_t = detail::input_format_t;
+    /// SAX interface type, see @ref nlohmann::json_sax
+    using json_sax_t = json_sax<basic_json>;
+
+    ////////////////
+    // exceptions //
+    ////////////////
+
+    /// @name exceptions
+    /// Classes to implement user-defined exceptions.
+    /// @{
+
+    /// @copydoc detail::exception
+    using exception = detail::exception;
+    /// @copydoc detail::parse_error
+    using parse_error = detail::parse_error;
+    /// @copydoc detail::invalid_iterator
+    using invalid_iterator = detail::invalid_iterator;
+    /// @copydoc detail::type_error
+    using type_error = detail::type_error;
+    /// @copydoc detail::out_of_range
+    using out_of_range = detail::out_of_range;
+    /// @copydoc detail::other_error
+    using other_error = detail::other_error;
+
+    /// @}
+
+
+    /////////////////////
+    // container types //
+    /////////////////////
+
+    /// @name container types
+    /// The canonic container types to use @ref basic_json like any other STL
+    /// container.
+    /// @{
+
+    /// the type of elements in a basic_json container
+    using value_type = basic_json;
+
+    /// the type of an element reference
+    using reference = value_type&;
+    /// the type of an element const reference
+    using const_reference = const value_type&;
+
+    /// a type to represent differences between iterators
+    using difference_type = std::ptrdiff_t;
+    /// a type to represent container sizes
+    using size_type = std::size_t;
+
+    /// the allocator type
+    using allocator_type = AllocatorType<basic_json>;
+
+    /// the type of an element pointer
+    using pointer = typename std::allocator_traits<allocator_type>::pointer;
+    /// the type of an element const pointer
+    using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
+
+    /// an iterator for a basic_json container
+    using iterator = iter_impl<basic_json>;
+    /// a const iterator for a basic_json container
+    using const_iterator = iter_impl<const basic_json>;
+    /// a reverse iterator for a basic_json container
+    using reverse_iterator = json_reverse_iterator<typename basic_json::iterator>;
+    /// a const reverse iterator for a basic_json container
+    using const_reverse_iterator = json_reverse_iterator<typename basic_json::const_iterator>;
+
+    /// @}
+
+
+    /*!
+    @brief returns the allocator associated with the container
+    */
+    static allocator_type get_allocator()
+    {
+        return allocator_type();
+    }
+
+    /*!
+    @brief returns version information on the library
+
+    This function returns a JSON object with information about the library,
+    including the version number and information on the platform and compiler.
+
+    @return JSON object holding version information
+    key         | description
+    ----------- | ---------------
+    `compiler`  | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version).
+    `copyright` | The copyright line for the library as string.
+    `name`      | The name of the library as string.
+    `platform`  | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`.
+    `url`       | The URL of the project as string.
+    `version`   | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string).
+
+    @liveexample{The following code shows an example output of the `meta()`
+    function.,meta}
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @complexity Constant.
+
+    @since 2.1.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json meta()
+    {
+        basic_json result;
+
+        result["copyright"] = "(C) 2013-2021 Niels Lohmann";
+        result["name"] = "JSON for Modern C++";
+        result["url"] = "https://github.com/nlohmann/json";
+        result["version"]["string"] =
+            std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." +
+            std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." +
+            std::to_string(NLOHMANN_JSON_VERSION_PATCH);
+        result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR;
+        result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR;
+        result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH;
+
+#ifdef _WIN32
+        result["platform"] = "win32";
+#elif defined __linux__
+        result["platform"] = "linux";
+#elif defined __APPLE__
+        result["platform"] = "apple";
+#elif defined __unix__
+        result["platform"] = "unix";
+#else
+        result["platform"] = "unknown";
+#endif
+
+#if defined(__ICC) || defined(__INTEL_COMPILER)
+        result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}};
+#elif defined(__clang__)
+        result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}};
+#elif defined(__GNUC__) || defined(__GNUG__)
+        result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}};
+#elif defined(__HP_cc) || defined(__HP_aCC)
+        result["compiler"] = "hp"
+#elif defined(__IBMCPP__)
+        result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}};
+#elif defined(_MSC_VER)
+        result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}};
+#elif defined(__PGI)
+        result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}};
+#elif defined(__SUNPRO_CC)
+        result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}};
+#else
+        result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}};
+#endif
+
+#ifdef __cplusplus
+        result["compiler"]["c++"] = std::to_string(__cplusplus);
+#else
+        result["compiler"]["c++"] = "unknown";
+#endif
+        return result;
+    }
+
+
+    ///////////////////////////
+    // JSON value data types //
+    ///////////////////////////
+
+    /// @name JSON value data types
+    /// The data types to store a JSON value. These types are derived from
+    /// the template arguments passed to class @ref basic_json.
+    /// @{
+
+#if defined(JSON_HAS_CPP_14)
+    // Use transparent comparator if possible, combined with perfect forwarding
+    // on find() and count() calls prevents unnecessary string construction.
+    using object_comparator_t = std::less<>;
+#else
+    using object_comparator_t = std::less<StringType>;
+#endif
+
+    /*!
+    @brief a type for an object
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows:
+    > An object is an unordered collection of zero or more name/value pairs,
+    > where a name is a string and a value is a string, number, boolean, null,
+    > object, or array.
+
+    To store objects in C++, a type is defined by the template parameters
+    described below.
+
+    @tparam ObjectType  the container to store objects (e.g., `std::map` or
+    `std::unordered_map`)
+    @tparam StringType the type of the keys or names (e.g., `std::string`).
+    The comparison function `std::less<StringType>` is used to order elements
+    inside the container.
+    @tparam AllocatorType the allocator to use for objects (e.g.,
+    `std::allocator`)
+
+    #### Default type
+
+    With the default values for @a ObjectType (`std::map`), @a StringType
+    (`std::string`), and @a AllocatorType (`std::allocator`), the default
+    value for @a object_t is:
+
+    @code {.cpp}
+    std::map<
+      std::string, // key_type
+      basic_json, // value_type
+      std::less<std::string>, // key_compare
+      std::allocator<std::pair<const std::string, basic_json>> // allocator_type
+    >
+    @endcode
+
+    #### Behavior
+
+    The choice of @a object_t influences the behavior of the JSON class. With
+    the default type, objects have the following behavior:
+
+    - When all names are unique, objects will be interoperable in the sense
+      that all software implementations receiving that object will agree on
+      the name-value mappings.
+    - When the names within an object are not unique, it is unspecified which
+      one of the values for a given key will be chosen. For instance,
+      `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or
+      `{"key": 2}`.
+    - Internally, name/value pairs are stored in lexicographical order of the
+      names. Objects will also be serialized (see @ref dump) in this order.
+      For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored
+      and serialized as `{"a": 2, "b": 1}`.
+    - When comparing objects, the order of the name/value pairs is irrelevant.
+      This makes objects interoperable in the sense that they will not be
+      affected by these differences. For instance, `{"b": 1, "a": 2}` and
+      `{"a": 2, "b": 1}` will be treated as equal.
+
+    #### Limits
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
+    > An implementation may set limits on the maximum depth of nesting.
+
+    In this class, the object's limit of nesting is not explicitly constrained.
+    However, a maximum depth of nesting may be introduced by the compiler or
+    runtime environment. A theoretical limit can be queried by calling the
+    @ref max_size function of a JSON object.
+
+    #### Storage
+
+    Objects are stored as pointers in a @ref basic_json type. That is, for any
+    access to object values, a pointer of type `object_t*` must be
+    dereferenced.
+
+    @sa see @ref array_t -- type for an array value
+
+    @since version 1.0.0
+
+    @note The order name/value pairs are added to the object is *not*
+    preserved by the library. Therefore, iterating an object may return
+    name/value pairs in a different order than they were originally stored. In
+    fact, keys will be traversed in alphabetical order as `std::map` with
+    `std::less` is used by default. Please note this behavior conforms to [RFC
+    8259](https://tools.ietf.org/html/rfc8259), because any order implements the
+    specified "unordered" nature of JSON objects.
+    */
+    using object_t = ObjectType<StringType,
+          basic_json,
+          object_comparator_t,
+          AllocatorType<std::pair<const StringType,
+          basic_json>>>;
+
+    /*!
+    @brief a type for an array
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows:
+    > An array is an ordered sequence of zero or more values.
+
+    To store objects in C++, a type is defined by the template parameters
+    explained below.
+
+    @tparam ArrayType  container type to store arrays (e.g., `std::vector` or
+    `std::list`)
+    @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`)
+
+    #### Default type
+
+    With the default values for @a ArrayType (`std::vector`) and @a
+    AllocatorType (`std::allocator`), the default value for @a array_t is:
+
+    @code {.cpp}
+    std::vector<
+      basic_json, // value_type
+      std::allocator<basic_json> // allocator_type
+    >
+    @endcode
+
+    #### Limits
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
+    > An implementation may set limits on the maximum depth of nesting.
+
+    In this class, the array's limit of nesting is not explicitly constrained.
+    However, a maximum depth of nesting may be introduced by the compiler or
+    runtime environment. A theoretical limit can be queried by calling the
+    @ref max_size function of a JSON array.
+
+    #### Storage
+
+    Arrays are stored as pointers in a @ref basic_json type. That is, for any
+    access to array values, a pointer of type `array_t*` must be dereferenced.
+
+    @sa see @ref object_t -- type for an object value
+
+    @since version 1.0.0
+    */
+    using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
+
+    /*!
+    @brief a type for a string
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows:
+    > A string is a sequence of zero or more Unicode characters.
+
+    To store objects in C++, a type is defined by the template parameter
+    described below. Unicode values are split by the JSON class into
+    byte-sized characters during deserialization.
+
+    @tparam StringType  the container to store strings (e.g., `std::string`).
+    Note this container is used for keys/names in objects, see @ref object_t.
+
+    #### Default type
+
+    With the default values for @a StringType (`std::string`), the default
+    value for @a string_t is:
+
+    @code {.cpp}
+    std::string
+    @endcode
+
+    #### Encoding
+
+    Strings are stored in UTF-8 encoding. Therefore, functions like
+    `std::string::size()` or `std::string::length()` return the number of
+    bytes in the string rather than the number of characters or glyphs.
+
+    #### String comparison
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) states:
+    > Software implementations are typically required to test names of object
+    > members for equality. Implementations that transform the textual
+    > representation into sequences of Unicode code units and then perform the
+    > comparison numerically, code unit by code unit, are interoperable in the
+    > sense that implementations will agree in all cases on equality or
+    > inequality of two strings. For example, implementations that compare
+    > strings with escaped characters unconverted may incorrectly find that
+    > `"a\\b"` and `"a\u005Cb"` are not equal.
+
+    This implementation is interoperable as it does compare strings code unit
+    by code unit.
+
+    #### Storage
+
+    String values are stored as pointers in a @ref basic_json type. That is,
+    for any access to string values, a pointer of type `string_t*` must be
+    dereferenced.
+
+    @since version 1.0.0
+    */
+    using string_t = StringType;
+
+    /*!
+    @brief a type for a boolean
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a
+    type which differentiates the two literals `true` and `false`.
+
+    To store objects in C++, a type is defined by the template parameter @a
+    BooleanType which chooses the type to use.
+
+    #### Default type
+
+    With the default values for @a BooleanType (`bool`), the default value for
+    @a boolean_t is:
+
+    @code {.cpp}
+    bool
+    @endcode
+
+    #### Storage
+
+    Boolean values are stored directly inside a @ref basic_json type.
+
+    @since version 1.0.0
+    */
+    using boolean_t = BooleanType;
+
+    /*!
+    @brief a type for a number (integer)
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
+    > The representation of numbers is similar to that used in most
+    > programming languages. A number is represented in base 10 using decimal
+    > digits. It contains an integer component that may be prefixed with an
+    > optional minus sign, which may be followed by a fraction part and/or an
+    > exponent part. Leading zeros are not allowed. (...) Numeric values that
+    > cannot be represented in the grammar below (such as Infinity and NaN)
+    > are not permitted.
+
+    This description includes both integer and floating-point numbers.
+    However, C++ allows more precise storage if it is known whether the number
+    is a signed integer, an unsigned integer or a floating-point number.
+    Therefore, three different types, @ref number_integer_t, @ref
+    number_unsigned_t and @ref number_float_t are used.
+
+    To store integer numbers in C++, a type is defined by the template
+    parameter @a NumberIntegerType which chooses the type to use.
+
+    #### Default type
+
+    With the default values for @a NumberIntegerType (`int64_t`), the default
+    value for @a number_integer_t is:
+
+    @code {.cpp}
+    int64_t
+    @endcode
+
+    #### Default behavior
+
+    - The restrictions about leading zeros is not enforced in C++. Instead,
+      leading zeros in integer literals lead to an interpretation as octal
+      number. Internally, the value will be stored as decimal number. For
+      instance, the C++ integer literal `010` will be serialized to `8`.
+      During deserialization, leading zeros yield an error.
+    - Not-a-number (NaN) values will be serialized to `null`.
+
+    #### Limits
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
+    > An implementation may set limits on the range and precision of numbers.
+
+    When the default type is used, the maximal integer number that can be
+    stored is `9223372036854775807` (INT64_MAX) and the minimal integer number
+    that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers
+    that are out of range will yield over/underflow when used in a
+    constructor. During deserialization, too large or small integer numbers
+    will be automatically be stored as @ref number_unsigned_t or @ref
+    number_float_t.
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) further states:
+    > Note that when such software is used, numbers that are integers and are
+    > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
+    > that implementations will agree exactly on their numeric values.
+
+    As this range is a subrange of the exactly supported range [INT64_MIN,
+    INT64_MAX], this class's integer type is interoperable.
+
+    #### Storage
+
+    Integer number values are stored directly inside a @ref basic_json type.
+
+    @sa see @ref number_float_t -- type for number values (floating-point)
+
+    @sa see @ref number_unsigned_t -- type for number values (unsigned integer)
+
+    @since version 1.0.0
+    */
+    using number_integer_t = NumberIntegerType;
+
+    /*!
+    @brief a type for a number (unsigned)
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
+    > The representation of numbers is similar to that used in most
+    > programming languages. A number is represented in base 10 using decimal
+    > digits. It contains an integer component that may be prefixed with an
+    > optional minus sign, which may be followed by a fraction part and/or an
+    > exponent part. Leading zeros are not allowed. (...) Numeric values that
+    > cannot be represented in the grammar below (such as Infinity and NaN)
+    > are not permitted.
+
+    This description includes both integer and floating-point numbers.
+    However, C++ allows more precise storage if it is known whether the number
+    is a signed integer, an unsigned integer or a floating-point number.
+    Therefore, three different types, @ref number_integer_t, @ref
+    number_unsigned_t and @ref number_float_t are used.
+
+    To store unsigned integer numbers in C++, a type is defined by the
+    template parameter @a NumberUnsignedType which chooses the type to use.
+
+    #### Default type
+
+    With the default values for @a NumberUnsignedType (`uint64_t`), the
+    default value for @a number_unsigned_t is:
+
+    @code {.cpp}
+    uint64_t
+    @endcode
+
+    #### Default behavior
+
+    - The restrictions about leading zeros is not enforced in C++. Instead,
+      leading zeros in integer literals lead to an interpretation as octal
+      number. Internally, the value will be stored as decimal number. For
+      instance, the C++ integer literal `010` will be serialized to `8`.
+      During deserialization, leading zeros yield an error.
+    - Not-a-number (NaN) values will be serialized to `null`.
+
+    #### Limits
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies:
+    > An implementation may set limits on the range and precision of numbers.
+
+    When the default type is used, the maximal integer number that can be
+    stored is `18446744073709551615` (UINT64_MAX) and the minimal integer
+    number that can be stored is `0`. Integer numbers that are out of range
+    will yield over/underflow when used in a constructor. During
+    deserialization, too large or small integer numbers will be automatically
+    be stored as @ref number_integer_t or @ref number_float_t.
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) further states:
+    > Note that when such software is used, numbers that are integers and are
+    > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense
+    > that implementations will agree exactly on their numeric values.
+
+    As this range is a subrange (when considered in conjunction with the
+    number_integer_t type) of the exactly supported range [0, UINT64_MAX],
+    this class's integer type is interoperable.
+
+    #### Storage
+
+    Integer number values are stored directly inside a @ref basic_json type.
+
+    @sa see @ref number_float_t -- type for number values (floating-point)
+    @sa see @ref number_integer_t -- type for number values (integer)
+
+    @since version 2.0.0
+    */
+    using number_unsigned_t = NumberUnsignedType;
+
+    /*!
+    @brief a type for a number (floating-point)
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows:
+    > The representation of numbers is similar to that used in most
+    > programming languages. A number is represented in base 10 using decimal
+    > digits. It contains an integer component that may be prefixed with an
+    > optional minus sign, which may be followed by a fraction part and/or an
+    > exponent part. Leading zeros are not allowed. (...) Numeric values that
+    > cannot be represented in the grammar below (such as Infinity and NaN)
+    > are not permitted.
+
+    This description includes both integer and floating-point numbers.
+    However, C++ allows more precise storage if it is known whether the number
+    is a signed integer, an unsigned integer or a floating-point number.
+    Therefore, three different types, @ref number_integer_t, @ref
+    number_unsigned_t and @ref number_float_t are used.
+
+    To store floating-point numbers in C++, a type is defined by the template
+    parameter @a NumberFloatType which chooses the type to use.
+
+    #### Default type
+
+    With the default values for @a NumberFloatType (`double`), the default
+    value for @a number_float_t is:
+
+    @code {.cpp}
+    double
+    @endcode
+
+    #### Default behavior
+
+    - The restrictions about leading zeros is not enforced in C++. Instead,
+      leading zeros in floating-point literals will be ignored. Internally,
+      the value will be stored as decimal number. For instance, the C++
+      floating-point literal `01.2` will be serialized to `1.2`. During
+      deserialization, leading zeros yield an error.
+    - Not-a-number (NaN) values will be serialized to `null`.
+
+    #### Limits
+
+    [RFC 8259](https://tools.ietf.org/html/rfc8259) states:
+    > This specification allows implementations to set limits on the range and
+    > precision of numbers accepted. Since software that implements IEEE
+    > 754-2008 binary64 (double precision) numbers is generally available and
+    > widely used, good interoperability can be achieved by implementations
+    > that expect no more precision or range than these provide, in the sense
+    > that implementations will approximate JSON numbers within the expected
+    > precision.
+
+    This implementation does exactly follow this approach, as it uses double
+    precision floating-point numbers. Note values smaller than
+    `-1.79769313486232e+308` and values greater than `1.79769313486232e+308`
+    will be stored as NaN internally and be serialized to `null`.
+
+    #### Storage
+
+    Floating-point number values are stored directly inside a @ref basic_json
+    type.
+
+    @sa see @ref number_integer_t -- type for number values (integer)
+
+    @sa see @ref number_unsigned_t -- type for number values (unsigned integer)
+
+    @since version 1.0.0
+    */
+    using number_float_t = NumberFloatType;
+
+    /*!
+    @brief a type for a packed binary type
+
+    This type is a type designed to carry binary data that appears in various
+    serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and
+    BSON's generic binary subtype. This type is NOT a part of standard JSON and
+    exists solely for compatibility with these binary types. As such, it is
+    simply defined as an ordered sequence of zero or more byte values.
+
+    Additionally, as an implementation detail, the subtype of the binary data is
+    carried around as a `std::uint8_t`, which is compatible with both of the
+    binary data formats that use binary subtyping, (though the specific
+    numbering is incompatible with each other, and it is up to the user to
+    translate between them).
+
+    [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type
+    as:
+    > Major type 2: a byte string. The string's length in bytes is represented
+    > following the rules for positive integers (major type 0).
+
+    [MessagePack's documentation on the bin type
+    family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family)
+    describes this type as:
+    > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes
+    > in addition to the size of the byte array.
+
+    [BSON's specifications](http://bsonspec.org/spec.html) describe several
+    binary types; however, this type is intended to represent the generic binary
+    type which has the description:
+    > Generic binary subtype - This is the most commonly used binary subtype and
+    > should be the 'default' for drivers and tools.
+
+    None of these impose any limitations on the internal representation other
+    than the basic unit of storage be some type of array whose parts are
+    decomposable into bytes.
+
+    The default representation of this binary format is a
+    `std::vector<std::uint8_t>`, which is a very common way to represent a byte
+    array in modern C++.
+
+    #### Default type
+
+    The default values for @a BinaryType is `std::vector<std::uint8_t>`
+
+    #### Storage
+
+    Binary Arrays are stored as pointers in a @ref basic_json type. That is,
+    for any access to array values, a pointer of the type `binary_t*` must be
+    dereferenced.
+
+    #### Notes on subtypes
+
+    - CBOR
+       - Binary values are represented as byte strings. Subtypes are serialized
+         as tagged values.
+    - MessagePack
+       - If a subtype is given and the binary array contains exactly 1, 2, 4, 8,
+         or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8)
+         is used. For other sizes, the ext family (ext8, ext16, ext32) is used.
+         The subtype is then added as singed 8-bit integer.
+       - If no subtype is given, the bin family (bin8, bin16, bin32) is used.
+    - BSON
+       - If a subtype is given, it is used and added as unsigned 8-bit integer.
+       - If no subtype is given, the generic binary subtype 0x00 is used.
+
+    @sa see @ref binary -- create a binary array
+
+    @since version 3.8.0
+    */
+    using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
+    /// @}
+
+  private:
+
+    /// helper for exception-safe object creation
+    template<typename T, typename... Args>
+    JSON_HEDLEY_RETURNS_NON_NULL
+    static T* create(Args&& ... args)
+    {
+        AllocatorType<T> alloc;
+        using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
+
+        auto deleter = [&](T * obj)
+        {
+            AllocatorTraits::deallocate(alloc, obj, 1);
+        };
+        std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
+        AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
+        JSON_ASSERT(obj != nullptr);
+        return obj.release();
+    }
+
+    ////////////////////////
+    // JSON value storage //
+    ////////////////////////
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    /*!
+    @brief a JSON value
+
+    The actual storage for a JSON value of the @ref basic_json class. This
+    union combines the different storage types for the JSON value types
+    defined in @ref value_t.
+
+    JSON type | value_t type    | used type
+    --------- | --------------- | ------------------------
+    object    | object          | pointer to @ref object_t
+    array     | array           | pointer to @ref array_t
+    string    | string          | pointer to @ref string_t
+    boolean   | boolean         | @ref boolean_t
+    number    | number_integer  | @ref number_integer_t
+    number    | number_unsigned | @ref number_unsigned_t
+    number    | number_float    | @ref number_float_t
+    binary    | binary          | pointer to @ref binary_t
+    null      | null            | *no value is stored*
+
+    @note Variable-length types (objects, arrays, and strings) are stored as
+    pointers. The size of the union should not exceed 64 bits if the default
+    value types are used.
+
+    @since version 1.0.0
+    */
+    union json_value
+    {
+        /// object (stored with pointer to save storage)
+        object_t* object;
+        /// array (stored with pointer to save storage)
+        array_t* array;
+        /// string (stored with pointer to save storage)
+        string_t* string;
+        /// binary (stored with pointer to save storage)
+        binary_t* binary;
+        /// boolean
+        boolean_t boolean;
+        /// number (integer)
+        number_integer_t number_integer;
+        /// number (unsigned integer)
+        number_unsigned_t number_unsigned;
+        /// number (floating-point)
+        number_float_t number_float;
+
+        /// default constructor (for null values)
+        json_value() = default;
+        /// constructor for booleans
+        json_value(boolean_t v) noexcept : boolean(v) {}
+        /// constructor for numbers (integer)
+        json_value(number_integer_t v) noexcept : number_integer(v) {}
+        /// constructor for numbers (unsigned)
+        json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
+        /// constructor for numbers (floating-point)
+        json_value(number_float_t v) noexcept : number_float(v) {}
+        /// constructor for empty values of a given type
+        json_value(value_t t)
+        {
+            switch (t)
+            {
+                case value_t::object:
+                {
+                    object = create<object_t>();
+                    break;
+                }
+
+                case value_t::array:
+                {
+                    array = create<array_t>();
+                    break;
+                }
+
+                case value_t::string:
+                {
+                    string = create<string_t>("");
+                    break;
+                }
+
+                case value_t::binary:
+                {
+                    binary = create<binary_t>();
+                    break;
+                }
+
+                case value_t::boolean:
+                {
+                    boolean = boolean_t(false);
+                    break;
+                }
+
+                case value_t::number_integer:
+                {
+                    number_integer = number_integer_t(0);
+                    break;
+                }
+
+                case value_t::number_unsigned:
+                {
+                    number_unsigned = number_unsigned_t(0);
+                    break;
+                }
+
+                case value_t::number_float:
+                {
+                    number_float = number_float_t(0.0);
+                    break;
+                }
+
+                case value_t::null:
+                {
+                    object = nullptr;  // silence warning, see #821
+                    break;
+                }
+
+                case value_t::discarded:
+                default:
+                {
+                    object = nullptr;  // silence warning, see #821
+                    if (JSON_HEDLEY_UNLIKELY(t == value_t::null))
+                    {
+                        JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.4", basic_json())); // LCOV_EXCL_LINE
+                    }
+                    break;
+                }
+            }
+        }
+
+        /// constructor for strings
+        json_value(const string_t& value)
+        {
+            string = create<string_t>(value);
+        }
+
+        /// constructor for rvalue strings
+        json_value(string_t&& value)
+        {
+            string = create<string_t>(std::move(value));
+        }
+
+        /// constructor for objects
+        json_value(const object_t& value)
+        {
+            object = create<object_t>(value);
+        }
+
+        /// constructor for rvalue objects
+        json_value(object_t&& value)
+        {
+            object = create<object_t>(std::move(value));
+        }
+
+        /// constructor for arrays
+        json_value(const array_t& value)
+        {
+            array = create<array_t>(value);
+        }
+
+        /// constructor for rvalue arrays
+        json_value(array_t&& value)
+        {
+            array = create<array_t>(std::move(value));
+        }
+
+        /// constructor for binary arrays
+        json_value(const typename binary_t::container_type& value)
+        {
+            binary = create<binary_t>(value);
+        }
+
+        /// constructor for rvalue binary arrays
+        json_value(typename binary_t::container_type&& value)
+        {
+            binary = create<binary_t>(std::move(value));
+        }
+
+        /// constructor for binary arrays (internal type)
+        json_value(const binary_t& value)
+        {
+            binary = create<binary_t>(value);
+        }
+
+        /// constructor for rvalue binary arrays (internal type)
+        json_value(binary_t&& value)
+        {
+            binary = create<binary_t>(std::move(value));
+        }
+
+        void destroy(value_t t)
+        {
+            if (t == value_t::array || t == value_t::object)
+            {
+                // flatten the current json_value to a heap-allocated stack
+                std::vector<basic_json> stack;
+
+                // move the top-level items to stack
+                if (t == value_t::array)
+                {
+                    stack.reserve(array->size());
+                    std::move(array->begin(), array->end(), std::back_inserter(stack));
+                }
+                else
+                {
+                    stack.reserve(object->size());
+                    for (auto&& it : *object)
+                    {
+                        stack.push_back(std::move(it.second));
+                    }
+                }
+
+                while (!stack.empty())
+                {
+                    // move the last item to local variable to be processed
+                    basic_json current_item(std::move(stack.back()));
+                    stack.pop_back();
+
+                    // if current_item is array/object, move
+                    // its children to the stack to be processed later
+                    if (current_item.is_array())
+                    {
+                        std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
+
+                        current_item.m_value.array->clear();
+                    }
+                    else if (current_item.is_object())
+                    {
+                        for (auto&& it : *current_item.m_value.object)
+                        {
+                            stack.push_back(std::move(it.second));
+                        }
+
+                        current_item.m_value.object->clear();
+                    }
+
+                    // it's now safe that current_item get destructed
+                    // since it doesn't have any children
+                }
+            }
+
+            switch (t)
+            {
+                case value_t::object:
+                {
+                    AllocatorType<object_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
+                    break;
+                }
+
+                case value_t::array:
+                {
+                    AllocatorType<array_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, array);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, array, 1);
+                    break;
+                }
+
+                case value_t::string:
+                {
+                    AllocatorType<string_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
+                    break;
+                }
+
+                case value_t::binary:
+                {
+                    AllocatorType<binary_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, binary);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, binary, 1);
+                    break;
+                }
+
+                case value_t::null:
+                case value_t::boolean:
+                case value_t::number_integer:
+                case value_t::number_unsigned:
+                case value_t::number_float:
+                case value_t::discarded:
+                default:
+                {
+                    break;
+                }
+            }
+        }
+    };
+
+  private:
+    /*!
+    @brief checks the class invariants
+
+    This function asserts the class invariants. It needs to be called at the
+    end of every constructor to make sure that created objects respect the
+    invariant. Furthermore, it has to be called each time the type of a JSON
+    value is changed, because the invariant expresses a relationship between
+    @a m_type and @a m_value.
+
+    Furthermore, the parent relation is checked for arrays and objects: If
+    @a check_parents true and the value is an array or object, then the
+    container's elements must have the current value as parent.
+
+    @param[in] check_parents  whether the parent relation should be checked.
+               The value is true by default and should only be set to false
+               during destruction of objects when the invariant does not
+               need to hold.
+    */
+    void assert_invariant(bool check_parents = true) const noexcept
+    {
+        JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr);
+        JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr);
+        JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr);
+        JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr);
+
+#if JSON_DIAGNOSTICS
+        JSON_TRY
+        {
+            // cppcheck-suppress assertWithSideEffect
+            JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j)
+            {
+                return j.m_parent == this;
+            }));
+        }
+        JSON_CATCH(...) {} // LCOV_EXCL_LINE
+#endif
+        static_cast<void>(check_parents);
+    }
+
+    void set_parents()
+    {
+#if JSON_DIAGNOSTICS
+        switch (m_type)
+        {
+            case value_t::array:
+            {
+                for (auto& element : *m_value.array)
+                {
+                    element.m_parent = this;
+                }
+                break;
+            }
+
+            case value_t::object:
+            {
+                for (auto& element : *m_value.object)
+                {
+                    element.second.m_parent = this;
+                }
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                break;
+        }
+#endif
+    }
+
+    iterator set_parents(iterator it, typename iterator::difference_type count)
+    {
+#if JSON_DIAGNOSTICS
+        for (typename iterator::difference_type i = 0; i < count; ++i)
+        {
+            (it + i)->m_parent = this;
+        }
+#else
+        static_cast<void>(count);
+#endif
+        return it;
+    }
+
+    reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1))
+    {
+#if JSON_DIAGNOSTICS
+        if (old_capacity != std::size_t(-1))
+        {
+            // see https://github.com/nlohmann/json/issues/2838
+            JSON_ASSERT(type() == value_t::array);
+            if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity))
+            {
+                // capacity has changed: update all parents
+                set_parents();
+                return j;
+            }
+        }
+
+        // ordered_json uses a vector internally, so pointers could have
+        // been invalidated; see https://github.com/nlohmann/json/issues/2962
+#ifdef JSON_HEDLEY_MSVC_VERSION
+#pragma warning(push )
+#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr
+#endif
+        if (detail::is_ordered_map<object_t>::value)
+        {
+            set_parents();
+            return j;
+        }
+#ifdef JSON_HEDLEY_MSVC_VERSION
+#pragma warning( pop )
+#endif
+
+        j.m_parent = this;
+#else
+        static_cast<void>(j);
+        static_cast<void>(old_capacity);
+#endif
+        return j;
+    }
+
+  public:
+    //////////////////////////
+    // JSON parser callback //
+    //////////////////////////
+
+    /*!
+    @brief parser event types
+
+    The parser callback distinguishes the following events:
+    - `object_start`: the parser read `{` and started to process a JSON object
+    - `key`: the parser read a key of a value in an object
+    - `object_end`: the parser read `}` and finished processing a JSON object
+    - `array_start`: the parser read `[` and started to process a JSON array
+    - `array_end`: the parser read `]` and finished processing a JSON array
+    - `value`: the parser finished reading a JSON value
+
+    @image html callback_events.png "Example when certain parse events are triggered"
+
+    @sa see @ref parser_callback_t for more information and examples
+    */
+    using parse_event_t = detail::parse_event_t;
+
+    /*!
+    @brief per-element parser callback type
+
+    With a parser callback function, the result of parsing a JSON text can be
+    influenced. When passed to @ref parse, it is called on certain events
+    (passed as @ref parse_event_t via parameter @a event) with a set recursion
+    depth @a depth and context JSON value @a parsed. The return value of the
+    callback function is a boolean indicating whether the element that emitted
+    the callback shall be kept or not.
+
+    We distinguish six scenarios (determined by the event type) in which the
+    callback function can be called. The following table describes the values
+    of the parameters @a depth, @a event, and @a parsed.
+
+    parameter @a event | description | parameter @a depth | parameter @a parsed
+    ------------------ | ----------- | ------------------ | -------------------
+    parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded
+    parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key
+    parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object
+    parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded
+    parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array
+    parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value
+
+    @image html callback_events.png "Example when certain parse events are triggered"
+
+    Discarding a value (i.e., returning `false`) has different effects
+    depending on the context in which function was called:
+
+    - Discarded values in structured types are skipped. That is, the parser
+      will behave as if the discarded value was never read.
+    - In case a value outside a structured type is skipped, it is replaced
+      with `null`. This case happens if the top-level element is skipped.
+
+    @param[in] depth  the depth of the recursion during parsing
+
+    @param[in] event  an event of type parse_event_t indicating the context in
+    the callback function has been called
+
+    @param[in,out] parsed  the current intermediate parse result; note that
+    writing to this value has no effect for parse_event_t::key events
+
+    @return Whether the JSON value which called the function during parsing
+    should be kept (`true`) or not (`false`). In the latter case, it is either
+    skipped completely or replaced by an empty discarded object.
+
+    @sa see @ref parse for examples
+
+    @since version 1.0.0
+    */
+    using parser_callback_t = detail::parser_callback_t<basic_json>;
+
+    //////////////////
+    // constructors //
+    //////////////////
+
+    /// @name constructors and destructors
+    /// Constructors of class @ref basic_json, copy/move constructor, copy
+    /// assignment, static functions creating objects, and the destructor.
+    /// @{
+
+    /*!
+    @brief create an empty value with a given type
+
+    Create an empty JSON value with a given type. The value will be default
+    initialized with an empty value which depends on the type:
+
+    Value type  | initial value
+    ----------- | -------------
+    null        | `null`
+    boolean     | `false`
+    string      | `""`
+    number      | `0`
+    object      | `{}`
+    array       | `[]`
+    binary      | empty array
+
+    @param[in] v  the type of the value to create
+
+    @complexity Constant.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The following code shows the constructor for different @ref
+    value_t values,basic_json__value_t}
+
+    @sa see @ref clear() -- restores the postcondition of this constructor
+
+    @since version 1.0.0
+    */
+    basic_json(const value_t v)
+        : m_type(v), m_value(v)
+    {
+        assert_invariant();
+    }
+
+    /*!
+    @brief create a null object
+
+    Create a `null` JSON value. It either takes a null pointer as parameter
+    (explicitly creating `null`) or no parameter (implicitly creating `null`).
+    The passed null pointer itself is not read -- it is only used to choose
+    the right constructor.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this constructor never throws
+    exceptions.
+
+    @liveexample{The following code shows the constructor with and without a
+    null pointer parameter.,basic_json__nullptr_t}
+
+    @since version 1.0.0
+    */
+    basic_json(std::nullptr_t = nullptr) noexcept
+        : basic_json(value_t::null)
+    {
+        assert_invariant();
+    }
+
+    /*!
+    @brief create a JSON value
+
+    This is a "catch all" constructor for all compatible JSON types; that is,
+    types for which a `to_json()` method exists. The constructor forwards the
+    parameter @a val to that method (to `json_serializer<U>::to_json` method
+    with `U = uncvref_t<CompatibleType>`, to be exact).
+
+    Template type @a CompatibleType includes, but is not limited to, the
+    following types:
+    - **arrays**: @ref array_t and all kinds of compatible containers such as
+      `std::vector`, `std::deque`, `std::list`, `std::forward_list`,
+      `std::array`, `std::valarray`, `std::set`, `std::unordered_set`,
+      `std::multiset`, and `std::unordered_multiset` with a `value_type` from
+      which a @ref basic_json value can be constructed.
+    - **objects**: @ref object_t and all kinds of compatible associative
+      containers such as `std::map`, `std::unordered_map`, `std::multimap`,
+      and `std::unordered_multimap` with a `key_type` compatible to
+      @ref string_t and a `value_type` from which a @ref basic_json value can
+      be constructed.
+    - **strings**: @ref string_t, string literals, and all compatible string
+      containers can be used.
+    - **numbers**: @ref number_integer_t, @ref number_unsigned_t,
+      @ref number_float_t, and all convertible number types such as `int`,
+      `size_t`, `int64_t`, `float` or `double` can be used.
+    - **boolean**: @ref boolean_t / `bool` can be used.
+    - **binary**: @ref binary_t / `std::vector<std::uint8_t>` may be used,
+      unfortunately because string literals cannot be distinguished from binary
+      character arrays by the C++ type system, all types compatible with `const
+      char*` will be directed to the string constructor instead.  This is both
+      for backwards compatibility, and due to the fact that a binary type is not
+      a standard JSON type.
+
+    See the examples below.
+
+    @tparam CompatibleType a type such that:
+    - @a CompatibleType is not derived from `std::istream`,
+    - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move
+         constructors),
+    - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments)
+    - @a CompatibleType is not a @ref basic_json nested type (e.g.,
+         @ref json_pointer, @ref iterator, etc ...)
+    - `json_serializer<U>` has a `to_json(basic_json_t&, CompatibleType&&)` method
+
+    @tparam U = `uncvref_t<CompatibleType>`
+
+    @param[in] val the value to be forwarded to the respective constructor
+
+    @complexity Usually linear in the size of the passed @a val, also
+                depending on the implementation of the called `to_json()`
+                method.
+
+    @exceptionsafety Depends on the called constructor. For types directly
+    supported by the library (i.e., all types for which no `to_json()` function
+    was provided), strong guarantee holds: if an exception is thrown, there are
+    no changes to any JSON value.
+
+    @liveexample{The following code shows the constructor with several
+    compatible types.,basic_json__CompatibleType}
+
+    @since version 2.1.0
+    */
+    template < typename CompatibleType,
+               typename U = detail::uncvref_t<CompatibleType>,
+               detail::enable_if_t <
+                   !detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value, int > = 0 >
+    basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape)
+                JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
+                                           std::forward<CompatibleType>(val))))
+    {
+        JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief create a JSON value from an existing one
+
+    This is a constructor for existing @ref basic_json types.
+    It does not hijack copy/move constructors, since the parameter has different
+    template arguments than the current ones.
+
+    The constructor tries to convert the internal @ref m_value of the parameter.
+
+    @tparam BasicJsonType a type such that:
+    - @a BasicJsonType is a @ref basic_json type.
+    - @a BasicJsonType has different template arguments than @ref basic_json_t.
+
+    @param[in] val the @ref basic_json value to be converted.
+
+    @complexity Usually linear in the size of the passed @a val, also
+                depending on the implementation of the called `to_json()`
+                method.
+
+    @exceptionsafety Depends on the called constructor. For types directly
+    supported by the library (i.e., all types for which no `to_json()` function
+    was provided), strong guarantee holds: if an exception is thrown, there are
+    no changes to any JSON value.
+
+    @since version 3.2.0
+    */
+    template < typename BasicJsonType,
+               detail::enable_if_t <
+                   detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value, int > = 0 >
+    basic_json(const BasicJsonType& val)
+    {
+        using other_boolean_t = typename BasicJsonType::boolean_t;
+        using other_number_float_t = typename BasicJsonType::number_float_t;
+        using other_number_integer_t = typename BasicJsonType::number_integer_t;
+        using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t;
+        using other_string_t = typename BasicJsonType::string_t;
+        using other_object_t = typename BasicJsonType::object_t;
+        using other_array_t = typename BasicJsonType::array_t;
+        using other_binary_t = typename BasicJsonType::binary_t;
+
+        switch (val.type())
+        {
+            case value_t::boolean:
+                JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>());
+                break;
+            case value_t::number_float:
+                JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>());
+                break;
+            case value_t::number_integer:
+                JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>());
+                break;
+            case value_t::number_unsigned:
+                JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>());
+                break;
+            case value_t::string:
+                JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t&>());
+                break;
+            case value_t::object:
+                JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t&>());
+                break;
+            case value_t::array:
+                JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t&>());
+                break;
+            case value_t::binary:
+                JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t&>());
+                break;
+            case value_t::null:
+                *this = nullptr;
+                break;
+            case value_t::discarded:
+                m_type = value_t::discarded;
+                break;
+            default:            // LCOV_EXCL_LINE
+                JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+        }
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief create a container (array or object) from an initializer list
+
+    Creates a JSON value of type array or object from the passed initializer
+    list @a init. In case @a type_deduction is `true` (default), the type of
+    the JSON value to be created is deducted from the initializer list @a init
+    according to the following rules:
+
+    1. If the list is empty, an empty JSON object value `{}` is created.
+    2. If the list consists of pairs whose first element is a string, a JSON
+       object value is created where the first elements of the pairs are
+       treated as keys and the second elements are as values.
+    3. In all other cases, an array is created.
+
+    The rules aim to create the best fit between a C++ initializer list and
+    JSON values. The rationale is as follows:
+
+    1. The empty initializer list is written as `{}` which is exactly an empty
+       JSON object.
+    2. C++ has no way of describing mapped types other than to list a list of
+       pairs. As JSON requires that keys must be of type string, rule 2 is the
+       weakest constraint one can pose on initializer lists to interpret them
+       as an object.
+    3. In all other cases, the initializer list could not be interpreted as
+       JSON object type, so interpreting it as JSON array type is safe.
+
+    With the rules described above, the following JSON values cannot be
+    expressed by an initializer list:
+
+    - the empty array (`[]`): use @ref array(initializer_list_t)
+      with an empty initializer list in this case
+    - arrays whose elements satisfy rule 2: use @ref
+      array(initializer_list_t) with the same initializer list
+      in this case
+
+    @note When used without parentheses around an empty initializer list, @ref
+    basic_json() is called instead of this function, yielding the JSON null
+    value.
+
+    @param[in] init  initializer list with JSON values
+
+    @param[in] type_deduction internal parameter; when set to `true`, the type
+    of the JSON value is deducted from the initializer list @a init; when set
+    to `false`, the type provided via @a manual_type is forced. This mode is
+    used by the functions @ref array(initializer_list_t) and
+    @ref object(initializer_list_t).
+
+    @param[in] manual_type internal parameter; when @a type_deduction is set
+    to `false`, the created JSON value will use the provided type (only @ref
+    value_t::array and @ref value_t::object are valid); when @a type_deduction
+    is set to `true`, this parameter has no effect
+
+    @throw type_error.301 if @a type_deduction is `false`, @a manual_type is
+    `value_t::object`, but @a init contains an element which is not a pair
+    whose first element is a string. In this case, the constructor could not
+    create an object. If @a type_deduction would have be `true`, an array
+    would have been created. See @ref object(initializer_list_t)
+    for an example.
+
+    @complexity Linear in the size of the initializer list @a init.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The example below shows how JSON values are created from
+    initializer lists.,basic_json__list_init_t}
+
+    @sa see @ref array(initializer_list_t) -- create a JSON array
+    value from an initializer list
+    @sa see @ref object(initializer_list_t) -- create a JSON object
+    value from an initializer list
+
+    @since version 1.0.0
+    */
+    basic_json(initializer_list_t init,
+               bool type_deduction = true,
+               value_t manual_type = value_t::array)
+    {
+        // check if each element is an array with two elements whose first
+        // element is a string
+        bool is_an_object = std::all_of(init.begin(), init.end(),
+                                        [](const detail::json_ref<basic_json>& element_ref)
+        {
+            return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
+        });
+
+        // adjust type if type deduction is not wanted
+        if (!type_deduction)
+        {
+            // if array is wanted, do not create an object though possible
+            if (manual_type == value_t::array)
+            {
+                is_an_object = false;
+            }
+
+            // if object is wanted but impossible, throw an exception
+            if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object))
+            {
+                JSON_THROW(type_error::create(301, "cannot create object from initializer list", basic_json()));
+            }
+        }
+
+        if (is_an_object)
+        {
+            // the initializer list is a list of pairs -> create object
+            m_type = value_t::object;
+            m_value = value_t::object;
+
+            for (auto& element_ref : init)
+            {
+                auto element = element_ref.moved_or_copied();
+                m_value.object->emplace(
+                    std::move(*((*element.m_value.array)[0].m_value.string)),
+                    std::move((*element.m_value.array)[1]));
+            }
+        }
+        else
+        {
+            // the initializer list describes an array -> create array
+            m_type = value_t::array;
+            m_value.array = create<array_t>(init.begin(), init.end());
+        }
+
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief explicitly create a binary array (without subtype)
+
+    Creates a JSON binary array value from a given binary container. Binary
+    values are part of various binary formats, such as CBOR, MessagePack, and
+    BSON. This constructor is used to create a value for serialization to those
+    formats.
+
+    @note Note, this function exists because of the difficulty in correctly
+    specifying the correct template overload in the standard value ctor, as both
+    JSON arrays and JSON binary arrays are backed with some form of a
+    `std::vector`. Because JSON binary arrays are a non-standard extension it
+    was decided that it would be best to prevent automatic initialization of a
+    binary array type, for backwards compatibility and so it does not happen on
+    accident.
+
+    @param[in] init container containing bytes to use as binary type
+
+    @return JSON binary array value
+
+    @complexity Linear in the size of @a init.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @since version 3.8.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json binary(const typename binary_t::container_type& init)
+    {
+        auto res = basic_json();
+        res.m_type = value_t::binary;
+        res.m_value = init;
+        return res;
+    }
+
+    /*!
+    @brief explicitly create a binary array (with subtype)
+
+    Creates a JSON binary array value from a given binary container. Binary
+    values are part of various binary formats, such as CBOR, MessagePack, and
+    BSON. This constructor is used to create a value for serialization to those
+    formats.
+
+    @note Note, this function exists because of the difficulty in correctly
+    specifying the correct template overload in the standard value ctor, as both
+    JSON arrays and JSON binary arrays are backed with some form of a
+    `std::vector`. Because JSON binary arrays are a non-standard extension it
+    was decided that it would be best to prevent automatic initialization of a
+    binary array type, for backwards compatibility and so it does not happen on
+    accident.
+
+    @param[in] init container containing bytes to use as binary type
+    @param[in] subtype subtype to use in MessagePack and BSON
+
+    @return JSON binary array value
+
+    @complexity Linear in the size of @a init.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @since version 3.8.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json binary(const typename binary_t::container_type& init, typename binary_t::subtype_type subtype)
+    {
+        auto res = basic_json();
+        res.m_type = value_t::binary;
+        res.m_value = binary_t(init, subtype);
+        return res;
+    }
+
+    /// @copydoc binary(const typename binary_t::container_type&)
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json binary(typename binary_t::container_type&& init)
+    {
+        auto res = basic_json();
+        res.m_type = value_t::binary;
+        res.m_value = std::move(init);
+        return res;
+    }
+
+    /// @copydoc binary(const typename binary_t::container_type&, typename binary_t::subtype_type)
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json binary(typename binary_t::container_type&& init, typename binary_t::subtype_type subtype)
+    {
+        auto res = basic_json();
+        res.m_type = value_t::binary;
+        res.m_value = binary_t(std::move(init), subtype);
+        return res;
+    }
+
+    /*!
+    @brief explicitly create an array from an initializer list
+
+    Creates a JSON array value from a given initializer list. That is, given a
+    list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the
+    initializer list is empty, the empty array `[]` is created.
+
+    @note This function is only needed to express two edge cases that cannot
+    be realized with the initializer list constructor (@ref
+    basic_json(initializer_list_t, bool, value_t)). These cases
+    are:
+    1. creating an array whose elements are all pairs whose first element is a
+    string -- in this case, the initializer list constructor would create an
+    object, taking the first elements as keys
+    2. creating an empty array -- passing the empty initializer list to the
+    initializer list constructor yields an empty object
+
+    @param[in] init  initializer list with JSON values to create an array from
+    (optional)
+
+    @return JSON array value
+
+    @complexity Linear in the size of @a init.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The following code shows an example for the `array`
+    function.,array}
+
+    @sa see @ref basic_json(initializer_list_t, bool, value_t) --
+    create a JSON value from an initializer list
+    @sa see @ref object(initializer_list_t) -- create a JSON object
+    value from an initializer list
+
+    @since version 1.0.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json array(initializer_list_t init = {})
+    {
+        return basic_json(init, false, value_t::array);
+    }
+
+    /*!
+    @brief explicitly create an object from an initializer list
+
+    Creates a JSON object value from a given initializer list. The initializer
+    lists elements must be pairs, and their first elements must be strings. If
+    the initializer list is empty, the empty object `{}` is created.
+
+    @note This function is only added for symmetry reasons. In contrast to the
+    related function @ref array(initializer_list_t), there are
+    no cases which can only be expressed by this function. That is, any
+    initializer list @a init can also be passed to the initializer list
+    constructor @ref basic_json(initializer_list_t, bool, value_t).
+
+    @param[in] init  initializer list to create an object from (optional)
+
+    @return JSON object value
+
+    @throw type_error.301 if @a init is not a list of pairs whose first
+    elements are strings. In this case, no object can be created. When such a
+    value is passed to @ref basic_json(initializer_list_t, bool, value_t),
+    an array would have been created from the passed initializer list @a init.
+    See example below.
+
+    @complexity Linear in the size of @a init.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The following code shows an example for the `object`
+    function.,object}
+
+    @sa see @ref basic_json(initializer_list_t, bool, value_t) --
+    create a JSON value from an initializer list
+    @sa see @ref array(initializer_list_t) -- create a JSON array
+    value from an initializer list
+
+    @since version 1.0.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json object(initializer_list_t init = {})
+    {
+        return basic_json(init, false, value_t::object);
+    }
+
+    /*!
+    @brief construct an array with count copies of given value
+
+    Constructs a JSON array value by creating @a cnt copies of a passed value.
+    In case @a cnt is `0`, an empty array is created.
+
+    @param[in] cnt  the number of JSON copies of @a val to create
+    @param[in] val  the JSON value to copy
+
+    @post `std::distance(begin(),end()) == cnt` holds.
+
+    @complexity Linear in @a cnt.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The following code shows examples for the @ref
+    basic_json(size_type\, const basic_json&)
+    constructor.,basic_json__size_type_basic_json}
+
+    @since version 1.0.0
+    */
+    basic_json(size_type cnt, const basic_json& val)
+        : m_type(value_t::array)
+    {
+        m_value.array = create<array_t>(cnt, val);
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief construct a JSON container given an iterator range
+
+    Constructs the JSON value with the contents of the range `[first, last)`.
+    The semantics depends on the different types a JSON value can have:
+    - In case of a null type, invalid_iterator.206 is thrown.
+    - In case of other primitive types (number, boolean, or string), @a first
+      must be `begin()` and @a last must be `end()`. In this case, the value is
+      copied. Otherwise, invalid_iterator.204 is thrown.
+    - In case of structured types (array, object), the constructor behaves as
+      similar versions for `std::vector` or `std::map`; that is, a JSON array
+      or object is constructed from the values in the range.
+
+    @tparam InputIT an input iterator type (@ref iterator or @ref
+    const_iterator)
+
+    @param[in] first begin of the range to copy from (included)
+    @param[in] last end of the range to copy from (excluded)
+
+    @pre Iterators @a first and @a last must be initialized. **This
+         precondition is enforced with an assertion (see warning).** If
+         assertions are switched off, a violation of this precondition yields
+         undefined behavior.
+
+    @pre Range `[first, last)` is valid. Usually, this precondition cannot be
+         checked efficiently. Only certain edge cases are detected; see the
+         description of the exceptions below. A violation of this precondition
+         yields undefined behavior.
+
+    @warning A precondition is enforced with a runtime assertion that will
+             result in calling `std::abort` if this precondition is not met.
+             Assertions can be disabled by defining `NDEBUG` at compile time.
+             See https://en.cppreference.com/w/cpp/error/assert for more
+             information.
+
+    @throw invalid_iterator.201 if iterators @a first and @a last are not
+    compatible (i.e., do not belong to the same JSON value). In this case,
+    the range `[first, last)` is undefined.
+    @throw invalid_iterator.204 if iterators @a first and @a last belong to a
+    primitive type (number, boolean, or string), but @a first does not point
+    to the first element any more. In this case, the range `[first, last)` is
+    undefined. See example code below.
+    @throw invalid_iterator.206 if iterators @a first and @a last belong to a
+    null value. In this case, the range `[first, last)` is undefined.
+
+    @complexity Linear in distance between @a first and @a last.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @liveexample{The example below shows several ways to create JSON values by
+    specifying a subrange with iterators.,basic_json__InputIt_InputIt}
+
+    @since version 1.0.0
+    */
+    template < class InputIT, typename std::enable_if <
+                   std::is_same<InputIT, typename basic_json_t::iterator>::value ||
+                   std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int >::type = 0 >
+    basic_json(InputIT first, InputIT last)
+    {
+        JSON_ASSERT(first.m_object != nullptr);
+        JSON_ASSERT(last.m_object != nullptr);
+
+        // make sure iterator fits the current value
+        if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", basic_json()));
+        }
+
+        // copy type from first iterator
+        m_type = first.m_object->m_type;
+
+        // check if iterator range is complete for primitive values
+        switch (m_type)
+        {
+            case value_t::boolean:
+            case value_t::number_float:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::string:
+            {
+                if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin()
+                                         || !last.m_it.primitive_iterator.is_end()))
+                {
+                    JSON_THROW(invalid_iterator::create(204, "iterators out of range", *first.m_object));
+                }
+                break;
+            }
+
+            case value_t::null:
+            case value_t::object:
+            case value_t::array:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+                break;
+        }
+
+        switch (m_type)
+        {
+            case value_t::number_integer:
+            {
+                m_value.number_integer = first.m_object->m_value.number_integer;
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                m_value.number_unsigned = first.m_object->m_value.number_unsigned;
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                m_value.number_float = first.m_object->m_value.number_float;
+                break;
+            }
+
+            case value_t::boolean:
+            {
+                m_value.boolean = first.m_object->m_value.boolean;
+                break;
+            }
+
+            case value_t::string:
+            {
+                m_value = *first.m_object->m_value.string;
+                break;
+            }
+
+            case value_t::object:
+            {
+                m_value.object = create<object_t>(first.m_it.object_iterator,
+                                                  last.m_it.object_iterator);
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_value.array = create<array_t>(first.m_it.array_iterator,
+                                                last.m_it.array_iterator);
+                break;
+            }
+
+            case value_t::binary:
+            {
+                m_value = *first.m_object->m_value.binary;
+                break;
+            }
+
+            case value_t::null:
+            case value_t::discarded:
+            default:
+                JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object));
+        }
+
+        set_parents();
+        assert_invariant();
+    }
+
+
+    ///////////////////////////////////////
+    // other constructors and destructor //
+    ///////////////////////////////////////
+
+    template<typename JsonRef,
+             detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
+                                 std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
+    basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
+
+    /*!
+    @brief copy constructor
+
+    Creates a copy of a given JSON value.
+
+    @param[in] other  the JSON value to copy
+
+    @post `*this == other`
+
+    @complexity Linear in the size of @a other.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes to any JSON value.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is linear.
+    - As postcondition, it holds: `other == basic_json(other)`.
+
+    @liveexample{The following code shows an example for the copy
+    constructor.,basic_json__basic_json}
+
+    @since version 1.0.0
+    */
+    basic_json(const basic_json& other)
+        : m_type(other.m_type)
+    {
+        // check of passed value is valid
+        other.assert_invariant();
+
+        switch (m_type)
+        {
+            case value_t::object:
+            {
+                m_value = *other.m_value.object;
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_value = *other.m_value.array;
+                break;
+            }
+
+            case value_t::string:
+            {
+                m_value = *other.m_value.string;
+                break;
+            }
+
+            case value_t::boolean:
+            {
+                m_value = other.m_value.boolean;
+                break;
+            }
+
+            case value_t::number_integer:
+            {
+                m_value = other.m_value.number_integer;
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                m_value = other.m_value.number_unsigned;
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                m_value = other.m_value.number_float;
+                break;
+            }
+
+            case value_t::binary:
+            {
+                m_value = *other.m_value.binary;
+                break;
+            }
+
+            case value_t::null:
+            case value_t::discarded:
+            default:
+                break;
+        }
+
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief move constructor
+
+    Move constructor. Constructs a JSON value with the contents of the given
+    value @a other using move semantics. It "steals" the resources from @a
+    other and leaves it as JSON null value.
+
+    @param[in,out] other  value to move to this object
+
+    @post `*this` has the same value as @a other before the call.
+    @post @a other is a JSON null value.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this constructor never throws
+    exceptions.
+
+    @requirement This function helps `basic_json` satisfying the
+    [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible)
+    requirements.
+
+    @liveexample{The code below shows the move constructor explicitly called
+    via std::move.,basic_json__moveconstructor}
+
+    @since version 1.0.0
+    */
+    basic_json(basic_json&& other) noexcept
+        : m_type(std::move(other.m_type)),
+          m_value(std::move(other.m_value))
+    {
+        // check that passed value is valid
+        other.assert_invariant(false);
+
+        // invalidate payload
+        other.m_type = value_t::null;
+        other.m_value = {};
+
+        set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief copy assignment
+
+    Copy assignment operator. Copies a JSON value via the "copy and swap"
+    strategy: It is expressed in terms of the copy constructor, destructor,
+    and the `swap()` member function.
+
+    @param[in] other  value to copy from
+
+    @complexity Linear.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is linear.
+
+    @liveexample{The code below shows and example for the copy assignment. It
+    creates a copy of value `a` which is then swapped with `b`. Finally\, the
+    copy of `a` (which is the null value after the swap) is
+    destroyed.,basic_json__copyassignment}
+
+    @since version 1.0.0
+    */
+    basic_json& operator=(basic_json other) noexcept (
+        std::is_nothrow_move_constructible<value_t>::value&&
+        std::is_nothrow_move_assignable<value_t>::value&&
+        std::is_nothrow_move_constructible<json_value>::value&&
+        std::is_nothrow_move_assignable<json_value>::value
+    )
+    {
+        // check that passed value is valid
+        other.assert_invariant();
+
+        using std::swap;
+        swap(m_type, other.m_type);
+        swap(m_value, other.m_value);
+
+        set_parents();
+        assert_invariant();
+        return *this;
+    }
+
+    /*!
+    @brief destructor
+
+    Destroys the JSON value and frees all allocated memory.
+
+    @complexity Linear.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is linear.
+    - All stored elements are destroyed and all memory is freed.
+
+    @since version 1.0.0
+    */
+    ~basic_json() noexcept
+    {
+        assert_invariant(false);
+        m_value.destroy(m_type);
+    }
+
+    /// @}
+
+  public:
+    ///////////////////////
+    // object inspection //
+    ///////////////////////
+
+    /// @name object inspection
+    /// Functions to inspect the type of a JSON value.
+    /// @{
+
+    /*!
+    @brief serialization
+
+    Serialization function for JSON values. The function tries to mimic
+    Python's `json.dumps()` function, and currently supports its @a indent
+    and @a ensure_ascii parameters.
+
+    @param[in] indent If indent is nonnegative, then array elements and object
+    members will be pretty-printed with that indent level. An indent level of
+    `0` will only insert newlines. `-1` (the default) selects the most compact
+    representation.
+    @param[in] indent_char The character to use for indentation if @a indent is
+    greater than `0`. The default is ` ` (space).
+    @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters
+    in the output are escaped with `\uXXXX` sequences, and the result consists
+    of ASCII characters only.
+    @param[in] error_handler  how to react on decoding errors; there are three
+    possible values: `strict` (throws and exception in case a decoding error
+    occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD),
+    and `ignore` (ignore invalid UTF-8 sequences during serialization; all
+    bytes are copied to the output unchanged).
+
+    @return string containing the serialization of the JSON value
+
+    @throw type_error.316 if a string stored inside the JSON value is not
+                          UTF-8 encoded and @a error_handler is set to strict
+
+    @note Binary values are serialized as object containing two keys:
+      - "bytes": an array of bytes as integers
+      - "subtype": the subtype as integer or "null" if the binary has no subtype
+
+    @complexity Linear.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @liveexample{The following example shows the effect of different @a indent\,
+    @a indent_char\, and @a ensure_ascii parameters to the result of the
+    serialization.,dump}
+
+    @see https://docs.python.org/2/library/json.html#json.dump
+
+    @since version 1.0.0; indentation character @a indent_char, option
+           @a ensure_ascii and exceptions added in version 3.0.0; error
+           handlers added in version 3.4.0; serialization of binary values added
+           in version 3.8.0.
+    */
+    string_t dump(const int indent = -1,
+                  const char indent_char = ' ',
+                  const bool ensure_ascii = false,
+                  const error_handler_t error_handler = error_handler_t::strict) const
+    {
+        string_t result;
+        serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
+
+        if (indent >= 0)
+        {
+            s.dump(*this, true, ensure_ascii, static_cast<unsigned int>(indent));
+        }
+        else
+        {
+            s.dump(*this, false, ensure_ascii, 0);
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief return the type of the JSON value (explicit)
+
+    Return the type of the JSON value as a value from the @ref value_t
+    enumeration.
+
+    @return the type of the JSON value
+            Value type                | return value
+            ------------------------- | -------------------------
+            null                      | value_t::null
+            boolean                   | value_t::boolean
+            string                    | value_t::string
+            number (integer)          | value_t::number_integer
+            number (unsigned integer) | value_t::number_unsigned
+            number (floating-point)   | value_t::number_float
+            object                    | value_t::object
+            array                     | value_t::array
+            binary                    | value_t::binary
+            discarded                 | value_t::discarded
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `type()` for all JSON
+    types.,type}
+
+    @sa see @ref operator value_t() -- return the type of the JSON value (implicit)
+    @sa see @ref type_name() -- return the type as string
+
+    @since version 1.0.0
+    */
+    constexpr value_t type() const noexcept
+    {
+        return m_type;
+    }
+
+    /*!
+    @brief return whether type is primitive
+
+    This function returns true if and only if the JSON type is primitive
+    (string, number, boolean, or null).
+
+    @return `true` if type is primitive (string, number, boolean, or null),
+    `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_primitive()` for all JSON
+    types.,is_primitive}
+
+    @sa see @ref is_structured() -- returns whether JSON value is structured
+    @sa see @ref is_null() -- returns whether JSON value is `null`
+    @sa see @ref is_string() -- returns whether JSON value is a string
+    @sa see @ref is_boolean() -- returns whether JSON value is a boolean
+    @sa see @ref is_number() -- returns whether JSON value is a number
+    @sa see @ref is_binary() -- returns whether JSON value is a binary array
+
+    @since version 1.0.0
+    */
+    constexpr bool is_primitive() const noexcept
+    {
+        return is_null() || is_string() || is_boolean() || is_number() || is_binary();
+    }
+
+    /*!
+    @brief return whether type is structured
+
+    This function returns true if and only if the JSON type is structured
+    (array or object).
+
+    @return `true` if type is structured (array or object), `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_structured()` for all JSON
+    types.,is_structured}
+
+    @sa see @ref is_primitive() -- returns whether value is primitive
+    @sa see @ref is_array() -- returns whether value is an array
+    @sa see @ref is_object() -- returns whether value is an object
+
+    @since version 1.0.0
+    */
+    constexpr bool is_structured() const noexcept
+    {
+        return is_array() || is_object();
+    }
+
+    /*!
+    @brief return whether value is null
+
+    This function returns true if and only if the JSON value is null.
+
+    @return `true` if type is null, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_null()` for all JSON
+    types.,is_null}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_null() const noexcept
+    {
+        return m_type == value_t::null;
+    }
+
+    /*!
+    @brief return whether value is a boolean
+
+    This function returns true if and only if the JSON value is a boolean.
+
+    @return `true` if type is boolean, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_boolean()` for all JSON
+    types.,is_boolean}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_boolean() const noexcept
+    {
+        return m_type == value_t::boolean;
+    }
+
+    /*!
+    @brief return whether value is a number
+
+    This function returns true if and only if the JSON value is a number. This
+    includes both integer (signed and unsigned) and floating-point values.
+
+    @return `true` if type is number (regardless whether integer, unsigned
+    integer or floating-type), `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_number()` for all JSON
+    types.,is_number}
+
+    @sa see @ref is_number_integer() -- check if value is an integer or unsigned
+    integer number
+    @sa see @ref is_number_unsigned() -- check if value is an unsigned integer
+    number
+    @sa see @ref is_number_float() -- check if value is a floating-point number
+
+    @since version 1.0.0
+    */
+    constexpr bool is_number() const noexcept
+    {
+        return is_number_integer() || is_number_float();
+    }
+
+    /*!
+    @brief return whether value is an integer number
+
+    This function returns true if and only if the JSON value is a signed or
+    unsigned integer number. This excludes floating-point values.
+
+    @return `true` if type is an integer or unsigned integer number, `false`
+    otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_number_integer()` for all
+    JSON types.,is_number_integer}
+
+    @sa see @ref is_number() -- check if value is a number
+    @sa see @ref is_number_unsigned() -- check if value is an unsigned integer
+    number
+    @sa see @ref is_number_float() -- check if value is a floating-point number
+
+    @since version 1.0.0
+    */
+    constexpr bool is_number_integer() const noexcept
+    {
+        return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
+    }
+
+    /*!
+    @brief return whether value is an unsigned integer number
+
+    This function returns true if and only if the JSON value is an unsigned
+    integer number. This excludes floating-point and signed integer values.
+
+    @return `true` if type is an unsigned integer number, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_number_unsigned()` for all
+    JSON types.,is_number_unsigned}
+
+    @sa see @ref is_number() -- check if value is a number
+    @sa see @ref is_number_integer() -- check if value is an integer or unsigned
+    integer number
+    @sa see @ref is_number_float() -- check if value is a floating-point number
+
+    @since version 2.0.0
+    */
+    constexpr bool is_number_unsigned() const noexcept
+    {
+        return m_type == value_t::number_unsigned;
+    }
+
+    /*!
+    @brief return whether value is a floating-point number
+
+    This function returns true if and only if the JSON value is a
+    floating-point number. This excludes signed and unsigned integer values.
+
+    @return `true` if type is a floating-point number, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_number_float()` for all
+    JSON types.,is_number_float}
+
+    @sa see @ref is_number() -- check if value is number
+    @sa see @ref is_number_integer() -- check if value is an integer number
+    @sa see @ref is_number_unsigned() -- check if value is an unsigned integer
+    number
+
+    @since version 1.0.0
+    */
+    constexpr bool is_number_float() const noexcept
+    {
+        return m_type == value_t::number_float;
+    }
+
+    /*!
+    @brief return whether value is an object
+
+    This function returns true if and only if the JSON value is an object.
+
+    @return `true` if type is object, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_object()` for all JSON
+    types.,is_object}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_object() const noexcept
+    {
+        return m_type == value_t::object;
+    }
+
+    /*!
+    @brief return whether value is an array
+
+    This function returns true if and only if the JSON value is an array.
+
+    @return `true` if type is array, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_array()` for all JSON
+    types.,is_array}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_array() const noexcept
+    {
+        return m_type == value_t::array;
+    }
+
+    /*!
+    @brief return whether value is a string
+
+    This function returns true if and only if the JSON value is a string.
+
+    @return `true` if type is string, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_string()` for all JSON
+    types.,is_string}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_string() const noexcept
+    {
+        return m_type == value_t::string;
+    }
+
+    /*!
+    @brief return whether value is a binary array
+
+    This function returns true if and only if the JSON value is a binary array.
+
+    @return `true` if type is binary array, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_binary()` for all JSON
+    types.,is_binary}
+
+    @since version 3.8.0
+    */
+    constexpr bool is_binary() const noexcept
+    {
+        return m_type == value_t::binary;
+    }
+
+    /*!
+    @brief return whether value is discarded
+
+    This function returns true if and only if the JSON value was discarded
+    during parsing with a callback function (see @ref parser_callback_t).
+
+    @note This function will always be `false` for JSON values after parsing.
+    That is, discarded values can only occur during parsing, but will be
+    removed when inside a structured value or replaced by null in other cases.
+
+    @return `true` if type is discarded, `false` otherwise.
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies `is_discarded()` for all JSON
+    types.,is_discarded}
+
+    @since version 1.0.0
+    */
+    constexpr bool is_discarded() const noexcept
+    {
+        return m_type == value_t::discarded;
+    }
+
+    /*!
+    @brief return the type of the JSON value (implicit)
+
+    Implicitly return the type of the JSON value as a value from the @ref
+    value_t enumeration.
+
+    @return the type of the JSON value
+
+    @complexity Constant.
+
+    @exceptionsafety No-throw guarantee: this member function never throws
+    exceptions.
+
+    @liveexample{The following code exemplifies the @ref value_t operator for
+    all JSON types.,operator__value_t}
+
+    @sa see @ref type() -- return the type of the JSON value (explicit)
+    @sa see @ref type_name() -- return the type as string
+
+    @since version 1.0.0
+    */
+    constexpr operator value_t() const noexcept
+    {
+        return m_type;
+    }
+
+    /// @}
+
+  private:
+    //////////////////
+    // value access //
+    //////////////////
+
+    /// get a boolean (explicit)
+    boolean_t get_impl(boolean_t* /*unused*/) const
+    {
+        if (JSON_HEDLEY_LIKELY(is_boolean()))
+        {
+            return m_value.boolean;
+        }
+
+        JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()), *this));
+    }
+
+    /// get a pointer to the value (object)
+    object_t* get_impl_ptr(object_t* /*unused*/) noexcept
+    {
+        return is_object() ? m_value.object : nullptr;
+    }
+
+    /// get a pointer to the value (object)
+    constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept
+    {
+        return is_object() ? m_value.object : nullptr;
+    }
+
+    /// get a pointer to the value (array)
+    array_t* get_impl_ptr(array_t* /*unused*/) noexcept
+    {
+        return is_array() ? m_value.array : nullptr;
+    }
+
+    /// get a pointer to the value (array)
+    constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept
+    {
+        return is_array() ? m_value.array : nullptr;
+    }
+
+    /// get a pointer to the value (string)
+    string_t* get_impl_ptr(string_t* /*unused*/) noexcept
+    {
+        return is_string() ? m_value.string : nullptr;
+    }
+
+    /// get a pointer to the value (string)
+    constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept
+    {
+        return is_string() ? m_value.string : nullptr;
+    }
+
+    /// get a pointer to the value (boolean)
+    boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept
+    {
+        return is_boolean() ? &m_value.boolean : nullptr;
+    }
+
+    /// get a pointer to the value (boolean)
+    constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept
+    {
+        return is_boolean() ? &m_value.boolean : nullptr;
+    }
+
+    /// get a pointer to the value (integer number)
+    number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept
+    {
+        return is_number_integer() ? &m_value.number_integer : nullptr;
+    }
+
+    /// get a pointer to the value (integer number)
+    constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept
+    {
+        return is_number_integer() ? &m_value.number_integer : nullptr;
+    }
+
+    /// get a pointer to the value (unsigned number)
+    number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept
+    {
+        return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
+    }
+
+    /// get a pointer to the value (unsigned number)
+    constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept
+    {
+        return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
+    }
+
+    /// get a pointer to the value (floating-point number)
+    number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept
+    {
+        return is_number_float() ? &m_value.number_float : nullptr;
+    }
+
+    /// get a pointer to the value (floating-point number)
+    constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept
+    {
+        return is_number_float() ? &m_value.number_float : nullptr;
+    }
+
+    /// get a pointer to the value (binary)
+    binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept
+    {
+        return is_binary() ? m_value.binary : nullptr;
+    }
+
+    /// get a pointer to the value (binary)
+    constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept
+    {
+        return is_binary() ? m_value.binary : nullptr;
+    }
+
+    /*!
+    @brief helper function to implement get_ref()
+
+    This function helps to implement get_ref() without code duplication for
+    const and non-const overloads
+
+    @tparam ThisType will be deduced as `basic_json` or `const basic_json`
+
+    @throw type_error.303 if ReferenceType does not match underlying value
+    type of the current JSON
+    */
+    template<typename ReferenceType, typename ThisType>
+    static ReferenceType get_ref_impl(ThisType& obj)
+    {
+        // delegate the call to get_ptr<>()
+        auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
+
+        if (JSON_HEDLEY_LIKELY(ptr != nullptr))
+        {
+            return *ptr;
+        }
+
+        JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj));
+    }
+
+  public:
+    /// @name value access
+    /// Direct access to the stored value of a JSON value.
+    /// @{
+
+    /*!
+    @brief get a pointer value (implicit)
+
+    Implicit pointer access to the internally stored JSON value. No copies are
+    made.
+
+    @warning Writing data to the pointee of the result yields an undefined
+    state.
+
+    @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
+    object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
+    @ref number_unsigned_t, or @ref number_float_t. Enforced by a static
+    assertion.
+
+    @return pointer to the internally stored JSON value if the requested
+    pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how pointers to internal values of a
+    JSON value can be requested. Note that no type conversions are made and a
+    `nullptr` is returned if the value and the requested pointer type does not
+    match.,get_ptr}
+
+    @since version 1.0.0
+    */
+    template<typename PointerType, typename std::enable_if<
+                 std::is_pointer<PointerType>::value, int>::type = 0>
+    auto get_ptr() noexcept -> decltype(std::declval<basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
+    {
+        // delegate the call to get_impl_ptr<>()
+        return get_impl_ptr(static_cast<PointerType>(nullptr));
+    }
+
+    /*!
+    @brief get a pointer value (implicit)
+    @copydoc get_ptr()
+    */
+    template < typename PointerType, typename std::enable_if <
+                   std::is_pointer<PointerType>::value&&
+                   std::is_const<typename std::remove_pointer<PointerType>::type>::value, int >::type = 0 >
+    constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
+    {
+        // delegate the call to get_impl_ptr<>() const
+        return get_impl_ptr(static_cast<PointerType>(nullptr));
+    }
+
+  private:
+    /*!
+    @brief get a value (explicit)
+
+    Explicit type conversion between the JSON value and a compatible value
+    which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
+    and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
+    The value is converted by calling the @ref json_serializer<ValueType>
+    `from_json()` method.
+
+    The function is equivalent to executing
+    @code {.cpp}
+    ValueType ret;
+    JSONSerializer<ValueType>::from_json(*this, ret);
+    return ret;
+    @endcode
+
+    This overloads is chosen if:
+    - @a ValueType is not @ref basic_json,
+    - @ref json_serializer<ValueType> has a `from_json()` method of the form
+      `void from_json(const basic_json&, ValueType&)`, and
+    - @ref json_serializer<ValueType> does not have a `from_json()` method of
+      the form `ValueType from_json(const basic_json&)`
+
+    @tparam ValueType the returned value type
+
+    @return copy of the JSON value, converted to @a ValueType
+
+    @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+    @liveexample{The example below shows several conversions from JSON values
+    to other types. There a few things to note: (1) Floating-point numbers can
+    be converted to integers\, (2) A JSON array can be converted to a standard
+    `std::vector<short>`\, (3) A JSON object can be converted to C++
+    associative containers such as `std::unordered_map<std::string\,
+    json>`.,get__ValueType_const}
+
+    @since version 2.1.0
+    */
+    template < typename ValueType,
+               detail::enable_if_t <
+                   detail::is_default_constructible<ValueType>::value&&
+                   detail::has_from_json<basic_json_t, ValueType>::value,
+                   int > = 0 >
+    ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept(
+                JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
+    {
+        auto ret = ValueType();
+        JSONSerializer<ValueType>::from_json(*this, ret);
+        return ret;
+    }
+
+    /*!
+    @brief get a value (explicit); special case
+
+    Explicit type conversion between the JSON value and a compatible value
+    which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible)
+    and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible).
+    The value is converted by calling the @ref json_serializer<ValueType>
+    `from_json()` method.
+
+    The function is equivalent to executing
+    @code {.cpp}
+    return JSONSerializer<ValueType>::from_json(*this);
+    @endcode
+
+    This overloads is chosen if:
+    - @a ValueType is not @ref basic_json and
+    - @ref json_serializer<ValueType> has a `from_json()` method of the form
+      `ValueType from_json(const basic_json&)`
+
+    @note If @ref json_serializer<ValueType> has both overloads of
+    `from_json()`, this one is chosen.
+
+    @tparam ValueType the returned value type
+
+    @return copy of the JSON value, converted to @a ValueType
+
+    @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+    @since version 2.1.0
+    */
+    template < typename ValueType,
+               detail::enable_if_t <
+                   detail::has_non_default_from_json<basic_json_t, ValueType>::value,
+                   int > = 0 >
+    ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(
+                JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
+    {
+        return JSONSerializer<ValueType>::from_json(*this);
+    }
+
+    /*!
+    @brief get special-case overload
+
+    This overloads converts the current @ref basic_json in a different
+    @ref basic_json type
+
+    @tparam BasicJsonType == @ref basic_json
+
+    @return a copy of *this, converted into @a BasicJsonType
+
+    @complexity Depending on the implementation of the called `from_json()`
+                method.
+
+    @since version 3.2.0
+    */
+    template < typename BasicJsonType,
+               detail::enable_if_t <
+                   detail::is_basic_json<BasicJsonType>::value,
+                   int > = 0 >
+    BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const
+    {
+        return *this;
+    }
+
+    /*!
+    @brief get special-case overload
+
+    This overloads avoids a lot of template boilerplate, it can be seen as the
+    identity method
+
+    @tparam BasicJsonType == @ref basic_json
+
+    @return a copy of *this
+
+    @complexity Constant.
+
+    @since version 2.1.0
+    */
+    template<typename BasicJsonType,
+             detail::enable_if_t<
+                 std::is_same<BasicJsonType, basic_json_t>::value,
+                 int> = 0>
+    basic_json get_impl(detail::priority_tag<3> /*unused*/) const
+    {
+        return *this;
+    }
+
+    /*!
+    @brief get a pointer value (explicit)
+    @copydoc get()
+    */
+    template<typename PointerType,
+             detail::enable_if_t<
+                 std::is_pointer<PointerType>::value,
+                 int> = 0>
+    constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept
+    -> decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
+    {
+        // delegate the call to get_ptr
+        return get_ptr<PointerType>();
+    }
+
+  public:
+    /*!
+    @brief get a (pointer) value (explicit)
+
+    Performs explicit type conversion between the JSON value and a compatible value if required.
+
+    - If the requested type is a pointer to the internally stored JSON value that pointer is returned.
+    No copies are made.
+
+    - If the requested type is the current @ref basic_json, or a different @ref basic_json convertible
+    from the current @ref basic_json.
+
+    - Otherwise the value is converted by calling the @ref json_serializer<ValueType> `from_json()`
+    method.
+
+    @tparam ValueTypeCV the provided value type
+    @tparam ValueType the returned value type
+
+    @return copy of the JSON value, converted to @tparam ValueType if necessary
+
+    @throw what @ref json_serializer<ValueType> `from_json()` method throws if conversion is required
+
+    @since version 2.1.0
+    */
+    template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>>
+#if defined(JSON_HAS_CPP_14)
+    constexpr
+#endif
+    auto get() const noexcept(
+    noexcept(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {})))
+    -> decltype(std::declval<const basic_json_t&>().template get_impl<ValueType>(detail::priority_tag<4> {}))
+    {
+        // we cannot static_assert on ValueTypeCV being non-const, because
+        // there is support for get<const basic_json_t>(), which is why we
+        // still need the uncvref
+        static_assert(!std::is_reference<ValueTypeCV>::value,
+                      "get() cannot be used with reference types, you might want to use get_ref()");
+        return get_impl<ValueType>(detail::priority_tag<4> {});
+    }
+
+    /*!
+    @brief get a pointer value (explicit)
+
+    Explicit pointer access to the internally stored JSON value. No copies are
+    made.
+
+    @warning The pointer becomes invalid if the underlying JSON object
+    changes.
+
+    @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref
+    object_t, @ref string_t, @ref boolean_t, @ref number_integer_t,
+    @ref number_unsigned_t, or @ref number_float_t.
+
+    @return pointer to the internally stored JSON value if the requested
+    pointer type @a PointerType fits to the JSON value; `nullptr` otherwise
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how pointers to internal values of a
+    JSON value can be requested. Note that no type conversions are made and a
+    `nullptr` is returned if the value and the requested pointer type does not
+    match.,get__PointerType}
+
+    @sa see @ref get_ptr() for explicit pointer-member access
+
+    @since version 1.0.0
+    */
+    template<typename PointerType, typename std::enable_if<
+                 std::is_pointer<PointerType>::value, int>::type = 0>
+    auto get() noexcept -> decltype(std::declval<basic_json_t&>().template get_ptr<PointerType>())
+    {
+        // delegate the call to get_ptr
+        return get_ptr<PointerType>();
+    }
+
+    /*!
+    @brief get a value (explicit)
+
+    Explicit type conversion between the JSON value and a compatible value.
+    The value is filled into the input parameter by calling the @ref json_serializer<ValueType>
+    `from_json()` method.
+
+    The function is equivalent to executing
+    @code {.cpp}
+    ValueType v;
+    JSONSerializer<ValueType>::from_json(*this, v);
+    @endcode
+
+    This overloads is chosen if:
+    - @a ValueType is not @ref basic_json,
+    - @ref json_serializer<ValueType> has a `from_json()` method of the form
+      `void from_json(const basic_json&, ValueType&)`, and
+
+    @tparam ValueType the input parameter type.
+
+    @return the input parameter, allowing chaining calls.
+
+    @throw what @ref json_serializer<ValueType> `from_json()` method throws
+
+    @liveexample{The example below shows several conversions from JSON values
+    to other types. There a few things to note: (1) Floating-point numbers can
+    be converted to integers\, (2) A JSON array can be converted to a standard
+    `std::vector<short>`\, (3) A JSON object can be converted to C++
+    associative containers such as `std::unordered_map<std::string\,
+    json>`.,get_to}
+
+    @since version 3.3.0
+    */
+    template < typename ValueType,
+               detail::enable_if_t <
+                   !detail::is_basic_json<ValueType>::value&&
+                   detail::has_from_json<basic_json_t, ValueType>::value,
+                   int > = 0 >
+    ValueType & get_to(ValueType& v) const noexcept(noexcept(
+                JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
+    {
+        JSONSerializer<ValueType>::from_json(*this, v);
+        return v;
+    }
+
+    // specialization to allow to call get_to with a basic_json value
+    // see https://github.com/nlohmann/json/issues/2175
+    template<typename ValueType,
+             detail::enable_if_t <
+                 detail::is_basic_json<ValueType>::value,
+                 int> = 0>
+    ValueType & get_to(ValueType& v) const
+    {
+        v = *this;
+        return v;
+    }
+
+    template <
+        typename T, std::size_t N,
+        typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+        detail::enable_if_t <
+            detail::has_from_json<basic_json_t, Array>::value, int > = 0 >
+    Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
+    noexcept(noexcept(JSONSerializer<Array>::from_json(
+                          std::declval<const basic_json_t&>(), v)))
+    {
+        JSONSerializer<Array>::from_json(*this, v);
+        return v;
+    }
+
+    /*!
+    @brief get a reference value (implicit)
+
+    Implicit reference access to the internally stored JSON value. No copies
+    are made.
+
+    @warning Writing data to the referee of the result yields an undefined
+    state.
+
+    @tparam ReferenceType reference type; must be a reference to @ref array_t,
+    @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or
+    @ref number_float_t. Enforced by static assertion.
+
+    @return reference to the internally stored JSON value if the requested
+    reference type @a ReferenceType fits to the JSON value; throws
+    type_error.303 otherwise
+
+    @throw type_error.303 in case passed type @a ReferenceType is incompatible
+    with the stored JSON value; see example below
+
+    @complexity Constant.
+
+    @liveexample{The example shows several calls to `get_ref()`.,get_ref}
+
+    @since version 1.1.0
+    */
+    template<typename ReferenceType, typename std::enable_if<
+                 std::is_reference<ReferenceType>::value, int>::type = 0>
+    ReferenceType get_ref()
+    {
+        // delegate call to get_ref_impl
+        return get_ref_impl<ReferenceType>(*this);
+    }
+
+    /*!
+    @brief get a reference value (implicit)
+    @copydoc get_ref()
+    */
+    template < typename ReferenceType, typename std::enable_if <
+                   std::is_reference<ReferenceType>::value&&
+                   std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int >::type = 0 >
+    ReferenceType get_ref() const
+    {
+        // delegate call to get_ref_impl
+        return get_ref_impl<ReferenceType>(*this);
+    }
+
+    /*!
+    @brief get a value (implicit)
+
+    Implicit type conversion between the JSON value and a compatible value.
+    The call is realized by calling @ref get() const.
+
+    @tparam ValueType non-pointer type compatible to the JSON value, for
+    instance `int` for JSON integer numbers, `bool` for JSON booleans, or
+    `std::vector` types for JSON arrays. The character type of @ref string_t
+    as well as an initializer list of this type is excluded to avoid
+    ambiguities as these types implicitly convert to `std::string`.
+
+    @return copy of the JSON value, converted to type @a ValueType
+
+    @throw type_error.302 in case passed type @a ValueType is incompatible
+    to the JSON value type (e.g., the JSON value is of type boolean, but a
+    string is requested); see example below
+
+    @complexity Linear in the size of the JSON value.
+
+    @liveexample{The example below shows several conversions from JSON values
+    to other types. There a few things to note: (1) Floating-point numbers can
+    be converted to integers\, (2) A JSON array can be converted to a standard
+    `std::vector<short>`\, (3) A JSON object can be converted to C++
+    associative containers such as `std::unordered_map<std::string\,
+    json>`.,operator__ValueType}
+
+    @since version 1.0.0
+    */
+    template < typename ValueType, typename std::enable_if <
+                   detail::conjunction <
+                       detail::negation<std::is_pointer<ValueType>>,
+                       detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>,
+                                        detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
+                                        detail::negation<detail::is_basic_json<ValueType>>,
+                                        detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
+
+#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
+                                                detail::negation<std::is_same<ValueType, std::string_view>>,
+#endif
+                                                detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
+                                                >::value, int >::type = 0 >
+                                        JSON_EXPLICIT operator ValueType() const
+    {
+        // delegate the call to get<>() const
+        return get<ValueType>();
+    }
+
+    /*!
+    @return reference to the binary value
+
+    @throw type_error.302 if the value is not binary
+
+    @sa see @ref is_binary() to check if the value is binary
+
+    @since version 3.8.0
+    */
+    binary_t& get_binary()
+    {
+        if (!is_binary())
+        {
+            JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this));
+        }
+
+        return *get_ptr<binary_t*>();
+    }
+
+    /// @copydoc get_binary()
+    const binary_t& get_binary() const
+    {
+        if (!is_binary())
+        {
+            JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this));
+        }
+
+        return *get_ptr<const binary_t*>();
+    }
+
+    /// @}
+
+
+    ////////////////////
+    // element access //
+    ////////////////////
+
+    /// @name element access
+    /// Access to the JSON value.
+    /// @{
+
+    /*!
+    @brief access specified array element with bounds checking
+
+    Returns a reference to the element at specified location @a idx, with
+    bounds checking.
+
+    @param[in] idx  index of the element to access
+
+    @return reference to the element at index @a idx
+
+    @throw type_error.304 if the JSON value is not an array; in this case,
+    calling `at` with an index makes no sense. See example below.
+    @throw out_of_range.401 if the index @a idx is out of range of the array;
+    that is, `idx >= size()`. See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @since version 1.0.0
+
+    @liveexample{The example below shows how array elements can be read and
+    written using `at()`. It also demonstrates the different exceptions that
+    can be thrown.,at__size_type}
+    */
+    reference at(size_type idx)
+    {
+        // at only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            JSON_TRY
+            {
+                return set_parent(m_value.array->at(idx));
+            }
+            JSON_CATCH (std::out_of_range&)
+            {
+                // create better exception explanation
+                JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
+            }
+        }
+        else
+        {
+            JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief access specified array element with bounds checking
+
+    Returns a const reference to the element at specified location @a idx,
+    with bounds checking.
+
+    @param[in] idx  index of the element to access
+
+    @return const reference to the element at index @a idx
+
+    @throw type_error.304 if the JSON value is not an array; in this case,
+    calling `at` with an index makes no sense. See example below.
+    @throw out_of_range.401 if the index @a idx is out of range of the array;
+    that is, `idx >= size()`. See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @since version 1.0.0
+
+    @liveexample{The example below shows how array elements can be read using
+    `at()`. It also demonstrates the different exceptions that can be thrown.,
+    at__size_type_const}
+    */
+    const_reference at(size_type idx) const
+    {
+        // at only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            JSON_TRY
+            {
+                return m_value.array->at(idx);
+            }
+            JSON_CATCH (std::out_of_range&)
+            {
+                // create better exception explanation
+                JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
+            }
+        }
+        else
+        {
+            JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief access specified object element with bounds checking
+
+    Returns a reference to the element at with specified key @a key, with
+    bounds checking.
+
+    @param[in] key  key of the element to access
+
+    @return reference to the element at key @a key
+
+    @throw type_error.304 if the JSON value is not an object; in this case,
+    calling `at` with a key makes no sense. See example below.
+    @throw out_of_range.403 if the key @a key is is not stored in the object;
+    that is, `find(key) == end()`. See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Logarithmic in the size of the container.
+
+    @sa see @ref operator[](const typename object_t::key_type&) for unchecked
+    access by reference
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.0.0
+
+    @liveexample{The example below shows how object elements can be read and
+    written using `at()`. It also demonstrates the different exceptions that
+    can be thrown.,at__object_t_key_type}
+    */
+    reference at(const typename object_t::key_type& key)
+    {
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            JSON_TRY
+            {
+                return set_parent(m_value.object->at(key));
+            }
+            JSON_CATCH (std::out_of_range&)
+            {
+                // create better exception explanation
+                JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this));
+            }
+        }
+        else
+        {
+            JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief access specified object element with bounds checking
+
+    Returns a const reference to the element at with specified key @a key,
+    with bounds checking.
+
+    @param[in] key  key of the element to access
+
+    @return const reference to the element at key @a key
+
+    @throw type_error.304 if the JSON value is not an object; in this case,
+    calling `at` with a key makes no sense. See example below.
+    @throw out_of_range.403 if the key @a key is is not stored in the object;
+    that is, `find(key) == end()`. See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Logarithmic in the size of the container.
+
+    @sa see @ref operator[](const typename object_t::key_type&) for unchecked
+    access by reference
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.0.0
+
+    @liveexample{The example below shows how object elements can be read using
+    `at()`. It also demonstrates the different exceptions that can be thrown.,
+    at__object_t_key_type_const}
+    */
+    const_reference at(const typename object_t::key_type& key) const
+    {
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            JSON_TRY
+            {
+                return m_value.object->at(key);
+            }
+            JSON_CATCH (std::out_of_range&)
+            {
+                // create better exception explanation
+                JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this));
+            }
+        }
+        else
+        {
+            JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief access specified array element
+
+    Returns a reference to the element at specified location @a idx.
+
+    @note If @a idx is beyond the range of the array (i.e., `idx >= size()`),
+    then the array is silently filled up with `null` values to make `idx` a
+    valid reference to the last stored element.
+
+    @param[in] idx  index of the element to access
+
+    @return reference to the element at index @a idx
+
+    @throw type_error.305 if the JSON value is not an array or null; in that
+    cases, using the [] operator with an index makes no sense.
+
+    @complexity Constant if @a idx is in the range of the array. Otherwise
+    linear in `idx - size()`.
+
+    @liveexample{The example below shows how array elements can be read and
+    written using `[]` operator. Note the addition of `null`
+    values.,operatorarray__size_type}
+
+    @since version 1.0.0
+    */
+    reference operator[](size_type idx)
+    {
+        // implicitly convert null value to an empty array
+        if (is_null())
+        {
+            m_type = value_t::array;
+            m_value.array = create<array_t>();
+            assert_invariant();
+        }
+
+        // operator[] only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            // fill up array with null values if given idx is outside range
+            if (idx >= m_value.array->size())
+            {
+#if JSON_DIAGNOSTICS
+                // remember array size & capacity before resizing
+                const auto old_size = m_value.array->size();
+                const auto old_capacity = m_value.array->capacity();
+#endif
+                m_value.array->resize(idx + 1);
+
+#if JSON_DIAGNOSTICS
+                if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity))
+                {
+                    // capacity has changed: update all parents
+                    set_parents();
+                }
+                else
+                {
+                    // set parent for values added above
+                    set_parents(begin() + static_cast<typename iterator::difference_type>(old_size), static_cast<typename iterator::difference_type>(idx + 1 - old_size));
+                }
+#endif
+                assert_invariant();
+            }
+
+            return m_value.array->operator[](idx);
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief access specified array element
+
+    Returns a const reference to the element at specified location @a idx.
+
+    @param[in] idx  index of the element to access
+
+    @return const reference to the element at index @a idx
+
+    @throw type_error.305 if the JSON value is not an array; in that case,
+    using the [] operator with an index makes no sense.
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how array elements can be read using
+    the `[]` operator.,operatorarray__size_type_const}
+
+    @since version 1.0.0
+    */
+    const_reference operator[](size_type idx) const
+    {
+        // const operator[] only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            return m_value.array->operator[](idx);
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief access specified object element
+
+    Returns a reference to the element at with specified key @a key.
+
+    @note If @a key is not found in the object, then it is silently added to
+    the object and filled with a `null` value to make `key` a valid reference.
+    In case the value was `null` before, it is converted to an object.
+
+    @param[in] key  key of the element to access
+
+    @return reference to the element at key @a key
+
+    @throw type_error.305 if the JSON value is not an object or null; in that
+    cases, using the [] operator with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be read and
+    written using the `[]` operator.,operatorarray__key_type}
+
+    @sa see @ref at(const typename object_t::key_type&) for access by reference
+    with range checking
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.0.0
+    */
+    reference operator[](const typename object_t::key_type& key)
+    {
+        // implicitly convert null value to an empty object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value.object = create<object_t>();
+            assert_invariant();
+        }
+
+        // operator[] only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            return set_parent(m_value.object->operator[](key));
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief read-only access specified object element
+
+    Returns a const reference to the element at with specified key @a key. No
+    bounds checking is performed.
+
+    @warning If the element with key @a key does not exist, the behavior is
+    undefined.
+
+    @param[in] key  key of the element to access
+
+    @return const reference to the element at key @a key
+
+    @pre The element with key @a key must exist. **This precondition is
+         enforced with an assertion.**
+
+    @throw type_error.305 if the JSON value is not an object; in that case,
+    using the [] operator with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be read using
+    the `[]` operator.,operatorarray__key_type_const}
+
+    @sa see @ref at(const typename object_t::key_type&) for access by reference
+    with range checking
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.0.0
+    */
+    const_reference operator[](const typename object_t::key_type& key) const
+    {
+        // const operator[] only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
+            return m_value.object->find(key)->second;
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief access specified object element
+
+    Returns a reference to the element at with specified key @a key.
+
+    @note If @a key is not found in the object, then it is silently added to
+    the object and filled with a `null` value to make `key` a valid reference.
+    In case the value was `null` before, it is converted to an object.
+
+    @param[in] key  key of the element to access
+
+    @return reference to the element at key @a key
+
+    @throw type_error.305 if the JSON value is not an object or null; in that
+    cases, using the [] operator with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be read and
+    written using the `[]` operator.,operatorarray__key_type}
+
+    @sa see @ref at(const typename object_t::key_type&) for access by reference
+    with range checking
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.1.0
+    */
+    template<typename T>
+    JSON_HEDLEY_NON_NULL(2)
+    reference operator[](T* key)
+    {
+        // implicitly convert null to object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value = value_t::object;
+            assert_invariant();
+        }
+
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            return set_parent(m_value.object->operator[](key));
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief read-only access specified object element
+
+    Returns a const reference to the element at with specified key @a key. No
+    bounds checking is performed.
+
+    @warning If the element with key @a key does not exist, the behavior is
+    undefined.
+
+    @param[in] key  key of the element to access
+
+    @return const reference to the element at key @a key
+
+    @pre The element with key @a key must exist. **This precondition is
+         enforced with an assertion.**
+
+    @throw type_error.305 if the JSON value is not an object; in that case,
+    using the [] operator with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be read using
+    the `[]` operator.,operatorarray__key_type_const}
+
+    @sa see @ref at(const typename object_t::key_type&) for access by reference
+    with range checking
+    @sa see @ref value() for access by value with a default value
+
+    @since version 1.1.0
+    */
+    template<typename T>
+    JSON_HEDLEY_NON_NULL(2)
+    const_reference operator[](T* key) const
+    {
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            JSON_ASSERT(m_value.object->find(key) != m_value.object->end());
+            return m_value.object->find(key)->second;
+        }
+
+        JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief access specified object element with default value
+
+    Returns either a copy of an object's element at the specified key @a key
+    or a given default value if no element with key @a key exists.
+
+    The function is basically equivalent to executing
+    @code {.cpp}
+    try {
+        return at(key);
+    } catch(out_of_range) {
+        return default_value;
+    }
+    @endcode
+
+    @note Unlike @ref at(const typename object_t::key_type&), this function
+    does not throw if the given key @a key was not found.
+
+    @note Unlike @ref operator[](const typename object_t::key_type& key), this
+    function does not implicitly add an element to the position defined by @a
+    key. This function is furthermore also applicable to const objects.
+
+    @param[in] key  key of the element to access
+    @param[in] default_value  the value to return if @a key is not found
+
+    @tparam ValueType type compatible to JSON values, for instance `int` for
+    JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
+    JSON arrays. Note the type of the expected value at @a key and the default
+    value @a default_value must be compatible.
+
+    @return copy of the element at key @a key or @a default_value if @a key
+    is not found
+
+    @throw type_error.302 if @a default_value does not match the type of the
+    value at @a key
+    @throw type_error.306 if the JSON value is not an object; in that case,
+    using `value()` with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be queried
+    with a default value.,basic_json__value}
+
+    @sa see @ref at(const typename object_t::key_type&) for access by reference
+    with range checking
+    @sa see @ref operator[](const typename object_t::key_type&) for unchecked
+    access by reference
+
+    @since version 1.0.0
+    */
+    // using std::is_convertible in a std::enable_if will fail when using explicit conversions
+    template < class ValueType, typename std::enable_if <
+                   detail::is_getable<basic_json_t, ValueType>::value
+                   && !std::is_same<value_t, ValueType>::value, int >::type = 0 >
+    ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
+    {
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            // if key is found, return value and given default value otherwise
+            const auto it = find(key);
+            if (it != end())
+            {
+                return it->template get<ValueType>();
+            }
+
+            return default_value;
+        }
+
+        JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief overload for a default value of type const char*
+    @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const
+    */
+    string_t value(const typename object_t::key_type& key, const char* default_value) const
+    {
+        return value(key, string_t(default_value));
+    }
+
+    /*!
+    @brief access specified object element via JSON Pointer with default value
+
+    Returns either a copy of an object's element at the specified key @a key
+    or a given default value if no element with key @a key exists.
+
+    The function is basically equivalent to executing
+    @code {.cpp}
+    try {
+        return at(ptr);
+    } catch(out_of_range) {
+        return default_value;
+    }
+    @endcode
+
+    @note Unlike @ref at(const json_pointer&), this function does not throw
+    if the given key @a key was not found.
+
+    @param[in] ptr  a JSON pointer to the element to access
+    @param[in] default_value  the value to return if @a ptr found no value
+
+    @tparam ValueType type compatible to JSON values, for instance `int` for
+    JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for
+    JSON arrays. Note the type of the expected value at @a key and the default
+    value @a default_value must be compatible.
+
+    @return copy of the element at key @a key or @a default_value if @a key
+    is not found
+
+    @throw type_error.302 if @a default_value does not match the type of the
+    value at @a ptr
+    @throw type_error.306 if the JSON value is not an object; in that case,
+    using `value()` with a key makes no sense.
+
+    @complexity Logarithmic in the size of the container.
+
+    @liveexample{The example below shows how object elements can be queried
+    with a default value.,basic_json__value_ptr}
+
+    @sa see @ref operator[](const json_pointer&) for unchecked access by reference
+
+    @since version 2.0.2
+    */
+    template<class ValueType, typename std::enable_if<
+                 detail::is_getable<basic_json_t, ValueType>::value, int>::type = 0>
+    ValueType value(const json_pointer& ptr, const ValueType& default_value) const
+    {
+        // at only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            // if pointer resolves a value, return it or use default value
+            JSON_TRY
+            {
+                return ptr.get_checked(this).template get<ValueType>();
+            }
+            JSON_INTERNAL_CATCH (out_of_range&)
+            {
+                return default_value;
+            }
+        }
+
+        JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief overload for a default value of type const char*
+    @copydoc basic_json::value(const json_pointer&, ValueType) const
+    */
+    JSON_HEDLEY_NON_NULL(3)
+    string_t value(const json_pointer& ptr, const char* default_value) const
+    {
+        return value(ptr, string_t(default_value));
+    }
+
+    /*!
+    @brief access the first element
+
+    Returns a reference to the first element in the container. For a JSON
+    container `c`, the expression `c.front()` is equivalent to `*c.begin()`.
+
+    @return In case of a structured type (array or object), a reference to the
+    first element is returned. In case of number, string, boolean, or binary
+    values, a reference to the value is returned.
+
+    @complexity Constant.
+
+    @pre The JSON value must not be `null` (would throw `std::out_of_range`)
+    or an empty array or object (undefined behavior, **guarded by
+    assertions**).
+    @post The JSON value remains unchanged.
+
+    @throw invalid_iterator.214 when called on `null` value
+
+    @liveexample{The following code shows an example for `front()`.,front}
+
+    @sa see @ref back() -- access the last element
+
+    @since version 1.0.0
+    */
+    reference front()
+    {
+        return *begin();
+    }
+
+    /*!
+    @copydoc basic_json::front()
+    */
+    const_reference front() const
+    {
+        return *cbegin();
+    }
+
+    /*!
+    @brief access the last element
+
+    Returns a reference to the last element in the container. For a JSON
+    container `c`, the expression `c.back()` is equivalent to
+    @code {.cpp}
+    auto tmp = c.end();
+    --tmp;
+    return *tmp;
+    @endcode
+
+    @return In case of a structured type (array or object), a reference to the
+    last element is returned. In case of number, string, boolean, or binary
+    values, a reference to the value is returned.
+
+    @complexity Constant.
+
+    @pre The JSON value must not be `null` (would throw `std::out_of_range`)
+    or an empty array or object (undefined behavior, **guarded by
+    assertions**).
+    @post The JSON value remains unchanged.
+
+    @throw invalid_iterator.214 when called on a `null` value. See example
+    below.
+
+    @liveexample{The following code shows an example for `back()`.,back}
+
+    @sa see @ref front() -- access the first element
+
+    @since version 1.0.0
+    */
+    reference back()
+    {
+        auto tmp = end();
+        --tmp;
+        return *tmp;
+    }
+
+    /*!
+    @copydoc basic_json::back()
+    */
+    const_reference back() const
+    {
+        auto tmp = cend();
+        --tmp;
+        return *tmp;
+    }
+
+    /*!
+    @brief remove element given an iterator
+
+    Removes the element specified by iterator @a pos. The iterator @a pos must
+    be valid and dereferenceable. Thus the `end()` iterator (which is valid,
+    but is not dereferenceable) cannot be used as a value for @a pos.
+
+    If called on a primitive type other than `null`, the resulting JSON value
+    will be `null`.
+
+    @param[in] pos iterator to the element to remove
+    @return Iterator following the last removed element. If the iterator @a
+    pos refers to the last element, the `end()` iterator is returned.
+
+    @tparam IteratorType an @ref iterator or @ref const_iterator
+
+    @post Invalidates iterators and references at or after the point of the
+    erase, including the `end()` iterator.
+
+    @throw type_error.307 if called on a `null` value; example: `"cannot use
+    erase() with null"`
+    @throw invalid_iterator.202 if called on an iterator which does not belong
+    to the current JSON value; example: `"iterator does not fit current
+    value"`
+    @throw invalid_iterator.205 if called on a primitive type with invalid
+    iterator (i.e., any iterator which is not `begin()`); example: `"iterator
+    out of range"`
+
+    @complexity The complexity depends on the type:
+    - objects: amortized constant
+    - arrays: linear in distance between @a pos and the end of the container
+    - strings and binary: linear in the length of the member
+    - other types: constant
+
+    @liveexample{The example shows the result of `erase()` for different JSON
+    types.,erase__IteratorType}
+
+    @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in
+    the given range
+    @sa see @ref erase(const typename object_t::key_type&) -- removes the element
+    from an object at the given key
+    @sa see @ref erase(const size_type) -- removes the element from an array at
+    the given index
+
+    @since version 1.0.0
+    */
+    template < class IteratorType, typename std::enable_if <
+                   std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
+                   std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type
+               = 0 >
+    IteratorType erase(IteratorType pos)
+    {
+        // make sure iterator fits the current value
+        if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
+        }
+
+        IteratorType result = end();
+
+        switch (m_type)
+        {
+            case value_t::boolean:
+            case value_t::number_float:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::string:
+            case value_t::binary:
+            {
+                if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin()))
+                {
+                    JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this));
+                }
+
+                if (is_string())
+                {
+                    AllocatorType<string_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
+                    m_value.string = nullptr;
+                }
+                else if (is_binary())
+                {
+                    AllocatorType<binary_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
+                    m_value.binary = nullptr;
+                }
+
+                m_type = value_t::null;
+                assert_invariant();
+                break;
+            }
+
+            case value_t::object:
+            {
+                result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
+                break;
+            }
+
+            case value_t::array:
+            {
+                result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::discarded:
+            default:
+                JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief remove elements given an iterator range
+
+    Removes the element specified by the range `[first; last)`. The iterator
+    @a first does not need to be dereferenceable if `first == last`: erasing
+    an empty range is a no-op.
+
+    If called on a primitive type other than `null`, the resulting JSON value
+    will be `null`.
+
+    @param[in] first iterator to the beginning of the range to remove
+    @param[in] last iterator past the end of the range to remove
+    @return Iterator following the last removed element. If the iterator @a
+    second refers to the last element, the `end()` iterator is returned.
+
+    @tparam IteratorType an @ref iterator or @ref const_iterator
+
+    @post Invalidates iterators and references at or after the point of the
+    erase, including the `end()` iterator.
+
+    @throw type_error.307 if called on a `null` value; example: `"cannot use
+    erase() with null"`
+    @throw invalid_iterator.203 if called on iterators which does not belong
+    to the current JSON value; example: `"iterators do not fit current value"`
+    @throw invalid_iterator.204 if called on a primitive type with invalid
+    iterators (i.e., if `first != begin()` and `last != end()`); example:
+    `"iterators out of range"`
+
+    @complexity The complexity depends on the type:
+    - objects: `log(size()) + std::distance(first, last)`
+    - arrays: linear in the distance between @a first and @a last, plus linear
+      in the distance between @a last and end of the container
+    - strings and binary: linear in the length of the member
+    - other types: constant
+
+    @liveexample{The example shows the result of `erase()` for different JSON
+    types.,erase__IteratorType_IteratorType}
+
+    @sa see @ref erase(IteratorType) -- removes the element at a given position
+    @sa see @ref erase(const typename object_t::key_type&) -- removes the element
+    from an object at the given key
+    @sa see @ref erase(const size_type) -- removes the element from an array at
+    the given index
+
+    @since version 1.0.0
+    */
+    template < class IteratorType, typename std::enable_if <
+                   std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
+                   std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type
+               = 0 >
+    IteratorType erase(IteratorType first, IteratorType last)
+    {
+        // make sure iterator fits the current value
+        if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", *this));
+        }
+
+        IteratorType result = end();
+
+        switch (m_type)
+        {
+            case value_t::boolean:
+            case value_t::number_float:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::string:
+            case value_t::binary:
+            {
+                if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
+                                       || !last.m_it.primitive_iterator.is_end()))
+                {
+                    JSON_THROW(invalid_iterator::create(204, "iterators out of range", *this));
+                }
+
+                if (is_string())
+                {
+                    AllocatorType<string_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.string);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.string, 1);
+                    m_value.string = nullptr;
+                }
+                else if (is_binary())
+                {
+                    AllocatorType<binary_t> alloc;
+                    std::allocator_traits<decltype(alloc)>::destroy(alloc, m_value.binary);
+                    std::allocator_traits<decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
+                    m_value.binary = nullptr;
+                }
+
+                m_type = value_t::null;
+                assert_invariant();
+                break;
+            }
+
+            case value_t::object:
+            {
+                result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
+                                              last.m_it.object_iterator);
+                break;
+            }
+
+            case value_t::array:
+            {
+                result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
+                                             last.m_it.array_iterator);
+                break;
+            }
+
+            case value_t::null:
+            case value_t::discarded:
+            default:
+                JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief remove element from a JSON object given a key
+
+    Removes elements from a JSON object with the key value @a key.
+
+    @param[in] key value of the elements to remove
+
+    @return Number of elements removed. If @a ObjectType is the default
+    `std::map` type, the return value will always be `0` (@a key was not
+    found) or `1` (@a key was found).
+
+    @post References and iterators to the erased elements are invalidated.
+    Other references and iterators are not affected.
+
+    @throw type_error.307 when called on a type other than JSON object;
+    example: `"cannot use erase() with null"`
+
+    @complexity `log(size()) + count(key)`
+
+    @liveexample{The example shows the effect of `erase()`.,erase__key_type}
+
+    @sa see @ref erase(IteratorType) -- removes the element at a given position
+    @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in
+    the given range
+    @sa see @ref erase(const size_type) -- removes the element from an array at
+    the given index
+
+    @since version 1.0.0
+    */
+    size_type erase(const typename object_t::key_type& key)
+    {
+        // this erase only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            return m_value.object->erase(key);
+        }
+
+        JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief remove element from a JSON array given an index
+
+    Removes element from a JSON array at the index @a idx.
+
+    @param[in] idx index of the element to remove
+
+    @throw type_error.307 when called on a type other than JSON object;
+    example: `"cannot use erase() with null"`
+    @throw out_of_range.401 when `idx >= size()`; example: `"array index 17
+    is out of range"`
+
+    @complexity Linear in distance between @a idx and the end of the container.
+
+    @liveexample{The example shows the effect of `erase()`.,erase__size_type}
+
+    @sa see @ref erase(IteratorType) -- removes the element at a given position
+    @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in
+    the given range
+    @sa see @ref erase(const typename object_t::key_type&) -- removes the element
+    from an object at the given key
+
+    @since version 1.0.0
+    */
+    void erase(const size_type idx)
+    {
+        // this erase only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            if (JSON_HEDLEY_UNLIKELY(idx >= size()))
+            {
+                JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this));
+            }
+
+            m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
+        }
+        else
+        {
+            JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /// @}
+
+
+    ////////////
+    // lookup //
+    ////////////
+
+    /// @name lookup
+    /// @{
+
+    /*!
+    @brief find an element in a JSON object
+
+    Finds an element in a JSON object with key equivalent to @a key. If the
+    element is not found or the JSON value is not an object, end() is
+    returned.
+
+    @note This method always returns @ref end() when executed on a JSON type
+          that is not an object.
+
+    @param[in] key key value of the element to search for.
+
+    @return Iterator to an element with key equivalent to @a key. If no such
+    element is found or the JSON value is not an object, past-the-end (see
+    @ref end()) iterator is returned.
+
+    @complexity Logarithmic in the size of the JSON object.
+
+    @liveexample{The example shows how `find()` is used.,find__key_type}
+
+    @sa see @ref contains(KeyT&&) const -- checks whether a key exists
+
+    @since version 1.0.0
+    */
+    template<typename KeyT>
+    iterator find(KeyT&& key)
+    {
+        auto result = end();
+
+        if (is_object())
+        {
+            result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief find an element in a JSON object
+    @copydoc find(KeyT&&)
+    */
+    template<typename KeyT>
+    const_iterator find(KeyT&& key) const
+    {
+        auto result = cend();
+
+        if (is_object())
+        {
+            result.m_it.object_iterator = m_value.object->find(std::forward<KeyT>(key));
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief returns the number of occurrences of a key in a JSON object
+
+    Returns the number of elements with key @a key. If ObjectType is the
+    default `std::map` type, the return value will always be `0` (@a key was
+    not found) or `1` (@a key was found).
+
+    @note This method always returns `0` when executed on a JSON type that is
+          not an object.
+
+    @param[in] key key value of the element to count
+
+    @return Number of elements with key @a key. If the JSON value is not an
+    object, the return value will be `0`.
+
+    @complexity Logarithmic in the size of the JSON object.
+
+    @liveexample{The example shows how `count()` is used.,count}
+
+    @since version 1.0.0
+    */
+    template<typename KeyT>
+    size_type count(KeyT&& key) const
+    {
+        // return 0 for all nonobject types
+        return is_object() ? m_value.object->count(std::forward<KeyT>(key)) : 0;
+    }
+
+    /*!
+    @brief check the existence of an element in a JSON object
+
+    Check whether an element exists in a JSON object with key equivalent to
+    @a key. If the element is not found or the JSON value is not an object,
+    false is returned.
+
+    @note This method always returns false when executed on a JSON type
+          that is not an object.
+
+    @param[in] key key value to check its existence.
+
+    @return true if an element with specified @a key exists. If no such
+    element with such key is found or the JSON value is not an object,
+    false is returned.
+
+    @complexity Logarithmic in the size of the JSON object.
+
+    @liveexample{The following code shows an example for `contains()`.,contains}
+
+    @sa see @ref find(KeyT&&) -- returns an iterator to an object element
+    @sa see @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer
+
+    @since version 3.6.0
+    */
+    template < typename KeyT, typename std::enable_if <
+                   !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int >::type = 0 >
+    bool contains(KeyT && key) const
+    {
+        return is_object() && m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
+    }
+
+    /*!
+    @brief check the existence of an element in a JSON object given a JSON pointer
+
+    Check whether the given JSON pointer @a ptr can be resolved in the current
+    JSON value.
+
+    @note This method can be executed on any JSON value type.
+
+    @param[in] ptr JSON pointer to check its existence.
+
+    @return true if the JSON pointer can be resolved to a stored value, false
+    otherwise.
+
+    @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`.
+
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+
+    @complexity Logarithmic in the size of the JSON object.
+
+    @liveexample{The following code shows an example for `contains()`.,contains_json_pointer}
+
+    @sa see @ref contains(KeyT &&) const -- checks the existence of a key
+
+    @since version 3.7.0
+    */
+    bool contains(const json_pointer& ptr) const
+    {
+        return ptr.contains(this);
+    }
+
+    /// @}
+
+
+    ///////////////
+    // iterators //
+    ///////////////
+
+    /// @name iterators
+    /// @{
+
+    /*!
+    @brief returns an iterator to the first element
+
+    Returns an iterator to the first element.
+
+    @image html range-begin-end.svg "Illustration from cppreference.com"
+
+    @return iterator to the first element
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+
+    @liveexample{The following code shows an example for `begin()`.,begin}
+
+    @sa see @ref cbegin() -- returns a const iterator to the beginning
+    @sa see @ref end() -- returns an iterator to the end
+    @sa see @ref cend() -- returns a const iterator to the end
+
+    @since version 1.0.0
+    */
+    iterator begin() noexcept
+    {
+        iterator result(this);
+        result.set_begin();
+        return result;
+    }
+
+    /*!
+    @copydoc basic_json::cbegin()
+    */
+    const_iterator begin() const noexcept
+    {
+        return cbegin();
+    }
+
+    /*!
+    @brief returns a const iterator to the first element
+
+    Returns a const iterator to the first element.
+
+    @image html range-begin-end.svg "Illustration from cppreference.com"
+
+    @return const iterator to the first element
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `const_cast<const basic_json&>(*this).begin()`.
+
+    @liveexample{The following code shows an example for `cbegin()`.,cbegin}
+
+    @sa see @ref begin() -- returns an iterator to the beginning
+    @sa see @ref end() -- returns an iterator to the end
+    @sa see @ref cend() -- returns a const iterator to the end
+
+    @since version 1.0.0
+    */
+    const_iterator cbegin() const noexcept
+    {
+        const_iterator result(this);
+        result.set_begin();
+        return result;
+    }
+
+    /*!
+    @brief returns an iterator to one past the last element
+
+    Returns an iterator to one past the last element.
+
+    @image html range-begin-end.svg "Illustration from cppreference.com"
+
+    @return iterator one past the last element
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+
+    @liveexample{The following code shows an example for `end()`.,end}
+
+    @sa see @ref cend() -- returns a const iterator to the end
+    @sa see @ref begin() -- returns an iterator to the beginning
+    @sa see @ref cbegin() -- returns a const iterator to the beginning
+
+    @since version 1.0.0
+    */
+    iterator end() noexcept
+    {
+        iterator result(this);
+        result.set_end();
+        return result;
+    }
+
+    /*!
+    @copydoc basic_json::cend()
+    */
+    const_iterator end() const noexcept
+    {
+        return cend();
+    }
+
+    /*!
+    @brief returns a const iterator to one past the last element
+
+    Returns a const iterator to one past the last element.
+
+    @image html range-begin-end.svg "Illustration from cppreference.com"
+
+    @return const iterator one past the last element
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `const_cast<const basic_json&>(*this).end()`.
+
+    @liveexample{The following code shows an example for `cend()`.,cend}
+
+    @sa see @ref end() -- returns an iterator to the end
+    @sa see @ref begin() -- returns an iterator to the beginning
+    @sa see @ref cbegin() -- returns a const iterator to the beginning
+
+    @since version 1.0.0
+    */
+    const_iterator cend() const noexcept
+    {
+        const_iterator result(this);
+        result.set_end();
+        return result;
+    }
+
+    /*!
+    @brief returns an iterator to the reverse-beginning
+
+    Returns an iterator to the reverse-beginning; that is, the last element.
+
+    @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `reverse_iterator(end())`.
+
+    @liveexample{The following code shows an example for `rbegin()`.,rbegin}
+
+    @sa see @ref crbegin() -- returns a const reverse iterator to the beginning
+    @sa see @ref rend() -- returns a reverse iterator to the end
+    @sa see @ref crend() -- returns a const reverse iterator to the end
+
+    @since version 1.0.0
+    */
+    reverse_iterator rbegin() noexcept
+    {
+        return reverse_iterator(end());
+    }
+
+    /*!
+    @copydoc basic_json::crbegin()
+    */
+    const_reverse_iterator rbegin() const noexcept
+    {
+        return crbegin();
+    }
+
+    /*!
+    @brief returns an iterator to the reverse-end
+
+    Returns an iterator to the reverse-end; that is, one before the first
+    element.
+
+    @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `reverse_iterator(begin())`.
+
+    @liveexample{The following code shows an example for `rend()`.,rend}
+
+    @sa see @ref crend() -- returns a const reverse iterator to the end
+    @sa see @ref rbegin() -- returns a reverse iterator to the beginning
+    @sa see @ref crbegin() -- returns a const reverse iterator to the beginning
+
+    @since version 1.0.0
+    */
+    reverse_iterator rend() noexcept
+    {
+        return reverse_iterator(begin());
+    }
+
+    /*!
+    @copydoc basic_json::crend()
+    */
+    const_reverse_iterator rend() const noexcept
+    {
+        return crend();
+    }
+
+    /*!
+    @brief returns a const reverse iterator to the last element
+
+    Returns a const iterator to the reverse-beginning; that is, the last
+    element.
+
+    @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `const_cast<const basic_json&>(*this).rbegin()`.
+
+    @liveexample{The following code shows an example for `crbegin()`.,crbegin}
+
+    @sa see @ref rbegin() -- returns a reverse iterator to the beginning
+    @sa see @ref rend() -- returns a reverse iterator to the end
+    @sa see @ref crend() -- returns a const reverse iterator to the end
+
+    @since version 1.0.0
+    */
+    const_reverse_iterator crbegin() const noexcept
+    {
+        return const_reverse_iterator(cend());
+    }
+
+    /*!
+    @brief returns a const reverse iterator to one before the first
+
+    Returns a const reverse iterator to the reverse-end; that is, one before
+    the first element.
+
+    @image html range-rbegin-rend.svg "Illustration from cppreference.com"
+
+    @complexity Constant.
+
+    @requirement This function helps `basic_json` satisfying the
+    [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `const_cast<const basic_json&>(*this).rend()`.
+
+    @liveexample{The following code shows an example for `crend()`.,crend}
+
+    @sa see @ref rend() -- returns a reverse iterator to the end
+    @sa see @ref rbegin() -- returns a reverse iterator to the beginning
+    @sa see @ref crbegin() -- returns a const reverse iterator to the beginning
+
+    @since version 1.0.0
+    */
+    const_reverse_iterator crend() const noexcept
+    {
+        return const_reverse_iterator(cbegin());
+    }
+
+  public:
+    /*!
+    @brief wrapper to access iterator member functions in range-based for
+
+    This function allows to access @ref iterator::key() and @ref
+    iterator::value() during range-based for loops. In these loops, a
+    reference to the JSON values is returned, so there is no access to the
+    underlying iterator.
+
+    For loop without iterator_wrapper:
+
+    @code{cpp}
+    for (auto it = j_object.begin(); it != j_object.end(); ++it)
+    {
+        std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+    }
+    @endcode
+
+    Range-based for loop without iterator proxy:
+
+    @code{cpp}
+    for (auto it : j_object)
+    {
+        // "it" is of type json::reference and has no key() member
+        std::cout << "value: " << it << '\n';
+    }
+    @endcode
+
+    Range-based for loop with iterator proxy:
+
+    @code{cpp}
+    for (auto it : json::iterator_wrapper(j_object))
+    {
+        std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+    }
+    @endcode
+
+    @note When iterating over an array, `key()` will return the index of the
+          element as string (see example).
+
+    @param[in] ref  reference to a JSON value
+    @return iteration proxy object wrapping @a ref with an interface to use in
+            range-based for loops
+
+    @liveexample{The following code shows how the wrapper is used,iterator_wrapper}
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @note The name of this function is not yet final and may change in the
+    future.
+
+    @deprecated This stream operator is deprecated and will be removed in
+                future 4.0.0 of the library. Please use @ref items() instead;
+                that is, replace `json::iterator_wrapper(j)` with `j.items()`.
+    */
+    JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
+    static iteration_proxy<iterator> iterator_wrapper(reference ref) noexcept
+    {
+        return ref.items();
+    }
+
+    /*!
+    @copydoc iterator_wrapper(reference)
+    */
+    JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items())
+    static iteration_proxy<const_iterator> iterator_wrapper(const_reference ref) noexcept
+    {
+        return ref.items();
+    }
+
+    /*!
+    @brief helper to access iterator member functions in range-based for
+
+    This function allows to access @ref iterator::key() and @ref
+    iterator::value() during range-based for loops. In these loops, a
+    reference to the JSON values is returned, so there is no access to the
+    underlying iterator.
+
+    For loop without `items()` function:
+
+    @code{cpp}
+    for (auto it = j_object.begin(); it != j_object.end(); ++it)
+    {
+        std::cout << "key: " << it.key() << ", value:" << it.value() << '\n';
+    }
+    @endcode
+
+    Range-based for loop without `items()` function:
+
+    @code{cpp}
+    for (auto it : j_object)
+    {
+        // "it" is of type json::reference and has no key() member
+        std::cout << "value: " << it << '\n';
+    }
+    @endcode
+
+    Range-based for loop with `items()` function:
+
+    @code{cpp}
+    for (auto& el : j_object.items())
+    {
+        std::cout << "key: " << el.key() << ", value:" << el.value() << '\n';
+    }
+    @endcode
+
+    The `items()` function also allows to use
+    [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding)
+    (C++17):
+
+    @code{cpp}
+    for (auto& [key, val] : j_object.items())
+    {
+        std::cout << "key: " << key << ", value:" << val << '\n';
+    }
+    @endcode
+
+    @note When iterating over an array, `key()` will return the index of the
+          element as string (see example). For primitive types (e.g., numbers),
+          `key()` returns an empty string.
+
+    @warning Using `items()` on temporary objects is dangerous. Make sure the
+             object's lifetime exeeds the iteration. See
+             <https://github.com/nlohmann/json/issues/2040> for more
+             information.
+
+    @return iteration proxy object wrapping @a ref with an interface to use in
+            range-based for loops
+
+    @liveexample{The following code shows how the function is used.,items}
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @since version 3.1.0, structured bindings support since 3.5.0.
+    */
+    iteration_proxy<iterator> items() noexcept
+    {
+        return iteration_proxy<iterator>(*this);
+    }
+
+    /*!
+    @copydoc items()
+    */
+    iteration_proxy<const_iterator> items() const noexcept
+    {
+        return iteration_proxy<const_iterator>(*this);
+    }
+
+    /// @}
+
+
+    //////////////
+    // capacity //
+    //////////////
+
+    /// @name capacity
+    /// @{
+
+    /*!
+    @brief checks whether the container is empty.
+
+    Checks if a JSON value has no elements (i.e. whether its @ref size is `0`).
+
+    @return The return value depends on the different types and is
+            defined as follows:
+            Value type  | return value
+            ----------- | -------------
+            null        | `true`
+            boolean     | `false`
+            string      | `false`
+            number      | `false`
+            binary      | `false`
+            object      | result of function `object_t::empty()`
+            array       | result of function `array_t::empty()`
+
+    @liveexample{The following code uses `empty()` to check if a JSON
+    object contains any elements.,empty}
+
+    @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+    the Container concept; that is, their `empty()` functions have constant
+    complexity.
+
+    @iterators No changes.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @note This function does not return whether a string stored as JSON value
+    is empty - it returns whether the JSON container itself is empty which is
+    false in the case of a string.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `begin() == end()`.
+
+    @sa see @ref size() -- returns the number of elements
+
+    @since version 1.0.0
+    */
+    bool empty() const noexcept
+    {
+        switch (m_type)
+        {
+            case value_t::null:
+            {
+                // null values are empty
+                return true;
+            }
+
+            case value_t::array:
+            {
+                // delegate call to array_t::empty()
+                return m_value.array->empty();
+            }
+
+            case value_t::object:
+            {
+                // delegate call to object_t::empty()
+                return m_value.object->empty();
+            }
+
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                // all other types are nonempty
+                return false;
+            }
+        }
+    }
+
+    /*!
+    @brief returns the number of elements
+
+    Returns the number of elements in a JSON value.
+
+    @return The return value depends on the different types and is
+            defined as follows:
+            Value type  | return value
+            ----------- | -------------
+            null        | `0`
+            boolean     | `1`
+            string      | `1`
+            number      | `1`
+            binary      | `1`
+            object      | result of function object_t::size()
+            array       | result of function array_t::size()
+
+    @liveexample{The following code calls `size()` on the different value
+    types.,size}
+
+    @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+    the Container concept; that is, their size() functions have constant
+    complexity.
+
+    @iterators No changes.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @note This function does not return the length of a string stored as JSON
+    value - it returns the number of elements in the JSON value which is 1 in
+    the case of a string.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of `std::distance(begin(), end())`.
+
+    @sa see @ref empty() -- checks whether the container is empty
+    @sa see @ref max_size() -- returns the maximal number of elements
+
+    @since version 1.0.0
+    */
+    size_type size() const noexcept
+    {
+        switch (m_type)
+        {
+            case value_t::null:
+            {
+                // null values are empty
+                return 0;
+            }
+
+            case value_t::array:
+            {
+                // delegate call to array_t::size()
+                return m_value.array->size();
+            }
+
+            case value_t::object:
+            {
+                // delegate call to object_t::size()
+                return m_value.object->size();
+            }
+
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                // all other types have size 1
+                return 1;
+            }
+        }
+    }
+
+    /*!
+    @brief returns the maximum possible number of elements
+
+    Returns the maximum number of elements a JSON value is able to hold due to
+    system or library implementation limitations, i.e. `std::distance(begin(),
+    end())` for the JSON value.
+
+    @return The return value depends on the different types and is
+            defined as follows:
+            Value type  | return value
+            ----------- | -------------
+            null        | `0` (same as `size()`)
+            boolean     | `1` (same as `size()`)
+            string      | `1` (same as `size()`)
+            number      | `1` (same as `size()`)
+            binary      | `1` (same as `size()`)
+            object      | result of function `object_t::max_size()`
+            array       | result of function `array_t::max_size()`
+
+    @liveexample{The following code calls `max_size()` on the different value
+    types. Note the output is implementation specific.,max_size}
+
+    @complexity Constant, as long as @ref array_t and @ref object_t satisfy
+    the Container concept; that is, their `max_size()` functions have constant
+    complexity.
+
+    @iterators No changes.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @requirement This function helps `basic_json` satisfying the
+    [Container](https://en.cppreference.com/w/cpp/named_req/Container)
+    requirements:
+    - The complexity is constant.
+    - Has the semantics of returning `b.size()` where `b` is the largest
+      possible JSON value.
+
+    @sa see @ref size() -- returns the number of elements
+
+    @since version 1.0.0
+    */
+    size_type max_size() const noexcept
+    {
+        switch (m_type)
+        {
+            case value_t::array:
+            {
+                // delegate call to array_t::max_size()
+                return m_value.array->max_size();
+            }
+
+            case value_t::object:
+            {
+                // delegate call to object_t::max_size()
+                return m_value.object->max_size();
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                // all other types have max_size() == size()
+                return size();
+            }
+        }
+    }
+
+    /// @}
+
+
+    ///////////////
+    // modifiers //
+    ///////////////
+
+    /// @name modifiers
+    /// @{
+
+    /*!
+    @brief clears the contents
+
+    Clears the content of a JSON value and resets it to the default value as
+    if @ref basic_json(value_t) would have been called with the current value
+    type from @ref type():
+
+    Value type  | initial value
+    ----------- | -------------
+    null        | `null`
+    boolean     | `false`
+    string      | `""`
+    number      | `0`
+    binary      | An empty byte vector
+    object      | `{}`
+    array       | `[]`
+
+    @post Has the same effect as calling
+    @code {.cpp}
+    *this = basic_json(type());
+    @endcode
+
+    @liveexample{The example below shows the effect of `clear()` to different
+    JSON types.,clear}
+
+    @complexity Linear in the size of the JSON value.
+
+    @iterators All iterators, pointers and references related to this container
+               are invalidated.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @sa see @ref basic_json(value_t) -- constructor that creates an object with the
+        same value than calling `clear()`
+
+    @since version 1.0.0
+    */
+    void clear() noexcept
+    {
+        switch (m_type)
+        {
+            case value_t::number_integer:
+            {
+                m_value.number_integer = 0;
+                break;
+            }
+
+            case value_t::number_unsigned:
+            {
+                m_value.number_unsigned = 0;
+                break;
+            }
+
+            case value_t::number_float:
+            {
+                m_value.number_float = 0.0;
+                break;
+            }
+
+            case value_t::boolean:
+            {
+                m_value.boolean = false;
+                break;
+            }
+
+            case value_t::string:
+            {
+                m_value.string->clear();
+                break;
+            }
+
+            case value_t::binary:
+            {
+                m_value.binary->clear();
+                break;
+            }
+
+            case value_t::array:
+            {
+                m_value.array->clear();
+                break;
+            }
+
+            case value_t::object:
+            {
+                m_value.object->clear();
+                break;
+            }
+
+            case value_t::null:
+            case value_t::discarded:
+            default:
+                break;
+        }
+    }
+
+    /*!
+    @brief add an object to an array
+
+    Appends the given element @a val to the end of the JSON value. If the
+    function is called on a JSON null value, an empty array is created before
+    appending @a val.
+
+    @param[in] val the value to add to the JSON array
+
+    @throw type_error.308 when called on a type other than JSON array or
+    null; example: `"cannot use push_back() with number"`
+
+    @complexity Amortized constant.
+
+    @liveexample{The example shows how `push_back()` and `+=` can be used to
+    add elements to a JSON array. Note how the `null` value was silently
+    converted to a JSON array.,push_back}
+
+    @since version 1.0.0
+    */
+    void push_back(basic_json&& val)
+    {
+        // push_back only works for null objects or arrays
+        if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
+        {
+            JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
+        }
+
+        // transform null object into an array
+        if (is_null())
+        {
+            m_type = value_t::array;
+            m_value = value_t::array;
+            assert_invariant();
+        }
+
+        // add element to array (move semantics)
+        const auto old_capacity = m_value.array->capacity();
+        m_value.array->push_back(std::move(val));
+        set_parent(m_value.array->back(), old_capacity);
+        // if val is moved from, basic_json move constructor marks it null so we do not call the destructor
+    }
+
+    /*!
+    @brief add an object to an array
+    @copydoc push_back(basic_json&&)
+    */
+    reference operator+=(basic_json&& val)
+    {
+        push_back(std::move(val));
+        return *this;
+    }
+
+    /*!
+    @brief add an object to an array
+    @copydoc push_back(basic_json&&)
+    */
+    void push_back(const basic_json& val)
+    {
+        // push_back only works for null objects or arrays
+        if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
+        {
+            JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
+        }
+
+        // transform null object into an array
+        if (is_null())
+        {
+            m_type = value_t::array;
+            m_value = value_t::array;
+            assert_invariant();
+        }
+
+        // add element to array
+        const auto old_capacity = m_value.array->capacity();
+        m_value.array->push_back(val);
+        set_parent(m_value.array->back(), old_capacity);
+    }
+
+    /*!
+    @brief add an object to an array
+    @copydoc push_back(basic_json&&)
+    */
+    reference operator+=(const basic_json& val)
+    {
+        push_back(val);
+        return *this;
+    }
+
+    /*!
+    @brief add an object to an object
+
+    Inserts the given element @a val to the JSON object. If the function is
+    called on a JSON null value, an empty object is created before inserting
+    @a val.
+
+    @param[in] val the value to add to the JSON object
+
+    @throw type_error.308 when called on a type other than JSON object or
+    null; example: `"cannot use push_back() with number"`
+
+    @complexity Logarithmic in the size of the container, O(log(`size()`)).
+
+    @liveexample{The example shows how `push_back()` and `+=` can be used to
+    add elements to a JSON object. Note how the `null` value was silently
+    converted to a JSON object.,push_back__object_t__value}
+
+    @since version 1.0.0
+    */
+    void push_back(const typename object_t::value_type& val)
+    {
+        // push_back only works for null objects or objects
+        if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
+        {
+            JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this));
+        }
+
+        // transform null object into an object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value = value_t::object;
+            assert_invariant();
+        }
+
+        // add element to object
+        auto res = m_value.object->insert(val);
+        set_parent(res.first->second);
+    }
+
+    /*!
+    @brief add an object to an object
+    @copydoc push_back(const typename object_t::value_type&)
+    */
+    reference operator+=(const typename object_t::value_type& val)
+    {
+        push_back(val);
+        return *this;
+    }
+
+    /*!
+    @brief add an object to an object
+
+    This function allows to use `push_back` with an initializer list. In case
+
+    1. the current value is an object,
+    2. the initializer list @a init contains only two elements, and
+    3. the first element of @a init is a string,
+
+    @a init is converted into an object element and added using
+    @ref push_back(const typename object_t::value_type&). Otherwise, @a init
+    is converted to a JSON value and added using @ref push_back(basic_json&&).
+
+    @param[in] init  an initializer list
+
+    @complexity Linear in the size of the initializer list @a init.
+
+    @note This function is required to resolve an ambiguous overload error,
+          because pairs like `{"key", "value"}` can be both interpreted as
+          `object_t::value_type` or `std::initializer_list<basic_json>`, see
+          https://github.com/nlohmann/json/issues/235 for more information.
+
+    @liveexample{The example shows how initializer lists are treated as
+    objects when possible.,push_back__initializer_list}
+    */
+    void push_back(initializer_list_t init)
+    {
+        if (is_object() && init.size() == 2 && (*init.begin())->is_string())
+        {
+            basic_json&& key = init.begin()->moved_or_copied();
+            push_back(typename object_t::value_type(
+                          std::move(key.get_ref<string_t&>()), (init.begin() + 1)->moved_or_copied()));
+        }
+        else
+        {
+            push_back(basic_json(init));
+        }
+    }
+
+    /*!
+    @brief add an object to an object
+    @copydoc push_back(initializer_list_t)
+    */
+    reference operator+=(initializer_list_t init)
+    {
+        push_back(init);
+        return *this;
+    }
+
+    /*!
+    @brief add an object to an array
+
+    Creates a JSON value from the passed parameters @a args to the end of the
+    JSON value. If the function is called on a JSON null value, an empty array
+    is created before appending the value created from @a args.
+
+    @param[in] args arguments to forward to a constructor of @ref basic_json
+    @tparam Args compatible types to create a @ref basic_json object
+
+    @return reference to the inserted element
+
+    @throw type_error.311 when called on a type other than JSON array or
+    null; example: `"cannot use emplace_back() with number"`
+
+    @complexity Amortized constant.
+
+    @liveexample{The example shows how `push_back()` can be used to add
+    elements to a JSON array. Note how the `null` value was silently converted
+    to a JSON array.,emplace_back}
+
+    @since version 2.0.8, returns reference since 3.7.0
+    */
+    template<class... Args>
+    reference emplace_back(Args&& ... args)
+    {
+        // emplace_back only works for null objects or arrays
+        if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
+        {
+            JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()), *this));
+        }
+
+        // transform null object into an array
+        if (is_null())
+        {
+            m_type = value_t::array;
+            m_value = value_t::array;
+            assert_invariant();
+        }
+
+        // add element to array (perfect forwarding)
+        const auto old_capacity = m_value.array->capacity();
+        m_value.array->emplace_back(std::forward<Args>(args)...);
+        return set_parent(m_value.array->back(), old_capacity);
+    }
+
+    /*!
+    @brief add an object to an object if key does not exist
+
+    Inserts a new element into a JSON object constructed in-place with the
+    given @a args if there is no element with the key in the container. If the
+    function is called on a JSON null value, an empty object is created before
+    appending the value created from @a args.
+
+    @param[in] args arguments to forward to a constructor of @ref basic_json
+    @tparam Args compatible types to create a @ref basic_json object
+
+    @return a pair consisting of an iterator to the inserted element, or the
+            already-existing element if no insertion happened, and a bool
+            denoting whether the insertion took place.
+
+    @throw type_error.311 when called on a type other than JSON object or
+    null; example: `"cannot use emplace() with number"`
+
+    @complexity Logarithmic in the size of the container, O(log(`size()`)).
+
+    @liveexample{The example shows how `emplace()` can be used to add elements
+    to a JSON object. Note how the `null` value was silently converted to a
+    JSON object. Further note how no value is added if there was already one
+    value stored with the same key.,emplace}
+
+    @since version 2.0.8
+    */
+    template<class... Args>
+    std::pair<iterator, bool> emplace(Args&& ... args)
+    {
+        // emplace only works for null objects or arrays
+        if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
+        {
+            JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()), *this));
+        }
+
+        // transform null object into an object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value = value_t::object;
+            assert_invariant();
+        }
+
+        // add element to array (perfect forwarding)
+        auto res = m_value.object->emplace(std::forward<Args>(args)...);
+        set_parent(res.first->second);
+
+        // create result iterator and set iterator to the result of emplace
+        auto it = begin();
+        it.m_it.object_iterator = res.first;
+
+        // return pair of iterator and boolean
+        return {it, res.second};
+    }
+
+    /// Helper for insertion of an iterator
+    /// @note: This uses std::distance to support GCC 4.8,
+    ///        see https://github.com/nlohmann/json/pull/1257
+    template<typename... Args>
+    iterator insert_iterator(const_iterator pos, Args&& ... args)
+    {
+        iterator result(this);
+        JSON_ASSERT(m_value.array != nullptr);
+
+        auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
+        m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
+        result.m_it.array_iterator = m_value.array->begin() + insert_pos;
+
+        // This could have been written as:
+        // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
+        // but the return value of insert is missing in GCC 4.8, so it is written this way instead.
+
+        set_parents();
+        return result;
+    }
+
+    /*!
+    @brief inserts element
+
+    Inserts element @a val before iterator @a pos.
+
+    @param[in] pos iterator before which the content will be inserted; may be
+    the end() iterator
+    @param[in] val element to insert
+    @return iterator pointing to the inserted @a val.
+
+    @throw type_error.309 if called on JSON values other than arrays;
+    example: `"cannot use insert() with string"`
+    @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+    example: `"iterator does not fit current value"`
+
+    @complexity Constant plus linear in the distance between @a pos and end of
+    the container.
+
+    @liveexample{The example shows how `insert()` is used.,insert}
+
+    @since version 1.0.0
+    */
+    iterator insert(const_iterator pos, const basic_json& val)
+    {
+        // insert only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            // check if iterator pos fits to this JSON value
+            if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
+            {
+                JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
+            }
+
+            // insert to array and return iterator
+            return insert_iterator(pos, val);
+        }
+
+        JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief inserts element
+    @copydoc insert(const_iterator, const basic_json&)
+    */
+    iterator insert(const_iterator pos, basic_json&& val)
+    {
+        return insert(pos, val);
+    }
+
+    /*!
+    @brief inserts elements
+
+    Inserts @a cnt copies of @a val before iterator @a pos.
+
+    @param[in] pos iterator before which the content will be inserted; may be
+    the end() iterator
+    @param[in] cnt number of copies of @a val to insert
+    @param[in] val element to insert
+    @return iterator pointing to the first element inserted, or @a pos if
+    `cnt==0`
+
+    @throw type_error.309 if called on JSON values other than arrays; example:
+    `"cannot use insert() with string"`
+    @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+    example: `"iterator does not fit current value"`
+
+    @complexity Linear in @a cnt plus linear in the distance between @a pos
+    and end of the container.
+
+    @liveexample{The example shows how `insert()` is used.,insert__count}
+
+    @since version 1.0.0
+    */
+    iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
+    {
+        // insert only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            // check if iterator pos fits to this JSON value
+            if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
+            {
+                JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
+            }
+
+            // insert to array and return iterator
+            return insert_iterator(pos, cnt, val);
+        }
+
+        JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
+    }
+
+    /*!
+    @brief inserts elements
+
+    Inserts elements from range `[first, last)` before iterator @a pos.
+
+    @param[in] pos iterator before which the content will be inserted; may be
+    the end() iterator
+    @param[in] first begin of the range of elements to insert
+    @param[in] last end of the range of elements to insert
+
+    @throw type_error.309 if called on JSON values other than arrays; example:
+    `"cannot use insert() with string"`
+    @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+    example: `"iterator does not fit current value"`
+    @throw invalid_iterator.210 if @a first and @a last do not belong to the
+    same JSON value; example: `"iterators do not fit"`
+    @throw invalid_iterator.211 if @a first or @a last are iterators into
+    container for which insert is called; example: `"passed iterators may not
+    belong to container"`
+
+    @return iterator pointing to the first element inserted, or @a pos if
+    `first==last`
+
+    @complexity Linear in `std::distance(first, last)` plus linear in the
+    distance between @a pos and end of the container.
+
+    @liveexample{The example shows how `insert()` is used.,insert__range}
+
+    @since version 1.0.0
+    */
+    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
+    {
+        // insert only works for arrays
+        if (JSON_HEDLEY_UNLIKELY(!is_array()))
+        {
+            JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
+        }
+
+        // check if iterator pos fits to this JSON value
+        if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
+        {
+            JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
+        }
+
+        // check if range iterators belong to the same JSON object
+        if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(first.m_object == this))
+        {
+            JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", *this));
+        }
+
+        // insert to array and return iterator
+        return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
+    }
+
+    /*!
+    @brief inserts elements
+
+    Inserts elements from initializer list @a ilist before iterator @a pos.
+
+    @param[in] pos iterator before which the content will be inserted; may be
+    the end() iterator
+    @param[in] ilist initializer list to insert the values from
+
+    @throw type_error.309 if called on JSON values other than arrays; example:
+    `"cannot use insert() with string"`
+    @throw invalid_iterator.202 if @a pos is not an iterator of *this;
+    example: `"iterator does not fit current value"`
+
+    @return iterator pointing to the first element inserted, or @a pos if
+    `ilist` is empty
+
+    @complexity Linear in `ilist.size()` plus linear in the distance between
+    @a pos and end of the container.
+
+    @liveexample{The example shows how `insert()` is used.,insert__ilist}
+
+    @since version 1.0.0
+    */
+    iterator insert(const_iterator pos, initializer_list_t ilist)
+    {
+        // insert only works for arrays
+        if (JSON_HEDLEY_UNLIKELY(!is_array()))
+        {
+            JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
+        }
+
+        // check if iterator pos fits to this JSON value
+        if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
+        {
+            JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
+        }
+
+        // insert to array and return iterator
+        return insert_iterator(pos, ilist.begin(), ilist.end());
+    }
+
+    /*!
+    @brief inserts elements
+
+    Inserts elements from range `[first, last)`.
+
+    @param[in] first begin of the range of elements to insert
+    @param[in] last end of the range of elements to insert
+
+    @throw type_error.309 if called on JSON values other than objects; example:
+    `"cannot use insert() with string"`
+    @throw invalid_iterator.202 if iterator @a first or @a last does does not
+    point to an object; example: `"iterators first and last must point to
+    objects"`
+    @throw invalid_iterator.210 if @a first and @a last do not belong to the
+    same JSON value; example: `"iterators do not fit"`
+
+    @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number
+    of elements to insert.
+
+    @liveexample{The example shows how `insert()` is used.,insert__range_object}
+
+    @since version 3.0.0
+    */
+    void insert(const_iterator first, const_iterator last)
+    {
+        // insert only works for objects
+        if (JSON_HEDLEY_UNLIKELY(!is_object()))
+        {
+            JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
+        }
+
+        // check if range iterators belong to the same JSON object
+        if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
+        }
+
+        // passed iterators must belong to objects
+        if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()))
+        {
+            JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this));
+        }
+
+        m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
+    }
+
+    /*!
+    @brief updates a JSON object from another object, overwriting existing keys
+
+    Inserts all values from JSON object @a j and overwrites existing keys.
+
+    @param[in] j  JSON object to read values from
+
+    @throw type_error.312 if called on JSON values other than objects; example:
+    `"cannot use update() with string"`
+
+    @complexity O(N*log(size() + N)), where N is the number of elements to
+                insert.
+
+    @liveexample{The example shows how `update()` is used.,update}
+
+    @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
+
+    @since version 3.0.0
+    */
+    void update(const_reference j)
+    {
+        // implicitly convert null value to an empty object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value.object = create<object_t>();
+            assert_invariant();
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(!is_object()))
+        {
+            JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
+        }
+        if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
+        {
+            JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()), *this));
+        }
+
+        for (auto it = j.cbegin(); it != j.cend(); ++it)
+        {
+            m_value.object->operator[](it.key()) = it.value();
+#if JSON_DIAGNOSTICS
+            m_value.object->operator[](it.key()).m_parent = this;
+#endif
+        }
+    }
+
+    /*!
+    @brief updates a JSON object from another object, overwriting existing keys
+
+    Inserts all values from from range `[first, last)` and overwrites existing
+    keys.
+
+    @param[in] first begin of the range of elements to insert
+    @param[in] last end of the range of elements to insert
+
+    @throw type_error.312 if called on JSON values other than objects; example:
+    `"cannot use update() with string"`
+    @throw invalid_iterator.202 if iterator @a first or @a last does does not
+    point to an object; example: `"iterators first and last must point to
+    objects"`
+    @throw invalid_iterator.210 if @a first and @a last do not belong to the
+    same JSON value; example: `"iterators do not fit"`
+
+    @complexity O(N*log(size() + N)), where N is the number of elements to
+                insert.
+
+    @liveexample{The example shows how `update()` is used__range.,update}
+
+    @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update
+
+    @since version 3.0.0
+    */
+    void update(const_iterator first, const_iterator last)
+    {
+        // implicitly convert null value to an empty object
+        if (is_null())
+        {
+            m_type = value_t::object;
+            m_value.object = create<object_t>();
+            assert_invariant();
+        }
+
+        if (JSON_HEDLEY_UNLIKELY(!is_object()))
+        {
+            JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
+        }
+
+        // check if range iterators belong to the same JSON object
+        if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
+        {
+            JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this));
+        }
+
+        // passed iterators must belong to objects
+        if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()
+                                 || !last.m_object->is_object()))
+        {
+            JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this));
+        }
+
+        for (auto it = first; it != last; ++it)
+        {
+            m_value.object->operator[](it.key()) = it.value();
+#if JSON_DIAGNOSTICS
+            m_value.object->operator[](it.key()).m_parent = this;
+#endif
+        }
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of the JSON value with those of @a other. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated.
+
+    @param[in,out] other JSON value to exchange the contents with
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how JSON values can be swapped with
+    `swap()`.,swap__reference}
+
+    @since version 1.0.0
+    */
+    void swap(reference other) noexcept (
+        std::is_nothrow_move_constructible<value_t>::value&&
+        std::is_nothrow_move_assignable<value_t>::value&&
+        std::is_nothrow_move_constructible<json_value>::value&&
+        std::is_nothrow_move_assignable<json_value>::value
+    )
+    {
+        std::swap(m_type, other.m_type);
+        std::swap(m_value, other.m_value);
+
+        set_parents();
+        other.set_parents();
+        assert_invariant();
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of the JSON value from @a left with those of @a right. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated. implemented as a friend function callable via ADL.
+
+    @param[in,out] left JSON value to exchange the contents with
+    @param[in,out] right JSON value to exchange the contents with
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how JSON values can be swapped with
+    `swap()`.,swap__reference}
+
+    @since version 1.0.0
+    */
+    friend void swap(reference left, reference right) noexcept (
+        std::is_nothrow_move_constructible<value_t>::value&&
+        std::is_nothrow_move_assignable<value_t>::value&&
+        std::is_nothrow_move_constructible<json_value>::value&&
+        std::is_nothrow_move_assignable<json_value>::value
+    )
+    {
+        left.swap(right);
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of a JSON array with those of @a other. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated.
+
+    @param[in,out] other array to exchange the contents with
+
+    @throw type_error.310 when JSON value is not an array; example: `"cannot
+    use swap() with string"`
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how arrays can be swapped with
+    `swap()`.,swap__array_t}
+
+    @since version 1.0.0
+    */
+    void swap(array_t& other) // NOLINT(bugprone-exception-escape)
+    {
+        // swap only works for arrays
+        if (JSON_HEDLEY_LIKELY(is_array()))
+        {
+            std::swap(*(m_value.array), other);
+        }
+        else
+        {
+            JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of a JSON object with those of @a other. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated.
+
+    @param[in,out] other object to exchange the contents with
+
+    @throw type_error.310 when JSON value is not an object; example:
+    `"cannot use swap() with string"`
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how objects can be swapped with
+    `swap()`.,swap__object_t}
+
+    @since version 1.0.0
+    */
+    void swap(object_t& other) // NOLINT(bugprone-exception-escape)
+    {
+        // swap only works for objects
+        if (JSON_HEDLEY_LIKELY(is_object()))
+        {
+            std::swap(*(m_value.object), other);
+        }
+        else
+        {
+            JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of a JSON string with those of @a other. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated.
+
+    @param[in,out] other string to exchange the contents with
+
+    @throw type_error.310 when JSON value is not a string; example: `"cannot
+    use swap() with boolean"`
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how strings can be swapped with
+    `swap()`.,swap__string_t}
+
+    @since version 1.0.0
+    */
+    void swap(string_t& other) // NOLINT(bugprone-exception-escape)
+    {
+        // swap only works for strings
+        if (JSON_HEDLEY_LIKELY(is_string()))
+        {
+            std::swap(*(m_value.string), other);
+        }
+        else
+        {
+            JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /*!
+    @brief exchanges the values
+
+    Exchanges the contents of a JSON string with those of @a other. Does not
+    invoke any move, copy, or swap operations on individual elements. All
+    iterators and references remain valid. The past-the-end iterator is
+    invalidated.
+
+    @param[in,out] other binary to exchange the contents with
+
+    @throw type_error.310 when JSON value is not a string; example: `"cannot
+    use swap() with boolean"`
+
+    @complexity Constant.
+
+    @liveexample{The example below shows how strings can be swapped with
+    `swap()`.,swap__binary_t}
+
+    @since version 3.8.0
+    */
+    void swap(binary_t& other) // NOLINT(bugprone-exception-escape)
+    {
+        // swap only works for strings
+        if (JSON_HEDLEY_LIKELY(is_binary()))
+        {
+            std::swap(*(m_value.binary), other);
+        }
+        else
+        {
+            JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /// @copydoc swap(binary_t&)
+    void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape)
+    {
+        // swap only works for strings
+        if (JSON_HEDLEY_LIKELY(is_binary()))
+        {
+            std::swap(*(m_value.binary), other);
+        }
+        else
+        {
+            JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
+        }
+    }
+
+    /// @}
+
+  public:
+    //////////////////////////////////////////
+    // lexicographical comparison operators //
+    //////////////////////////////////////////
+
+    /// @name lexicographical comparison operators
+    /// @{
+
+    /*!
+    @brief comparison: equal
+
+    Compares two JSON values for equality according to the following rules:
+    - Two JSON values are equal if (1) they are from the same type and (2)
+      their stored values are the same according to their respective
+      `operator==`.
+    - Integer and floating-point numbers are automatically converted before
+      comparison. Note that two NaN values are always treated as unequal.
+    - Two JSON null values are equal.
+
+    @note Floating-point inside JSON values numbers are compared with
+    `json::number_float_t::operator==` which is `double::operator==` by
+    default. To compare floating-point while respecting an epsilon, an alternative
+    [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39)
+    could be used, for instance
+    @code {.cpp}
+    template<typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, T>::type>
+    inline bool is_same(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) noexcept
+    {
+        return std::abs(a - b) <= epsilon;
+    }
+    @endcode
+    Or you can self-defined operator equal function like this:
+    @code {.cpp}
+    bool my_equal(const_reference lhs, const_reference rhs) {
+    const auto lhs_type lhs.type();
+    const auto rhs_type rhs.type();
+    if (lhs_type == rhs_type) {
+        switch(lhs_type)
+            // self_defined case
+            case value_t::number_float:
+                return std::abs(lhs - rhs) <= std::numeric_limits<float>::epsilon();
+            // other cases remain the same with the original
+            ...
+    }
+    ...
+    }
+    @endcode
+
+    @note NaN values never compare equal to themselves or to other NaN values.
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether the values @a lhs and @a rhs are equal
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @complexity Linear.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__equal}
+
+    @since version 1.0.0
+    */
+    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
+    {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
+        const auto lhs_type = lhs.type();
+        const auto rhs_type = rhs.type();
+
+        if (lhs_type == rhs_type)
+        {
+            switch (lhs_type)
+            {
+                case value_t::array:
+                    return *lhs.m_value.array == *rhs.m_value.array;
+
+                case value_t::object:
+                    return *lhs.m_value.object == *rhs.m_value.object;
+
+                case value_t::null:
+                    return true;
+
+                case value_t::string:
+                    return *lhs.m_value.string == *rhs.m_value.string;
+
+                case value_t::boolean:
+                    return lhs.m_value.boolean == rhs.m_value.boolean;
+
+                case value_t::number_integer:
+                    return lhs.m_value.number_integer == rhs.m_value.number_integer;
+
+                case value_t::number_unsigned:
+                    return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
+
+                case value_t::number_float:
+                    return lhs.m_value.number_float == rhs.m_value.number_float;
+
+                case value_t::binary:
+                    return *lhs.m_value.binary == *rhs.m_value.binary;
+
+                case value_t::discarded:
+                default:
+                    return false;
+            }
+        }
+        else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
+        {
+            return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
+        }
+        else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
+        {
+            return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
+        }
+        else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
+        {
+            return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
+        }
+        else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
+        {
+            return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
+        }
+        else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
+        {
+            return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
+        }
+        else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
+        {
+            return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
+        }
+
+        return false;
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+    }
+
+    /*!
+    @brief comparison: equal
+    @copydoc operator==(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs == basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: equal
+    @copydoc operator==(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) == rhs;
+    }
+
+    /*!
+    @brief comparison: not equal
+
+    Compares two JSON values for inequality by calculating `not (lhs == rhs)`.
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether the values @a lhs and @a rhs are not equal
+
+    @complexity Linear.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__notequal}
+
+    @since version 1.0.0
+    */
+    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
+    {
+        return !(lhs == rhs);
+    }
+
+    /*!
+    @brief comparison: not equal
+    @copydoc operator!=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs != basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: not equal
+    @copydoc operator!=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) != rhs;
+    }
+
+    /*!
+    @brief comparison: less than
+
+    Compares whether one JSON value @a lhs is less than another JSON value @a
+    rhs according to the following rules:
+    - If @a lhs and @a rhs have the same type, the values are compared using
+      the default `<` operator.
+    - Integer and floating-point numbers are automatically converted before
+      comparison
+    - In case @a lhs and @a rhs have different types, the values are ignored
+      and the order of the types is considered, see
+      @ref operator<(const value_t, const value_t).
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether @a lhs is less than @a rhs
+
+    @complexity Linear.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__less}
+
+    @since version 1.0.0
+    */
+    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
+    {
+        const auto lhs_type = lhs.type();
+        const auto rhs_type = rhs.type();
+
+        if (lhs_type == rhs_type)
+        {
+            switch (lhs_type)
+            {
+                case value_t::array:
+                    // note parentheses are necessary, see
+                    // https://github.com/nlohmann/json/issues/1530
+                    return (*lhs.m_value.array) < (*rhs.m_value.array);
+
+                case value_t::object:
+                    return (*lhs.m_value.object) < (*rhs.m_value.object);
+
+                case value_t::null:
+                    return false;
+
+                case value_t::string:
+                    return (*lhs.m_value.string) < (*rhs.m_value.string);
+
+                case value_t::boolean:
+                    return (lhs.m_value.boolean) < (rhs.m_value.boolean);
+
+                case value_t::number_integer:
+                    return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
+
+                case value_t::number_unsigned:
+                    return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
+
+                case value_t::number_float:
+                    return (lhs.m_value.number_float) < (rhs.m_value.number_float);
+
+                case value_t::binary:
+                    return (*lhs.m_value.binary) < (*rhs.m_value.binary);
+
+                case value_t::discarded:
+                default:
+                    return false;
+            }
+        }
+        else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
+        {
+            return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
+        }
+        else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
+        {
+            return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
+        }
+        else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
+        {
+            return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
+        }
+        else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
+        {
+            return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
+        }
+        else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
+        {
+            return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
+        }
+        else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
+        {
+            return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
+        }
+
+        // We only reach this line if we cannot compare values. In that case,
+        // we compare types. Note we have to call the operator explicitly,
+        // because MSVC has problems otherwise.
+        return operator<(lhs_type, rhs_type);
+    }
+
+    /*!
+    @brief comparison: less than
+    @copydoc operator<(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs < basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: less than
+    @copydoc operator<(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) < rhs;
+    }
+
+    /*!
+    @brief comparison: less than or equal
+
+    Compares whether one JSON value @a lhs is less than or equal to another
+    JSON value by calculating `not (rhs < lhs)`.
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether @a lhs is less than or equal to @a rhs
+
+    @complexity Linear.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__greater}
+
+    @since version 1.0.0
+    */
+    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
+    {
+        return !(rhs < lhs);
+    }
+
+    /*!
+    @brief comparison: less than or equal
+    @copydoc operator<=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs <= basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: less than or equal
+    @copydoc operator<=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) <= rhs;
+    }
+
+    /*!
+    @brief comparison: greater than
+
+    Compares whether one JSON value @a lhs is greater than another
+    JSON value by calculating `not (lhs <= rhs)`.
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether @a lhs is greater than to @a rhs
+
+    @complexity Linear.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__lessequal}
+
+    @since version 1.0.0
+    */
+    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
+    {
+        return !(lhs <= rhs);
+    }
+
+    /*!
+    @brief comparison: greater than
+    @copydoc operator>(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs > basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: greater than
+    @copydoc operator>(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) > rhs;
+    }
+
+    /*!
+    @brief comparison: greater than or equal
+
+    Compares whether one JSON value @a lhs is greater than or equal to another
+    JSON value by calculating `not (lhs < rhs)`.
+
+    @param[in] lhs  first JSON value to consider
+    @param[in] rhs  second JSON value to consider
+    @return whether @a lhs is greater than or equal to @a rhs
+
+    @complexity Linear.
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @liveexample{The example demonstrates comparing several JSON
+    types.,operator__greaterequal}
+
+    @since version 1.0.0
+    */
+    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
+    {
+        return !(lhs < rhs);
+    }
+
+    /*!
+    @brief comparison: greater than or equal
+    @copydoc operator>=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
+    {
+        return lhs >= basic_json(rhs);
+    }
+
+    /*!
+    @brief comparison: greater than or equal
+    @copydoc operator>=(const_reference, const_reference)
+    */
+    template<typename ScalarType, typename std::enable_if<
+                 std::is_scalar<ScalarType>::value, int>::type = 0>
+    friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
+    {
+        return basic_json(lhs) >= rhs;
+    }
+
+    /// @}
+
+    ///////////////////
+    // serialization //
+    ///////////////////
+
+    /// @name serialization
+    /// @{
+#ifndef JSON_NO_IO
+    /*!
+    @brief serialize to stream
+
+    Serialize the given JSON value @a j to the output stream @a o. The JSON
+    value will be serialized using the @ref dump member function.
+
+    - The indentation of the output can be controlled with the member variable
+      `width` of the output stream @a o. For instance, using the manipulator
+      `std::setw(4)` on @a o sets the indentation level to `4` and the
+      serialization result is the same as calling `dump(4)`.
+
+    - The indentation character can be controlled with the member variable
+      `fill` of the output stream @a o. For instance, the manipulator
+      `std::setfill('\\t')` sets indentation to use a tab character rather than
+      the default space character.
+
+    @param[in,out] o  stream to serialize to
+    @param[in] j  JSON value to serialize
+
+    @return the stream @a o
+
+    @throw type_error.316 if a string stored inside the JSON value is not
+                          UTF-8 encoded
+
+    @complexity Linear.
+
+    @liveexample{The example below shows the serialization with different
+    parameters to `width` to adjust the indentation level.,operator_serialize}
+
+    @since version 1.0.0; indentation character added in version 3.0.0
+    */
+    friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
+    {
+        // read width member and use it as indentation parameter if nonzero
+        const bool pretty_print = o.width() > 0;
+        const auto indentation = pretty_print ? o.width() : 0;
+
+        // reset width to 0 for subsequent calls to this stream
+        o.width(0);
+
+        // do the actual serialization
+        serializer s(detail::output_adapter<char>(o), o.fill());
+        s.dump(j, pretty_print, false, static_cast<unsigned int>(indentation));
+        return o;
+    }
+
+    /*!
+    @brief serialize to stream
+    @deprecated This stream operator is deprecated and will be removed in
+                future 4.0.0 of the library. Please use
+                @ref operator<<(std::ostream&, const basic_json&)
+                instead; that is, replace calls like `j >> o;` with `o << j;`.
+    @since version 1.0.0; deprecated since version 3.0.0
+    */
+    JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&))
+    friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
+    {
+        return o << j;
+    }
+#endif  // JSON_NO_IO
+    /// @}
+
+
+    /////////////////////
+    // deserialization //
+    /////////////////////
+
+    /// @name deserialization
+    /// @{
+
+    /*!
+    @brief deserialize from a compatible input
+
+    @tparam InputType A compatible input, for instance
+    - an std::istream object
+    - a FILE pointer
+    - a C-style array of characters
+    - a pointer to a null-terminated string of single byte characters
+    - an object obj for which begin(obj) and end(obj) produces a valid pair of
+      iterators.
+
+    @param[in] i  input to read from
+    @param[in] cb  a parser callback function of type @ref parser_callback_t
+    which is used to control the deserialization by filtering unwanted values
+    (optional)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+    @param[in] ignore_comments  whether comments should be ignored and treated
+    like whitespace (true) or yield a parse error (true); (optional, false by
+    default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.101 if a parse error occurs; example: `""unexpected end
+    of input; expected string literal""`
+    @throw parse_error.102 if to_unicode fails or surrogate error
+    @throw parse_error.103 if to_unicode fails
+
+    @complexity Linear in the length of the input. The parser is a predictive
+    LL(1) parser. The complexity can be higher if the parser callback function
+    @a cb or reading from the input @a i has a super-linear complexity.
+
+    @note A UTF-8 byte order mark is silently ignored.
+
+    @liveexample{The example below demonstrates the `parse()` function reading
+    from an array.,parse__array__parser_callback_t}
+
+    @liveexample{The example below demonstrates the `parse()` function with
+    and without callback function.,parse__string__parser_callback_t}
+
+    @liveexample{The example below demonstrates the `parse()` function with
+    and without callback function.,parse__istream__parser_callback_t}
+
+    @liveexample{The example below demonstrates the `parse()` function reading
+    from a contiguous container.,parse__contiguouscontainer__parser_callback_t}
+
+    @since version 2.0.3 (contiguous containers); version 3.9.0 allowed to
+    ignore comments.
+    */
+    template<typename InputType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json parse(InputType&& i,
+                            const parser_callback_t cb = nullptr,
+                            const bool allow_exceptions = true,
+                            const bool ignore_comments = false)
+    {
+        basic_json result;
+        parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
+        return result;
+    }
+
+    /*!
+    @brief deserialize from a pair of character iterators
+
+    The value_type of the iterator must be a integral type with size of 1, 2 or
+    4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32.
+
+    @param[in] first iterator to start of character range
+    @param[in] last  iterator to end of character range
+    @param[in] cb  a parser callback function of type @ref parser_callback_t
+    which is used to control the deserialization by filtering unwanted values
+    (optional)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+    @param[in] ignore_comments  whether comments should be ignored and treated
+    like whitespace (true) or yield a parse error (true); (optional, false by
+    default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.101 if a parse error occurs; example: `""unexpected end
+    of input; expected string literal""`
+    @throw parse_error.102 if to_unicode fails or surrogate error
+    @throw parse_error.103 if to_unicode fails
+    */
+    template<typename IteratorType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json parse(IteratorType first,
+                            IteratorType last,
+                            const parser_callback_t cb = nullptr,
+                            const bool allow_exceptions = true,
+                            const bool ignore_comments = false)
+    {
+        basic_json result;
+        parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
+        return result;
+    }
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len))
+    static basic_json parse(detail::span_input_adapter&& i,
+                            const parser_callback_t cb = nullptr,
+                            const bool allow_exceptions = true,
+                            const bool ignore_comments = false)
+    {
+        basic_json result;
+        parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result);
+        return result;
+    }
+
+    /*!
+    @brief check if the input is valid JSON
+
+    Unlike the @ref parse(InputType&&, const parser_callback_t,const bool)
+    function, this function neither throws an exception in case of invalid JSON
+    input (i.e., a parse error) nor creates diagnostic information.
+
+    @tparam InputType A compatible input, for instance
+    - an std::istream object
+    - a FILE pointer
+    - a C-style array of characters
+    - a pointer to a null-terminated string of single byte characters
+    - an object obj for which begin(obj) and end(obj) produces a valid pair of
+      iterators.
+
+    @param[in] i input to read from
+    @param[in] ignore_comments  whether comments should be ignored and treated
+    like whitespace (true) or yield a parse error (true); (optional, false by
+    default)
+
+    @return Whether the input read from @a i is valid JSON.
+
+    @complexity Linear in the length of the input. The parser is a predictive
+    LL(1) parser.
+
+    @note A UTF-8 byte order mark is silently ignored.
+
+    @liveexample{The example below demonstrates the `accept()` function reading
+    from a string.,accept__string}
+    */
+    template<typename InputType>
+    static bool accept(InputType&& i,
+                       const bool ignore_comments = false)
+    {
+        return parser(detail::input_adapter(std::forward<InputType>(i)), nullptr, false, ignore_comments).accept(true);
+    }
+
+    template<typename IteratorType>
+    static bool accept(IteratorType first, IteratorType last,
+                       const bool ignore_comments = false)
+    {
+        return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true);
+    }
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len))
+    static bool accept(detail::span_input_adapter&& i,
+                       const bool ignore_comments = false)
+    {
+        return parser(i.get(), nullptr, false, ignore_comments).accept(true);
+    }
+
+    /*!
+    @brief generate SAX events
+
+    The SAX event lister must follow the interface of @ref json_sax.
+
+    This function reads from a compatible input. Examples are:
+    - an std::istream object
+    - a FILE pointer
+    - a C-style array of characters
+    - a pointer to a null-terminated string of single byte characters
+    - an object obj for which begin(obj) and end(obj) produces a valid pair of
+      iterators.
+
+    @param[in] i  input to read from
+    @param[in,out] sax  SAX event listener
+    @param[in] format  the format to parse (JSON, CBOR, MessagePack, or UBJSON)
+    @param[in] strict  whether the input has to be consumed completely
+    @param[in] ignore_comments  whether comments should be ignored and treated
+    like whitespace (true) or yield a parse error (true); (optional, false by
+    default); only applies to the JSON file format.
+
+    @return return value of the last processed SAX event
+
+    @throw parse_error.101 if a parse error occurs; example: `""unexpected end
+    of input; expected string literal""`
+    @throw parse_error.102 if to_unicode fails or surrogate error
+    @throw parse_error.103 if to_unicode fails
+
+    @complexity Linear in the length of the input. The parser is a predictive
+    LL(1) parser. The complexity can be higher if the SAX consumer @a sax has
+    a super-linear complexity.
+
+    @note A UTF-8 byte order mark is silently ignored.
+
+    @liveexample{The example below demonstrates the `sax_parse()` function
+    reading from string and processing the events with a user-defined SAX
+    event consumer.,sax_parse}
+
+    @since version 3.2.0
+    */
+    template <typename InputType, typename SAX>
+    JSON_HEDLEY_NON_NULL(2)
+    static bool sax_parse(InputType&& i, SAX* sax,
+                          input_format_t format = input_format_t::json,
+                          const bool strict = true,
+                          const bool ignore_comments = false)
+    {
+        auto ia = detail::input_adapter(std::forward<InputType>(i));
+        return format == input_format_t::json
+               ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
+               : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
+    }
+
+    template<class IteratorType, class SAX>
+    JSON_HEDLEY_NON_NULL(3)
+    static bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
+                          input_format_t format = input_format_t::json,
+                          const bool strict = true,
+                          const bool ignore_comments = false)
+    {
+        auto ia = detail::input_adapter(std::move(first), std::move(last));
+        return format == input_format_t::json
+               ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
+               : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
+    }
+
+    template <typename SAX>
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...))
+    JSON_HEDLEY_NON_NULL(2)
+    static bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
+                          input_format_t format = input_format_t::json,
+                          const bool strict = true,
+                          const bool ignore_comments = false)
+    {
+        auto ia = i.get();
+        return format == input_format_t::json
+               // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+               ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict)
+               // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+               : detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
+    }
+#ifndef JSON_NO_IO
+    /*!
+    @brief deserialize from stream
+    @deprecated This stream operator is deprecated and will be removed in
+                version 4.0.0 of the library. Please use
+                @ref operator>>(std::istream&, basic_json&)
+                instead; that is, replace calls like `j << i;` with `i >> j;`.
+    @since version 1.0.0; deprecated since version 3.0.0
+    */
+    JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&))
+    friend std::istream& operator<<(basic_json& j, std::istream& i)
+    {
+        return operator>>(i, j);
+    }
+
+    /*!
+    @brief deserialize from stream
+
+    Deserializes an input stream to a JSON value.
+
+    @param[in,out] i  input stream to read a serialized JSON value from
+    @param[in,out] j  JSON value to write the deserialized input to
+
+    @throw parse_error.101 in case of an unexpected token
+    @throw parse_error.102 if to_unicode fails or surrogate error
+    @throw parse_error.103 if to_unicode fails
+
+    @complexity Linear in the length of the input. The parser is a predictive
+    LL(1) parser.
+
+    @note A UTF-8 byte order mark is silently ignored.
+
+    @liveexample{The example below shows how a JSON value is constructed by
+    reading a serialization from a stream.,operator_deserialize}
+
+    @sa parse(std::istream&, const parser_callback_t) for a variant with a
+    parser callback function to filter values while parsing
+
+    @since version 1.0.0
+    */
+    friend std::istream& operator>>(std::istream& i, basic_json& j)
+    {
+        parser(detail::input_adapter(i)).parse(false, j);
+        return i;
+    }
+#endif  // JSON_NO_IO
+    /// @}
+
+    ///////////////////////////
+    // convenience functions //
+    ///////////////////////////
+
+    /*!
+    @brief return the type as string
+
+    Returns the type name as string to be used in error messages - usually to
+    indicate that a function was called on a wrong JSON type.
+
+    @return a string representation of a the @a m_type member:
+            Value type  | return value
+            ----------- | -------------
+            null        | `"null"`
+            boolean     | `"boolean"`
+            string      | `"string"`
+            number      | `"number"` (for all number types)
+            object      | `"object"`
+            array       | `"array"`
+            binary      | `"binary"`
+            discarded   | `"discarded"`
+
+    @exceptionsafety No-throw guarantee: this function never throws exceptions.
+
+    @complexity Constant.
+
+    @liveexample{The following code exemplifies `type_name()` for all JSON
+    types.,type_name}
+
+    @sa see @ref type() -- return the type of the JSON value
+    @sa see @ref operator value_t() -- return the type of the JSON value (implicit)
+
+    @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept`
+    since 3.0.0
+    */
+    JSON_HEDLEY_RETURNS_NON_NULL
+    const char* type_name() const noexcept
+    {
+        {
+            switch (m_type)
+            {
+                case value_t::null:
+                    return "null";
+                case value_t::object:
+                    return "object";
+                case value_t::array:
+                    return "array";
+                case value_t::string:
+                    return "string";
+                case value_t::boolean:
+                    return "boolean";
+                case value_t::binary:
+                    return "binary";
+                case value_t::discarded:
+                    return "discarded";
+                case value_t::number_integer:
+                case value_t::number_unsigned:
+                case value_t::number_float:
+                default:
+                    return "number";
+            }
+        }
+    }
+
+
+  JSON_PRIVATE_UNLESS_TESTED:
+    //////////////////////
+    // member variables //
+    //////////////////////
+
+    /// the type of the current element
+    value_t m_type = value_t::null;
+
+    /// the value of the current element
+    json_value m_value = {};
+
+#if JSON_DIAGNOSTICS
+    /// a pointer to a parent value (for debugging purposes)
+    basic_json* m_parent = nullptr;
+#endif
+
+    //////////////////////////////////////////
+    // binary serialization/deserialization //
+    //////////////////////////////////////////
+
+    /// @name binary serialization/deserialization support
+    /// @{
+
+  public:
+    /*!
+    @brief create a CBOR serialization of a given JSON value
+
+    Serializes a given JSON value @a j to a byte vector using the CBOR (Concise
+    Binary Object Representation) serialization format. CBOR is a binary
+    serialization format which aims to be more compact than JSON itself, yet
+    more efficient to parse.
+
+    The library uses the following mapping from JSON values types to
+    CBOR types according to the CBOR specification (RFC 7049):
+
+    JSON value type | value/range                                | CBOR type                          | first byte
+    --------------- | ------------------------------------------ | ---------------------------------- | ---------------
+    null            | `null`                                     | Null                               | 0xF6
+    boolean         | `true`                                     | True                               | 0xF5
+    boolean         | `false`                                    | False                              | 0xF4
+    number_integer  | -9223372036854775808..-2147483649          | Negative integer (8 bytes follow)  | 0x3B
+    number_integer  | -2147483648..-32769                        | Negative integer (4 bytes follow)  | 0x3A
+    number_integer  | -32768..-129                               | Negative integer (2 bytes follow)  | 0x39
+    number_integer  | -128..-25                                  | Negative integer (1 byte follow)   | 0x38
+    number_integer  | -24..-1                                    | Negative integer                   | 0x20..0x37
+    number_integer  | 0..23                                      | Integer                            | 0x00..0x17
+    number_integer  | 24..255                                    | Unsigned integer (1 byte follow)   | 0x18
+    number_integer  | 256..65535                                 | Unsigned integer (2 bytes follow)  | 0x19
+    number_integer  | 65536..4294967295                          | Unsigned integer (4 bytes follow)  | 0x1A
+    number_integer  | 4294967296..18446744073709551615           | Unsigned integer (8 bytes follow)  | 0x1B
+    number_unsigned | 0..23                                      | Integer                            | 0x00..0x17
+    number_unsigned | 24..255                                    | Unsigned integer (1 byte follow)   | 0x18
+    number_unsigned | 256..65535                                 | Unsigned integer (2 bytes follow)  | 0x19
+    number_unsigned | 65536..4294967295                          | Unsigned integer (4 bytes follow)  | 0x1A
+    number_unsigned | 4294967296..18446744073709551615           | Unsigned integer (8 bytes follow)  | 0x1B
+    number_float    | *any value representable by a float*       | Single-Precision Float             | 0xFA
+    number_float    | *any value NOT representable by a float*   | Double-Precision Float             | 0xFB
+    string          | *length*: 0..23                            | UTF-8 string                       | 0x60..0x77
+    string          | *length*: 23..255                          | UTF-8 string (1 byte follow)       | 0x78
+    string          | *length*: 256..65535                       | UTF-8 string (2 bytes follow)      | 0x79
+    string          | *length*: 65536..4294967295                | UTF-8 string (4 bytes follow)      | 0x7A
+    string          | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow)      | 0x7B
+    array           | *size*: 0..23                              | array                              | 0x80..0x97
+    array           | *size*: 23..255                            | array (1 byte follow)              | 0x98
+    array           | *size*: 256..65535                         | array (2 bytes follow)             | 0x99
+    array           | *size*: 65536..4294967295                  | array (4 bytes follow)             | 0x9A
+    array           | *size*: 4294967296..18446744073709551615   | array (8 bytes follow)             | 0x9B
+    object          | *size*: 0..23                              | map                                | 0xA0..0xB7
+    object          | *size*: 23..255                            | map (1 byte follow)                | 0xB8
+    object          | *size*: 256..65535                         | map (2 bytes follow)               | 0xB9
+    object          | *size*: 65536..4294967295                  | map (4 bytes follow)               | 0xBA
+    object          | *size*: 4294967296..18446744073709551615   | map (8 bytes follow)               | 0xBB
+    binary          | *size*: 0..23                              | byte string                        | 0x40..0x57
+    binary          | *size*: 23..255                            | byte string (1 byte follow)        | 0x58
+    binary          | *size*: 256..65535                         | byte string (2 bytes follow)       | 0x59
+    binary          | *size*: 65536..4294967295                  | byte string (4 bytes follow)       | 0x5A
+    binary          | *size*: 4294967296..18446744073709551615   | byte string (8 bytes follow)       | 0x5B
+
+    Binary values with subtype are mapped to tagged values (0xD8..0xDB)
+    depending on the subtype, followed by a byte string, see "binary" cells
+    in the table above.
+
+    @note The mapping is **complete** in the sense that any JSON value type
+          can be converted to a CBOR value.
+
+    @note If NaN or Infinity are stored inside a JSON number, they are
+          serialized properly. This behavior differs from the @ref dump()
+          function which serializes NaN or Infinity to `null`.
+
+    @note The following CBOR types are not used in the conversion:
+          - UTF-8 strings terminated by "break" (0x7F)
+          - arrays terminated by "break" (0x9F)
+          - maps terminated by "break" (0xBF)
+          - byte strings terminated by "break" (0x5F)
+          - date/time (0xC0..0xC1)
+          - bignum (0xC2..0xC3)
+          - decimal fraction (0xC4)
+          - bigfloat (0xC5)
+          - expected conversions (0xD5..0xD7)
+          - simple values (0xE0..0xF3, 0xF8)
+          - undefined (0xF7)
+          - half-precision floats (0xF9)
+          - break (0xFF)
+
+    @param[in] j  JSON value to serialize
+    @return CBOR serialization as byte vector
+
+    @complexity Linear in the size of the JSON value @a j.
+
+    @liveexample{The example shows the serialization of a JSON value to a byte
+    vector in CBOR format.,to_cbor}
+
+    @sa http://cbor.io
+    @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the
+        analogous deserialization
+    @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format
+    @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the
+             related UBJSON format
+
+    @since version 2.0.9; compact representation of floating-point numbers
+           since version 3.8.0
+    */
+    static std::vector<std::uint8_t> to_cbor(const basic_json& j)
+    {
+        std::vector<std::uint8_t> result;
+        to_cbor(j, result);
+        return result;
+    }
+
+    static void to_cbor(const basic_json& j, detail::output_adapter<std::uint8_t> o)
+    {
+        binary_writer<std::uint8_t>(o).write_cbor(j);
+    }
+
+    static void to_cbor(const basic_json& j, detail::output_adapter<char> o)
+    {
+        binary_writer<char>(o).write_cbor(j);
+    }
+
+    /*!
+    @brief create a MessagePack serialization of a given JSON value
+
+    Serializes a given JSON value @a j to a byte vector using the MessagePack
+    serialization format. MessagePack is a binary serialization format which
+    aims to be more compact than JSON itself, yet more efficient to parse.
+
+    The library uses the following mapping from JSON values types to
+    MessagePack types according to the MessagePack specification:
+
+    JSON value type | value/range                       | MessagePack type | first byte
+    --------------- | --------------------------------- | ---------------- | ----------
+    null            | `null`                            | nil              | 0xC0
+    boolean         | `true`                            | true             | 0xC3
+    boolean         | `false`                           | false            | 0xC2
+    number_integer  | -9223372036854775808..-2147483649 | int64            | 0xD3
+    number_integer  | -2147483648..-32769               | int32            | 0xD2
+    number_integer  | -32768..-129                      | int16            | 0xD1
+    number_integer  | -128..-33                         | int8             | 0xD0
+    number_integer  | -32..-1                           | negative fixint  | 0xE0..0xFF
+    number_integer  | 0..127                            | positive fixint  | 0x00..0x7F
+    number_integer  | 128..255                          | uint 8           | 0xCC
+    number_integer  | 256..65535                        | uint 16          | 0xCD
+    number_integer  | 65536..4294967295                 | uint 32          | 0xCE
+    number_integer  | 4294967296..18446744073709551615  | uint 64          | 0xCF
+    number_unsigned | 0..127                            | positive fixint  | 0x00..0x7F
+    number_unsigned | 128..255                          | uint 8           | 0xCC
+    number_unsigned | 256..65535                        | uint 16          | 0xCD
+    number_unsigned | 65536..4294967295                 | uint 32          | 0xCE
+    number_unsigned | 4294967296..18446744073709551615  | uint 64          | 0xCF
+    number_float    | *any value representable by a float*     | float 32 | 0xCA
+    number_float    | *any value NOT representable by a float* | float 64 | 0xCB
+    string          | *length*: 0..31                   | fixstr           | 0xA0..0xBF
+    string          | *length*: 32..255                 | str 8            | 0xD9
+    string          | *length*: 256..65535              | str 16           | 0xDA
+    string          | *length*: 65536..4294967295       | str 32           | 0xDB
+    array           | *size*: 0..15                     | fixarray         | 0x90..0x9F
+    array           | *size*: 16..65535                 | array 16         | 0xDC
+    array           | *size*: 65536..4294967295         | array 32         | 0xDD
+    object          | *size*: 0..15                     | fix map          | 0x80..0x8F
+    object          | *size*: 16..65535                 | map 16           | 0xDE
+    object          | *size*: 65536..4294967295         | map 32           | 0xDF
+    binary          | *size*: 0..255                    | bin 8            | 0xC4
+    binary          | *size*: 256..65535                | bin 16           | 0xC5
+    binary          | *size*: 65536..4294967295         | bin 32           | 0xC6
+
+    @note The mapping is **complete** in the sense that any JSON value type
+          can be converted to a MessagePack value.
+
+    @note The following values can **not** be converted to a MessagePack value:
+          - strings with more than 4294967295 bytes
+          - byte strings with more than 4294967295 bytes
+          - arrays with more than 4294967295 elements
+          - objects with more than 4294967295 elements
+
+    @note Any MessagePack output created @ref to_msgpack can be successfully
+          parsed by @ref from_msgpack.
+
+    @note If NaN or Infinity are stored inside a JSON number, they are
+          serialized properly. This behavior differs from the @ref dump()
+          function which serializes NaN or Infinity to `null`.
+
+    @param[in] j  JSON value to serialize
+    @return MessagePack serialization as byte vector
+
+    @complexity Linear in the size of the JSON value @a j.
+
+    @liveexample{The example shows the serialization of a JSON value to a byte
+    vector in MessagePack format.,to_msgpack}
+
+    @sa http://msgpack.org
+    @sa see @ref from_msgpack for the analogous deserialization
+    @sa see @ref to_cbor(const basic_json& for the related CBOR format
+    @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the
+             related UBJSON format
+
+    @since version 2.0.9
+    */
+    static std::vector<std::uint8_t> to_msgpack(const basic_json& j)
+    {
+        std::vector<std::uint8_t> result;
+        to_msgpack(j, result);
+        return result;
+    }
+
+    static void to_msgpack(const basic_json& j, detail::output_adapter<std::uint8_t> o)
+    {
+        binary_writer<std::uint8_t>(o).write_msgpack(j);
+    }
+
+    static void to_msgpack(const basic_json& j, detail::output_adapter<char> o)
+    {
+        binary_writer<char>(o).write_msgpack(j);
+    }
+
+    /*!
+    @brief create a UBJSON serialization of a given JSON value
+
+    Serializes a given JSON value @a j to a byte vector using the UBJSON
+    (Universal Binary JSON) serialization format. UBJSON aims to be more compact
+    than JSON itself, yet more efficient to parse.
+
+    The library uses the following mapping from JSON values types to
+    UBJSON types according to the UBJSON specification:
+
+    JSON value type | value/range                       | UBJSON type | marker
+    --------------- | --------------------------------- | ----------- | ------
+    null            | `null`                            | null        | `Z`
+    boolean         | `true`                            | true        | `T`
+    boolean         | `false`                           | false       | `F`
+    number_integer  | -9223372036854775808..-2147483649 | int64       | `L`
+    number_integer  | -2147483648..-32769               | int32       | `l`
+    number_integer  | -32768..-129                      | int16       | `I`
+    number_integer  | -128..127                         | int8        | `i`
+    number_integer  | 128..255                          | uint8       | `U`
+    number_integer  | 256..32767                        | int16       | `I`
+    number_integer  | 32768..2147483647                 | int32       | `l`
+    number_integer  | 2147483648..9223372036854775807   | int64       | `L`
+    number_unsigned | 0..127                            | int8        | `i`
+    number_unsigned | 128..255                          | uint8       | `U`
+    number_unsigned | 256..32767                        | int16       | `I`
+    number_unsigned | 32768..2147483647                 | int32       | `l`
+    number_unsigned | 2147483648..9223372036854775807   | int64       | `L`
+    number_unsigned | 2147483649..18446744073709551615  | high-precision | `H`
+    number_float    | *any value*                       | float64     | `D`
+    string          | *with shortest length indicator*  | string      | `S`
+    array           | *see notes on optimized format*   | array       | `[`
+    object          | *see notes on optimized format*   | map         | `{`
+
+    @note The mapping is **complete** in the sense that any JSON value type
+          can be converted to a UBJSON value.
+
+    @note The following values can **not** be converted to a UBJSON value:
+          - strings with more than 9223372036854775807 bytes (theoretical)
+
+    @note The following markers are not used in the conversion:
+          - `Z`: no-op values are not created.
+          - `C`: single-byte strings are serialized with `S` markers.
+
+    @note Any UBJSON output created @ref to_ubjson can be successfully parsed
+          by @ref from_ubjson.
+
+    @note If NaN or Infinity are stored inside a JSON number, they are
+          serialized properly. This behavior differs from the @ref dump()
+          function which serializes NaN or Infinity to `null`.
+
+    @note The optimized formats for containers are supported: Parameter
+          @a use_size adds size information to the beginning of a container and
+          removes the closing marker. Parameter @a use_type further checks
+          whether all elements of a container have the same type and adds the
+          type marker to the beginning of the container. The @a use_type
+          parameter must only be used together with @a use_size = true. Note
+          that @a use_size = true alone may result in larger representations -
+          the benefit of this parameter is that the receiving side is
+          immediately informed on the number of elements of the container.
+
+    @note If the JSON data contains the binary type, the value stored is a list
+          of integers, as suggested by the UBJSON documentation.  In particular,
+          this means that serialization and the deserialization of a JSON
+          containing binary values into UBJSON and back will result in a
+          different JSON object.
+
+    @param[in] j  JSON value to serialize
+    @param[in] use_size  whether to add size annotations to container types
+    @param[in] use_type  whether to add type annotations to container types
+                         (must be combined with @a use_size = true)
+    @return UBJSON serialization as byte vector
+
+    @complexity Linear in the size of the JSON value @a j.
+
+    @liveexample{The example shows the serialization of a JSON value to a byte
+    vector in UBJSON format.,to_ubjson}
+
+    @sa http://ubjson.org
+    @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the
+        analogous deserialization
+    @sa see @ref to_cbor(const basic_json& for the related CBOR format
+    @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format
+
+    @since version 3.1.0
+    */
+    static std::vector<std::uint8_t> to_ubjson(const basic_json& j,
+            const bool use_size = false,
+            const bool use_type = false)
+    {
+        std::vector<std::uint8_t> result;
+        to_ubjson(j, result, use_size, use_type);
+        return result;
+    }
+
+    static void to_ubjson(const basic_json& j, detail::output_adapter<std::uint8_t> o,
+                          const bool use_size = false, const bool use_type = false)
+    {
+        binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
+    }
+
+    static void to_ubjson(const basic_json& j, detail::output_adapter<char> o,
+                          const bool use_size = false, const bool use_type = false)
+    {
+        binary_writer<char>(o).write_ubjson(j, use_size, use_type);
+    }
+
+
+    /*!
+    @brief Serializes the given JSON object `j` to BSON and returns a vector
+           containing the corresponding BSON-representation.
+
+    BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are
+    stored as a single entity (a so-called document).
+
+    The library uses the following mapping from JSON values types to BSON types:
+
+    JSON value type | value/range                       | BSON type   | marker
+    --------------- | --------------------------------- | ----------- | ------
+    null            | `null`                            | null        | 0x0A
+    boolean         | `true`, `false`                   | boolean     | 0x08
+    number_integer  | -9223372036854775808..-2147483649 | int64       | 0x12
+    number_integer  | -2147483648..2147483647           | int32       | 0x10
+    number_integer  | 2147483648..9223372036854775807   | int64       | 0x12
+    number_unsigned | 0..2147483647                     | int32       | 0x10
+    number_unsigned | 2147483648..9223372036854775807   | int64       | 0x12
+    number_unsigned | 9223372036854775808..18446744073709551615| --   | --
+    number_float    | *any value*                       | double      | 0x01
+    string          | *any value*                       | string      | 0x02
+    array           | *any value*                       | document    | 0x04
+    object          | *any value*                       | document    | 0x03
+    binary          | *any value*                       | binary      | 0x05
+
+    @warning The mapping is **incomplete**, since only JSON-objects (and things
+    contained therein) can be serialized to BSON.
+    Also, integers larger than 9223372036854775807 cannot be serialized to BSON,
+    and the keys may not contain U+0000, since they are serialized a
+    zero-terminated c-strings.
+
+    @throw out_of_range.407  if `j.is_number_unsigned() && j.get<std::uint64_t>() > 9223372036854775807`
+    @throw out_of_range.409  if a key in `j` contains a NULL (U+0000)
+    @throw type_error.317    if `!j.is_object()`
+
+    @pre The input `j` is required to be an object: `j.is_object() == true`.
+
+    @note Any BSON output created via @ref to_bson can be successfully parsed
+          by @ref from_bson.
+
+    @param[in] j  JSON value to serialize
+    @return BSON serialization as byte vector
+
+    @complexity Linear in the size of the JSON value @a j.
+
+    @liveexample{The example shows the serialization of a JSON value to a byte
+    vector in BSON format.,to_bson}
+
+    @sa http://bsonspec.org/spec.html
+    @sa see @ref from_bson(detail::input_adapter&&, const bool strict) for the
+        analogous deserialization
+    @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the
+             related UBJSON format
+    @sa see @ref to_cbor(const basic_json&) for the related CBOR format
+    @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format
+    */
+    static std::vector<std::uint8_t> to_bson(const basic_json& j)
+    {
+        std::vector<std::uint8_t> result;
+        to_bson(j, result);
+        return result;
+    }
+
+    /*!
+    @brief Serializes the given JSON object `j` to BSON and forwards the
+           corresponding BSON-representation to the given output_adapter `o`.
+    @param j The JSON object to convert to BSON.
+    @param o The output adapter that receives the binary BSON representation.
+    @pre The input `j` shall be an object: `j.is_object() == true`
+    @sa see @ref to_bson(const basic_json&)
+    */
+    static void to_bson(const basic_json& j, detail::output_adapter<std::uint8_t> o)
+    {
+        binary_writer<std::uint8_t>(o).write_bson(j);
+    }
+
+    /*!
+    @copydoc to_bson(const basic_json&, detail::output_adapter<std::uint8_t>)
+    */
+    static void to_bson(const basic_json& j, detail::output_adapter<char> o)
+    {
+        binary_writer<char>(o).write_bson(j);
+    }
+
+
+    /*!
+    @brief create a JSON value from an input in CBOR format
+
+    Deserializes a given input @a i to a JSON value using the CBOR (Concise
+    Binary Object Representation) serialization format.
+
+    The library maps CBOR types to JSON value types as follows:
+
+    CBOR type              | JSON value type | first byte
+    ---------------------- | --------------- | ----------
+    Integer                | number_unsigned | 0x00..0x17
+    Unsigned integer       | number_unsigned | 0x18
+    Unsigned integer       | number_unsigned | 0x19
+    Unsigned integer       | number_unsigned | 0x1A
+    Unsigned integer       | number_unsigned | 0x1B
+    Negative integer       | number_integer  | 0x20..0x37
+    Negative integer       | number_integer  | 0x38
+    Negative integer       | number_integer  | 0x39
+    Negative integer       | number_integer  | 0x3A
+    Negative integer       | number_integer  | 0x3B
+    Byte string            | binary          | 0x40..0x57
+    Byte string            | binary          | 0x58
+    Byte string            | binary          | 0x59
+    Byte string            | binary          | 0x5A
+    Byte string            | binary          | 0x5B
+    UTF-8 string           | string          | 0x60..0x77
+    UTF-8 string           | string          | 0x78
+    UTF-8 string           | string          | 0x79
+    UTF-8 string           | string          | 0x7A
+    UTF-8 string           | string          | 0x7B
+    UTF-8 string           | string          | 0x7F
+    array                  | array           | 0x80..0x97
+    array                  | array           | 0x98
+    array                  | array           | 0x99
+    array                  | array           | 0x9A
+    array                  | array           | 0x9B
+    array                  | array           | 0x9F
+    map                    | object          | 0xA0..0xB7
+    map                    | object          | 0xB8
+    map                    | object          | 0xB9
+    map                    | object          | 0xBA
+    map                    | object          | 0xBB
+    map                    | object          | 0xBF
+    False                  | `false`         | 0xF4
+    True                   | `true`          | 0xF5
+    Null                   | `null`          | 0xF6
+    Half-Precision Float   | number_float    | 0xF9
+    Single-Precision Float | number_float    | 0xFA
+    Double-Precision Float | number_float    | 0xFB
+
+    @warning The mapping is **incomplete** in the sense that not all CBOR
+             types can be converted to a JSON value. The following CBOR types
+             are not supported and will yield parse errors (parse_error.112):
+             - date/time (0xC0..0xC1)
+             - bignum (0xC2..0xC3)
+             - decimal fraction (0xC4)
+             - bigfloat (0xC5)
+             - expected conversions (0xD5..0xD7)
+             - simple values (0xE0..0xF3, 0xF8)
+             - undefined (0xF7)
+
+    @warning CBOR allows map keys of any type, whereas JSON only allows
+             strings as keys in object values. Therefore, CBOR maps with keys
+             other than UTF-8 strings are rejected (parse_error.113).
+
+    @note Any CBOR output created @ref to_cbor can be successfully parsed by
+          @ref from_cbor.
+
+    @param[in] i  an input in CBOR format convertible to an input adapter
+    @param[in] strict  whether to expect the input to be consumed until EOF
+                       (true by default)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+    @param[in] tag_handler how to treat CBOR tags (optional, error by default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.110 if the given input ends prematurely or the end of
+    file was not reached when @a strict was set to true
+    @throw parse_error.112 if unsupported features from CBOR were
+    used in the given input @a v or if the input is not valid CBOR
+    @throw parse_error.113 if a string was expected as map key, but not found
+
+    @complexity Linear in the size of the input @a i.
+
+    @liveexample{The example shows the deserialization of a byte vector in CBOR
+    format to a JSON value.,from_cbor}
+
+    @sa http://cbor.io
+    @sa see @ref to_cbor(const basic_json&) for the analogous serialization
+    @sa see @ref from_msgpack(InputType&&, const bool, const bool) for the
+        related MessagePack format
+    @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the
+        related UBJSON format
+
+    @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
+           consume input adapters, removed start_index parameter, and added
+           @a strict parameter since 3.0.0; added @a allow_exceptions parameter
+           since 3.2.0; added @a tag_handler parameter since 3.9.0.
+    */
+    template<typename InputType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_cbor(InputType&& i,
+                                const bool strict = true,
+                                const bool allow_exceptions = true,
+                                const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::forward<InputType>(i));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    /*!
+    @copydoc from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t)
+    */
+    template<typename IteratorType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_cbor(IteratorType first, IteratorType last,
+                                const bool strict = true,
+                                const bool allow_exceptions = true,
+                                const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::move(first), std::move(last));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    template<typename T>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
+    static basic_json from_cbor(const T* ptr, std::size_t len,
+                                const bool strict = true,
+                                const bool allow_exceptions = true,
+                                const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
+    {
+        return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
+    }
+
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len))
+    static basic_json from_cbor(detail::span_input_adapter&& i,
+                                const bool strict = true,
+                                const bool allow_exceptions = true,
+                                const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = i.get();
+        // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    /*!
+    @brief create a JSON value from an input in MessagePack format
+
+    Deserializes a given input @a i to a JSON value using the MessagePack
+    serialization format.
+
+    The library maps MessagePack types to JSON value types as follows:
+
+    MessagePack type | JSON value type | first byte
+    ---------------- | --------------- | ----------
+    positive fixint  | number_unsigned | 0x00..0x7F
+    fixmap           | object          | 0x80..0x8F
+    fixarray         | array           | 0x90..0x9F
+    fixstr           | string          | 0xA0..0xBF
+    nil              | `null`          | 0xC0
+    false            | `false`         | 0xC2
+    true             | `true`          | 0xC3
+    float 32         | number_float    | 0xCA
+    float 64         | number_float    | 0xCB
+    uint 8           | number_unsigned | 0xCC
+    uint 16          | number_unsigned | 0xCD
+    uint 32          | number_unsigned | 0xCE
+    uint 64          | number_unsigned | 0xCF
+    int 8            | number_integer  | 0xD0
+    int 16           | number_integer  | 0xD1
+    int 32           | number_integer  | 0xD2
+    int 64           | number_integer  | 0xD3
+    str 8            | string          | 0xD9
+    str 16           | string          | 0xDA
+    str 32           | string          | 0xDB
+    array 16         | array           | 0xDC
+    array 32         | array           | 0xDD
+    map 16           | object          | 0xDE
+    map 32           | object          | 0xDF
+    bin 8            | binary          | 0xC4
+    bin 16           | binary          | 0xC5
+    bin 32           | binary          | 0xC6
+    ext 8            | binary          | 0xC7
+    ext 16           | binary          | 0xC8
+    ext 32           | binary          | 0xC9
+    fixext 1         | binary          | 0xD4
+    fixext 2         | binary          | 0xD5
+    fixext 4         | binary          | 0xD6
+    fixext 8         | binary          | 0xD7
+    fixext 16        | binary          | 0xD8
+    negative fixint  | number_integer  | 0xE0-0xFF
+
+    @note Any MessagePack output created @ref to_msgpack can be successfully
+          parsed by @ref from_msgpack.
+
+    @param[in] i  an input in MessagePack format convertible to an input
+                  adapter
+    @param[in] strict  whether to expect the input to be consumed until EOF
+                       (true by default)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.110 if the given input ends prematurely or the end of
+    file was not reached when @a strict was set to true
+    @throw parse_error.112 if unsupported features from MessagePack were
+    used in the given input @a i or if the input is not valid MessagePack
+    @throw parse_error.113 if a string was expected as map key, but not found
+
+    @complexity Linear in the size of the input @a i.
+
+    @liveexample{The example shows the deserialization of a byte vector in
+    MessagePack format to a JSON value.,from_msgpack}
+
+    @sa http://msgpack.org
+    @sa see @ref to_msgpack(const basic_json&) for the analogous serialization
+    @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the
+        related CBOR format
+    @sa see @ref from_ubjson(InputType&&, const bool, const bool) for
+        the related UBJSON format
+    @sa see @ref from_bson(InputType&&, const bool, const bool) for
+        the related BSON format
+
+    @since version 2.0.9; parameter @a start_index since 2.1.1; changed to
+           consume input adapters, removed start_index parameter, and added
+           @a strict parameter since 3.0.0; added @a allow_exceptions parameter
+           since 3.2.0
+    */
+    template<typename InputType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_msgpack(InputType&& i,
+                                   const bool strict = true,
+                                   const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::forward<InputType>(i));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    /*!
+    @copydoc from_msgpack(InputType&&, const bool, const bool)
+    */
+    template<typename IteratorType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_msgpack(IteratorType first, IteratorType last,
+                                   const bool strict = true,
+                                   const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::move(first), std::move(last));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+
+    template<typename T>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
+    static basic_json from_msgpack(const T* ptr, std::size_t len,
+                                   const bool strict = true,
+                                   const bool allow_exceptions = true)
+    {
+        return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
+    }
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len))
+    static basic_json from_msgpack(detail::span_input_adapter&& i,
+                                   const bool strict = true,
+                                   const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = i.get();
+        // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+
+    /*!
+    @brief create a JSON value from an input in UBJSON format
+
+    Deserializes a given input @a i to a JSON value using the UBJSON (Universal
+    Binary JSON) serialization format.
+
+    The library maps UBJSON types to JSON value types as follows:
+
+    UBJSON type | JSON value type                         | marker
+    ----------- | --------------------------------------- | ------
+    no-op       | *no value, next value is read*          | `N`
+    null        | `null`                                  | `Z`
+    false       | `false`                                 | `F`
+    true        | `true`                                  | `T`
+    float32     | number_float                            | `d`
+    float64     | number_float                            | `D`
+    uint8       | number_unsigned                         | `U`
+    int8        | number_integer                          | `i`
+    int16       | number_integer                          | `I`
+    int32       | number_integer                          | `l`
+    int64       | number_integer                          | `L`
+    high-precision number | number_integer, number_unsigned, or number_float - depends on number string | 'H'
+    string      | string                                  | `S`
+    char        | string                                  | `C`
+    array       | array (optimized values are supported)  | `[`
+    object      | object (optimized values are supported) | `{`
+
+    @note The mapping is **complete** in the sense that any UBJSON value can
+          be converted to a JSON value.
+
+    @param[in] i  an input in UBJSON format convertible to an input adapter
+    @param[in] strict  whether to expect the input to be consumed until EOF
+                       (true by default)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.110 if the given input ends prematurely or the end of
+    file was not reached when @a strict was set to true
+    @throw parse_error.112 if a parse error occurs
+    @throw parse_error.113 if a string could not be parsed successfully
+
+    @complexity Linear in the size of the input @a i.
+
+    @liveexample{The example shows the deserialization of a byte vector in
+    UBJSON format to a JSON value.,from_ubjson}
+
+    @sa http://ubjson.org
+    @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the
+             analogous serialization
+    @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the
+        related CBOR format
+    @sa see @ref from_msgpack(InputType&&, const bool, const bool) for
+        the related MessagePack format
+    @sa see @ref from_bson(InputType&&, const bool, const bool) for
+        the related BSON format
+
+    @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0
+    */
+    template<typename InputType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_ubjson(InputType&& i,
+                                  const bool strict = true,
+                                  const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::forward<InputType>(i));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    /*!
+    @copydoc from_ubjson(InputType&&, const bool, const bool)
+    */
+    template<typename IteratorType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_ubjson(IteratorType first, IteratorType last,
+                                  const bool strict = true,
+                                  const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::move(first), std::move(last));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    template<typename T>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
+    static basic_json from_ubjson(const T* ptr, std::size_t len,
+                                  const bool strict = true,
+                                  const bool allow_exceptions = true)
+    {
+        return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
+    }
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len))
+    static basic_json from_ubjson(detail::span_input_adapter&& i,
+                                  const bool strict = true,
+                                  const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = i.get();
+        // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+
+    /*!
+    @brief Create a JSON value from an input in BSON format
+
+    Deserializes a given input @a i to a JSON value using the BSON (Binary JSON)
+    serialization format.
+
+    The library maps BSON record types to JSON value types as follows:
+
+    BSON type       | BSON marker byte | JSON value type
+    --------------- | ---------------- | ---------------------------
+    double          | 0x01             | number_float
+    string          | 0x02             | string
+    document        | 0x03             | object
+    array           | 0x04             | array
+    binary          | 0x05             | binary
+    undefined       | 0x06             | still unsupported
+    ObjectId        | 0x07             | still unsupported
+    boolean         | 0x08             | boolean
+    UTC Date-Time   | 0x09             | still unsupported
+    null            | 0x0A             | null
+    Regular Expr.   | 0x0B             | still unsupported
+    DB Pointer      | 0x0C             | still unsupported
+    JavaScript Code | 0x0D             | still unsupported
+    Symbol          | 0x0E             | still unsupported
+    JavaScript Code | 0x0F             | still unsupported
+    int32           | 0x10             | number_integer
+    Timestamp       | 0x11             | still unsupported
+    128-bit decimal float | 0x13       | still unsupported
+    Max Key         | 0x7F             | still unsupported
+    Min Key         | 0xFF             | still unsupported
+
+    @warning The mapping is **incomplete**. The unsupported mappings
+             are indicated in the table above.
+
+    @param[in] i  an input in BSON format convertible to an input adapter
+    @param[in] strict  whether to expect the input to be consumed until EOF
+                       (true by default)
+    @param[in] allow_exceptions  whether to throw exceptions in case of a
+    parse error (optional, true by default)
+
+    @return deserialized JSON value; in case of a parse error and
+            @a allow_exceptions set to `false`, the return value will be
+            value_t::discarded.
+
+    @throw parse_error.114 if an unsupported BSON record type is encountered
+
+    @complexity Linear in the size of the input @a i.
+
+    @liveexample{The example shows the deserialization of a byte vector in
+    BSON format to a JSON value.,from_bson}
+
+    @sa http://bsonspec.org/spec.html
+    @sa see @ref to_bson(const basic_json&) for the analogous serialization
+    @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the
+        related CBOR format
+    @sa see @ref from_msgpack(InputType&&, const bool, const bool) for
+        the related MessagePack format
+    @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the
+        related UBJSON format
+    */
+    template<typename InputType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_bson(InputType&& i,
+                                const bool strict = true,
+                                const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::forward<InputType>(i));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    /*!
+    @copydoc from_bson(InputType&&, const bool, const bool)
+    */
+    template<typename IteratorType>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json from_bson(IteratorType first, IteratorType last,
+                                const bool strict = true,
+                                const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = detail::input_adapter(std::move(first), std::move(last));
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+
+    template<typename T>
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
+    static basic_json from_bson(const T* ptr, std::size_t len,
+                                const bool strict = true,
+                                const bool allow_exceptions = true)
+    {
+        return from_bson(ptr, ptr + len, strict, allow_exceptions);
+    }
+
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len))
+    static basic_json from_bson(detail::span_input_adapter&& i,
+                                const bool strict = true,
+                                const bool allow_exceptions = true)
+    {
+        basic_json result;
+        detail::json_sax_dom_parser<basic_json> sdp(result, allow_exceptions);
+        auto ia = i.get();
+        // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg)
+        const bool res = binary_reader<decltype(ia)>(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict);
+        return res ? result : basic_json(value_t::discarded);
+    }
+    /// @}
+
+    //////////////////////////
+    // JSON Pointer support //
+    //////////////////////////
+
+    /// @name JSON Pointer functions
+    /// @{
+
+    /*!
+    @brief access specified element via JSON Pointer
+
+    Uses a JSON pointer to retrieve a reference to the respective JSON value.
+    No bound checking is performed. Similar to @ref operator[](const typename
+    object_t::key_type&), `null` values are created in arrays and objects if
+    necessary.
+
+    In particular:
+    - If the JSON pointer points to an object key that does not exist, it
+      is created an filled with a `null` value before a reference to it
+      is returned.
+    - If the JSON pointer points to an array index that does not exist, it
+      is created an filled with a `null` value before a reference to it
+      is returned. All indices between the current maximum and the given
+      index are also filled with `null`.
+    - The special value `-` is treated as a synonym for the index past the
+      end.
+
+    @param[in] ptr  a JSON pointer
+
+    @return reference to the element pointed to by @a ptr
+
+    @complexity Constant.
+
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+
+    @liveexample{The behavior is shown in the example.,operatorjson_pointer}
+
+    @since version 2.0.0
+    */
+    reference operator[](const json_pointer& ptr)
+    {
+        return ptr.get_unchecked(this);
+    }
+
+    /*!
+    @brief access specified element via JSON Pointer
+
+    Uses a JSON pointer to retrieve a reference to the respective JSON value.
+    No bound checking is performed. The function does not change the JSON
+    value; no `null` values are created. In particular, the special value
+    `-` yields an exception.
+
+    @param[in] ptr  JSON pointer to the desired element
+
+    @return const reference to the element pointed to by @a ptr
+
+    @complexity Constant.
+
+    @throw parse_error.106   if an array index begins with '0'
+    @throw parse_error.109   if an array index was not a number
+    @throw out_of_range.402  if the array index '-' is used
+    @throw out_of_range.404  if the JSON pointer can not be resolved
+
+    @liveexample{The behavior is shown in the example.,operatorjson_pointer_const}
+
+    @since version 2.0.0
+    */
+    const_reference operator[](const json_pointer& ptr) const
+    {
+        return ptr.get_unchecked(this);
+    }
+
+    /*!
+    @brief access specified element via JSON Pointer
+
+    Returns a reference to the element at with specified JSON pointer @a ptr,
+    with bounds checking.
+
+    @param[in] ptr  JSON pointer to the desired element
+
+    @return reference to the element pointed to by @a ptr
+
+    @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
+    begins with '0'. See example below.
+
+    @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
+    is not a number. See example below.
+
+    @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
+    is out of range. See example below.
+
+    @throw out_of_range.402 if the array index '-' is used in the passed JSON
+    pointer @a ptr. As `at` provides checked access (and no elements are
+    implicitly inserted), the index '-' is always invalid. See example below.
+
+    @throw out_of_range.403 if the JSON pointer describes a key of an object
+    which cannot be found. See example below.
+
+    @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
+    See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @since version 2.0.0
+
+    @liveexample{The behavior is shown in the example.,at_json_pointer}
+    */
+    reference at(const json_pointer& ptr)
+    {
+        return ptr.get_checked(this);
+    }
+
+    /*!
+    @brief access specified element via JSON Pointer
+
+    Returns a const reference to the element at with specified JSON pointer @a
+    ptr, with bounds checking.
+
+    @param[in] ptr  JSON pointer to the desired element
+
+    @return reference to the element pointed to by @a ptr
+
+    @throw parse_error.106 if an array index in the passed JSON pointer @a ptr
+    begins with '0'. See example below.
+
+    @throw parse_error.109 if an array index in the passed JSON pointer @a ptr
+    is not a number. See example below.
+
+    @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr
+    is out of range. See example below.
+
+    @throw out_of_range.402 if the array index '-' is used in the passed JSON
+    pointer @a ptr. As `at` provides checked access (and no elements are
+    implicitly inserted), the index '-' is always invalid. See example below.
+
+    @throw out_of_range.403 if the JSON pointer describes a key of an object
+    which cannot be found. See example below.
+
+    @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved.
+    See example below.
+
+    @exceptionsafety Strong guarantee: if an exception is thrown, there are no
+    changes in the JSON value.
+
+    @complexity Constant.
+
+    @since version 2.0.0
+
+    @liveexample{The behavior is shown in the example.,at_json_pointer_const}
+    */
+    const_reference at(const json_pointer& ptr) const
+    {
+        return ptr.get_checked(this);
+    }
+
+    /*!
+    @brief return flattened JSON value
+
+    The function creates a JSON object whose keys are JSON pointers (see [RFC
+    6901](https://tools.ietf.org/html/rfc6901)) and whose values are all
+    primitive. The original JSON value can be restored using the @ref
+    unflatten() function.
+
+    @return an object that maps JSON pointers to primitive values
+
+    @note Empty objects and arrays are flattened to `null` and will not be
+          reconstructed correctly by the @ref unflatten() function.
+
+    @complexity Linear in the size the JSON value.
+
+    @liveexample{The following code shows how a JSON object is flattened to an
+    object whose keys consist of JSON pointers.,flatten}
+
+    @sa see @ref unflatten() for the reverse function
+
+    @since version 2.0.0
+    */
+    basic_json flatten() const
+    {
+        basic_json result(value_t::object);
+        json_pointer::flatten("", *this, result);
+        return result;
+    }
+
+    /*!
+    @brief unflatten a previously flattened JSON value
+
+    The function restores the arbitrary nesting of a JSON value that has been
+    flattened before using the @ref flatten() function. The JSON value must
+    meet certain constraints:
+    1. The value must be an object.
+    2. The keys must be JSON pointers (see
+       [RFC 6901](https://tools.ietf.org/html/rfc6901))
+    3. The mapped values must be primitive JSON types.
+
+    @return the original JSON from a flattened version
+
+    @note Empty objects and arrays are flattened by @ref flatten() to `null`
+          values and can not unflattened to their original type. Apart from
+          this example, for a JSON value `j`, the following is always true:
+          `j == j.flatten().unflatten()`.
+
+    @complexity Linear in the size the JSON value.
+
+    @throw type_error.314  if value is not an object
+    @throw type_error.315  if object values are not primitive
+
+    @liveexample{The following code shows how a flattened JSON object is
+    unflattened into the original nested JSON object.,unflatten}
+
+    @sa see @ref flatten() for the reverse function
+
+    @since version 2.0.0
+    */
+    basic_json unflatten() const
+    {
+        return json_pointer::unflatten(*this);
+    }
+
+    /// @}
+
+    //////////////////////////
+    // JSON Patch functions //
+    //////////////////////////
+
+    /// @name JSON Patch functions
+    /// @{
+
+    /*!
+    @brief applies a JSON patch
+
+    [JSON Patch](http://jsonpatch.com) defines a JSON document structure for
+    expressing a sequence of operations to apply to a JSON) document. With
+    this function, a JSON Patch is applied to the current JSON value by
+    executing all operations from the patch.
+
+    @param[in] json_patch  JSON patch document
+    @return patched document
+
+    @note The application of a patch is atomic: Either all operations succeed
+          and the patched document is returned or an exception is thrown. In
+          any case, the original value is not changed: the patch is applied
+          to a copy of the value.
+
+    @throw parse_error.104 if the JSON patch does not consist of an array of
+    objects
+
+    @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory
+    attributes are missing); example: `"operation add must have member path"`
+
+    @throw out_of_range.401 if an array index is out of range.
+
+    @throw out_of_range.403 if a JSON pointer inside the patch could not be
+    resolved successfully in the current JSON value; example: `"key baz not
+    found"`
+
+    @throw out_of_range.405 if JSON pointer has no parent ("add", "remove",
+    "move")
+
+    @throw other_error.501 if "test" operation was unsuccessful
+
+    @complexity Linear in the size of the JSON value and the length of the
+    JSON patch. As usually only a fraction of the JSON value is affected by
+    the patch, the complexity can usually be neglected.
+
+    @liveexample{The following code shows how a JSON patch is applied to a
+    value.,patch}
+
+    @sa see @ref diff -- create a JSON patch by comparing two JSON values
+
+    @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
+    @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901)
+
+    @since version 2.0.0
+    */
+    basic_json patch(const basic_json& json_patch) const
+    {
+        // make a working copy to apply the patch to
+        basic_json result = *this;
+
+        // the valid JSON Patch operations
+        enum class patch_operations {add, remove, replace, move, copy, test, invalid};
+
+        const auto get_op = [](const std::string & op)
+        {
+            if (op == "add")
+            {
+                return patch_operations::add;
+            }
+            if (op == "remove")
+            {
+                return patch_operations::remove;
+            }
+            if (op == "replace")
+            {
+                return patch_operations::replace;
+            }
+            if (op == "move")
+            {
+                return patch_operations::move;
+            }
+            if (op == "copy")
+            {
+                return patch_operations::copy;
+            }
+            if (op == "test")
+            {
+                return patch_operations::test;
+            }
+
+            return patch_operations::invalid;
+        };
+
+        // wrapper for "add" operation; add value at ptr
+        const auto operation_add = [&result](json_pointer & ptr, basic_json val)
+        {
+            // adding to the root of the target document means replacing it
+            if (ptr.empty())
+            {
+                result = val;
+                return;
+            }
+
+            // make sure the top element of the pointer exists
+            json_pointer top_pointer = ptr.top();
+            if (top_pointer != ptr)
+            {
+                result.at(top_pointer);
+            }
+
+            // get reference to parent of JSON pointer ptr
+            const auto last_path = ptr.back();
+            ptr.pop_back();
+            basic_json& parent = result[ptr];
+
+            switch (parent.m_type)
+            {
+                case value_t::null:
+                case value_t::object:
+                {
+                    // use operator[] to add value
+                    parent[last_path] = val;
+                    break;
+                }
+
+                case value_t::array:
+                {
+                    if (last_path == "-")
+                    {
+                        // special case: append to back
+                        parent.push_back(val);
+                    }
+                    else
+                    {
+                        const auto idx = json_pointer::array_index(last_path);
+                        if (JSON_HEDLEY_UNLIKELY(idx > parent.size()))
+                        {
+                            // avoid undefined behavior
+                            JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", parent));
+                        }
+
+                        // default case: insert add offset
+                        parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
+                    }
+                    break;
+                }
+
+                // if there exists a parent it cannot be primitive
+                case value_t::string: // LCOV_EXCL_LINE
+                case value_t::boolean: // LCOV_EXCL_LINE
+                case value_t::number_integer: // LCOV_EXCL_LINE
+                case value_t::number_unsigned: // LCOV_EXCL_LINE
+                case value_t::number_float: // LCOV_EXCL_LINE
+                case value_t::binary: // LCOV_EXCL_LINE
+                case value_t::discarded: // LCOV_EXCL_LINE
+                default:            // LCOV_EXCL_LINE
+                    JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
+            }
+        };
+
+        // wrapper for "remove" operation; remove value at ptr
+        const auto operation_remove = [this, &result](json_pointer & ptr)
+        {
+            // get reference to parent of JSON pointer ptr
+            const auto last_path = ptr.back();
+            ptr.pop_back();
+            basic_json& parent = result.at(ptr);
+
+            // remove child
+            if (parent.is_object())
+            {
+                // perform range check
+                auto it = parent.find(last_path);
+                if (JSON_HEDLEY_LIKELY(it != parent.end()))
+                {
+                    parent.erase(it);
+                }
+                else
+                {
+                    JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found", *this));
+                }
+            }
+            else if (parent.is_array())
+            {
+                // note erase performs range check
+                parent.erase(json_pointer::array_index(last_path));
+            }
+        };
+
+        // type check: top level value must be an array
+        if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array()))
+        {
+            JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", json_patch));
+        }
+
+        // iterate and apply the operations
+        for (const auto& val : json_patch)
+        {
+            // wrapper to get a value for an operation
+            const auto get_value = [&val](const std::string & op,
+                                          const std::string & member,
+                                          bool string_type) -> basic_json &
+            {
+                // find value
+                auto it = val.m_value.object->find(member);
+
+                // context-sensitive error message
+                const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
+
+                // check if desired value is present
+                if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end()))
+                {
+                    // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
+                    JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'", val));
+                }
+
+                // check if result is of type string
+                if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
+                {
+                    // NOLINTNEXTLINE(performance-inefficient-string-concatenation)
+                    JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'", val));
+                }
+
+                // no error: return value
+                return it->second;
+            };
+
+            // type check: every element of the array must be an object
+            if (JSON_HEDLEY_UNLIKELY(!val.is_object()))
+            {
+                JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", val));
+            }
+
+            // collect mandatory members
+            const auto op = get_value("op", "op", true).template get<std::string>();
+            const auto path = get_value(op, "path", true).template get<std::string>();
+            json_pointer ptr(path);
+
+            switch (get_op(op))
+            {
+                case patch_operations::add:
+                {
+                    operation_add(ptr, get_value("add", "value", false));
+                    break;
+                }
+
+                case patch_operations::remove:
+                {
+                    operation_remove(ptr);
+                    break;
+                }
+
+                case patch_operations::replace:
+                {
+                    // the "path" location must exist - use at()
+                    result.at(ptr) = get_value("replace", "value", false);
+                    break;
+                }
+
+                case patch_operations::move:
+                {
+                    const auto from_path = get_value("move", "from", true).template get<std::string>();
+                    json_pointer from_ptr(from_path);
+
+                    // the "from" location must exist - use at()
+                    basic_json v = result.at(from_ptr);
+
+                    // The move operation is functionally identical to a
+                    // "remove" operation on the "from" location, followed
+                    // immediately by an "add" operation at the target
+                    // location with the value that was just removed.
+                    operation_remove(from_ptr);
+                    operation_add(ptr, v);
+                    break;
+                }
+
+                case patch_operations::copy:
+                {
+                    const auto from_path = get_value("copy", "from", true).template get<std::string>();
+                    const json_pointer from_ptr(from_path);
+
+                    // the "from" location must exist - use at()
+                    basic_json v = result.at(from_ptr);
+
+                    // The copy is functionally identical to an "add"
+                    // operation at the target location using the value
+                    // specified in the "from" member.
+                    operation_add(ptr, v);
+                    break;
+                }
+
+                case patch_operations::test:
+                {
+                    bool success = false;
+                    JSON_TRY
+                    {
+                        // check if "value" matches the one at "path"
+                        // the "path" location must exist - use at()
+                        success = (result.at(ptr) == get_value("test", "value", false));
+                    }
+                    JSON_INTERNAL_CATCH (out_of_range&)
+                    {
+                        // ignore out of range errors: success remains false
+                    }
+
+                    // throw an exception if test fails
+                    if (JSON_HEDLEY_UNLIKELY(!success))
+                    {
+                        JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump(), val));
+                    }
+
+                    break;
+                }
+
+                case patch_operations::invalid:
+                default:
+                {
+                    // op must be "add", "remove", "replace", "move", "copy", or
+                    // "test"
+                    JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid", val));
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /*!
+    @brief creates a diff as a JSON patch
+
+    Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can
+    be changed into the value @a target by calling @ref patch function.
+
+    @invariant For two JSON values @a source and @a target, the following code
+    yields always `true`:
+    @code {.cpp}
+    source.patch(diff(source, target)) == target;
+    @endcode
+
+    @note Currently, only `remove`, `add`, and `replace` operations are
+          generated.
+
+    @param[in] source  JSON value to compare from
+    @param[in] target  JSON value to compare against
+    @param[in] path    helper value to create JSON pointers
+
+    @return a JSON patch to convert the @a source to @a target
+
+    @complexity Linear in the lengths of @a source and @a target.
+
+    @liveexample{The following code shows how a JSON patch is created as a
+    diff for two JSON values.,diff}
+
+    @sa see @ref patch -- apply a JSON patch
+    @sa see @ref merge_patch -- apply a JSON Merge Patch
+
+    @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902)
+
+    @since version 2.0.0
+    */
+    JSON_HEDLEY_WARN_UNUSED_RESULT
+    static basic_json diff(const basic_json& source, const basic_json& target,
+                           const std::string& path = "")
+    {
+        // the patch
+        basic_json result(value_t::array);
+
+        // if the values are the same, return empty patch
+        if (source == target)
+        {
+            return result;
+        }
+
+        if (source.type() != target.type())
+        {
+            // different types: replace value
+            result.push_back(
+            {
+                {"op", "replace"}, {"path", path}, {"value", target}
+            });
+            return result;
+        }
+
+        switch (source.type())
+        {
+            case value_t::array:
+            {
+                // first pass: traverse common elements
+                std::size_t i = 0;
+                while (i < source.size() && i < target.size())
+                {
+                    // recursive call to compare array values at index i
+                    auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
+                    result.insert(result.end(), temp_diff.begin(), temp_diff.end());
+                    ++i;
+                }
+
+                // i now reached the end of at least one array
+                // in a second pass, traverse the remaining elements
+
+                // remove my remaining elements
+                const auto end_index = static_cast<difference_type>(result.size());
+                while (i < source.size())
+                {
+                    // add operations in reverse order to avoid invalid
+                    // indices
+                    result.insert(result.begin() + end_index, object(
+                    {
+                        {"op", "remove"},
+                        {"path", path + "/" + std::to_string(i)}
+                    }));
+                    ++i;
+                }
+
+                // add other remaining elements
+                while (i < target.size())
+                {
+                    result.push_back(
+                    {
+                        {"op", "add"},
+                        {"path", path + "/-"},
+                        {"value", target[i]}
+                    });
+                    ++i;
+                }
+
+                break;
+            }
+
+            case value_t::object:
+            {
+                // first pass: traverse this object's elements
+                for (auto it = source.cbegin(); it != source.cend(); ++it)
+                {
+                    // escape the key name to be used in a JSON patch
+                    const auto path_key = path + "/" + detail::escape(it.key());
+
+                    if (target.find(it.key()) != target.end())
+                    {
+                        // recursive call to compare object values at key it
+                        auto temp_diff = diff(it.value(), target[it.key()], path_key);
+                        result.insert(result.end(), temp_diff.begin(), temp_diff.end());
+                    }
+                    else
+                    {
+                        // found a key that is not in o -> remove it
+                        result.push_back(object(
+                        {
+                            {"op", "remove"}, {"path", path_key}
+                        }));
+                    }
+                }
+
+                // second pass: traverse other object's elements
+                for (auto it = target.cbegin(); it != target.cend(); ++it)
+                {
+                    if (source.find(it.key()) == source.end())
+                    {
+                        // found a key that is not in this -> add it
+                        const auto path_key = path + "/" + detail::escape(it.key());
+                        result.push_back(
+                        {
+                            {"op", "add"}, {"path", path_key},
+                            {"value", it.value()}
+                        });
+                    }
+                }
+
+                break;
+            }
+
+            case value_t::null:
+            case value_t::string:
+            case value_t::boolean:
+            case value_t::number_integer:
+            case value_t::number_unsigned:
+            case value_t::number_float:
+            case value_t::binary:
+            case value_t::discarded:
+            default:
+            {
+                // both primitive type: replace value
+                result.push_back(
+                {
+                    {"op", "replace"}, {"path", path}, {"value", target}
+                });
+                break;
+            }
+        }
+
+        return result;
+    }
+
+    /// @}
+
+    ////////////////////////////////
+    // JSON Merge Patch functions //
+    ////////////////////////////////
+
+    /// @name JSON Merge Patch functions
+    /// @{
+
+    /*!
+    @brief applies a JSON Merge Patch
+
+    The merge patch format is primarily intended for use with the HTTP PATCH
+    method as a means of describing a set of modifications to a target
+    resource's content. This function applies a merge patch to the current
+    JSON value.
+
+    The function implements the following algorithm from Section 2 of
+    [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396):
+
+    ```
+    define MergePatch(Target, Patch):
+      if Patch is an Object:
+        if Target is not an Object:
+          Target = {} // Ignore the contents and set it to an empty Object
+        for each Name/Value pair in Patch:
+          if Value is null:
+            if Name exists in Target:
+              remove the Name/Value pair from Target
+          else:
+            Target[Name] = MergePatch(Target[Name], Value)
+        return Target
+      else:
+        return Patch
+    ```
+
+    Thereby, `Target` is the current object; that is, the patch is applied to
+    the current value.
+
+    @param[in] apply_patch  the patch to apply
+
+    @complexity Linear in the lengths of @a patch.
+
+    @liveexample{The following code shows how a JSON Merge Patch is applied to
+    a JSON document.,merge_patch}
+
+    @sa see @ref patch -- apply a JSON patch
+    @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396)
+
+    @since version 3.0.0
+    */
+    void merge_patch(const basic_json& apply_patch)
+    {
+        if (apply_patch.is_object())
+        {
+            if (!is_object())
+            {
+                *this = object();
+            }
+            for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
+            {
+                if (it.value().is_null())
+                {
+                    erase(it.key());
+                }
+                else
+                {
+                    operator[](it.key()).merge_patch(it.value());
+                }
+            }
+        }
+        else
+        {
+            *this = apply_patch;
+        }
+    }
+
+    /// @}
+};
+
+/*!
+@brief user-defined to_string function for JSON values
+
+This function implements a user-defined to_string  for JSON objects.
+
+@param[in] j  a JSON object
+@return a std::string object
+*/
+
+NLOHMANN_BASIC_JSON_TPL_DECLARATION
+std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j)
+{
+    return j.dump();
+}
+} // namespace nlohmann
+
+///////////////////////
+// nonmember support //
+///////////////////////
+
+// specialization of std::swap, and std::hash
+namespace std
+{
+
+/// hash value for JSON objects
+template<>
+struct hash<nlohmann::json>
+{
+    /*!
+    @brief return a hash value for a JSON object
+
+    @since version 1.0.0
+    */
+    std::size_t operator()(const nlohmann::json& j) const
+    {
+        return nlohmann::detail::hash(j);
+    }
+};
+
+/// specialization for std::less<value_t>
+/// @note: do not remove the space after '<',
+///        see https://github.com/nlohmann/json/pull/679
+template<>
+struct less<::nlohmann::detail::value_t>
+{
+    /*!
+    @brief compare two value_t enum values
+    @since version 3.0.0
+    */
+    bool operator()(nlohmann::detail::value_t lhs,
+                    nlohmann::detail::value_t rhs) const noexcept
+    {
+        return nlohmann::detail::operator<(lhs, rhs);
+    }
+};
+
+// C++20 prohibit function specialization in the std namespace.
+#ifndef JSON_HAS_CPP_20
+
+/*!
+@brief exchanges the values of two JSON objects
+
+@since version 1.0.0
+*/
+template<>
+inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name)
+    is_nothrow_move_constructible<nlohmann::json>::value&&  // NOLINT(misc-redundant-expression)
+    is_nothrow_move_assignable<nlohmann::json>::value
+                              )
+{
+    j1.swap(j2);
+}
+
+#endif
+
+} // namespace std
+
+/*!
+@brief user-defined string literal for JSON values
+
+This operator implements a user-defined string literal for JSON objects. It
+can be used by adding `"_json"` to a string literal and returns a JSON object
+if no parse error occurred.
+
+@param[in] s  a string representation of a JSON object
+@param[in] n  the length of string @a s
+@return a JSON object
+
+@since version 1.0.0
+*/
+JSON_HEDLEY_NON_NULL(1)
+inline nlohmann::json operator "" _json(const char* s, std::size_t n)
+{
+    return nlohmann::json::parse(s, s + n);
+}
+
+/*!
+@brief user-defined string literal for JSON pointer
+
+This operator implements a user-defined string literal for JSON Pointers. It
+can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer
+object if no parse error occurred.
+
+@param[in] s  a string representation of a JSON Pointer
+@param[in] n  the length of string @a s
+@return a JSON pointer object
+
+@since version 2.0.0
+*/
+JSON_HEDLEY_NON_NULL(1)
+inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
+{
+    return nlohmann::json::json_pointer(std::string(s, n));
+}
+
+// #include <nlohmann/detail/macro_unscope.hpp>
+
+
+// restore clang diagnostic settings
+#if defined(__clang__)
+    #pragma clang diagnostic pop
+#endif
+
+// clean up
+#undef JSON_ASSERT
+#undef JSON_INTERNAL_CATCH
+#undef JSON_CATCH
+#undef JSON_THROW
+#undef JSON_TRY
+#undef JSON_PRIVATE_UNLESS_TESTED
+#undef JSON_HAS_CPP_11
+#undef JSON_HAS_CPP_14
+#undef JSON_HAS_CPP_17
+#undef JSON_HAS_CPP_20
+#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
+#undef NLOHMANN_BASIC_JSON_TPL
+#undef JSON_EXPLICIT
+#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
+
+// #include <nlohmann/thirdparty/hedley/hedley_undef.hpp>
+
+
+#undef JSON_HEDLEY_ALWAYS_INLINE
+#undef JSON_HEDLEY_ARM_VERSION
+#undef JSON_HEDLEY_ARM_VERSION_CHECK
+#undef JSON_HEDLEY_ARRAY_PARAM
+#undef JSON_HEDLEY_ASSUME
+#undef JSON_HEDLEY_BEGIN_C_DECLS
+#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
+#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
+#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
+#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
+#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
+#undef JSON_HEDLEY_CLANG_HAS_FEATURE
+#undef JSON_HEDLEY_CLANG_HAS_WARNING
+#undef JSON_HEDLEY_COMPCERT_VERSION
+#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
+#undef JSON_HEDLEY_CONCAT
+#undef JSON_HEDLEY_CONCAT3
+#undef JSON_HEDLEY_CONCAT3_EX
+#undef JSON_HEDLEY_CONCAT_EX
+#undef JSON_HEDLEY_CONST
+#undef JSON_HEDLEY_CONSTEXPR
+#undef JSON_HEDLEY_CONST_CAST
+#undef JSON_HEDLEY_CPP_CAST
+#undef JSON_HEDLEY_CRAY_VERSION
+#undef JSON_HEDLEY_CRAY_VERSION_CHECK
+#undef JSON_HEDLEY_C_DECL
+#undef JSON_HEDLEY_DEPRECATED
+#undef JSON_HEDLEY_DEPRECATED_FOR
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
+#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
+#undef JSON_HEDLEY_DIAGNOSTIC_POP
+#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
+#undef JSON_HEDLEY_DMC_VERSION
+#undef JSON_HEDLEY_DMC_VERSION_CHECK
+#undef JSON_HEDLEY_EMPTY_BASES
+#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
+#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
+#undef JSON_HEDLEY_END_C_DECLS
+#undef JSON_HEDLEY_FLAGS
+#undef JSON_HEDLEY_FLAGS_CAST
+#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
+#undef JSON_HEDLEY_GCC_HAS_BUILTIN
+#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
+#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
+#undef JSON_HEDLEY_GCC_HAS_EXTENSION
+#undef JSON_HEDLEY_GCC_HAS_FEATURE
+#undef JSON_HEDLEY_GCC_HAS_WARNING
+#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
+#undef JSON_HEDLEY_GCC_VERSION
+#undef JSON_HEDLEY_GCC_VERSION_CHECK
+#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
+#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
+#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
+#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
+#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
+#undef JSON_HEDLEY_GNUC_HAS_FEATURE
+#undef JSON_HEDLEY_GNUC_HAS_WARNING
+#undef JSON_HEDLEY_GNUC_VERSION
+#undef JSON_HEDLEY_GNUC_VERSION_CHECK
+#undef JSON_HEDLEY_HAS_ATTRIBUTE
+#undef JSON_HEDLEY_HAS_BUILTIN
+#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
+#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
+#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
+#undef JSON_HEDLEY_HAS_EXTENSION
+#undef JSON_HEDLEY_HAS_FEATURE
+#undef JSON_HEDLEY_HAS_WARNING
+#undef JSON_HEDLEY_IAR_VERSION
+#undef JSON_HEDLEY_IAR_VERSION_CHECK
+#undef JSON_HEDLEY_IBM_VERSION
+#undef JSON_HEDLEY_IBM_VERSION_CHECK
+#undef JSON_HEDLEY_IMPORT
+#undef JSON_HEDLEY_INLINE
+#undef JSON_HEDLEY_INTEL_CL_VERSION
+#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
+#undef JSON_HEDLEY_INTEL_VERSION
+#undef JSON_HEDLEY_INTEL_VERSION_CHECK
+#undef JSON_HEDLEY_IS_CONSTANT
+#undef JSON_HEDLEY_IS_CONSTEXPR_
+#undef JSON_HEDLEY_LIKELY
+#undef JSON_HEDLEY_MALLOC
+#undef JSON_HEDLEY_MCST_LCC_VERSION
+#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
+#undef JSON_HEDLEY_MESSAGE
+#undef JSON_HEDLEY_MSVC_VERSION
+#undef JSON_HEDLEY_MSVC_VERSION_CHECK
+#undef JSON_HEDLEY_NEVER_INLINE
+#undef JSON_HEDLEY_NON_NULL
+#undef JSON_HEDLEY_NO_ESCAPE
+#undef JSON_HEDLEY_NO_RETURN
+#undef JSON_HEDLEY_NO_THROW
+#undef JSON_HEDLEY_NULL
+#undef JSON_HEDLEY_PELLES_VERSION
+#undef JSON_HEDLEY_PELLES_VERSION_CHECK
+#undef JSON_HEDLEY_PGI_VERSION
+#undef JSON_HEDLEY_PGI_VERSION_CHECK
+#undef JSON_HEDLEY_PREDICT
+#undef JSON_HEDLEY_PRINTF_FORMAT
+#undef JSON_HEDLEY_PRIVATE
+#undef JSON_HEDLEY_PUBLIC
+#undef JSON_HEDLEY_PURE
+#undef JSON_HEDLEY_REINTERPRET_CAST
+#undef JSON_HEDLEY_REQUIRE
+#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
+#undef JSON_HEDLEY_REQUIRE_MSG
+#undef JSON_HEDLEY_RESTRICT
+#undef JSON_HEDLEY_RETURNS_NON_NULL
+#undef JSON_HEDLEY_SENTINEL
+#undef JSON_HEDLEY_STATIC_ASSERT
+#undef JSON_HEDLEY_STATIC_CAST
+#undef JSON_HEDLEY_STRINGIFY
+#undef JSON_HEDLEY_STRINGIFY_EX
+#undef JSON_HEDLEY_SUNPRO_VERSION
+#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
+#undef JSON_HEDLEY_TINYC_VERSION
+#undef JSON_HEDLEY_TINYC_VERSION_CHECK
+#undef JSON_HEDLEY_TI_ARMCL_VERSION
+#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
+#undef JSON_HEDLEY_TI_CL2000_VERSION
+#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
+#undef JSON_HEDLEY_TI_CL430_VERSION
+#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
+#undef JSON_HEDLEY_TI_CL6X_VERSION
+#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
+#undef JSON_HEDLEY_TI_CL7X_VERSION
+#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
+#undef JSON_HEDLEY_TI_CLPRU_VERSION
+#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
+#undef JSON_HEDLEY_TI_VERSION
+#undef JSON_HEDLEY_TI_VERSION_CHECK
+#undef JSON_HEDLEY_UNAVAILABLE
+#undef JSON_HEDLEY_UNLIKELY
+#undef JSON_HEDLEY_UNPREDICTABLE
+#undef JSON_HEDLEY_UNREACHABLE
+#undef JSON_HEDLEY_UNREACHABLE_RETURN
+#undef JSON_HEDLEY_VERSION
+#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
+#undef JSON_HEDLEY_VERSION_DECODE_MINOR
+#undef JSON_HEDLEY_VERSION_DECODE_REVISION
+#undef JSON_HEDLEY_VERSION_ENCODE
+#undef JSON_HEDLEY_WARNING
+#undef JSON_HEDLEY_WARN_UNUSED_RESULT
+#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
+#undef JSON_HEDLEY_FALL_THROUGH
+
+
+
+#endif  // INCLUDE_NLOHMANN_JSON_HPP_
ADD · third-party/metal-cpp +1 -0
--- a/third-party/metal-cpp
+++ b/third-party/metal-cpp
@@ -0,0 +1 @@
+Subproject commit 27c4382b7151d55a51692cdcb27aaa98752240de
ADD · third-party/mikktspace.c +1899 -0
--- a/third-party/mikktspace.c
+++ b/third-party/mikktspace.c
@@ -0,0 +1,1899 @@
+/** \file mikktspace/mikktspace.c
+ *  \ingroup mikktspace
+ */
+/**
+ *  Copyright (C) 2011 by Morten S. Mikkelsen
+ *
+ *  This software is provided 'as-is', without any express or implied
+ *  warranty.  In no event will the authors be held liable for any damages
+ *  arising from the use of this software.
+ *
+ *  Permission is granted to anyone to use this software for any purpose,
+ *  including commercial applications, and to alter it and redistribute it
+ *  freely, subject to the following restrictions:
+ *
+ *  1. The origin of this software must not be misrepresented; you must not
+ *     claim that you wrote the original software. If you use this software
+ *     in a product, an acknowledgment in the product documentation would be
+ *     appreciated but is not required.
+ *  2. Altered source versions must be plainly marked as such, and must not be
+ *     misrepresented as being the original software.
+ *  3. This notice may not be removed or altered from any source distribution.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <float.h>
+#include <stdlib.h>
+
+#include "mikktspace.h"
+
+#define TFALSE		0
+#define TTRUE		1
+
+#ifndef M_PI
+#define M_PI	3.1415926535897932384626433832795
+#endif
+
+#define INTERNAL_RND_SORT_SEED		39871946
+
+// internal structure
+typedef struct {
+	float x, y, z;
+} SVec3;
+
+static tbool			veq( const SVec3 v1, const SVec3 v2 )
+{
+	return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
+}
+
+static SVec3		vadd( const SVec3 v1, const SVec3 v2 )
+{
+	SVec3 vRes;
+
+	vRes.x = v1.x + v2.x;
+	vRes.y = v1.y + v2.y;
+	vRes.z = v1.z + v2.z;
+
+	return vRes;
+}
+
+
+static SVec3		vsub( const SVec3 v1, const SVec3 v2 )
+{
+	SVec3 vRes;
+
+	vRes.x = v1.x - v2.x;
+	vRes.y = v1.y - v2.y;
+	vRes.z = v1.z - v2.z;
+
+	return vRes;
+}
+
+static SVec3		vscale(const float fS, const SVec3 v)
+{
+	SVec3 vRes;
+
+	vRes.x = fS * v.x;
+	vRes.y = fS * v.y;
+	vRes.z = fS * v.z;
+
+	return vRes;
+}
+
+static float			LengthSquared( const SVec3 v )
+{
+	return v.x*v.x + v.y*v.y + v.z*v.z;
+}
+
+static float			Length( const SVec3 v )
+{
+	return sqrtf(LengthSquared(v));
+}
+
+static SVec3		Normalize( const SVec3 v )
+{
+	return vscale(1 / Length(v), v);
+}
+
+static float		vdot( const SVec3 v1, const SVec3 v2)
+{
+	return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
+}
+
+
+static tbool NotZero(const float fX)
+{
+	// could possibly use FLT_EPSILON instead
+	return fabsf(fX) > FLT_MIN;
+}
+
+static tbool VNotZero(const SVec3 v)
+{
+	// might change this to an epsilon based test
+	return NotZero(v.x) || NotZero(v.y) || NotZero(v.z);
+}
+
+
+
+typedef struct {
+	int iNrFaces;
+	int * pTriMembers;
+} SSubGroup;
+
+typedef struct {
+	int iNrFaces;
+	int * pFaceIndices;
+	int iVertexRepresentitive;
+	tbool bOrientPreservering;
+} SGroup;
+
+// 
+#define MARK_DEGENERATE				1
+#define QUAD_ONE_DEGEN_TRI			2
+#define GROUP_WITH_ANY				4
+#define ORIENT_PRESERVING			8
+
+
+
+typedef struct {
+	int FaceNeighbors[3];
+	SGroup * AssignedGroup[3];
+	
+	// normalized first order face derivatives
+	SVec3 vOs, vOt;
+	float fMagS, fMagT;	// original magnitudes
+
+	// determines if the current and the next triangle are a quad.
+	int iOrgFaceNumber;
+	int iFlag, iTSpacesOffs;
+	unsigned char vert_num[4];
+} STriInfo;
+
+typedef struct {
+	SVec3 vOs;
+	float fMagS;
+	SVec3 vOt;
+	float fMagT;
+	int iCounter;	// this is to average back into quads.
+	tbool bOrient;
+} STSpace;
+
+static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn);
+static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn);
+static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn);
+static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn);
+static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[],
+                             const int iNrActiveGroups, const int piTriListIn[], const float fThresCos,
+                             const SMikkTSpaceContext * pContext);
+
+static int MakeIndex(const int iFace, const int iVert)
+{
+	assert(iVert>=0 && iVert<4 && iFace>=0);
+	return (iFace<<2) | (iVert&0x3);
+}
+
+static void IndexToData(int * piFace, int * piVert, const int iIndexIn)
+{
+	piVert[0] = iIndexIn&0x3;
+	piFace[0] = iIndexIn>>2;
+}
+
+static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1)
+{
+	STSpace ts_res;
+
+	// this if is important. Due to floating point precision
+	// averaging when ts0==ts1 will cause a slight difference
+	// which results in tangent space splits later on
+	if (pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT &&
+	   veq(pTS0->vOs,pTS1->vOs)	&& veq(pTS0->vOt, pTS1->vOt))
+	{
+		ts_res.fMagS = pTS0->fMagS;
+		ts_res.fMagT = pTS0->fMagT;
+		ts_res.vOs = pTS0->vOs;
+		ts_res.vOt = pTS0->vOt;
+	}
+	else
+	{
+		ts_res.fMagS = 0.5f*(pTS0->fMagS+pTS1->fMagS);
+		ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT);
+		ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs);
+		ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt);
+		if ( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs);
+		if ( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt);
+	}
+
+	return ts_res;
+}
+
+
+
+static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index);
+static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index);
+static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index);
+
+
+// degen triangles
+static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris);
+static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris);
+
+
+tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext)
+{
+	return genTangSpace(pContext, 180.0f);
+}
+
+tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold)
+{
+	// count nr_triangles
+	int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL;
+	STriInfo * pTriInfos = NULL;
+	SGroup * pGroups = NULL;
+	STSpace * psTspace = NULL;
+	int iNrTrianglesIn = 0, f=0, t=0, i=0;
+	int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0;
+	int iNrActiveGroups = 0, index = 0;
+	const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext);
+	tbool bRes = TFALSE;
+	const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f);
+
+	// verify all call-backs have been set
+	if ( pContext->m_pInterface->m_getNumFaces==NULL ||
+		pContext->m_pInterface->m_getNumVerticesOfFace==NULL ||
+		pContext->m_pInterface->m_getPosition==NULL ||
+		pContext->m_pInterface->m_getNormal==NULL ||
+		pContext->m_pInterface->m_getTexCoord==NULL )
+		return TFALSE;
+
+	// count triangles on supported faces
+	for (f=0; f<iNrFaces; f++)
+	{
+		const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
+		if (verts==3) ++iNrTrianglesIn;
+		else if (verts==4) iNrTrianglesIn += 2;
+	}
+	if (iNrTrianglesIn<=0) return TFALSE;
+
+	// allocate memory for an index list
+	piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn);
+	pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn);
+	if (piTriListIn==NULL || pTriInfos==NULL)
+	{
+		if (piTriListIn!=NULL) free(piTriListIn);
+		if (pTriInfos!=NULL) free(pTriInfos);
+		return TFALSE;
+	}
+
+	// make an initial triangle --> face index list
+	iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn);
+
+	// make a welded index list of identical positions and attributes (pos, norm, texc)
+	//printf("gen welded index list begin\n");
+	GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn);
+	//printf("gen welded index list end\n");
+
+	// Mark all degenerate triangles
+	iTotTris = iNrTrianglesIn;
+	iDegenTriangles = 0;
+	for (t=0; t<iTotTris; t++)
+	{
+		const int i0 = piTriListIn[t*3+0];
+		const int i1 = piTriListIn[t*3+1];
+		const int i2 = piTriListIn[t*3+2];
+		const SVec3 p0 = GetPosition(pContext, i0);
+		const SVec3 p1 = GetPosition(pContext, i1);
+		const SVec3 p2 = GetPosition(pContext, i2);
+		if (veq(p0,p1) || veq(p0,p2) || veq(p1,p2))	// degenerate
+		{
+			pTriInfos[t].iFlag |= MARK_DEGENERATE;
+			++iDegenTriangles;
+		}
+	}
+	iNrTrianglesIn = iTotTris - iDegenTriangles;
+
+	// mark all triangle pairs that belong to a quad with only one
+	// good triangle. These need special treatment in DegenEpilogue().
+	// Additionally, move all good triangles to the start of
+	// pTriInfos[] and piTriListIn[] without changing order and
+	// put the degenerate triangles last.
+	DegenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris);
+
+	
+	// evaluate triangle level attributes and neighbor list
+	//printf("gen neighbors list begin\n");
+	InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn);
+	//printf("gen neighbors list end\n");
+
+	
+	// based on the 4 rules, identify groups based on connectivity
+	iNrMaxGroups = iNrTrianglesIn*3;
+	pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups);
+	piGroupTrianglesBuffer = (int *) malloc(sizeof(int)*iNrTrianglesIn*3);
+	if (pGroups==NULL || piGroupTrianglesBuffer==NULL)
+	{
+		if (pGroups!=NULL) free(pGroups);
+		if (piGroupTrianglesBuffer!=NULL) free(piGroupTrianglesBuffer);
+		free(piTriListIn);
+		free(pTriInfos);
+		return TFALSE;
+	}
+	//printf("gen 4rule groups begin\n");
+	iNrActiveGroups =
+		Build4RuleGroups(pTriInfos, pGroups, piGroupTrianglesBuffer, piTriListIn, iNrTrianglesIn);
+	//printf("gen 4rule groups end\n");
+
+	//
+
+	psTspace = (STSpace *) malloc(sizeof(STSpace)*iNrTSPaces);
+	if (psTspace==NULL)
+	{
+		free(piTriListIn);
+		free(pTriInfos);
+		free(pGroups);
+		free(piGroupTrianglesBuffer);
+		return TFALSE;
+	}
+	memset(psTspace, 0, sizeof(STSpace)*iNrTSPaces);
+	for (t=0; t<iNrTSPaces; t++)
+	{
+		psTspace[t].vOs.x=1.0f; psTspace[t].vOs.y=0.0f; psTspace[t].vOs.z=0.0f; psTspace[t].fMagS = 1.0f;
+		psTspace[t].vOt.x=0.0f; psTspace[t].vOt.y=1.0f; psTspace[t].vOt.z=0.0f; psTspace[t].fMagT = 1.0f;
+	}
+
+	// make tspaces, each group is split up into subgroups if necessary
+	// based on fAngularThreshold. Finally a tangent space is made for
+	// every resulting subgroup
+	//printf("gen tspaces begin\n");
+	bRes = GenerateTSpaces(psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, pContext);
+	//printf("gen tspaces end\n");
+	
+	// clean up
+	free(pGroups);
+	free(piGroupTrianglesBuffer);
+
+	if (!bRes)	// if an allocation in GenerateTSpaces() failed
+	{
+		// clean up and return false
+		free(pTriInfos); free(piTriListIn); free(psTspace);
+		return TFALSE;
+	}
+
+
+	// degenerate quads with one good triangle will be fixed by copying a space from
+	// the good triangle to the coinciding vertex.
+	// all other degenerate triangles will just copy a space from any good triangle
+	// with the same welded index in piTriListIn[].
+	DegenEpilogue(psTspace, pTriInfos, piTriListIn, pContext, iNrTrianglesIn, iTotTris);
+
+	free(pTriInfos); free(piTriListIn);
+
+	index = 0;
+	for (f=0; f<iNrFaces; f++)
+	{
+		const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
+		if (verts!=3 && verts!=4) continue;
+		
+
+		// I've decided to let degenerate triangles and group-with-anythings
+		// vary between left/right hand coordinate systems at the vertices.
+		// All healthy triangles on the other hand are built to always be either or.
+
+		/*// force the coordinate system orientation to be uniform for every face.
+		// (this is already the case for good triangles but not for
+		// degenerate ones and those with bGroupWithAnything==true)
+		bool bOrient = psTspace[index].bOrient;
+		if (psTspace[index].iCounter == 0)	// tspace was not derived from a group
+		{
+			// look for a space created in GenerateTSpaces() by iCounter>0
+			bool bNotFound = true;
+			int i=1;
+			while (i<verts && bNotFound)
+			{
+				if (psTspace[index+i].iCounter > 0) bNotFound=false;
+				else ++i;
+			}
+			if (!bNotFound) bOrient = psTspace[index+i].bOrient;
+		}*/
+
+		// set data
+		for (i=0; i<verts; i++)
+		{
+			const STSpace * pTSpace = &psTspace[index];
+			float tang[] = {pTSpace->vOs.x, pTSpace->vOs.y, pTSpace->vOs.z};
+			float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z};
+			if (pContext->m_pInterface->m_setTSpace!=NULL)
+				pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i);
+			if (pContext->m_pInterface->m_setTSpaceBasic!=NULL)
+				pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i);
+
+			++index;
+		}
+	}
+
+	free(psTspace);
+
+	
+	return TTRUE;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+typedef struct {
+	float vert[3];
+	int index;
+} STmpVert;
+
+static const int g_iCells = 2048;
+
+#ifdef _MSC_VER
+#  define NOINLINE __declspec(noinline)
+#else
+#  define NOINLINE __attribute__ ((noinline))
+#endif
+
+// it is IMPORTANT that this function is called to evaluate the hash since
+// inlining could potentially reorder instructions and generate different
+// results for the same effective input value fVal.
+static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal)
+{
+	const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin));
+	const int iIndex = (int)fIndex;
+	return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1);
+}
+
+static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in);
+static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int pTable[], const int iEntries);
+static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn);
+
+static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
+{
+
+	// Generate bounding box
+	int * piHashTable=NULL, * piHashCount=NULL, * piHashOffsets=NULL, * piHashCount2=NULL;
+	STmpVert * pTmpVert = NULL;
+	int i=0, iChannel=0, k=0, e=0;
+	int iMaxCount=0;
+	SVec3 vMin = GetPosition(pContext, 0), vMax = vMin, vDim;
+	float fMin, fMax;
+	for (i=1; i<(iNrTrianglesIn*3); i++)
+	{
+		const int index = piTriList_in_and_out[i];
+
+		const SVec3 vP = GetPosition(pContext, index);
+		if (vMin.x > vP.x) vMin.x = vP.x;
+		else if (vMax.x < vP.x) vMax.x = vP.x;
+		if (vMin.y > vP.y) vMin.y = vP.y;
+		else if (vMax.y < vP.y) vMax.y = vP.y;
+		if (vMin.z > vP.z) vMin.z = vP.z;
+		else if (vMax.z < vP.z) vMax.z = vP.z;
+	}
+
+	vDim = vsub(vMax,vMin);
+	iChannel = 0;
+	fMin = vMin.x; fMax=vMax.x;
+	if (vDim.y>vDim.x && vDim.y>vDim.z)
+	{
+		iChannel=1;
+		fMin = vMin.y;
+		fMax = vMax.y;
+	}
+	else if (vDim.z>vDim.x)
+	{
+		iChannel=2;
+		fMin = vMin.z;
+		fMax = vMax.z;
+	}
+
+	// make allocations
+	piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3);
+	piHashCount = (int *) malloc(sizeof(int)*g_iCells);
+	piHashOffsets = (int *) malloc(sizeof(int)*g_iCells);
+	piHashCount2 = (int *) malloc(sizeof(int)*g_iCells);
+
+	if (piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL)
+	{
+		if (piHashTable!=NULL) free(piHashTable);
+		if (piHashCount!=NULL) free(piHashCount);
+		if (piHashOffsets!=NULL) free(piHashOffsets);
+		if (piHashCount2!=NULL) free(piHashCount2);
+		GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn);
+		return;
+	}
+	memset(piHashCount, 0, sizeof(int)*g_iCells);
+	memset(piHashCount2, 0, sizeof(int)*g_iCells);
+
+	// count amount of elements in each cell unit
+	for (i=0; i<(iNrTrianglesIn*3); i++)
+	{
+		const int index = piTriList_in_and_out[i];
+		const SVec3 vP = GetPosition(pContext, index);
+		const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z);
+		const int iCell = FindGridCell(fMin, fMax, fVal);
+		++piHashCount[iCell];
+	}
+
+	// evaluate start index of each cell.
+	piHashOffsets[0]=0;
+	for (k=1; k<g_iCells; k++)
+		piHashOffsets[k]=piHashOffsets[k-1]+piHashCount[k-1];
+
+	// insert vertices
+	for (i=0; i<(iNrTrianglesIn*3); i++)
+	{
+		const int index = piTriList_in_and_out[i];
+		const SVec3 vP = GetPosition(pContext, index);
+		const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z);
+		const int iCell = FindGridCell(fMin, fMax, fVal);
+		int * pTable = NULL;
+
+		assert(piHashCount2[iCell]<piHashCount[iCell]);
+		pTable = &piHashTable[piHashOffsets[iCell]];
+		pTable[piHashCount2[iCell]] = i;	// vertex i has been inserted.
+		++piHashCount2[iCell];
+	}
+	for (k=0; k<g_iCells; k++)
+		assert(piHashCount2[k] == piHashCount[k]);	// verify the count
+	free(piHashCount2);
+
+	// find maximum amount of entries in any hash entry
+	iMaxCount = piHashCount[0];
+	for (k=1; k<g_iCells; k++)
+		if (iMaxCount<piHashCount[k])
+			iMaxCount=piHashCount[k];
+	pTmpVert = (STmpVert *) malloc(sizeof(STmpVert)*iMaxCount);
+	
+
+	// complete the merge
+	for (k=0; k<g_iCells; k++)
+	{
+		// extract table of cell k and amount of entries in it
+		int * pTable = &piHashTable[piHashOffsets[k]];
+		const int iEntries = piHashCount[k];
+		if (iEntries < 2) continue;
+
+		if (pTmpVert!=NULL)
+		{
+			for (e=0; e<iEntries; e++)
+			{
+				int i = pTable[e];
+				const SVec3 vP = GetPosition(pContext, piTriList_in_and_out[i]);
+				pTmpVert[e].vert[0] = vP.x; pTmpVert[e].vert[1] = vP.y;
+				pTmpVert[e].vert[2] = vP.z; pTmpVert[e].index = i;
+			}
+			MergeVertsFast(piTriList_in_and_out, pTmpVert, pContext, 0, iEntries-1);
+		}
+		else
+			MergeVertsSlow(piTriList_in_and_out, pContext, pTable, iEntries);
+	}
+
+	if (pTmpVert!=NULL) { free(pTmpVert); }
+	free(piHashTable);
+	free(piHashCount);
+	free(piHashOffsets);
+}
+
+static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in)
+{
+	// make bbox
+	int c=0, l=0, channel=0;
+	float fvMin[3], fvMax[3];
+	float dx=0, dy=0, dz=0, fSep=0;
+	for (c=0; c<3; c++)
+	{	fvMin[c]=pTmpVert[iL_in].vert[c]; fvMax[c]=fvMin[c];	}
+	for (l=(iL_in+1); l<=iR_in; l++) {
+		for (c=0; c<3; c++) {
+			if (fvMin[c]>pTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c];
+			if (fvMax[c]<pTmpVert[l].vert[c]) fvMax[c]=pTmpVert[l].vert[c];
+		}
+	}
+
+	dx = fvMax[0]-fvMin[0];
+	dy = fvMax[1]-fvMin[1];
+	dz = fvMax[2]-fvMin[2];
+
+	channel = 0;
+	if (dy>dx && dy>dz) channel=1;
+	else if (dz>dx) channel=2;
+
+	fSep = 0.5f*(fvMax[channel]+fvMin[channel]);
+
+	// stop if all vertices are NaNs
+	if (!isfinite(fSep))
+		return;
+
+	// terminate recursion when the separation/average value
+	// is no longer strictly between fMin and fMax values.
+	if (fSep>=fvMax[channel] || fSep<=fvMin[channel])
+	{
+		// complete the weld
+		for (l=iL_in; l<=iR_in; l++)
+		{
+			int i = pTmpVert[l].index;
+			const int index = piTriList_in_and_out[i];
+			const SVec3 vP = GetPosition(pContext, index);
+			const SVec3 vN = GetNormal(pContext, index);
+			const SVec3 vT = GetTexCoord(pContext, index);
+
+			tbool bNotFound = TTRUE;
+			int l2=iL_in, i2rec=-1;
+			while (l2<l && bNotFound)
+			{
+				const int i2 = pTmpVert[l2].index;
+				const int index2 = piTriList_in_and_out[i2];
+				const SVec3 vP2 = GetPosition(pContext, index2);
+				const SVec3 vN2 = GetNormal(pContext, index2);
+				const SVec3 vT2 = GetTexCoord(pContext, index2);
+				i2rec=i2;
+
+				//if (vP==vP2 && vN==vN2 && vT==vT2)
+				if (vP.x==vP2.x && vP.y==vP2.y && vP.z==vP2.z &&
+					vN.x==vN2.x && vN.y==vN2.y && vN.z==vN2.z &&
+					vT.x==vT2.x && vT.y==vT2.y && vT.z==vT2.z)
+					bNotFound = TFALSE;
+				else
+					++l2;
+			}
+			
+			// merge if previously found
+			if (!bNotFound)
+				piTriList_in_and_out[i] = piTriList_in_and_out[i2rec];
+		}
+	}
+	else
+	{
+		int iL=iL_in, iR=iR_in;
+		assert((iR_in-iL_in)>0);	// at least 2 entries
+
+		// separate (by fSep) all points between iL_in and iR_in in pTmpVert[]
+		while (iL < iR)
+		{
+			tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE;
+			while ((!bReadyLeftSwap) && iL<iR)
+			{
+				assert(iL>=iL_in && iL<=iR_in);
+				bReadyLeftSwap = !(pTmpVert[iL].vert[channel]<fSep);
+				if (!bReadyLeftSwap) ++iL;
+			}
+			while ((!bReadyRightSwap) && iL<iR)
+			{
+				assert(iR>=iL_in && iR<=iR_in);
+				bReadyRightSwap = pTmpVert[iR].vert[channel]<fSep;
+				if (!bReadyRightSwap) --iR;
+			}
+			assert( (iL<iR) || !(bReadyLeftSwap && bReadyRightSwap) );
+
+			if (bReadyLeftSwap && bReadyRightSwap)
+			{
+				const STmpVert sTmp = pTmpVert[iL];
+				assert(iL<iR);
+				pTmpVert[iL] = pTmpVert[iR];
+				pTmpVert[iR] = sTmp;
+				++iL; --iR;
+			}
+		}
+
+		assert(iL==(iR+1) || (iL==iR));
+		if (iL==iR)
+		{
+			const tbool bReadyRightSwap = pTmpVert[iR].vert[channel]<fSep;
+			if (bReadyRightSwap) ++iL;
+			else --iR;
+		}
+
+		// only need to weld when there is more than 1 instance of the (x,y,z)
+		if (iL_in < iR)
+			MergeVertsFast(piTriList_in_and_out, pTmpVert, pContext, iL_in, iR);	// weld all left of fSep
+		if (iL < iR_in)
+			MergeVertsFast(piTriList_in_and_out, pTmpVert, pContext, iL, iR_in);	// weld all right of (or equal to) fSep
+	}
+}
+
+static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int pTable[], const int iEntries)
+{
+	// this can be optimized further using a tree structure or more hashing.
+	int e=0;
+	for (e=0; e<iEntries; e++)
+	{
+		int i = pTable[e];
+		const int index = piTriList_in_and_out[i];
+		const SVec3 vP = GetPosition(pContext, index);
+		const SVec3 vN = GetNormal(pContext, index);
+		const SVec3 vT = GetTexCoord(pContext, index);
+
+		tbool bNotFound = TTRUE;
+		int e2=0, i2rec=-1;
+		while (e2<e && bNotFound)
+		{
+			const int i2 = pTable[e2];
+			const int index2 = piTriList_in_and_out[i2];
+			const SVec3 vP2 = GetPosition(pContext, index2);
+			const SVec3 vN2 = GetNormal(pContext, index2);
+			const SVec3 vT2 = GetTexCoord(pContext, index2);
+			i2rec = i2;
+
+			if (veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
+				bNotFound = TFALSE;
+			else
+				++e2;
+		}
+		
+		// merge if previously found
+		if (!bNotFound)
+			piTriList_in_and_out[i] = piTriList_in_and_out[i2rec];
+	}
+}
+
+static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
+{
+	int iNumUniqueVerts = 0, t=0, i=0;
+	for (t=0; t<iNrTrianglesIn; t++)
+	{
+		for (i=0; i<3; i++)
+		{
+			const int offs = t*3 + i;
+			const int index = piTriList_in_and_out[offs];
+
+			const SVec3 vP = GetPosition(pContext, index);
+			const SVec3 vN = GetNormal(pContext, index);
+			const SVec3 vT = GetTexCoord(pContext, index);
+
+			tbool bFound = TFALSE;
+			int t2=0, index2rec=-1;
+			while (!bFound && t2<=t)
+			{
+				int j=0;
+				while (!bFound && j<3)
+				{
+					const int index2 = piTriList_in_and_out[t2*3 + j];
+					const SVec3 vP2 = GetPosition(pContext, index2);
+					const SVec3 vN2 = GetNormal(pContext, index2);
+					const SVec3 vT2 = GetTexCoord(pContext, index2);
+					
+					if (veq(vP,vP2) && veq(vN,vN2) && veq(vT,vT2))
+						bFound = TTRUE;
+					else
+						++j;
+				}
+				if (!bFound) ++t2;
+			}
+
+			assert(bFound);
+			// if we found our own
+			if (index2rec == index) { ++iNumUniqueVerts; }
+
+			piTriList_in_and_out[offs] = index2rec;
+		}
+	}
+}
+
+static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
+{
+	int iTSpacesOffs = 0, f=0, t=0;
+	int iDstTriIndex = 0;
+	for (f=0; f<pContext->m_pInterface->m_getNumFaces(pContext); f++)
+	{
+		const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f);
+		if (verts!=3 && verts!=4) continue;
+
+		pTriInfos[iDstTriIndex].iOrgFaceNumber = f;
+		pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs;
+
+		if (verts==3)
+		{
+			unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num;
+			pVerts[0]=0; pVerts[1]=1; pVerts[2]=2;
+			piTriList_out[iDstTriIndex*3+0] = MakeIndex(f, 0);
+			piTriList_out[iDstTriIndex*3+1] = MakeIndex(f, 1);
+			piTriList_out[iDstTriIndex*3+2] = MakeIndex(f, 2);
+			++iDstTriIndex;	// next
+		}
+		else
+		{
+			{
+				pTriInfos[iDstTriIndex+1].iOrgFaceNumber = f;
+				pTriInfos[iDstTriIndex+1].iTSpacesOffs = iTSpacesOffs;
+			}
+
+			{
+				// need an order independent way to evaluate
+				// tspace on quads. This is done by splitting
+				// along the shortest diagonal.
+				const int i0 = MakeIndex(f, 0);
+				const int i1 = MakeIndex(f, 1);
+				const int i2 = MakeIndex(f, 2);
+				const int i3 = MakeIndex(f, 3);
+				const SVec3 T0 = GetTexCoord(pContext, i0);
+				const SVec3 T1 = GetTexCoord(pContext, i1);
+				const SVec3 T2 = GetTexCoord(pContext, i2);
+				const SVec3 T3 = GetTexCoord(pContext, i3);
+				const float distSQ_02 = LengthSquared(vsub(T2,T0));
+				const float distSQ_13 = LengthSquared(vsub(T3,T1));
+				tbool bQuadDiagIs_02;
+				if (distSQ_02<distSQ_13)
+					bQuadDiagIs_02 = TTRUE;
+				else if (distSQ_13<distSQ_02)
+					bQuadDiagIs_02 = TFALSE;
+				else
+				{
+					const SVec3 P0 = GetPosition(pContext, i0);
+					const SVec3 P1 = GetPosition(pContext, i1);
+					const SVec3 P2 = GetPosition(pContext, i2);
+					const SVec3 P3 = GetPosition(pContext, i3);
+					const float distSQ_02 = LengthSquared(vsub(P2,P0));
+					const float distSQ_13 = LengthSquared(vsub(P3,P1));
+
+					bQuadDiagIs_02 = distSQ_13<distSQ_02 ? TFALSE : TTRUE;
+				}
+
+				if (bQuadDiagIs_02)
+				{
+					{
+						unsigned char * pVerts_A = pTriInfos[iDstTriIndex].vert_num;
+						pVerts_A[0]=0; pVerts_A[1]=1; pVerts_A[2]=2;
+					}
+					piTriList_out[iDstTriIndex*3+0] = i0;
+					piTriList_out[iDstTriIndex*3+1] = i1;
+					piTriList_out[iDstTriIndex*3+2] = i2;
+					++iDstTriIndex;	// next
+					{
+						unsigned char * pVerts_B = pTriInfos[iDstTriIndex].vert_num;
+						pVerts_B[0]=0; pVerts_B[1]=2; pVerts_B[2]=3;
+					}
+					piTriList_out[iDstTriIndex*3+0] = i0;
+					piTriList_out[iDstTriIndex*3+1] = i2;
+					piTriList_out[iDstTriIndex*3+2] = i3;
+					++iDstTriIndex;	// next
+				}
+				else
+				{
+					{
+						unsigned char * pVerts_A = pTriInfos[iDstTriIndex].vert_num;
+						pVerts_A[0]=0; pVerts_A[1]=1; pVerts_A[2]=3;
+					}
+					piTriList_out[iDstTriIndex*3+0] = i0;
+					piTriList_out[iDstTriIndex*3+1] = i1;
+					piTriList_out[iDstTriIndex*3+2] = i3;
+					++iDstTriIndex;	// next
+					{
+						unsigned char * pVerts_B = pTriInfos[iDstTriIndex].vert_num;
+						pVerts_B[0]=1; pVerts_B[1]=2; pVerts_B[2]=3;
+					}
+					piTriList_out[iDstTriIndex*3+0] = i1;
+					piTriList_out[iDstTriIndex*3+1] = i2;
+					piTriList_out[iDstTriIndex*3+2] = i3;
+					++iDstTriIndex;	// next
+				}
+			}
+		}
+
+		iTSpacesOffs += verts;
+		assert(iDstTriIndex<=iNrTrianglesIn);
+	}
+
+	for (t=0; t<iNrTrianglesIn; t++)
+		pTriInfos[t].iFlag = 0;
+
+	// return total amount of tspaces
+	return iTSpacesOffs;
+}
+
+static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index)
+{
+	int iF, iI;
+	SVec3 res; float pos[3];
+	IndexToData(&iF, &iI, index);
+	pContext->m_pInterface->m_getPosition(pContext, pos, iF, iI);
+	res.x=pos[0]; res.y=pos[1]; res.z=pos[2];
+	return res;
+}
+
+static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index)
+{
+	int iF, iI;
+	SVec3 res; float norm[3];
+	IndexToData(&iF, &iI, index);
+	pContext->m_pInterface->m_getNormal(pContext, norm, iF, iI);
+	res.x=norm[0]; res.y=norm[1]; res.z=norm[2];
+	return res;
+}
+
+static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index)
+{
+	int iF, iI;
+	SVec3 res; float texc[2];
+	IndexToData(&iF, &iI, index);
+	pContext->m_pInterface->m_getTexCoord(pContext, texc, iF, iI);
+	res.x=texc[0]; res.y=texc[1]; res.z=1.0f;
+	return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+typedef union {
+	struct
+	{
+		int i0, i1, f;
+	};
+	int array[3];
+} SEdge;
+
+static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn);
+static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn);
+
+// returns the texture area times 2
+static float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[])
+{
+	const SVec3 t1 = GetTexCoord(pContext, indices[0]);
+	const SVec3 t2 = GetTexCoord(pContext, indices[1]);
+	const SVec3 t3 = GetTexCoord(pContext, indices[2]);
+
+	const float t21x = t2.x-t1.x;
+	const float t21y = t2.y-t1.y;
+	const float t31x = t3.x-t1.x;
+	const float t31y = t3.y-t1.y;
+
+	const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x;
+
+	return fSignedAreaSTx2<0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2;
+}
+
+static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn)
+{
+	int f=0, i=0, t=0;
+	// pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function.
+
+	// generate neighbor info list
+	for (f=0; f<iNrTrianglesIn; f++)
+		for (i=0; i<3; i++)
+		{
+			pTriInfos[f].FaceNeighbors[i] = -1;
+			pTriInfos[f].AssignedGroup[i] = NULL;
+
+			pTriInfos[f].vOs.x=0.0f; pTriInfos[f].vOs.y=0.0f; pTriInfos[f].vOs.z=0.0f;
+			pTriInfos[f].vOt.x=0.0f; pTriInfos[f].vOt.y=0.0f; pTriInfos[f].vOt.z=0.0f;
+			pTriInfos[f].fMagS = 0;
+			pTriInfos[f].fMagT = 0;
+
+			// assumed bad
+			pTriInfos[f].iFlag |= GROUP_WITH_ANY;
+		}
+
+	// evaluate first order derivatives
+	for (f=0; f<iNrTrianglesIn; f++)
+	{
+		// initial values
+		const SVec3 v1 = GetPosition(pContext, piTriListIn[f*3+0]);
+		const SVec3 v2 = GetPosition(pContext, piTriListIn[f*3+1]);
+		const SVec3 v3 = GetPosition(pContext, piTriListIn[f*3+2]);
+		const SVec3 t1 = GetTexCoord(pContext, piTriListIn[f*3+0]);
+		const SVec3 t2 = GetTexCoord(pContext, piTriListIn[f*3+1]);
+		const SVec3 t3 = GetTexCoord(pContext, piTriListIn[f*3+2]);
+
+		const float t21x = t2.x-t1.x;
+		const float t21y = t2.y-t1.y;
+		const float t31x = t3.x-t1.x;
+		const float t31y = t3.y-t1.y;
+		const SVec3 d1 = vsub(v2,v1);
+		const SVec3 d2 = vsub(v3,v1);
+
+		const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x;
+		//assert(fSignedAreaSTx2!=0);
+		SVec3 vOs = vsub(vscale(t31y,d1), vscale(t21y,d2));	// eq 18
+		SVec3 vOt = vadd(vscale(-t31x,d1), vscale(t21x,d2)); // eq 19
+
+		pTriInfos[f].iFlag |= (fSignedAreaSTx2>0 ? ORIENT_PRESERVING : 0);
+
+		if ( NotZero(fSignedAreaSTx2) )
+		{
+			const float fAbsArea = fabsf(fSignedAreaSTx2);
+			const float fLenOs = Length(vOs);
+			const float fLenOt = Length(vOt);
+			const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f;
+			if ( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs);
+			if ( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt);
+
+			// evaluate magnitudes prior to normalization of vOs and vOt
+			pTriInfos[f].fMagS = fLenOs / fAbsArea;
+			pTriInfos[f].fMagT = fLenOt / fAbsArea;
+
+			// if this is a good triangle
+			if ( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT))
+				pTriInfos[f].iFlag &= (~GROUP_WITH_ANY);
+		}
+	}
+
+	// force otherwise healthy quads to a fixed orientation
+	while (t<(iNrTrianglesIn-1))
+	{
+		const int iFO_a = pTriInfos[t].iOrgFaceNumber;
+		const int iFO_b = pTriInfos[t+1].iOrgFaceNumber;
+		if (iFO_a==iFO_b)	// this is a quad
+		{
+			const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
+			const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
+			
+			// bad triangles should already have been removed by
+			// DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false
+			if ((bIsDeg_a||bIsDeg_b)==TFALSE)
+			{
+				const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+				const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+				// if this happens the quad has extremely bad mapping!!
+				if (bOrientA!=bOrientB)
+				{
+					//printf("found quad with bad mapping\n");
+					tbool bChooseOrientFirstTri = TFALSE;
+					if ((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE;
+					else if ( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) )
+						bChooseOrientFirstTri = TTRUE;
+
+					// force match
+					{
+						const int t0 = bChooseOrientFirstTri ? t : (t+1);
+						const int t1 = bChooseOrientFirstTri ? (t+1) : t;
+						pTriInfos[t1].iFlag &= (~ORIENT_PRESERVING);	// clear first
+						pTriInfos[t1].iFlag |= (pTriInfos[t0].iFlag&ORIENT_PRESERVING);	// copy bit
+					}
+				}
+			}
+			t += 2;
+		}
+		else
+			++t;
+	}
+	
+	// match up edge pairs
+	{
+		SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3);
+		if (pEdges==NULL)
+			BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn);
+		else
+		{
+			BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn);
+	
+			free(pEdges);
+		}
+	}
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup);
+static void AddTriToGroup(SGroup * pGroup, const int iTriIndex);
+
+static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn)
+{
+	const int iNrMaxGroups = iNrTrianglesIn*3;
+	int iNrActiveGroups = 0;
+	int iOffset = 0, f=0, i=0;
+	(void)iNrMaxGroups;  /* quiet warnings in non debug mode */
+	for (f=0; f<iNrTrianglesIn; f++)
+	{
+		for (i=0; i<3; i++)
+		{
+			// if not assigned to a group
+			if ((pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 && pTriInfos[f].AssignedGroup[i]==NULL)
+			{
+				tbool bOrPre;
+				int neigh_indexL, neigh_indexR;
+				const int vert_index = piTriListIn[f*3+i];
+				assert(iNrActiveGroups<iNrMaxGroups);
+				pTriInfos[f].AssignedGroup[i] = &pGroups[iNrActiveGroups];
+				pTriInfos[f].AssignedGroup[i]->iVertexRepresentitive = vert_index;
+				pTriInfos[f].AssignedGroup[i]->bOrientPreservering = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0;
+				pTriInfos[f].AssignedGroup[i]->iNrFaces = 0;
+				pTriInfos[f].AssignedGroup[i]->pFaceIndices = &piGroupTrianglesBuffer[iOffset];
+				++iNrActiveGroups;
+
+				AddTriToGroup(pTriInfos[f].AssignedGroup[i], f);
+				bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+				neigh_indexL = pTriInfos[f].FaceNeighbors[i];
+				neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2];
+				if (neigh_indexL>=0) // neighbor
+				{
+					const tbool bAnswer =
+						AssignRecur(piTriListIn, pTriInfos, neigh_indexL,
+									pTriInfos[f].AssignedGroup[i] );
+					
+					const tbool bOrPre2 = (pTriInfos[neigh_indexL].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+					const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE;
+					assert(bAnswer || bDiff);
+					(void)bAnswer, (void)bDiff;  /* quiet warnings in non debug mode */
+				}
+				if (neigh_indexR>=0) // neighbor
+				{
+					const tbool bAnswer =
+						AssignRecur(piTriListIn, pTriInfos, neigh_indexR,
+									pTriInfos[f].AssignedGroup[i] );
+
+					const tbool bOrPre2 = (pTriInfos[neigh_indexR].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+					const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE;
+					assert(bAnswer || bDiff);
+					(void)bAnswer, (void)bDiff;  /* quiet warnings in non debug mode */
+				}
+
+				// update offset
+				iOffset += pTriInfos[f].AssignedGroup[i]->iNrFaces;
+				// since the groups are disjoint a triangle can never
+				// belong to more than 3 groups. Subsequently something
+				// is completely screwed if this assertion ever hits.
+				assert(iOffset <= iNrMaxGroups);
+			}
+		}
+	}
+
+	return iNrActiveGroups;
+}
+
+static void AddTriToGroup(SGroup * pGroup, const int iTriIndex)
+{
+	pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex;
+	++pGroup->iNrFaces;
+}
+
+static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[],
+				 const int iMyTriIndex, SGroup * pGroup)
+{
+	STriInfo * pMyTriInfo = &psTriInfos[iMyTriIndex];
+
+	// track down vertex
+	const int iVertRep = pGroup->iVertexRepresentitive;
+	const int * pVerts = &piTriListIn[3*iMyTriIndex+0];
+	int i=-1;
+	if (pVerts[0]==iVertRep) i=0;
+	else if (pVerts[1]==iVertRep) i=1;
+	else if (pVerts[2]==iVertRep) i=2;
+	assert(i>=0 && i<3);
+
+	// early out
+	if (pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE;
+	else if (pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE;
+	if ((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0)
+	{
+		// first to group with a group-with-anything triangle
+		// determines it's orientation.
+		// This is the only existing order dependency in the code!!
+		if ( pMyTriInfo->AssignedGroup[0] == NULL &&
+			pMyTriInfo->AssignedGroup[1] == NULL &&
+			pMyTriInfo->AssignedGroup[2] == NULL )
+		{
+			pMyTriInfo->iFlag &= (~ORIENT_PRESERVING);
+			pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0);
+		}
+	}
+	{
+		const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE;
+		if (bOrient != pGroup->bOrientPreservering) return TFALSE;
+	}
+
+	AddTriToGroup(pGroup, iMyTriIndex);
+	pMyTriInfo->AssignedGroup[i] = pGroup;
+
+	{
+		const int neigh_indexL = pMyTriInfo->FaceNeighbors[i];
+		const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2];
+		if (neigh_indexL>=0)
+			AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup);
+		if (neigh_indexR>=0)
+			AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup);
+	}
+
+
+
+	return TTRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2);
+static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed);
+static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext * pContext, const int iVertexRepresentitive);
+
+static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[],
+                             const int iNrActiveGroups, const int piTriListIn[], const float fThresCos,
+                             const SMikkTSpaceContext * pContext)
+{
+	STSpace * pSubGroupTspace = NULL;
+	SSubGroup * pUniSubGroups = NULL;
+	int * pTmpMembers = NULL;
+	int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0;
+	for (g=0; g<iNrActiveGroups; g++)
+		if (iMaxNrFaces < pGroups[g].iNrFaces)
+			iMaxNrFaces = pGroups[g].iNrFaces;
+
+	if (iMaxNrFaces == 0) return TTRUE;
+
+	// make initial allocations
+	pSubGroupTspace = (STSpace *) malloc(sizeof(STSpace)*iMaxNrFaces);
+	pUniSubGroups = (SSubGroup *) malloc(sizeof(SSubGroup)*iMaxNrFaces);
+	pTmpMembers = (int *) malloc(sizeof(int)*iMaxNrFaces);
+	if (pSubGroupTspace==NULL || pUniSubGroups==NULL || pTmpMembers==NULL)
+	{
+		if (pSubGroupTspace!=NULL) free(pSubGroupTspace);
+		if (pUniSubGroups!=NULL) free(pUniSubGroups);
+		if (pTmpMembers!=NULL) free(pTmpMembers);
+		return TFALSE;
+	}
+
+
+	iUniqueTspaces = 0;
+	for (g=0; g<iNrActiveGroups; g++)
+	{
+		const SGroup * pGroup = &pGroups[g];
+		int iUniqueSubGroups = 0, s=0;
+
+		for (i=0; i<pGroup->iNrFaces; i++)	// triangles
+		{
+			const int f = pGroup->pFaceIndices[i];	// triangle number
+			int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0;
+			SSubGroup tmp_group;
+			tbool bFound;
+			SVec3 n, vOs, vOt;
+			if (pTriInfos[f].AssignedGroup[0]==pGroup) index=0;
+			else if (pTriInfos[f].AssignedGroup[1]==pGroup) index=1;
+			else if (pTriInfos[f].AssignedGroup[2]==pGroup) index=2;
+			assert(index>=0 && index<3);
+
+			iVertIndex = piTriListIn[f*3+index];
+			assert(iVertIndex==pGroup->iVertexRepresentitive);
+
+			// is normalized already
+			n = GetNormal(pContext, iVertIndex);
+			
+			// project
+			vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
+			vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
+			if ( VNotZero(vOs) ) vOs = Normalize(vOs);
+			if ( VNotZero(vOt) ) vOt = Normalize(vOt);
+
+			// original face number
+			iOF_1 = pTriInfos[f].iOrgFaceNumber;
+			
+			iMembers = 0;
+			for (j=0; j<pGroup->iNrFaces; j++)
+			{
+				const int t = pGroup->pFaceIndices[j];	// triangle number
+				const int iOF_2 = pTriInfos[t].iOrgFaceNumber;
+
+				// project
+				SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n));
+				SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n));
+				if ( VNotZero(vOs2) ) vOs2 = Normalize(vOs2);
+				if ( VNotZero(vOt2) ) vOt2 = Normalize(vOt2);
+
+				{
+					const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE;
+					// make sure triangles which belong to the same quad are joined.
+					const tbool bSameOrgFace = iOF_1==iOF_2 ? TTRUE : TFALSE;
+
+					const float fCosS = vdot(vOs,vOs2);
+					const float fCosT = vdot(vOt,vOt2);
+
+					assert(f!=t || bSameOrgFace);	// sanity check
+					if (bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos))
+						pTmpMembers[iMembers++] = t;
+				}
+			}
+
+			// sort pTmpMembers
+			tmp_group.iNrFaces = iMembers;
+			tmp_group.pTriMembers = pTmpMembers;
+			if (iMembers>1)
+			{
+				unsigned int uSeed = INTERNAL_RND_SORT_SEED;	// could replace with a random seed?
+				QuickSort(pTmpMembers, 0, iMembers-1, uSeed);
+			}
+
+			// look for an existing match
+			bFound = TFALSE;
+			l=0;
+			while (l<iUniqueSubGroups && !bFound)
+			{
+				bFound = CompareSubGroups(&tmp_group, &pUniSubGroups[l]);
+				if (!bFound) ++l;
+			}
+			
+			// assign tangent space index
+			assert(bFound || l==iUniqueSubGroups);
+			//piTempTangIndices[f*3+index] = iUniqueTspaces+l;
+
+			// if no match was found we allocate a new subgroup
+			if (!bFound)
+			{
+				// insert new subgroup
+				int * pIndices = (int *) malloc(sizeof(int)*iMembers);
+				if (pIndices==NULL)
+				{
+					// clean up and return false
+					int s=0;
+					for (s=0; s<iUniqueSubGroups; s++)
+						free(pUniSubGroups[s].pTriMembers);
+					free(pUniSubGroups);
+					free(pTmpMembers);
+					free(pSubGroupTspace);
+					return TFALSE;
+				}
+				pUniSubGroups[iUniqueSubGroups].iNrFaces = iMembers;
+				pUniSubGroups[iUniqueSubGroups].pTriMembers = pIndices;
+				memcpy(pIndices, tmp_group.pTriMembers, iMembers*sizeof(int));
+				pSubGroupTspace[iUniqueSubGroups] =
+					EvalTspace(tmp_group.pTriMembers, iMembers, piTriListIn, pTriInfos, pContext, pGroup->iVertexRepresentitive);
+				++iUniqueSubGroups;
+			}
+
+			// output tspace
+			{
+				const int iOffs = pTriInfos[f].iTSpacesOffs;
+				const int iVert = pTriInfos[f].vert_num[index];
+				STSpace * pTS_out = &psTspace[iOffs+iVert];
+				assert(pTS_out->iCounter<2);
+				assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering);
+				if (pTS_out->iCounter==1)
+				{
+					*pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]);
+					pTS_out->iCounter = 2;	// update counter
+					pTS_out->bOrient = pGroup->bOrientPreservering;
+				}
+				else
+				{
+					assert(pTS_out->iCounter==0);
+					*pTS_out = pSubGroupTspace[l];
+					pTS_out->iCounter = 1;	// update counter
+					pTS_out->bOrient = pGroup->bOrientPreservering;
+				}
+			}
+		}
+
+		// clean up and offset iUniqueTspaces
+		for (s=0; s<iUniqueSubGroups; s++)
+			free(pUniSubGroups[s].pTriMembers);
+		iUniqueTspaces += iUniqueSubGroups;
+	}
+
+	// clean up
+	free(pUniSubGroups);
+	free(pTmpMembers);
+	free(pSubGroupTspace);
+
+	return TTRUE;
+}
+
+static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[],
+                          const SMikkTSpaceContext * pContext, const int iVertexRepresentitive)
+{
+	STSpace res;
+	float fAngleSum = 0;
+	int face=0;
+	res.vOs.x=0.0f; res.vOs.y=0.0f; res.vOs.z=0.0f;
+	res.vOt.x=0.0f; res.vOt.y=0.0f; res.vOt.z=0.0f;
+	res.fMagS = 0; res.fMagT = 0;
+
+	for (face=0; face<iFaces; face++)
+	{
+		const int f = face_indices[face];
+
+		// only valid triangles get to add their contribution
+		if ( (pTriInfos[f].iFlag&GROUP_WITH_ANY)==0 )
+		{
+			SVec3 n, vOs, vOt, p0, p1, p2, v1, v2;
+			float fCos, fAngle, fMagS, fMagT;
+			int i=-1, index=-1, i0=-1, i1=-1, i2=-1;
+			if (piTriListIn[3*f+0]==iVertexRepresentitive) i=0;
+			else if (piTriListIn[3*f+1]==iVertexRepresentitive) i=1;
+			else if (piTriListIn[3*f+2]==iVertexRepresentitive) i=2;
+			assert(i>=0 && i<3);
+
+			// project
+			index = piTriListIn[3*f+i];
+			n = GetNormal(pContext, index);
+			vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n));
+			vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n));
+			if ( VNotZero(vOs) ) vOs = Normalize(vOs);
+			if ( VNotZero(vOt) ) vOt = Normalize(vOt);
+
+			i2 = piTriListIn[3*f + (i<2?(i+1):0)];
+			i1 = piTriListIn[3*f + i];
+			i0 = piTriListIn[3*f + (i>0?(i-1):2)];
+
+			p0 = GetPosition(pContext, i0);
+			p1 = GetPosition(pContext, i1);
+			p2 = GetPosition(pContext, i2);
+			v1 = vsub(p0,p1);
+			v2 = vsub(p2,p1);
+
+			// project
+			v1 = vsub(v1, vscale(vdot(n,v1),n)); if ( VNotZero(v1) ) v1 = Normalize(v1);
+			v2 = vsub(v2, vscale(vdot(n,v2),n)); if ( VNotZero(v2) ) v2 = Normalize(v2);
+
+			// weight contribution by the angle
+			// between the two edge vectors
+			fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos);
+			fAngle = (float) acos(fCos);
+			fMagS = pTriInfos[f].fMagS;
+			fMagT = pTriInfos[f].fMagT;
+
+			res.vOs=vadd(res.vOs, vscale(fAngle,vOs));
+			res.vOt=vadd(res.vOt,vscale(fAngle,vOt));
+			res.fMagS+=(fAngle*fMagS);
+			res.fMagT+=(fAngle*fMagT);
+			fAngleSum += fAngle;
+		}
+	}
+
+	// normalize
+	if ( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs);
+	if ( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt);
+	if (fAngleSum>0)
+	{
+		res.fMagS /= fAngleSum;
+		res.fMagT /= fAngleSum;
+	}
+
+	return res;
+}
+
+static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2)
+{
+	tbool bStillSame=TTRUE;
+	int i=0;
+	if (pg1->iNrFaces!=pg2->iNrFaces) return TFALSE;
+	while (i<pg1->iNrFaces && bStillSame)
+	{
+		bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE;
+		if (bStillSame) ++i;
+	}
+	return bStillSame;
+}
+
+static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed)
+{
+	int iL, iR, n, index, iMid, iTmp;
+
+	// Random
+	unsigned int t=uSeed&31;
+	t=(uSeed<<t)|(uSeed>>(32-t));
+	uSeed=uSeed+t+3;
+	// Random end
+
+	iL=iLeft; iR=iRight;
+	n = (iR-iL)+1;
+	assert(n>=0);
+	index = (int) (uSeed%n);
+
+	iMid=pSortBuffer[index + iL];
+
+
+	do
+	{
+		while (pSortBuffer[iL] < iMid)
+			++iL;
+		while (pSortBuffer[iR] > iMid)
+			--iR;
+
+		if (iL <= iR)
+		{
+			iTmp = pSortBuffer[iL];
+			pSortBuffer[iL] = pSortBuffer[iR];
+			pSortBuffer[iR] = iTmp;
+			++iL; --iR;
+		}
+	}
+	while (iL <= iR);
+
+	if (iLeft < iR)
+		QuickSort(pSortBuffer, iLeft, iR, uSeed);
+	if (iL < iRight)
+		QuickSort(pSortBuffer, iL, iRight, uSeed);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////
+
+static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed);
+static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in);
+
+static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn)
+{
+	// build array of edges
+	unsigned int uSeed = INTERNAL_RND_SORT_SEED;				// could replace with a random seed?
+	int iEntries=0, iCurStartIndex=-1, f=0, i=0;
+	for (f=0; f<iNrTrianglesIn; f++)
+		for (i=0; i<3; i++)
+		{
+			const int i0 = piTriListIn[f*3+i];
+			const int i1 = piTriListIn[f*3+(i<2?(i+1):0)];
+			pEdges[f*3+i].i0 = i0 < i1 ? i0 : i1;			// put minimum index in i0
+			pEdges[f*3+i].i1 = !(i0 < i1) ? i0 : i1;		// put maximum index in i1
+			pEdges[f*3+i].f = f;							// record face number
+		}
+
+	// sort over all edges by i0, this is the pricy one.
+	QuickSortEdges(pEdges, 0, iNrTrianglesIn*3-1, 0, uSeed);	// sort channel 0 which is i0
+
+	// sub sort over i1, should be fast.
+	// could replace this with a 64 bit int sort over (i0,i1)
+	// with i0 as msb in the quicksort call above.
+	iEntries = iNrTrianglesIn*3;
+	iCurStartIndex = 0;
+	for (i=1; i<iEntries; i++)
+	{
+		if (pEdges[iCurStartIndex].i0 != pEdges[i].i0)
+		{
+			const int iL = iCurStartIndex;
+			const int iR = i-1;
+			//const int iElems = i-iL;
+			iCurStartIndex = i;
+			QuickSortEdges(pEdges, iL, iR, 1, uSeed);	// sort channel 1 which is i1
+		}
+	}
+
+	// sub sort over f, which should be fast.
+	// this step is to remain compliant with BuildNeighborsSlow() when
+	// more than 2 triangles use the same edge (such as a butterfly topology).
+	iCurStartIndex = 0;
+	for (i=1; i<iEntries; i++)
+	{
+		if (pEdges[iCurStartIndex].i0 != pEdges[i].i0 || pEdges[iCurStartIndex].i1 != pEdges[i].i1)
+		{
+			const int iL = iCurStartIndex;
+			const int iR = i-1;
+			//const int iElems = i-iL;
+			iCurStartIndex = i;
+			QuickSortEdges(pEdges, iL, iR, 2, uSeed);	// sort channel 2 which is f
+		}
+	}
+
+	// pair up, adjacent triangles
+	for (i=0; i<iEntries; i++)
+	{
+		const int i0=pEdges[i].i0;
+		const int i1=pEdges[i].i1;
+		const int f = pEdges[i].f;
+		tbool bUnassigned_A;
+
+		int i0_A, i1_A;
+		int edgenum_A, edgenum_B=0;	// 0,1 or 2
+		GetEdge(&i0_A, &i1_A, &edgenum_A, &piTriListIn[f*3], i0, i1);	// resolve index ordering and edge_num
+		bUnassigned_A = pTriInfos[f].FaceNeighbors[edgenum_A] == -1 ? TTRUE : TFALSE;
+
+		if (bUnassigned_A)
+		{
+			// get true index ordering
+			int j=i+1, t;
+			tbool bNotFound = TTRUE;
+			while (j<iEntries && i0==pEdges[j].i0 && i1==pEdges[j].i1 && bNotFound)
+			{
+				tbool bUnassigned_B;
+				int i0_B, i1_B;
+				t = pEdges[j].f;
+				// flip i0_B and i1_B
+				GetEdge(&i1_B, &i0_B, &edgenum_B, &piTriListIn[t*3], pEdges[j].i0, pEdges[j].i1);	// resolve index ordering and edge_num
+				//assert(!(i0_A==i1_B && i1_A==i0_B));
+				bUnassigned_B =  pTriInfos[t].FaceNeighbors[edgenum_B]==-1 ? TTRUE : TFALSE;
+				if (i0_A==i0_B && i1_A==i1_B && bUnassigned_B)
+					bNotFound = TFALSE;
+				else
+					++j;
+			}
+
+			if (!bNotFound)
+			{
+				int t = pEdges[j].f;
+				pTriInfos[f].FaceNeighbors[edgenum_A] = t;
+				//assert(pTriInfos[t].FaceNeighbors[edgenum_B]==-1);
+				pTriInfos[t].FaceNeighbors[edgenum_B] = f;
+			}
+		}
+	}
+}
+
+static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn)
+{
+	int f=0, i=0;
+	for (f=0; f<iNrTrianglesIn; f++)
+	{
+		for (i=0; i<3; i++)
+		{
+			// if unassigned
+			if (pTriInfos[f].FaceNeighbors[i] == -1)
+			{
+				const int i0_A = piTriListIn[f*3+i];
+				const int i1_A = piTriListIn[f*3+(i<2?(i+1):0)];
+
+				// search for a neighbor
+				tbool bFound = TFALSE;
+				int t=0, j=0;
+				while (!bFound && t<iNrTrianglesIn)
+				{
+					if (t!=f)
+					{
+						j=0;
+						while (!bFound && j<3)
+						{
+							// in rev order
+							const int i1_B = piTriListIn[t*3+j];
+							const int i0_B = piTriListIn[t*3+(j<2?(j+1):0)];
+							//assert(!(i0_A==i1_B && i1_A==i0_B));
+							if (i0_A==i0_B && i1_A==i1_B)
+								bFound = TTRUE;
+							else
+								++j;
+						}
+					}
+					
+					if (!bFound) ++t;
+				}
+
+				// assign neighbors
+				if (bFound)
+				{
+					pTriInfos[f].FaceNeighbors[i] = t;
+					//assert(pTriInfos[t].FaceNeighbors[j]==-1);
+					pTriInfos[t].FaceNeighbors[j] = f;
+				}
+			}
+		}
+	}
+}
+
+static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed)
+{
+	unsigned int t;
+	int iL, iR, n, index, iMid;
+
+	// early out
+	SEdge sTmp;
+	const int iElems = iRight-iLeft+1;
+	if (iElems<2) return;
+	else if (iElems==2)
+	{
+		if (pSortBuffer[iLeft].array[channel] > pSortBuffer[iRight].array[channel])
+		{
+			sTmp = pSortBuffer[iLeft];
+			pSortBuffer[iLeft] = pSortBuffer[iRight];
+			pSortBuffer[iRight] = sTmp;
+		}
+		return;
+	}
+
+	// Random
+	t=uSeed&31;
+	t=(uSeed<<t)|(uSeed>>(32-t));
+	uSeed=uSeed+t+3;
+	// Random end
+
+	iL = iLeft;
+	iR = iRight;
+	n = (iR-iL)+1;
+	assert(n>=0);
+	index = (int) (uSeed%n);
+
+	iMid=pSortBuffer[index + iL].array[channel];
+
+	do
+	{
+		while (pSortBuffer[iL].array[channel] < iMid)
+			++iL;
+		while (pSortBuffer[iR].array[channel] > iMid)
+			--iR;
+
+		if (iL <= iR)
+		{
+			sTmp = pSortBuffer[iL];
+			pSortBuffer[iL] = pSortBuffer[iR];
+			pSortBuffer[iR] = sTmp;
+			++iL; --iR;
+		}
+	}
+	while (iL <= iR);
+
+	if (iLeft < iR)
+		QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed);
+	if (iL < iRight)
+		QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed);
+}
+
+// resolve ordering and edge number
+static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in)
+{
+	*edgenum_out = -1;
+	
+	// test if first index is on the edge
+	if (indices[0]==i0_in || indices[0]==i1_in)
+	{
+		// test if second index is on the edge
+		if (indices[1]==i0_in || indices[1]==i1_in)
+		{
+			edgenum_out[0]=0;	// first edge
+			i0_out[0]=indices[0];
+			i1_out[0]=indices[1];
+		}
+		else
+		{
+			edgenum_out[0]=2;	// third edge
+			i0_out[0]=indices[2];
+			i1_out[0]=indices[0];
+		}
+	}
+	else
+	{
+		// only second and third index is on the edge
+		edgenum_out[0]=1;	// second edge
+		i0_out[0]=indices[1];
+		i1_out[0]=indices[2];
+	}
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////// Degenerate triangles ////////////////////////////////////
+
+static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris)
+{
+	int iNextGoodTriangleSearchIndex=-1;
+	tbool bStillFindingGoodOnes;
+
+	// locate quads with only one good triangle
+	int t=0;
+	while (t<(iTotTris-1))
+	{
+		const int iFO_a = pTriInfos[t].iOrgFaceNumber;
+		const int iFO_b = pTriInfos[t+1].iOrgFaceNumber;
+		if (iFO_a==iFO_b)	// this is a quad
+		{
+			const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
+			const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE;
+			if ((bIsDeg_a^bIsDeg_b)!=0)
+			{
+				pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI;
+				pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI;
+			}
+			t += 2;
+		}
+		else
+			++t;
+	}
+
+	// reorder list so all degen triangles are moved to the back
+	// without reordering the good triangles
+	iNextGoodTriangleSearchIndex = 1;
+	t=0;
+	bStillFindingGoodOnes = TTRUE;
+	while (t<iNrTrianglesIn && bStillFindingGoodOnes)
+	{
+		const tbool bIsGood = (pTriInfos[t].iFlag&MARK_DEGENERATE)==0 ? TTRUE : TFALSE;
+		if (bIsGood)
+		{
+			if (iNextGoodTriangleSearchIndex < (t+2))
+				iNextGoodTriangleSearchIndex = t+2;
+		}
+		else
+		{
+			int t0, t1;
+			// search for the first good triangle.
+			tbool bJustADegenerate = TTRUE;
+			while (bJustADegenerate && iNextGoodTriangleSearchIndex<iTotTris)
+			{
+				const tbool bIsGood = (pTriInfos[iNextGoodTriangleSearchIndex].iFlag&MARK_DEGENERATE)==0 ? TTRUE : TFALSE;
+				if (bIsGood) bJustADegenerate=TFALSE;
+				else ++iNextGoodTriangleSearchIndex;
+			}
+
+			t0 = t;
+			t1 = iNextGoodTriangleSearchIndex;
+			++iNextGoodTriangleSearchIndex;
+			assert(iNextGoodTriangleSearchIndex > (t+1));
+
+			// swap triangle t0 and t1
+			if (!bJustADegenerate)
+			{
+				int i=0;
+				for (i=0; i<3; i++)
+				{
+					const int index = piTriList_out[t0*3+i];
+					piTriList_out[t0*3+i] = piTriList_out[t1*3+i];
+					piTriList_out[t1*3+i] = index;
+				}
+				{
+					const STriInfo tri_info = pTriInfos[t0];
+					pTriInfos[t0] = pTriInfos[t1];
+					pTriInfos[t1] = tri_info;
+				}
+			}
+			else
+				bStillFindingGoodOnes = TFALSE;	// this is not supposed to happen
+		}
+
+		if (bStillFindingGoodOnes) ++t;
+	}
+
+	assert(bStillFindingGoodOnes);	// code will still work.
+	assert(iNrTrianglesIn == t);
+}
+
+static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris)
+{
+	int t=0, i=0;
+	// deal with degenerate triangles
+	// punishment for degenerate triangles is O(N^2)
+	for (t=iNrTrianglesIn; t<iTotTris; t++)
+	{
+		// degenerate triangles on a quad with one good triangle are skipped
+		// here but processed in the next loop
+		const tbool bSkip = (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 ? TTRUE : TFALSE;
+
+		if (!bSkip)
+		{
+			for (i=0; i<3; i++)
+			{
+				const int index1 = piTriListIn[t*3+i];
+				// search through the good triangles
+				tbool bNotFound = TTRUE;
+				int j=0;
+				while (bNotFound && j<(3*iNrTrianglesIn))
+				{
+					const int index2 = piTriListIn[j];
+					if (index1==index2) bNotFound=TFALSE;
+					else ++j;
+				}
+
+				if (!bNotFound)
+				{
+					const int iTri = j/3;
+					const int iVert = j%3;
+					const int iSrcVert=pTriInfos[iTri].vert_num[iVert];
+					const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs;
+					const int iDstVert=pTriInfos[t].vert_num[i];
+					const int iDstOffs=pTriInfos[t].iTSpacesOffs;
+					
+					// copy tspace
+					psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert];
+				}
+			}
+		}
+	}
+
+	// deal with degenerate quads with one good triangle
+	for (t=0; t<iNrTrianglesIn; t++)
+	{
+		// this triangle belongs to a quad where the
+		// other triangle is degenerate
+		if ( (pTriInfos[t].iFlag&QUAD_ONE_DEGEN_TRI)!=0 )
+		{
+			SVec3 vDstP;
+			int iOrgF=-1, i=0;
+			tbool bNotFound;
+			unsigned char * pV = pTriInfos[t].vert_num;
+			int iFlag = (1<<pV[0]) | (1<<pV[1]) | (1<<pV[2]);
+			int iMissingIndex = 0;
+			if ((iFlag&2)==0) iMissingIndex=1;
+			else if ((iFlag&4)==0) iMissingIndex=2;
+			else if ((iFlag&8)==0) iMissingIndex=3;
+
+			iOrgF = pTriInfos[t].iOrgFaceNumber;
+			vDstP = GetPosition(pContext, MakeIndex(iOrgF, iMissingIndex));
+			bNotFound = TTRUE;
+			i=0;
+			while (bNotFound && i<3)
+			{
+				const int iVert = pV[i];
+				const SVec3 vSrcP = GetPosition(pContext, MakeIndex(iOrgF, iVert));
+				if (veq(vSrcP, vDstP)==TTRUE)
+				{
+					const int iOffs = pTriInfos[t].iTSpacesOffs;
+					psTspace[iOffs+iMissingIndex] = psTspace[iOffs+iVert];
+					bNotFound=TFALSE;
+				}
+				else
+					++i;
+			}
+			assert(!bNotFound);
+		}
+	}
+}
ADD · third-party/mikktspace.h +145 -0
--- a/third-party/mikktspace.h
+++ b/third-party/mikktspace.h
@@ -0,0 +1,145 @@
+/** \file mikktspace/mikktspace.h
+ *  \ingroup mikktspace
+ */
+/**
+ *  Copyright (C) 2011 by Morten S. Mikkelsen
+ *
+ *  This software is provided 'as-is', without any express or implied
+ *  warranty.  In no event will the authors be held liable for any damages
+ *  arising from the use of this software.
+ *
+ *  Permission is granted to anyone to use this software for any purpose,
+ *  including commercial applications, and to alter it and redistribute it
+ *  freely, subject to the following restrictions:
+ *
+ *  1. The origin of this software must not be misrepresented; you must not
+ *     claim that you wrote the original software. If you use this software
+ *     in a product, an acknowledgment in the product documentation would be
+ *     appreciated but is not required.
+ *  2. Altered source versions must be plainly marked as such, and must not be
+ *     misrepresented as being the original software.
+ *  3. This notice may not be removed or altered from any source distribution.
+ */
+
+#ifndef __MIKKTSPACE_H__
+#define __MIKKTSPACE_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Author: Morten S. Mikkelsen
+ * Version: 1.0
+ *
+ * The files mikktspace.h and mikktspace.c are designed to be
+ * stand-alone files and it is important that they are kept this way.
+ * Not having dependencies on structures/classes/libraries specific
+ * to the program, in which they are used, allows them to be copied
+ * and used as is into any tool, program or plugin.
+ * The code is designed to consistently generate the same
+ * tangent spaces, for a given mesh, in any tool in which it is used.
+ * This is done by performing an internal welding step and subsequently an order-independent evaluation
+ * of tangent space for meshes consisting of triangles and quads.
+ * This means faces can be received in any order and the same is true for
+ * the order of vertices of each face. The generated result will not be affected
+ * by such reordering. Additionally, whether degenerate (vertices or texture coordinates)
+ * primitives are present or not will not affect the generated results either.
+ * Once tangent space calculation is done the vertices of degenerate primitives will simply
+ * inherit tangent space from neighboring non degenerate primitives.
+ * The analysis behind this implementation can be found in my master's thesis
+ * which is available for download --> http://image.diku.dk/projects/media/morten.mikkelsen.08.pdf
+ * Note that though the tangent spaces at the vertices are generated in an order-independent way,
+ * by this implementation, the interpolated tangent space is still affected by which diagonal is
+ * chosen to split each quad. A sensible solution is to have your tools pipeline always
+ * split quads by the shortest diagonal. This choice is order-independent and works with mirroring.
+ * If these have the same length then compare the diagonals defined by the texture coordinates.
+ * XNormal which is a tool for baking normal maps allows you to write your own tangent space plugin
+ * and also quad triangulator plugin.
+ */
+
+
+typedef int tbool;
+typedef struct SMikkTSpaceContext SMikkTSpaceContext;
+
+typedef struct {
+	// Returns the number of faces (triangles/quads) on the mesh to be processed.
+	int (*m_getNumFaces)(const SMikkTSpaceContext * pContext);
+
+	// Returns the number of vertices on face number iFace
+	// iFace is a number in the range {0, 1, ..., getNumFaces()-1}
+	int (*m_getNumVerticesOfFace)(const SMikkTSpaceContext * pContext, const int iFace);
+
+	// returns the position/normal/texcoord of the referenced face of vertex number iVert.
+	// iVert is in the range {0,1,2} for triangles and {0,1,2,3} for quads.
+	void (*m_getPosition)(const SMikkTSpaceContext * pContext, float fvPosOut[], const int iFace, const int iVert);
+	void (*m_getNormal)(const SMikkTSpaceContext * pContext, float fvNormOut[], const int iFace, const int iVert);
+	void (*m_getTexCoord)(const SMikkTSpaceContext * pContext, float fvTexcOut[], const int iFace, const int iVert);
+
+	// either (or both) of the two setTSpace callbacks can be set.
+	// The call-back m_setTSpaceBasic() is sufficient for basic normal mapping.
+
+	// This function is used to return the tangent and fSign to the application.
+	// fvTangent is a unit length vector.
+	// For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
+	// bitangent = fSign * cross(vN, tangent);
+	// Note that the results are returned unindexed. It is possible to generate a new index list
+	// But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results.
+	// DO NOT! use an already existing index list.
+	void (*m_setTSpaceBasic)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert);
+
+	// This function is used to return tangent space results to the application.
+	// fvTangent and fvBiTangent are unit length vectors and fMagS and fMagT are their
+	// true magnitudes which can be used for relief mapping effects.
+	// fvBiTangent is the "real" bitangent and thus may not be perpendicular to fvTangent.
+	// However, both are perpendicular to the vertex normal.
+	// For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level.
+	// fSign = bIsOrientationPreserving ? 1.0f : (-1.0f);
+	// bitangent = fSign * cross(vN, tangent);
+	// Note that the results are returned unindexed. It is possible to generate a new index list
+	// But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results.
+	// DO NOT! use an already existing index list.
+	void (*m_setTSpace)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT,
+						const tbool bIsOrientationPreserving, const int iFace, const int iVert);
+} SMikkTSpaceInterface;
+
+struct SMikkTSpaceContext
+{
+	SMikkTSpaceInterface * m_pInterface;	// initialized with callback functions
+	void * m_pUserData;						// pointer to client side mesh data etc. (passed as the first parameter with every interface call)
+};
+
+// these are both thread safe!
+tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext);	// Default (recommended) fAngularThreshold is 180 degrees (which means threshold disabled)
+tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold);
+
+
+// To avoid visual errors (distortions/unwanted hard edges in lighting), when using sampled normal maps, the
+// normal map sampler must use the exact inverse of the pixel shader transformation.
+// The most efficient transformation we can possibly do in the pixel shader is
+// achieved by using, directly, the "unnormalized" interpolated tangent, bitangent and vertex normal: vT, vB and vN.
+// pixel shader (fast transform out)
+// vNout = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN );
+// where vNt is the tangent space normal. The normal map sampler must likewise use the
+// interpolated and "unnormalized" tangent, bitangent and vertex normal to be compliant with the pixel shader.
+// sampler does (exact inverse of pixel shader):
+// float3 row0 = cross(vB, vN);
+// float3 row1 = cross(vN, vT);
+// float3 row2 = cross(vT, vB);
+// float fSign = dot(vT, row0)<0 ? -1 : 1;
+// vNt = normalize( fSign * float3(dot(vNout,row0), dot(vNout,row1), dot(vNout,row2)) );
+// where vNout is the sampled normal in some chosen 3D space.
+//
+// Should you choose to reconstruct the bitangent in the pixel shader instead
+// of the vertex shader, as explained earlier, then be sure to do this in the normal map sampler also.
+// Finally, beware of quad triangulations. If the normal map sampler doesn't use the same triangulation of
+// quads as your renderer then problems will occur since the interpolated tangent spaces will differ
+// eventhough the vertex level tangent spaces match. This can be solved either by triangulating before
+// sampling/exporting or by using the order-independent choice of diagonal for splitting quads suggested earlier.
+// However, this must be used both by the sampler and your tools/rendering pipeline.
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
ADD · third-party/plog +1 -0
--- a/third-party/plog
+++ b/third-party/plog
@@ -0,0 +1 @@
+Subproject commit e5c033e317a01b2703d13aab42288d09b2efdafc
ADD · third-party/rtm +1 -0
--- a/third-party/rtm
+++ b/third-party/rtm
@@ -0,0 +1 @@
+Subproject commit bc5dd4ee40b5be1c0b3d8b20e3be628e170e0fa1
ADD · third-party/stb_image.h +7989 -0
--- a/third-party/stb_image.h
+++ b/third-party/stb_image.h
@@ -0,0 +1,7989 @@
+/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb
+                                  no warranty implied; use at your own risk
+
+   Do this:
+      #define STB_IMAGE_IMPLEMENTATION
+   before you include this file in *one* C or C++ file to create the implementation.
+
+   // i.e. it should look like this:
+   #include ...
+   #include ...
+   #include ...
+   #define STB_IMAGE_IMPLEMENTATION
+   #include "stb_image.h"
+
+   You can #define STBI_ASSERT(x) before the #include to avoid using assert.h.
+   And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free
+
+
+   QUICK NOTES:
+      Primarily of interest to game developers and other people who can
+          avoid problematic images and only need the trivial interface
+
+      JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
+      PNG 1/2/4/8/16-bit-per-channel
+
+      TGA (not sure what subset, if a subset)
+      BMP non-1bpp, non-RLE
+      PSD (composited view only, no extra channels, 8/16 bit-per-channel)
+
+      GIF (*comp always reports as 4-channel)
+      HDR (radiance rgbE format)
+      PIC (Softimage PIC)
+      PNM (PPM and PGM binary only)
+
+      Animated GIF still needs a proper API, but here's one way to do it:
+          http://gist.github.com/urraka/685d9a6340b26b830d49
+
+      - decode from memory or through FILE (define STBI_NO_STDIO to remove code)
+      - decode from arbitrary I/O callbacks
+      - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON)
+
+   Full documentation under "DOCUMENTATION" below.
+
+
+LICENSE
+
+  See end of file for license information.
+
+RECENT REVISION HISTORY:
+
+      2.30  (2024-05-31) avoid erroneous gcc warning
+      2.29  (2023-05-xx) optimizations
+      2.28  (2023-01-29) many error fixes, security errors, just tons of stuff
+      2.27  (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes
+      2.26  (2020-07-13) many minor fixes
+      2.25  (2020-02-02) fix warnings
+      2.24  (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically
+      2.23  (2019-08-11) fix clang static analysis warning
+      2.22  (2019-03-04) gif fixes, fix warnings
+      2.21  (2019-02-25) fix typo in comment
+      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
+      2.19  (2018-02-11) fix warning
+      2.18  (2018-01-30) fix warnings
+      2.17  (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings
+      2.16  (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes
+      2.15  (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC
+      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
+      2.13  (2016-12-04) experimental 16-bit API, only for PNG so far; fixes
+      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
+      2.11  (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64
+                         RGB-format JPEG; remove white matting in PSD;
+                         allocate large structures on the stack;
+                         correct channel count for PNG & BMP
+      2.10  (2016-01-22) avoid warning introduced in 2.09
+      2.09  (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED
+
+   See end of file for full revision history.
+
+
+ ============================    Contributors    =========================
+
+ Image formats                          Extensions, features
+    Sean Barrett (jpeg, png, bmp)          Jetro Lauha (stbi_info)
+    Nicolas Schulz (hdr, psd)              Martin "SpartanJ" Golini (stbi_info)
+    Jonathan Dummer (tga)                  James "moose2000" Brown (iPhone PNG)
+    Jean-Marc Lienher (gif)                Ben "Disch" Wenger (io callbacks)
+    Tom Seddon (pic)                       Omar Cornut (1/2/4-bit PNG)
+    Thatcher Ulrich (psd)                  Nicolas Guillemot (vertical flip)
+    Ken Miller (pgm, ppm)                  Richard Mitton (16-bit PSD)
+    github:urraka (animated gif)           Junggon Kim (PNM comments)
+    Christopher Forseth (animated gif)     Daniel Gibson (16-bit TGA)
+                                           socks-the-fox (16-bit PNG)
+                                           Jeremy Sawicki (handle all ImageNet JPGs)
+ Optimizations & bugfixes                  Mikhail Morozov (1-bit BMP)
+    Fabian "ryg" Giesen                    Anael Seghezzi (is-16-bit query)
+    Arseny Kapoulkine                      Simon Breuss (16-bit PNM)
+    John-Mark Allen
+    Carmelo J Fdez-Aguera
+
+ Bug & warning fixes
+    Marc LeBlanc            David Woo          Guillaume George     Martins Mozeiko
+    Christpher Lloyd        Jerry Jansson      Joseph Thomson       Blazej Dariusz Roszkowski
+    Phil Jordan                                Dave Moore           Roy Eltham
+    Hayaki Saito            Nathan Reed        Won Chun
+    Luke Graham             Johan Duparc       Nick Verigakis       the Horde3D community
+    Thomas Ruf              Ronny Chevalier                         github:rlyeh
+    Janez Zemva             John Bartholomew   Michal Cichon        github:romigrou
+    Jonathan Blow           Ken Hamada         Tero Hanninen        github:svdijk
+    Eugene Golushkov        Laurent Gomila     Cort Stratton        github:snagar
+    Aruelien Pocheville     Sergio Gonzalez    Thibault Reuille     github:Zelex
+    Cass Everitt            Ryamond Barbiero                        github:grim210
+    Paul Du Bois            Engin Manap        Aldo Culquicondor    github:sammyhw
+    Philipp Wiesemann       Dale Weiler        Oriol Ferrer Mesia   github:phprus
+    Josh Tobin              Neil Bickford      Matthew Gregan       github:poppolopoppo
+    Julian Raschke          Gregory Mullen     Christian Floisand   github:darealshinji
+    Baldur Karlsson         Kevin Schmidt      JR Smith             github:Michaelangel007
+                            Brad Weinberger    Matvey Cherevko      github:mosra
+    Luca Sas                Alexander Veselov  Zack Middleton       [reserved]
+    Ryan C. Gordon          [reserved]                              [reserved]
+                     DO NOT ADD YOUR NAME HERE
+
+                     Jacko Dirks
+
+  To add your name to the credits, pick a random blank space in the middle and fill it.
+  80% of merge conflicts on stb PRs are due to people adding their name at the end
+  of the credits.
+*/
+
+#ifndef STBI_INCLUDE_STB_IMAGE_H
+#define STBI_INCLUDE_STB_IMAGE_H
+
+// DOCUMENTATION
+//
+// Limitations:
+//    - no 12-bit-per-channel JPEG
+//    - no JPEGs with arithmetic coding
+//    - GIF always returns *comp=4
+//
+// Basic usage (see HDR discussion below for HDR usage):
+//    int x,y,n;
+//    unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
+//    // ... process data if not NULL ...
+//    // ... x = width, y = height, n = # 8-bit components per pixel ...
+//    // ... replace '0' with '1'..'4' to force that many components per pixel
+//    // ... but 'n' will always be the number that it would have been if you said 0
+//    stbi_image_free(data);
+//
+// Standard parameters:
+//    int *x                 -- outputs image width in pixels
+//    int *y                 -- outputs image height in pixels
+//    int *channels_in_file  -- outputs # of image components in image file
+//    int desired_channels   -- if non-zero, # of image components requested in result
+//
+// The return value from an image loader is an 'unsigned char *' which points
+// to the pixel data, or NULL on an allocation failure or if the image is
+// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels,
+// with each pixel consisting of N interleaved 8-bit components; the first
+// pixel pointed to is top-left-most in the image. There is no padding between
+// image scanlines or between pixels, regardless of format. The number of
+// components N is 'desired_channels' if desired_channels is non-zero, or
+// *channels_in_file otherwise. If desired_channels is non-zero,
+// *channels_in_file has the number of components that _would_ have been
+// output otherwise. E.g. if you set desired_channels to 4, you will always
+// get RGBA output, but you can check *channels_in_file to see if it's trivially
+// opaque because e.g. there were only 3 channels in the source image.
+//
+// An output image with N components has the following components interleaved
+// in this order in each pixel:
+//
+//     N=#comp     components
+//       1           grey
+//       2           grey, alpha
+//       3           red, green, blue
+//       4           red, green, blue, alpha
+//
+// If image loading fails for any reason, the return value will be NULL,
+// and *x, *y, *channels_in_file will be unchanged. The function
+// stbi_failure_reason() can be queried for an extremely brief, end-user
+// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS
+// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
+// more user-friendly ones.
+//
+// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
+//
+// To query the width, height and component count of an image without having to
+// decode the full file, you can use the stbi_info family of functions:
+//
+//   int x,y,n,ok;
+//   ok = stbi_info(filename, &x, &y, &n);
+//   // returns ok=1 and sets x, y, n if image is a supported format,
+//   // 0 otherwise.
+//
+// Note that stb_image pervasively uses ints in its public API for sizes,
+// including sizes of memory buffers. This is now part of the API and thus
+// hard to change without causing breakage. As a result, the various image
+// loaders all have certain limits on image size; these differ somewhat
+// by format but generally boil down to either just under 2GB or just under
+// 1GB. When the decoded image would be larger than this, stb_image decoding
+// will fail.
+//
+// Additionally, stb_image will reject image files that have any of their
+// dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS,
+// which defaults to 2**24 = 16777216 pixels. Due to the above memory limit,
+// the only way to have an image with such dimensions load correctly
+// is for it to have a rather extreme aspect ratio. Either way, the
+// assumption here is that such larger images are likely to be malformed
+// or malicious. If you do need to load an image with individual dimensions
+// larger than that, and it still fits in the overall size limit, you can
+// #define STBI_MAX_DIMENSIONS on your own to be something larger.
+//
+// ===========================================================================
+//
+// UNICODE:
+//
+//   If compiling for Windows and you wish to use Unicode filenames, compile
+//   with
+//       #define STBI_WINDOWS_UTF8
+//   and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert
+//   Windows wchar_t filenames to utf8.
+//
+// ===========================================================================
+//
+// Philosophy
+//
+// stb libraries are designed with the following priorities:
+//
+//    1. easy to use
+//    2. easy to maintain
+//    3. good performance
+//
+// Sometimes I let "good performance" creep up in priority over "easy to maintain",
+// and for best performance I may provide less-easy-to-use APIs that give higher
+// performance, in addition to the easy-to-use ones. Nevertheless, it's important
+// to keep in mind that from the standpoint of you, a client of this library,
+// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all.
+//
+// Some secondary priorities arise directly from the first two, some of which
+// provide more explicit reasons why performance can't be emphasized.
+//
+//    - Portable ("ease of use")
+//    - Small source code footprint ("easy to maintain")
+//    - No dependencies ("ease of use")
+//
+// ===========================================================================
+//
+// I/O callbacks
+//
+// I/O callbacks allow you to read from arbitrary sources, like packaged
+// files or some other source. Data read from callbacks are processed
+// through a small internal buffer (currently 128 bytes) to try to reduce
+// overhead.
+//
+// The three functions you must define are "read" (reads some bytes of data),
+// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
+//
+// ===========================================================================
+//
+// SIMD support
+//
+// The JPEG decoder will try to automatically use SIMD kernels on x86 when
+// supported by the compiler. For ARM Neon support, you must explicitly
+// request it.
+//
+// (The old do-it-yourself SIMD API is no longer supported in the current
+// code.)
+//
+// On x86, SSE2 will automatically be used when available based on a run-time
+// test; if not, the generic C versions are used as a fall-back. On ARM targets,
+// the typical path is to have separate builds for NEON and non-NEON devices
+// (at least this is true for iOS and Android). Therefore, the NEON support is
+// toggled by a build flag: define STBI_NEON to get NEON loops.
+//
+// If for some reason you do not want to use any of SIMD code, or if
+// you have issues compiling it, you can disable it entirely by
+// defining STBI_NO_SIMD.
+//
+// ===========================================================================
+//
+// HDR image support   (disable by defining STBI_NO_HDR)
+//
+// stb_image supports loading HDR images in general, and currently the Radiance
+// .HDR file format specifically. You can still load any file through the existing
+// interface; if you attempt to load an HDR file, it will be automatically remapped
+// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
+// both of these constants can be reconfigured through this interface:
+//
+//     stbi_hdr_to_ldr_gamma(2.2f);
+//     stbi_hdr_to_ldr_scale(1.0f);
+//
+// (note, do not use _inverse_ constants; stbi_image will invert them
+// appropriately).
+//
+// Additionally, there is a new, parallel interface for loading files as
+// (linear) floats to preserve the full dynamic range:
+//
+//    float *data = stbi_loadf(filename, &x, &y, &n, 0);
+//
+// If you load LDR images through this interface, those images will
+// be promoted to floating point values, run through the inverse of
+// constants corresponding to the above:
+//
+//     stbi_ldr_to_hdr_scale(1.0f);
+//     stbi_ldr_to_hdr_gamma(2.2f);
+//
+// Finally, given a filename (or an open file or memory block--see header
+// file for details) containing image data, you can query for the "most
+// appropriate" interface to use (that is, whether the image is HDR or
+// not), using:
+//
+//     stbi_is_hdr(char *filename);
+//
+// ===========================================================================
+//
+// iPhone PNG support:
+//
+// We optionally support converting iPhone-formatted PNGs (which store
+// premultiplied BGRA) back to RGB, even though they're internally encoded
+// differently. To enable this conversion, call
+// stbi_convert_iphone_png_to_rgb(1).
+//
+// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
+// pixel to remove any premultiplied alpha *only* if the image file explicitly
+// says there's premultiplied data (currently only happens in iPhone images,
+// and only if iPhone convert-to-rgb processing is on).
+//
+// ===========================================================================
+//
+// ADDITIONAL CONFIGURATION
+//
+//  - You can suppress implementation of any of the decoders to reduce
+//    your code footprint by #defining one or more of the following
+//    symbols before creating the implementation.
+//
+//        STBI_NO_JPEG
+//        STBI_NO_PNG
+//        STBI_NO_BMP
+//        STBI_NO_PSD
+//        STBI_NO_TGA
+//        STBI_NO_GIF
+//        STBI_NO_HDR
+//        STBI_NO_PIC
+//        STBI_NO_PNM   (.ppm and .pgm)
+//
+//  - You can request *only* certain decoders and suppress all other ones
+//    (this will be more forward-compatible, as addition of new decoders
+//    doesn't require you to disable them explicitly):
+//
+//        STBI_ONLY_JPEG
+//        STBI_ONLY_PNG
+//        STBI_ONLY_BMP
+//        STBI_ONLY_PSD
+//        STBI_ONLY_TGA
+//        STBI_ONLY_GIF
+//        STBI_ONLY_HDR
+//        STBI_ONLY_PIC
+//        STBI_ONLY_PNM   (.ppm and .pgm)
+//
+//   - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still
+//     want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB
+//
+//  - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater
+//    than that size (in either width or height) without further processing.
+//    This is to let programs in the wild set an upper bound to prevent
+//    denial-of-service attacks on untrusted data, as one could generate a
+//    valid image of gigantic dimensions and force stb_image to allocate a
+//    huge block of memory and spend disproportionate time decoding it. By
+//    default this is set to (1 << 24), which is 16777216, but that's still
+//    very big.
+
+#ifndef STBI_NO_STDIO
+#include <stdio.h>
+#endif // STBI_NO_STDIO
+
+#define STBI_VERSION 1
+
+enum
+{
+   STBI_default = 0, // only used for desired_channels
+
+   STBI_grey       = 1,
+   STBI_grey_alpha = 2,
+   STBI_rgb        = 3,
+   STBI_rgb_alpha  = 4
+};
+
+#include <stdlib.h>
+typedef unsigned char stbi_uc;
+typedef unsigned short stbi_us;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef STBIDEF
+#ifdef STB_IMAGE_STATIC
+#define STBIDEF static
+#else
+#define STBIDEF extern
+#endif
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// PRIMARY API - works on images of any type
+//
+
+//
+// load image by filename, open file, or memory buffer
+//
+
+typedef struct
+{
+   int      (*read)  (void *user,char *data,int size);   // fill 'data' with 'size' bytes.  return number of bytes actually read
+   void     (*skip)  (void *user,int n);                 // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
+   int      (*eof)   (void *user);                       // returns nonzero if we are at end of file/data
+} stbi_io_callbacks;
+
+////////////////////////////////////
+//
+// 8-bits-per-channel interface
+//
+
+STBIDEF stbi_uc *stbi_load_from_memory   (stbi_uc           const *buffer, int len   , int *x, int *y, int *channels_in_file, int desired_channels);
+STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk  , void *user, int *x, int *y, int *channels_in_file, int desired_channels);
+
+#ifndef STBI_NO_STDIO
+STBIDEF stbi_uc *stbi_load            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
+STBIDEF stbi_uc *stbi_load_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
+// for stbi_load_from_file, file pointer is left pointing immediately after image
+#endif
+
+#ifndef STBI_NO_GIF
+STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
+#endif
+
+#ifdef STBI_WINDOWS_UTF8
+STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
+#endif
+
+////////////////////////////////////
+//
+// 16-bits-per-channel interface
+//
+
+STBIDEF stbi_us *stbi_load_16_from_memory   (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
+STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels);
+
+#ifndef STBI_NO_STDIO
+STBIDEF stbi_us *stbi_load_16          (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
+STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
+#endif
+
+////////////////////////////////////
+//
+// float-per-channel interface
+//
+#ifndef STBI_NO_LINEAR
+   STBIDEF float *stbi_loadf_from_memory     (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
+   STBIDEF float *stbi_loadf_from_callbacks  (stbi_io_callbacks const *clbk, void *user, int *x, int *y,  int *channels_in_file, int desired_channels);
+
+   #ifndef STBI_NO_STDIO
+   STBIDEF float *stbi_loadf            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
+   STBIDEF float *stbi_loadf_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
+   #endif
+#endif
+
+#ifndef STBI_NO_HDR
+   STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma);
+   STBIDEF void   stbi_hdr_to_ldr_scale(float scale);
+#endif // STBI_NO_HDR
+
+#ifndef STBI_NO_LINEAR
+   STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma);
+   STBIDEF void   stbi_ldr_to_hdr_scale(float scale);
+#endif // STBI_NO_LINEAR
+
+// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
+STBIDEF int    stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
+STBIDEF int    stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
+#ifndef STBI_NO_STDIO
+STBIDEF int      stbi_is_hdr          (char const *filename);
+STBIDEF int      stbi_is_hdr_from_file(FILE *f);
+#endif // STBI_NO_STDIO
+
+
+// get a VERY brief reason for failure
+// on most compilers (and ALL modern mainstream compilers) this is threadsafe
+STBIDEF const char *stbi_failure_reason  (void);
+
+// free the loaded image -- this is just free()
+STBIDEF void     stbi_image_free      (void *retval_from_stbi_load);
+
+// get image dimensions & components without fully decoding
+STBIDEF int      stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
+STBIDEF int      stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
+STBIDEF int      stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len);
+STBIDEF int      stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user);
+
+#ifndef STBI_NO_STDIO
+STBIDEF int      stbi_info               (char const *filename,     int *x, int *y, int *comp);
+STBIDEF int      stbi_info_from_file     (FILE *f,                  int *x, int *y, int *comp);
+STBIDEF int      stbi_is_16_bit          (char const *filename);
+STBIDEF int      stbi_is_16_bit_from_file(FILE *f);
+#endif
+
+
+
+// for image formats that explicitly notate that they have premultiplied alpha,
+// we just return the colors as stored in the file. set this flag to force
+// unpremultiplication. results are undefined if the unpremultiply overflow.
+STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
+
+// indicate whether we should process iphone images back to canonical format,
+// or just pass them through "as-is"
+STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
+
+// flip the image vertically, so the first pixel in the output array is the bottom left
+STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
+
+// as above, but only applies to images loaded on the thread that calls the function
+// this function is only available if your compiler supports thread-local variables;
+// calling it will fail to link if your compiler doesn't
+STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply);
+STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert);
+STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
+
+// ZLIB client - used by PNG, available for other purposes
+
+STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
+STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);
+STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
+STBIDEF int   stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
+
+STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
+STBIDEF int   stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+//
+//
+////   end header file   /////////////////////////////////////////////////////
+#endif // STBI_INCLUDE_STB_IMAGE_H
+
+#ifdef STB_IMAGE_IMPLEMENTATION
+
+#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \
+  || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \
+  || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \
+  || defined(STBI_ONLY_ZLIB)
+   #ifndef STBI_ONLY_JPEG
+   #define STBI_NO_JPEG
+   #endif
+   #ifndef STBI_ONLY_PNG
+   #define STBI_NO_PNG
+   #endif
+   #ifndef STBI_ONLY_BMP
+   #define STBI_NO_BMP
+   #endif
+   #ifndef STBI_ONLY_PSD
+   #define STBI_NO_PSD
+   #endif
+   #ifndef STBI_ONLY_TGA
+   #define STBI_NO_TGA
+   #endif
+   #ifndef STBI_ONLY_GIF
+   #define STBI_NO_GIF
+   #endif
+   #ifndef STBI_ONLY_HDR
+   #define STBI_NO_HDR
+   #endif
+   #ifndef STBI_ONLY_PIC
+   #define STBI_NO_PIC
+   #endif
+   #ifndef STBI_ONLY_PNM
+   #define STBI_NO_PNM
+   #endif
+#endif
+
+#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB)
+#define STBI_NO_ZLIB
+#endif
+
+
+#include <stdarg.h>
+#include <stddef.h> // ptrdiff_t on osx
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
+#include <math.h>  // ldexp, pow
+#endif
+
+#ifndef STBI_NO_STDIO
+#include <stdio.h>
+#endif
+
+#ifndef STBI_ASSERT
+#include <assert.h>
+#define STBI_ASSERT(x) assert(x)
+#endif
+
+#ifdef __cplusplus
+#define STBI_EXTERN extern "C"
+#else
+#define STBI_EXTERN extern
+#endif
+
+
+#ifndef _MSC_VER
+   #ifdef __cplusplus
+   #define stbi_inline inline
+   #else
+   #define stbi_inline
+   #endif
+#else
+   #define stbi_inline __forceinline
+#endif
+
+#ifndef STBI_NO_THREAD_LOCALS
+   #if defined(__cplusplus) &&  __cplusplus >= 201103L
+      #define STBI_THREAD_LOCAL       thread_local
+   #elif defined(__GNUC__) && __GNUC__ < 5
+      #define STBI_THREAD_LOCAL       __thread
+   #elif defined(_MSC_VER)
+      #define STBI_THREAD_LOCAL       __declspec(thread)
+   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
+      #define STBI_THREAD_LOCAL       _Thread_local
+   #endif
+
+   #ifndef STBI_THREAD_LOCAL
+      #if defined(__GNUC__)
+        #define STBI_THREAD_LOCAL       __thread
+      #endif
+   #endif
+#endif
+
+#if defined(_MSC_VER) || defined(__SYMBIAN32__)
+typedef unsigned short stbi__uint16;
+typedef   signed short stbi__int16;
+typedef unsigned int   stbi__uint32;
+typedef   signed int   stbi__int32;
+#else
+#include <stdint.h>
+typedef uint16_t stbi__uint16;
+typedef int16_t  stbi__int16;
+typedef uint32_t stbi__uint32;
+typedef int32_t  stbi__int32;
+#endif
+
+// should produce compiler error if size is wrong
+typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
+
+#ifdef _MSC_VER
+#define STBI_NOTUSED(v)  (void)(v)
+#else
+#define STBI_NOTUSED(v)  (void)sizeof(v)
+#endif
+
+#ifdef _MSC_VER
+#define STBI_HAS_LROTL
+#endif
+
+#ifdef STBI_HAS_LROTL
+   #define stbi_lrot(x,y)  _lrotl(x,y)
+#else
+   #define stbi_lrot(x,y)  (((x) << (y)) | ((x) >> (-(y) & 31)))
+#endif
+
+#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
+// ok
+#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED)
+// ok
+#else
+#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)."
+#endif
+
+#ifndef STBI_MALLOC
+#define STBI_MALLOC(sz)           malloc(sz)
+#define STBI_REALLOC(p,newsz)     realloc(p,newsz)
+#define STBI_FREE(p)              free(p)
+#endif
+
+#ifndef STBI_REALLOC_SIZED
+#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz)
+#endif
+
+// x86/x64 detection
+#if defined(__x86_64__) || defined(_M_X64)
+#define STBI__X64_TARGET
+#elif defined(__i386) || defined(_M_IX86)
+#define STBI__X86_TARGET
+#endif
+
+#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)
+// gcc doesn't support sse2 intrinsics unless you compile with -msse2,
+// which in turn means it gets to use SSE2 everywhere. This is unfortunate,
+// but previous attempts to provide the SSE2 functions with runtime
+// detection caused numerous issues. The way architecture extensions are
+// exposed in GCC/Clang is, sadly, not really suited for one-file libs.
+// New behavior: if compiled with -msse2, we use SSE2 without any
+// detection; if not, we don't use it at all.
+#define STBI_NO_SIMD
+#endif
+
+#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)
+// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET
+//
+// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the
+// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.
+// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not
+// simultaneously enabling "-mstackrealign".
+//
+// See https://github.com/nothings/stb/issues/81 for more information.
+//
+// So default to no SSE2 on 32-bit MinGW. If you've read this far and added
+// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.
+#define STBI_NO_SIMD
+#endif
+
+#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET))
+#define STBI_SSE2
+#include <emmintrin.h>
+
+#ifdef _MSC_VER
+
+#if _MSC_VER >= 1400  // not VC6
+#include <intrin.h> // __cpuid
+static int stbi__cpuid3(void)
+{
+   int info[4];
+   __cpuid(info,1);
+   return info[3];
+}
+#else
+static int stbi__cpuid3(void)
+{
+   int res;
+   __asm {
+      mov  eax,1
+      cpuid
+      mov  res,edx
+   }
+   return res;
+}
+#endif
+
+#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
+
+#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
+static int stbi__sse2_available(void)
+{
+   int info3 = stbi__cpuid3();
+   return ((info3 >> 26) & 1) != 0;
+}
+#endif
+
+#else // assume GCC-style if not VC++
+#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
+
+#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
+static int stbi__sse2_available(void)
+{
+   // If we're even attempting to compile this on GCC/Clang, that means
+   // -msse2 is on, which means the compiler is allowed to use SSE2
+   // instructions at will, and so are we.
+   return 1;
+}
+#endif
+
+#endif
+#endif
+
+// ARM NEON
+#if defined(STBI_NO_SIMD) && defined(STBI_NEON)
+#undef STBI_NEON
+#endif
+
+#ifdef STBI_NEON
+#include <arm_neon.h>
+#ifdef _MSC_VER
+#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
+#else
+#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
+#endif
+#endif
+
+#ifndef STBI_SIMD_ALIGN
+#define STBI_SIMD_ALIGN(type, name) type name
+#endif
+
+#ifndef STBI_MAX_DIMENSIONS
+#define STBI_MAX_DIMENSIONS (1 << 24)
+#endif
+
+///////////////////////////////////////////////
+//
+//  stbi__context struct and start_xxx functions
+
+// stbi__context structure is our basic context used by all images, so it
+// contains all the IO context, plus some basic image information
+typedef struct
+{
+   stbi__uint32 img_x, img_y;
+   int img_n, img_out_n;
+
+   stbi_io_callbacks io;
+   void *io_user_data;
+
+   int read_from_callbacks;
+   int buflen;
+   stbi_uc buffer_start[128];
+   int callback_already_read;
+
+   stbi_uc *img_buffer, *img_buffer_end;
+   stbi_uc *img_buffer_original, *img_buffer_original_end;
+} stbi__context;
+
+
+static void stbi__refill_buffer(stbi__context *s);
+
+// initialize a memory-decode context
+static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len)
+{
+   s->io.read = NULL;
+   s->read_from_callbacks = 0;
+   s->callback_already_read = 0;
+   s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer;
+   s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len;
+}
+
+// initialize a callback-based context
+static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user)
+{
+   s->io = *c;
+   s->io_user_data = user;
+   s->buflen = sizeof(s->buffer_start);
+   s->read_from_callbacks = 1;
+   s->callback_already_read = 0;
+   s->img_buffer = s->img_buffer_original = s->buffer_start;
+   stbi__refill_buffer(s);
+   s->img_buffer_original_end = s->img_buffer_end;
+}
+
+#ifndef STBI_NO_STDIO
+
+static int stbi__stdio_read(void *user, char *data, int size)
+{
+   return (int) fread(data,1,size,(FILE*) user);
+}
+
+static void stbi__stdio_skip(void *user, int n)
+{
+   int ch;
+   fseek((FILE*) user, n, SEEK_CUR);
+   ch = fgetc((FILE*) user);  /* have to read a byte to reset feof()'s flag */
+   if (ch != EOF) {
+      ungetc(ch, (FILE *) user);  /* push byte back onto stream if valid. */
+   }
+}
+
+static int stbi__stdio_eof(void *user)
+{
+   return feof((FILE*) user) || ferror((FILE *) user);
+}
+
+static stbi_io_callbacks stbi__stdio_callbacks =
+{
+   stbi__stdio_read,
+   stbi__stdio_skip,
+   stbi__stdio_eof,
+};
+
+static void stbi__start_file(stbi__context *s, FILE *f)
+{
+   stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f);
+}
+
+//static void stop_file(stbi__context *s) { }
+
+#endif // !STBI_NO_STDIO
+
+static void stbi__rewind(stbi__context *s)
+{
+   // conceptually rewind SHOULD rewind to the beginning of the stream,
+   // but we just rewind to the beginning of the initial buffer, because
+   // we only use it after doing 'test', which only ever looks at at most 92 bytes
+   s->img_buffer = s->img_buffer_original;
+   s->img_buffer_end = s->img_buffer_original_end;
+}
+
+enum
+{
+   STBI_ORDER_RGB,
+   STBI_ORDER_BGR
+};
+
+typedef struct
+{
+   int bits_per_channel;
+   int num_channels;
+   int channel_order;
+} stbi__result_info;
+
+#ifndef STBI_NO_JPEG
+static int      stbi__jpeg_test(stbi__context *s);
+static void    *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_PNG
+static int      stbi__png_test(stbi__context *s);
+static void    *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__png_info(stbi__context *s, int *x, int *y, int *comp);
+static int      stbi__png_is16(stbi__context *s);
+#endif
+
+#ifndef STBI_NO_BMP
+static int      stbi__bmp_test(stbi__context *s);
+static void    *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_TGA
+static int      stbi__tga_test(stbi__context *s);
+static void    *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__tga_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_PSD
+static int      stbi__psd_test(stbi__context *s);
+static void    *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc);
+static int      stbi__psd_info(stbi__context *s, int *x, int *y, int *comp);
+static int      stbi__psd_is16(stbi__context *s);
+#endif
+
+#ifndef STBI_NO_HDR
+static int      stbi__hdr_test(stbi__context *s);
+static float   *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_PIC
+static int      stbi__pic_test(stbi__context *s);
+static void    *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__pic_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_GIF
+static int      stbi__gif_test(stbi__context *s);
+static void    *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static void    *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
+static int      stbi__gif_info(stbi__context *s, int *x, int *y, int *comp);
+#endif
+
+#ifndef STBI_NO_PNM
+static int      stbi__pnm_test(stbi__context *s);
+static void    *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
+static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);
+static int      stbi__pnm_is16(stbi__context *s);
+#endif
+
+static
+#ifdef STBI_THREAD_LOCAL
+STBI_THREAD_LOCAL
+#endif
+const char *stbi__g_failure_reason;
+
+STBIDEF const char *stbi_failure_reason(void)
+{
+   return stbi__g_failure_reason;
+}
+
+#ifndef STBI_NO_FAILURE_STRINGS
+static int stbi__err(const char *str)
+{
+   stbi__g_failure_reason = str;
+   return 0;
+}
+#endif
+
+static void *stbi__malloc(size_t size)
+{
+    return STBI_MALLOC(size);
+}
+
+// stb_image uses ints pervasively, including for offset calculations.
+// therefore the largest decoded image size we can support with the
+// current code, even on 64-bit targets, is INT_MAX. this is not a
+// significant limitation for the intended use case.
+//
+// we do, however, need to make sure our size calculations don't
+// overflow. hence a few helper functions for size calculations that
+// multiply integers together, making sure that they're non-negative
+// and no overflow occurs.
+
+// return 1 if the sum is valid, 0 on overflow.
+// negative terms are considered invalid.
+static int stbi__addsizes_valid(int a, int b)
+{
+   if (b < 0) return 0;
+   // now 0 <= b <= INT_MAX, hence also
+   // 0 <= INT_MAX - b <= INTMAX.
+   // And "a + b <= INT_MAX" (which might overflow) is the
+   // same as a <= INT_MAX - b (no overflow)
+   return a <= INT_MAX - b;
+}
+
+// returns 1 if the product is valid, 0 on overflow.
+// negative factors are considered invalid.
+static int stbi__mul2sizes_valid(int a, int b)
+{
+   if (a < 0 || b < 0) return 0;
+   if (b == 0) return 1; // mul-by-0 is always safe
+   // portable way to check for no overflows in a*b
+   return a <= INT_MAX/b;
+}
+
+#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
+// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow
+static int stbi__mad2sizes_valid(int a, int b, int add)
+{
+   return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add);
+}
+#endif
+
+// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow
+static int stbi__mad3sizes_valid(int a, int b, int c, int add)
+{
+   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
+      stbi__addsizes_valid(a*b*c, add);
+}
+
+// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
+#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
+static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
+{
+   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
+      stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
+}
+#endif
+
+#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
+// mallocs with size overflow checking
+static void *stbi__malloc_mad2(int a, int b, int add)
+{
+   if (!stbi__mad2sizes_valid(a, b, add)) return NULL;
+   return stbi__malloc(a*b + add);
+}
+#endif
+
+static void *stbi__malloc_mad3(int a, int b, int c, int add)
+{
+   if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL;
+   return stbi__malloc(a*b*c + add);
+}
+
+#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM)
+static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
+{
+   if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
+   return stbi__malloc(a*b*c*d + add);
+}
+#endif
+
+// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.
+static int stbi__addints_valid(int a, int b)
+{
+   if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow
+   if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0.
+   return a <= INT_MAX - b;
+}
+
+// returns 1 if the product of two ints fits in a signed short, 0 on overflow.
+static int stbi__mul2shorts_valid(int a, int b)
+{
+   if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow
+   if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid
+   if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN
+   return a >= SHRT_MIN / b;
+}
+
+// stbi__err - error
+// stbi__errpf - error returning pointer to float
+// stbi__errpuc - error returning pointer to unsigned char
+
+#ifdef STBI_NO_FAILURE_STRINGS
+   #define stbi__err(x,y)  0
+#elif defined(STBI_FAILURE_USERMSG)
+   #define stbi__err(x,y)  stbi__err(y)
+#else
+   #define stbi__err(x,y)  stbi__err(x)
+#endif
+
+#define stbi__errpf(x,y)   ((float *)(size_t) (stbi__err(x,y)?NULL:NULL))
+#define stbi__errpuc(x,y)  ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))
+
+STBIDEF void stbi_image_free(void *retval_from_stbi_load)
+{
+   STBI_FREE(retval_from_stbi_load);
+}
+
+#ifndef STBI_NO_LINEAR
+static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp);
+#endif
+
+#ifndef STBI_NO_HDR
+static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp);
+#endif
+
+static int stbi__vertically_flip_on_load_global = 0;
+
+STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip)
+{
+   stbi__vertically_flip_on_load_global = flag_true_if_should_flip;
+}
+
+#ifndef STBI_THREAD_LOCAL
+#define stbi__vertically_flip_on_load  stbi__vertically_flip_on_load_global
+#else
+static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set;
+
+STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip)
+{
+   stbi__vertically_flip_on_load_local = flag_true_if_should_flip;
+   stbi__vertically_flip_on_load_set = 1;
+}
+
+#define stbi__vertically_flip_on_load  (stbi__vertically_flip_on_load_set       \
+                                         ? stbi__vertically_flip_on_load_local  \
+                                         : stbi__vertically_flip_on_load_global)
+#endif // STBI_THREAD_LOCAL
+
+static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
+{
+   memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields
+   ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed
+   ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
+   ri->num_channels = 0;
+
+   // test the formats with a very explicit header first (at least a FOURCC
+   // or distinctive magic number first)
+   #ifndef STBI_NO_PNG
+   if (stbi__png_test(s))  return stbi__png_load(s,x,y,comp,req_comp, ri);
+   #endif
+   #ifndef STBI_NO_BMP
+   if (stbi__bmp_test(s))  return stbi__bmp_load(s,x,y,comp,req_comp, ri);
+   #endif
+   #ifndef STBI_NO_GIF
+   if (stbi__gif_test(s))  return stbi__gif_load(s,x,y,comp,req_comp, ri);
+   #endif
+   #ifndef STBI_NO_PSD
+   if (stbi__psd_test(s))  return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc);
+   #else
+   STBI_NOTUSED(bpc);
+   #endif
+   #ifndef STBI_NO_PIC
+   if (stbi__pic_test(s))  return stbi__pic_load(s,x,y,comp,req_comp, ri);
+   #endif
+
+   // then the formats that can end up attempting to load with just 1 or 2
+   // bytes matching expectations; these are prone to false positives, so
+   // try them later
+   #ifndef STBI_NO_JPEG
+   if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
+   #endif
+   #ifndef STBI_NO_PNM
+   if (stbi__pnm_test(s))  return stbi__pnm_load(s,x,y,comp,req_comp, ri);
+   #endif
+
+   #ifndef STBI_NO_HDR
+   if (stbi__hdr_test(s)) {
+      float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri);
+      return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);
+   }
+   #endif
+
+   #ifndef STBI_NO_TGA
+   // test tga last because it's a crappy test!
+   if (stbi__tga_test(s))
+      return stbi__tga_load(s,x,y,comp,req_comp, ri);
+   #endif
+
+   return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt");
+}
+
+static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)
+{
+   int i;
+   int img_len = w * h * channels;
+   stbi_uc *reduced;
+
+   reduced = (stbi_uc *) stbi__malloc(img_len);
+   if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory");
+
+   for (i = 0; i < img_len; ++i)
+      reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling
+
+   STBI_FREE(orig);
+   return reduced;
+}
+
+static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels)
+{
+   int i;
+   int img_len = w * h * channels;
+   stbi__uint16 *enlarged;
+
+   enlarged = (stbi__uint16 *) stbi__malloc(img_len*2);
+   if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
+
+   for (i = 0; i < img_len; ++i)
+      enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff
+
+   STBI_FREE(orig);
+   return enlarged;
+}
+
+static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel)
+{
+   int row;
+   size_t bytes_per_row = (size_t)w * bytes_per_pixel;
+   stbi_uc temp[2048];
+   stbi_uc *bytes = (stbi_uc *)image;
+
+   for (row = 0; row < (h>>1); row++) {
+      stbi_uc *row0 = bytes + row*bytes_per_row;
+      stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row;
+      // swap row0 with row1
+      size_t bytes_left = bytes_per_row;
+      while (bytes_left) {
+         size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp);
+         memcpy(temp, row0, bytes_copy);
+         memcpy(row0, row1, bytes_copy);
+         memcpy(row1, temp, bytes_copy);
+         row0 += bytes_copy;
+         row1 += bytes_copy;
+         bytes_left -= bytes_copy;
+      }
+   }
+}
+
+#ifndef STBI_NO_GIF
+static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel)
+{
+   int slice;
+   int slice_size = w * h * bytes_per_pixel;
+
+   stbi_uc *bytes = (stbi_uc *)image;
+   for (slice = 0; slice < z; ++slice) {
+      stbi__vertical_flip(bytes, w, h, bytes_per_pixel);
+      bytes += slice_size;
+   }
+}
+#endif
+
+static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__result_info ri;
+   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8);
+
+   if (result == NULL)
+      return NULL;
+
+   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
+   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
+
+   if (ri.bits_per_channel != 8) {
+      result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
+      ri.bits_per_channel = 8;
+   }
+
+   // @TODO: move stbi__convert_format to here
+
+   if (stbi__vertically_flip_on_load) {
+      int channels = req_comp ? req_comp : *comp;
+      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc));
+   }
+
+   return (unsigned char *) result;
+}
+
+static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__result_info ri;
+   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16);
+
+   if (result == NULL)
+      return NULL;
+
+   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
+   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
+
+   if (ri.bits_per_channel != 16) {
+      result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
+      ri.bits_per_channel = 16;
+   }
+
+   // @TODO: move stbi__convert_format16 to here
+   // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision
+
+   if (stbi__vertically_flip_on_load) {
+      int channels = req_comp ? req_comp : *comp;
+      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16));
+   }
+
+   return (stbi__uint16 *) result;
+}
+
+#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR)
+static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp)
+{
+   if (stbi__vertically_flip_on_load && result != NULL) {
+      int channels = req_comp ? req_comp : *comp;
+      stbi__vertical_flip(result, *x, *y, channels * sizeof(float));
+   }
+}
+#endif
+
+#ifndef STBI_NO_STDIO
+
+#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
+STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
+STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
+#endif
+
+#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
+STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
+{
+	return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
+}
+#endif
+
+static FILE *stbi__fopen(char const *filename, char const *mode)
+{
+   FILE *f;
+#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8)
+   wchar_t wMode[64];
+   wchar_t wFilename[1024];
+	if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename)))
+      return 0;
+
+	if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode)))
+      return 0;
+
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+	if (0 != _wfopen_s(&f, wFilename, wMode))
+		f = 0;
+#else
+   f = _wfopen(wFilename, wMode);
+#endif
+
+#elif defined(_MSC_VER) && _MSC_VER >= 1400
+   if (0 != fopen_s(&f, filename, mode))
+      f=0;
+#else
+   f = fopen(filename, mode);
+#endif
+   return f;
+}
+
+
+STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)
+{
+   FILE *f = stbi__fopen(filename, "rb");
+   unsigned char *result;
+   if (!f) return stbi__errpuc("can't fopen", "Unable to open file");
+   result = stbi_load_from_file(f,x,y,comp,req_comp);
+   fclose(f);
+   return result;
+}
+
+STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
+{
+   unsigned char *result;
+   stbi__context s;
+   stbi__start_file(&s,f);
+   result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
+   if (result) {
+      // need to 'unget' all the characters in the IO buffer
+      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
+   }
+   return result;
+}
+
+STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__uint16 *result;
+   stbi__context s;
+   stbi__start_file(&s,f);
+   result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp);
+   if (result) {
+      // need to 'unget' all the characters in the IO buffer
+      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
+   }
+   return result;
+}
+
+STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp)
+{
+   FILE *f = stbi__fopen(filename, "rb");
+   stbi__uint16 *result;
+   if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file");
+   result = stbi_load_from_file_16(f,x,y,comp,req_comp);
+   fclose(f);
+   return result;
+}
+
+
+#endif //!STBI_NO_STDIO
+
+STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels)
+{
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
+}
+
+STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels)
+{
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user);
+   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
+}
+
+STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
+}
+
+STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
+   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
+}
+
+#ifndef STBI_NO_GIF
+STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
+{
+   unsigned char *result;
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+
+   result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);
+   if (stbi__vertically_flip_on_load) {
+      stbi__vertical_flip_slices( result, *x, *y, *z, *comp );
+   }
+
+   return result;
+}
+#endif
+
+#ifndef STBI_NO_LINEAR
+static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp)
+{
+   unsigned char *data;
+   #ifndef STBI_NO_HDR
+   if (stbi__hdr_test(s)) {
+      stbi__result_info ri;
+      float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri);
+      if (hdr_data)
+         stbi__float_postprocess(hdr_data,x,y,comp,req_comp);
+      return hdr_data;
+   }
+   #endif
+   data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp);
+   if (data)
+      return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp);
+   return stbi__errpf("unknown image type", "Image not of any known type, or corrupt");
+}
+
+STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__loadf_main(&s,x,y,comp,req_comp);
+}
+
+STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
+   return stbi__loadf_main(&s,x,y,comp,req_comp);
+}
+
+#ifndef STBI_NO_STDIO
+STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp)
+{
+   float *result;
+   FILE *f = stbi__fopen(filename, "rb");
+   if (!f) return stbi__errpf("can't fopen", "Unable to open file");
+   result = stbi_loadf_from_file(f,x,y,comp,req_comp);
+   fclose(f);
+   return result;
+}
+
+STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
+{
+   stbi__context s;
+   stbi__start_file(&s,f);
+   return stbi__loadf_main(&s,x,y,comp,req_comp);
+}
+#endif // !STBI_NO_STDIO
+
+#endif // !STBI_NO_LINEAR
+
+// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is
+// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always
+// reports false!
+
+STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len)
+{
+   #ifndef STBI_NO_HDR
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__hdr_test(&s);
+   #else
+   STBI_NOTUSED(buffer);
+   STBI_NOTUSED(len);
+   return 0;
+   #endif
+}
+
+#ifndef STBI_NO_STDIO
+STBIDEF int      stbi_is_hdr          (char const *filename)
+{
+   FILE *f = stbi__fopen(filename, "rb");
+   int result=0;
+   if (f) {
+      result = stbi_is_hdr_from_file(f);
+      fclose(f);
+   }
+   return result;
+}
+
+STBIDEF int stbi_is_hdr_from_file(FILE *f)
+{
+   #ifndef STBI_NO_HDR
+   long pos = ftell(f);
+   int res;
+   stbi__context s;
+   stbi__start_file(&s,f);
+   res = stbi__hdr_test(&s);
+   fseek(f, pos, SEEK_SET);
+   return res;
+   #else
+   STBI_NOTUSED(f);
+   return 0;
+   #endif
+}
+#endif // !STBI_NO_STDIO
+
+STBIDEF int      stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user)
+{
+   #ifndef STBI_NO_HDR
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
+   return stbi__hdr_test(&s);
+   #else
+   STBI_NOTUSED(clbk);
+   STBI_NOTUSED(user);
+   return 0;
+   #endif
+}
+
+#ifndef STBI_NO_LINEAR
+static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f;
+
+STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; }
+STBIDEF void   stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; }
+#endif
+
+static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f;
+
+STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; }
+STBIDEF void   stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; }
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Common code used by all image loaders
+//
+
+enum
+{
+   STBI__SCAN_load=0,
+   STBI__SCAN_type,
+   STBI__SCAN_header
+};
+
+static void stbi__refill_buffer(stbi__context *s)
+{
+   int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen);
+   s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original);
+   if (n == 0) {
+      // at end of file, treat same as if from memory, but need to handle case
+      // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file
+      s->read_from_callbacks = 0;
+      s->img_buffer = s->buffer_start;
+      s->img_buffer_end = s->buffer_start+1;
+      *s->img_buffer = 0;
+   } else {
+      s->img_buffer = s->buffer_start;
+      s->img_buffer_end = s->buffer_start + n;
+   }
+}
+
+stbi_inline static stbi_uc stbi__get8(stbi__context *s)
+{
+   if (s->img_buffer < s->img_buffer_end)
+      return *s->img_buffer++;
+   if (s->read_from_callbacks) {
+      stbi__refill_buffer(s);
+      return *s->img_buffer++;
+   }
+   return 0;
+}
+
+#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
+// nothing
+#else
+stbi_inline static int stbi__at_eof(stbi__context *s)
+{
+   if (s->io.read) {
+      if (!(s->io.eof)(s->io_user_data)) return 0;
+      // if feof() is true, check if buffer = end
+      // special case: we've only got the special 0 character at the end
+      if (s->read_from_callbacks == 0) return 1;
+   }
+
+   return s->img_buffer >= s->img_buffer_end;
+}
+#endif
+
+#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC)
+// nothing
+#else
+static void stbi__skip(stbi__context *s, int n)
+{
+   if (n == 0) return;  // already there!
+   if (n < 0) {
+      s->img_buffer = s->img_buffer_end;
+      return;
+   }
+   if (s->io.read) {
+      int blen = (int) (s->img_buffer_end - s->img_buffer);
+      if (blen < n) {
+         s->img_buffer = s->img_buffer_end;
+         (s->io.skip)(s->io_user_data, n - blen);
+         return;
+      }
+   }
+   s->img_buffer += n;
+}
+#endif
+
+#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM)
+// nothing
+#else
+static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)
+{
+   if (s->io.read) {
+      int blen = (int) (s->img_buffer_end - s->img_buffer);
+      if (blen < n) {
+         int res, count;
+
+         memcpy(buffer, s->img_buffer, blen);
+
+         count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen);
+         res = (count == (n-blen));
+         s->img_buffer = s->img_buffer_end;
+         return res;
+      }
+   }
+
+   if (s->img_buffer+n <= s->img_buffer_end) {
+      memcpy(buffer, s->img_buffer, n);
+      s->img_buffer += n;
+      return 1;
+   } else
+      return 0;
+}
+#endif
+
+#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
+// nothing
+#else
+static int stbi__get16be(stbi__context *s)
+{
+   int z = stbi__get8(s);
+   return (z << 8) + stbi__get8(s);
+}
+#endif
+
+#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
+// nothing
+#else
+static stbi__uint32 stbi__get32be(stbi__context *s)
+{
+   stbi__uint32 z = stbi__get16be(s);
+   return (z << 16) + stbi__get16be(s);
+}
+#endif
+
+#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF)
+// nothing
+#else
+static int stbi__get16le(stbi__context *s)
+{
+   int z = stbi__get8(s);
+   return z + (stbi__get8(s) << 8);
+}
+#endif
+
+#ifndef STBI_NO_BMP
+static stbi__uint32 stbi__get32le(stbi__context *s)
+{
+   stbi__uint32 z = stbi__get16le(s);
+   z += (stbi__uint32)stbi__get16le(s) << 16;
+   return z;
+}
+#endif
+
+#define STBI__BYTECAST(x)  ((stbi_uc) ((x) & 255))  // truncate int to byte without warnings
+
+#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
+// nothing
+#else
+//////////////////////////////////////////////////////////////////////////////
+//
+//  generic converter from built-in img_n to req_comp
+//    individual types do this automatically as much as possible (e.g. jpeg
+//    does all cases internally since it needs to colorspace convert anyway,
+//    and it never has alpha, so very few cases ). png can automatically
+//    interleave an alpha=255 channel, but falls back to this for other cases
+//
+//  assume data buffer is malloced, so malloc a new one and free that one
+//  only failure mode is malloc failing
+
+static stbi_uc stbi__compute_y(int r, int g, int b)
+{
+   return (stbi_uc) (((r*77) + (g*150) +  (29*b)) >> 8);
+}
+#endif
+
+#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
+// nothing
+#else
+static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
+{
+   int i,j;
+   unsigned char *good;
+
+   if (req_comp == img_n) return data;
+   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
+
+   good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0);
+   if (good == NULL) {
+      STBI_FREE(data);
+      return stbi__errpuc("outofmem", "Out of memory");
+   }
+
+   for (j=0; j < (int) y; ++j) {
+      unsigned char *src  = data + j * x * img_n   ;
+      unsigned char *dest = good + j * x * req_comp;
+
+      #define STBI__COMBO(a,b)  ((a)*8+(b))
+      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
+      // convert source image with img_n components to one with req_comp components;
+      // avoid switch per pixel, so use switch per scanline and massive macros
+      switch (STBI__COMBO(img_n, req_comp)) {
+         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255;                                     } break;
+         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
+         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255;                     } break;
+         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;
+         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
+         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                  } break;
+         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255;        } break;
+         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
+         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255;    } break;
+         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
+         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
+         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                    } break;
+         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion");
+      }
+      #undef STBI__CASE
+   }
+
+   STBI_FREE(data);
+   return good;
+}
+#endif
+
+#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
+// nothing
+#else
+static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
+{
+   return (stbi__uint16) (((r*77) + (g*150) +  (29*b)) >> 8);
+}
+#endif
+
+#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
+// nothing
+#else
+static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
+{
+   int i,j;
+   stbi__uint16 *good;
+
+   if (req_comp == img_n) return data;
+   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
+
+   good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
+   if (good == NULL) {
+      STBI_FREE(data);
+      return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
+   }
+
+   for (j=0; j < (int) y; ++j) {
+      stbi__uint16 *src  = data + j * x * img_n   ;
+      stbi__uint16 *dest = good + j * x * req_comp;
+
+      #define STBI__COMBO(a,b)  ((a)*8+(b))
+      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
+      // convert source image with img_n components to one with req_comp components;
+      // avoid switch per pixel, so use switch per scanline and massive macros
+      switch (STBI__COMBO(img_n, req_comp)) {
+         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff;                                     } break;
+         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
+         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff;                     } break;
+         STBI__CASE(2,1) { dest[0]=src[0];                                                     } break;
+         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
+         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                     } break;
+         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff;        } break;
+         STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
+         STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break;
+         STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
+         STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break;
+         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                       } break;
+         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion");
+      }
+      #undef STBI__CASE
+   }
+
+   STBI_FREE(data);
+   return good;
+}
+#endif
+
+#ifndef STBI_NO_LINEAR
+static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp)
+{
+   int i,k,n;
+   float *output;
+   if (!data) return NULL;
+   output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0);
+   if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); }
+   // compute number of non-alpha components
+   if (comp & 1) n = comp; else n = comp-1;
+   for (i=0; i < x*y; ++i) {
+      for (k=0; k < n; ++k) {
+         output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale);
+      }
+   }
+   if (n < comp) {
+      for (i=0; i < x*y; ++i) {
+         output[i*comp + n] = data[i*comp + n]/255.0f;
+      }
+   }
+   STBI_FREE(data);
+   return output;
+}
+#endif
+
+#ifndef STBI_NO_HDR
+#define stbi__float2int(x)   ((int) (x))
+static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp)
+{
+   int i,k,n;
+   stbi_uc *output;
+   if (!data) return NULL;
+   output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0);
+   if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); }
+   // compute number of non-alpha components
+   if (comp & 1) n = comp; else n = comp-1;
+   for (i=0; i < x*y; ++i) {
+      for (k=0; k < n; ++k) {
+         float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f;
+         if (z < 0) z = 0;
+         if (z > 255) z = 255;
+         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
+      }
+      if (k < comp) {
+         float z = data[i*comp+k] * 255 + 0.5f;
+         if (z < 0) z = 0;
+         if (z > 255) z = 255;
+         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
+      }
+   }
+   STBI_FREE(data);
+   return output;
+}
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  "baseline" JPEG/JFIF decoder
+//
+//    simple implementation
+//      - doesn't support delayed output of y-dimension
+//      - simple interface (only one output format: 8-bit interleaved RGB)
+//      - doesn't try to recover corrupt jpegs
+//      - doesn't allow partial loading, loading multiple at once
+//      - still fast on x86 (copying globals into locals doesn't help x86)
+//      - allocates lots of intermediate memory (full size of all components)
+//        - non-interleaved case requires this anyway
+//        - allows good upsampling (see next)
+//    high-quality
+//      - upsampled channels are bilinearly interpolated, even across blocks
+//      - quality integer IDCT derived from IJG's 'slow'
+//    performance
+//      - fast huffman; reasonable integer IDCT
+//      - some SIMD kernels for common paths on targets with SSE2/NEON
+//      - uses a lot of intermediate memory, could cache poorly
+
+#ifndef STBI_NO_JPEG
+
+// huffman decoding acceleration
+#define FAST_BITS   9  // larger handles more cases; smaller stomps less cache
+
+typedef struct
+{
+   stbi_uc  fast[1 << FAST_BITS];
+   // weirdly, repacking this into AoS is a 10% speed loss, instead of a win
+   stbi__uint16 code[256];
+   stbi_uc  values[256];
+   stbi_uc  size[257];
+   unsigned int maxcode[18];
+   int    delta[17];   // old 'firstsymbol' - old 'firstcode'
+} stbi__huffman;
+
+typedef struct
+{
+   stbi__context *s;
+   stbi__huffman huff_dc[4];
+   stbi__huffman huff_ac[4];
+   stbi__uint16 dequant[4][64];
+   stbi__int16 fast_ac[4][1 << FAST_BITS];
+
+// sizes for components, interleaved MCUs
+   int img_h_max, img_v_max;
+   int img_mcu_x, img_mcu_y;
+   int img_mcu_w, img_mcu_h;
+
+// definition of jpeg image component
+   struct
+   {
+      int id;
+      int h,v;
+      int tq;
+      int hd,ha;
+      int dc_pred;
+
+      int x,y,w2,h2;
+      stbi_uc *data;
+      void *raw_data, *raw_coeff;
+      stbi_uc *linebuf;
+      short   *coeff;   // progressive only
+      int      coeff_w, coeff_h; // number of 8x8 coefficient blocks
+   } img_comp[4];
+
+   stbi__uint32   code_buffer; // jpeg entropy-coded buffer
+   int            code_bits;   // number of valid bits
+   unsigned char  marker;      // marker seen while filling entropy buffer
+   int            nomore;      // flag if we saw a marker so must stop
+
+   int            progressive;
+   int            spec_start;
+   int            spec_end;
+   int            succ_high;
+   int            succ_low;
+   int            eob_run;
+   int            jfif;
+   int            app14_color_transform; // Adobe APP14 tag
+   int            rgb;
+
+   int scan_n, order[4];
+   int restart_interval, todo;
+
+// kernels
+   void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]);
+   void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step);
+   stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs);
+} stbi__jpeg;
+
+static int stbi__build_huffman(stbi__huffman *h, int *count)
+{
+   int i,j,k=0;
+   unsigned int code;
+   // build size list for each symbol (from JPEG spec)
+   for (i=0; i < 16; ++i) {
+      for (j=0; j < count[i]; ++j) {
+         h->size[k++] = (stbi_uc) (i+1);
+         if(k >= 257) return stbi__err("bad size list","Corrupt JPEG");
+      }
+   }
+   h->size[k] = 0;
+
+   // compute actual symbols (from jpeg spec)
+   code = 0;
+   k = 0;
+   for(j=1; j <= 16; ++j) {
+      // compute delta to add to code to compute symbol id
+      h->delta[j] = k - code;
+      if (h->size[k] == j) {
+         while (h->size[k] == j)
+            h->code[k++] = (stbi__uint16) (code++);
+         if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG");
+      }
+      // compute largest code + 1 for this size, preshifted as needed later
+      h->maxcode[j] = code << (16-j);
+      code <<= 1;
+   }
+   h->maxcode[j] = 0xffffffff;
+
+   // build non-spec acceleration table; 255 is flag for not-accelerated
+   memset(h->fast, 255, 1 << FAST_BITS);
+   for (i=0; i < k; ++i) {
+      int s = h->size[i];
+      if (s <= FAST_BITS) {
+         int c = h->code[i] << (FAST_BITS-s);
+         int m = 1 << (FAST_BITS-s);
+         for (j=0; j < m; ++j) {
+            h->fast[c+j] = (stbi_uc) i;
+         }
+      }
+   }
+   return 1;
+}
+
+// build a table that decodes both magnitude and value of small ACs in
+// one go.
+static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h)
+{
+   int i;
+   for (i=0; i < (1 << FAST_BITS); ++i) {
+      stbi_uc fast = h->fast[i];
+      fast_ac[i] = 0;
+      if (fast < 255) {
+         int rs = h->values[fast];
+         int run = (rs >> 4) & 15;
+         int magbits = rs & 15;
+         int len = h->size[fast];
+
+         if (magbits && len + magbits <= FAST_BITS) {
+            // magnitude code followed by receive_extend code
+            int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits);
+            int m = 1 << (magbits - 1);
+            if (k < m) k += (~0U << magbits) + 1;
+            // if the result is small enough, we can fit it in fast_ac table
+            if (k >= -128 && k <= 127)
+               fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits));
+         }
+      }
+   }
+}
+
+static void stbi__grow_buffer_unsafe(stbi__jpeg *j)
+{
+   do {
+      unsigned int b = j->nomore ? 0 : stbi__get8(j->s);
+      if (b == 0xff) {
+         int c = stbi__get8(j->s);
+         while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes
+         if (c != 0) {
+            j->marker = (unsigned char) c;
+            j->nomore = 1;
+            return;
+         }
+      }
+      j->code_buffer |= b << (24 - j->code_bits);
+      j->code_bits += 8;
+   } while (j->code_bits <= 24);
+}
+
+// (1 << n) - 1
+static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
+
+// decode a jpeg huffman value from the bitstream
+stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)
+{
+   unsigned int temp;
+   int c,k;
+
+   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
+
+   // look at the top FAST_BITS and determine what symbol ID it is,
+   // if the code is <= FAST_BITS
+   c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
+   k = h->fast[c];
+   if (k < 255) {
+      int s = h->size[k];
+      if (s > j->code_bits)
+         return -1;
+      j->code_buffer <<= s;
+      j->code_bits -= s;
+      return h->values[k];
+   }
+
+   // naive test is to shift the code_buffer down so k bits are
+   // valid, then test against maxcode. To speed this up, we've
+   // preshifted maxcode left so that it has (16-k) 0s at the
+   // end; in other words, regardless of the number of bits, it
+   // wants to be compared against something shifted to have 16;
+   // that way we don't need to shift inside the loop.
+   temp = j->code_buffer >> 16;
+   for (k=FAST_BITS+1 ; ; ++k)
+      if (temp < h->maxcode[k])
+         break;
+   if (k == 17) {
+      // error! code not found
+      j->code_bits -= 16;
+      return -1;
+   }
+
+   if (k > j->code_bits)
+      return -1;
+
+   // convert the huffman code to the symbol id
+   c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];
+   if(c < 0 || c >= 256) // symbol id out of bounds!
+       return -1;
+   STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);
+
+   // convert the id to a symbol
+   j->code_bits -= k;
+   j->code_buffer <<= k;
+   return h->values[c];
+}
+
+// bias[n] = (-1<<n) + 1
+static const int stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767};
+
+// combined JPEG 'receive' and JPEG 'extend', since baseline
+// always extends everything it receives.
+stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
+{
+   unsigned int k;
+   int sgn;
+   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
+   if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
+
+   sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative)
+   k = stbi_lrot(j->code_buffer, n);
+   j->code_buffer = k & ~stbi__bmask[n];
+   k &= stbi__bmask[n];
+   j->code_bits -= n;
+   return k + (stbi__jbias[n] & (sgn - 1));
+}
+
+// get some unsigned bits
+stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n)
+{
+   unsigned int k;
+   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
+   if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
+   k = stbi_lrot(j->code_buffer, n);
+   j->code_buffer = k & ~stbi__bmask[n];
+   k &= stbi__bmask[n];
+   j->code_bits -= n;
+   return k;
+}
+
+stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)
+{
+   unsigned int k;
+   if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);
+   if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing
+   k = j->code_buffer;
+   j->code_buffer <<= 1;
+   --j->code_bits;
+   return k & 0x80000000;
+}
+
+// given a value that's at position X in the zigzag stream,
+// where does it appear in the 8x8 matrix coded as row-major?
+static const stbi_uc stbi__jpeg_dezigzag[64+15] =
+{
+    0,  1,  8, 16,  9,  2,  3, 10,
+   17, 24, 32, 25, 18, 11,  4,  5,
+   12, 19, 26, 33, 40, 48, 41, 34,
+   27, 20, 13,  6,  7, 14, 21, 28,
+   35, 42, 49, 56, 57, 50, 43, 36,
+   29, 22, 15, 23, 30, 37, 44, 51,
+   58, 59, 52, 45, 38, 31, 39, 46,
+   53, 60, 61, 54, 47, 55, 62, 63,
+   // let corrupt input sample past end
+   63, 63, 63, 63, 63, 63, 63, 63,
+   63, 63, 63, 63, 63, 63, 63
+};
+
+// decode one 64-entry block--
+static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant)
+{
+   int diff,dc,k;
+   int t;
+
+   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
+   t = stbi__jpeg_huff_decode(j, hdc);
+   if (t < 0 || t > 15) return stbi__err("bad huffman code","Corrupt JPEG");
+
+   // 0 all the ac values now so we can do it 32-bits at a time
+   memset(data,0,64*sizeof(data[0]));
+
+   diff = t ? stbi__extend_receive(j, t) : 0;
+   if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG");
+   dc = j->img_comp[b].dc_pred + diff;
+   j->img_comp[b].dc_pred = dc;
+   if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
+   data[0] = (short) (dc * dequant[0]);
+
+   // decode AC components, see JPEG spec
+   k = 1;
+   do {
+      unsigned int zig;
+      int c,r,s;
+      if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
+      c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
+      r = fac[c];
+      if (r) { // fast-AC path
+         k += (r >> 4) & 15; // run
+         s = r & 15; // combined length
+         if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
+         j->code_buffer <<= s;
+         j->code_bits -= s;
+         // decode into unzigzag'd location
+         zig = stbi__jpeg_dezigzag[k++];
+         data[zig] = (short) ((r >> 8) * dequant[zig]);
+      } else {
+         int rs = stbi__jpeg_huff_decode(j, hac);
+         if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
+         s = rs & 15;
+         r = rs >> 4;
+         if (s == 0) {
+            if (rs != 0xf0) break; // end block
+            k += 16;
+         } else {
+            k += r;
+            // decode into unzigzag'd location
+            zig = stbi__jpeg_dezigzag[k++];
+            data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]);
+         }
+      }
+   } while (k < 64);
+   return 1;
+}
+
+static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b)
+{
+   int diff,dc;
+   int t;
+   if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
+
+   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
+
+   if (j->succ_high == 0) {
+      // first scan for DC coefficient, must be first
+      memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
+      t = stbi__jpeg_huff_decode(j, hdc);
+      if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
+      diff = t ? stbi__extend_receive(j, t) : 0;
+
+      if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG");
+      dc = j->img_comp[b].dc_pred + diff;
+      j->img_comp[b].dc_pred = dc;
+      if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
+      data[0] = (short) (dc * (1 << j->succ_low));
+   } else {
+      // refinement scan for DC coefficient
+      if (stbi__jpeg_get_bit(j))
+         data[0] += (short) (1 << j->succ_low);
+   }
+   return 1;
+}
+
+// @OPTIMIZE: store non-zigzagged during the decode passes,
+// and only de-zigzag when dequantizing
+static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac)
+{
+   int k;
+   if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
+
+   if (j->succ_high == 0) {
+      int shift = j->succ_low;
+
+      if (j->eob_run) {
+         --j->eob_run;
+         return 1;
+      }
+
+      k = j->spec_start;
+      do {
+         unsigned int zig;
+         int c,r,s;
+         if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
+         c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
+         r = fac[c];
+         if (r) { // fast-AC path
+            k += (r >> 4) & 15; // run
+            s = r & 15; // combined length
+            if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
+            j->code_buffer <<= s;
+            j->code_bits -= s;
+            zig = stbi__jpeg_dezigzag[k++];
+            data[zig] = (short) ((r >> 8) * (1 << shift));
+         } else {
+            int rs = stbi__jpeg_huff_decode(j, hac);
+            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
+            s = rs & 15;
+            r = rs >> 4;
+            if (s == 0) {
+               if (r < 15) {
+                  j->eob_run = (1 << r);
+                  if (r)
+                     j->eob_run += stbi__jpeg_get_bits(j, r);
+                  --j->eob_run;
+                  break;
+               }
+               k += 16;
+            } else {
+               k += r;
+               zig = stbi__jpeg_dezigzag[k++];
+               data[zig] = (short) (stbi__extend_receive(j,s) * (1 << shift));
+            }
+         }
+      } while (k <= j->spec_end);
+   } else {
+      // refinement scan for these AC coefficients
+
+      short bit = (short) (1 << j->succ_low);
+
+      if (j->eob_run) {
+         --j->eob_run;
+         for (k = j->spec_start; k <= j->spec_end; ++k) {
+            short *p = &data[stbi__jpeg_dezigzag[k]];
+            if (*p != 0)
+               if (stbi__jpeg_get_bit(j))
+                  if ((*p & bit)==0) {
+                     if (*p > 0)
+                        *p += bit;
+                     else
+                        *p -= bit;
+                  }
+         }
+      } else {
+         k = j->spec_start;
+         do {
+            int r,s;
+            int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh
+            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
+            s = rs & 15;
+            r = rs >> 4;
+            if (s == 0) {
+               if (r < 15) {
+                  j->eob_run = (1 << r) - 1;
+                  if (r)
+                     j->eob_run += stbi__jpeg_get_bits(j, r);
+                  r = 64; // force end of block
+               } else {
+                  // r=15 s=0 should write 16 0s, so we just do
+                  // a run of 15 0s and then write s (which is 0),
+                  // so we don't have to do anything special here
+               }
+            } else {
+               if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG");
+               // sign bit
+               if (stbi__jpeg_get_bit(j))
+                  s = bit;
+               else
+                  s = -bit;
+            }
+
+            // advance by r
+            while (k <= j->spec_end) {
+               short *p = &data[stbi__jpeg_dezigzag[k++]];
+               if (*p != 0) {
+                  if (stbi__jpeg_get_bit(j))
+                     if ((*p & bit)==0) {
+                        if (*p > 0)
+                           *p += bit;
+                        else
+                           *p -= bit;
+                     }
+               } else {
+                  if (r == 0) {
+                     *p = (short) s;
+                     break;
+                  }
+                  --r;
+               }
+            }
+         } while (k <= j->spec_end);
+      }
+   }
+   return 1;
+}
+
+// take a -128..127 value and stbi__clamp it and convert to 0..255
+stbi_inline static stbi_uc stbi__clamp(int x)
+{
+   // trick to use a single test to catch both cases
+   if ((unsigned int) x > 255) {
+      if (x < 0) return 0;
+      if (x > 255) return 255;
+   }
+   return (stbi_uc) x;
+}
+
+#define stbi__f2f(x)  ((int) (((x) * 4096 + 0.5)))
+#define stbi__fsh(x)  ((x) * 4096)
+
+// derived from jidctint -- DCT_ISLOW
+#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \
+   int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \
+   p2 = s2;                                    \
+   p3 = s6;                                    \
+   p1 = (p2+p3) * stbi__f2f(0.5411961f);       \
+   t2 = p1 + p3*stbi__f2f(-1.847759065f);      \
+   t3 = p1 + p2*stbi__f2f( 0.765366865f);      \
+   p2 = s0;                                    \
+   p3 = s4;                                    \
+   t0 = stbi__fsh(p2+p3);                      \
+   t1 = stbi__fsh(p2-p3);                      \
+   x0 = t0+t3;                                 \
+   x3 = t0-t3;                                 \
+   x1 = t1+t2;                                 \
+   x2 = t1-t2;                                 \
+   t0 = s7;                                    \
+   t1 = s5;                                    \
+   t2 = s3;                                    \
+   t3 = s1;                                    \
+   p3 = t0+t2;                                 \
+   p4 = t1+t3;                                 \
+   p1 = t0+t3;                                 \
+   p2 = t1+t2;                                 \
+   p5 = (p3+p4)*stbi__f2f( 1.175875602f);      \
+   t0 = t0*stbi__f2f( 0.298631336f);           \
+   t1 = t1*stbi__f2f( 2.053119869f);           \
+   t2 = t2*stbi__f2f( 3.072711026f);           \
+   t3 = t3*stbi__f2f( 1.501321110f);           \
+   p1 = p5 + p1*stbi__f2f(-0.899976223f);      \
+   p2 = p5 + p2*stbi__f2f(-2.562915447f);      \
+   p3 = p3*stbi__f2f(-1.961570560f);           \
+   p4 = p4*stbi__f2f(-0.390180644f);           \
+   t3 += p1+p4;                                \
+   t2 += p2+p3;                                \
+   t1 += p2+p4;                                \
+   t0 += p1+p3;
+
+static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])
+{
+   int i,val[64],*v=val;
+   stbi_uc *o;
+   short *d = data;
+
+   // columns
+   for (i=0; i < 8; ++i,++d, ++v) {
+      // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing
+      if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0
+           && d[40]==0 && d[48]==0 && d[56]==0) {
+         //    no shortcut                 0     seconds
+         //    (1|2|3|4|5|6|7)==0          0     seconds
+         //    all separate               -0.047 seconds
+         //    1 && 2|3 && 4|5 && 6|7:    -0.047 seconds
+         int dcterm = d[0]*4;
+         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;
+      } else {
+         STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56])
+         // constants scaled things up by 1<<12; let's bring them back
+         // down, but keep 2 extra bits of precision
+         x0 += 512; x1 += 512; x2 += 512; x3 += 512;
+         v[ 0] = (x0+t3) >> 10;
+         v[56] = (x0-t3) >> 10;
+         v[ 8] = (x1+t2) >> 10;
+         v[48] = (x1-t2) >> 10;
+         v[16] = (x2+t1) >> 10;
+         v[40] = (x2-t1) >> 10;
+         v[24] = (x3+t0) >> 10;
+         v[32] = (x3-t0) >> 10;
+      }
+   }
+
+   for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) {
+      // no fast case since the first 1D IDCT spread components out
+      STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7])
+      // constants scaled things up by 1<<12, plus we had 1<<2 from first
+      // loop, plus horizontal and vertical each scale by sqrt(8) so together
+      // we've got an extra 1<<3, so 1<<17 total we need to remove.
+      // so we want to round that, which means adding 0.5 * 1<<17,
+      // aka 65536. Also, we'll end up with -128 to 127 that we want
+      // to encode as 0..255 by adding 128, so we'll add that before the shift
+      x0 += 65536 + (128<<17);
+      x1 += 65536 + (128<<17);
+      x2 += 65536 + (128<<17);
+      x3 += 65536 + (128<<17);
+      // tried computing the shifts into temps, or'ing the temps to see
+      // if any were out of range, but that was slower
+      o[0] = stbi__clamp((x0+t3) >> 17);
+      o[7] = stbi__clamp((x0-t3) >> 17);
+      o[1] = stbi__clamp((x1+t2) >> 17);
+      o[6] = stbi__clamp((x1-t2) >> 17);
+      o[2] = stbi__clamp((x2+t1) >> 17);
+      o[5] = stbi__clamp((x2-t1) >> 17);
+      o[3] = stbi__clamp((x3+t0) >> 17);
+      o[4] = stbi__clamp((x3-t0) >> 17);
+   }
+}
+
+#ifdef STBI_SSE2
+// sse2 integer IDCT. not the fastest possible implementation but it
+// produces bit-identical results to the generic C version so it's
+// fully "transparent".
+static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
+{
+   // This is constructed to match our regular (generic) integer IDCT exactly.
+   __m128i row0, row1, row2, row3, row4, row5, row6, row7;
+   __m128i tmp;
+
+   // dot product constant: even elems=x, odd elems=y
+   #define dct_const(x,y)  _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y))
+
+   // out(0) = c0[even]*x + c0[odd]*y   (c0, x, y 16-bit, out 32-bit)
+   // out(1) = c1[even]*x + c1[odd]*y
+   #define dct_rot(out0,out1, x,y,c0,c1) \
+      __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \
+      __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \
+      __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \
+      __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \
+      __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \
+      __m128i out1##_h = _mm_madd_epi16(c0##hi, c1)
+
+   // out = in << 12  (in 16-bit, out 32-bit)
+   #define dct_widen(out, in) \
+      __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \
+      __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4)
+
+   // wide add
+   #define dct_wadd(out, a, b) \
+      __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \
+      __m128i out##_h = _mm_add_epi32(a##_h, b##_h)
+
+   // wide sub
+   #define dct_wsub(out, a, b) \
+      __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \
+      __m128i out##_h = _mm_sub_epi32(a##_h, b##_h)
+
+   // butterfly a/b, add bias, then shift by "s" and pack
+   #define dct_bfly32o(out0, out1, a,b,bias,s) \
+      { \
+         __m128i abiased_l = _mm_add_epi32(a##_l, bias); \
+         __m128i abiased_h = _mm_add_epi32(a##_h, bias); \
+         dct_wadd(sum, abiased, b); \
+         dct_wsub(dif, abiased, b); \
+         out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \
+         out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \
+      }
+
+   // 8-bit interleave step (for transposes)
+   #define dct_interleave8(a, b) \
+      tmp = a; \
+      a = _mm_unpacklo_epi8(a, b); \
+      b = _mm_unpackhi_epi8(tmp, b)
+
+   // 16-bit interleave step (for transposes)
+   #define dct_interleave16(a, b) \
+      tmp = a; \
+      a = _mm_unpacklo_epi16(a, b); \
+      b = _mm_unpackhi_epi16(tmp, b)
+
+   #define dct_pass(bias,shift) \
+      { \
+         /* even part */ \
+         dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \
+         __m128i sum04 = _mm_add_epi16(row0, row4); \
+         __m128i dif04 = _mm_sub_epi16(row0, row4); \
+         dct_widen(t0e, sum04); \
+         dct_widen(t1e, dif04); \
+         dct_wadd(x0, t0e, t3e); \
+         dct_wsub(x3, t0e, t3e); \
+         dct_wadd(x1, t1e, t2e); \
+         dct_wsub(x2, t1e, t2e); \
+         /* odd part */ \
+         dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \
+         dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \
+         __m128i sum17 = _mm_add_epi16(row1, row7); \
+         __m128i sum35 = _mm_add_epi16(row3, row5); \
+         dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \
+         dct_wadd(x4, y0o, y4o); \
+         dct_wadd(x5, y1o, y5o); \
+         dct_wadd(x6, y2o, y5o); \
+         dct_wadd(x7, y3o, y4o); \
+         dct_bfly32o(row0,row7, x0,x7,bias,shift); \
+         dct_bfly32o(row1,row6, x1,x6,bias,shift); \
+         dct_bfly32o(row2,row5, x2,x5,bias,shift); \
+         dct_bfly32o(row3,row4, x3,x4,bias,shift); \
+      }
+
+   __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f));
+   __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f));
+   __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f));
+   __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f));
+   __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f));
+   __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f));
+   __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));
+   __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));
+
+   // rounding biases in column/row passes, see stbi__idct_block for explanation.
+   __m128i bias_0 = _mm_set1_epi32(512);
+   __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17));
+
+   // load
+   row0 = _mm_load_si128((const __m128i *) (data + 0*8));
+   row1 = _mm_load_si128((const __m128i *) (data + 1*8));
+   row2 = _mm_load_si128((const __m128i *) (data + 2*8));
+   row3 = _mm_load_si128((const __m128i *) (data + 3*8));
+   row4 = _mm_load_si128((const __m128i *) (data + 4*8));
+   row5 = _mm_load_si128((const __m128i *) (data + 5*8));
+   row6 = _mm_load_si128((const __m128i *) (data + 6*8));
+   row7 = _mm_load_si128((const __m128i *) (data + 7*8));
+
+   // column pass
+   dct_pass(bias_0, 10);
+
+   {
+      // 16bit 8x8 transpose pass 1
+      dct_interleave16(row0, row4);
+      dct_interleave16(row1, row5);
+      dct_interleave16(row2, row6);
+      dct_interleave16(row3, row7);
+
+      // transpose pass 2
+      dct_interleave16(row0, row2);
+      dct_interleave16(row1, row3);
+      dct_interleave16(row4, row6);
+      dct_interleave16(row5, row7);
+
+      // transpose pass 3
+      dct_interleave16(row0, row1);
+      dct_interleave16(row2, row3);
+      dct_interleave16(row4, row5);
+      dct_interleave16(row6, row7);
+   }
+
+   // row pass
+   dct_pass(bias_1, 17);
+
+   {
+      // pack
+      __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7
+      __m128i p1 = _mm_packus_epi16(row2, row3);
+      __m128i p2 = _mm_packus_epi16(row4, row5);
+      __m128i p3 = _mm_packus_epi16(row6, row7);
+
+      // 8bit 8x8 transpose pass 1
+      dct_interleave8(p0, p2); // a0e0a1e1...
+      dct_interleave8(p1, p3); // c0g0c1g1...
+
+      // transpose pass 2
+      dct_interleave8(p0, p1); // a0c0e0g0...
+      dct_interleave8(p2, p3); // b0d0f0h0...
+
+      // transpose pass 3
+      dct_interleave8(p0, p2); // a0b0c0d0...
+      dct_interleave8(p1, p3); // a4b4c4d4...
+
+      // store
+      _mm_storel_epi64((__m128i *) out, p0); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, p2); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, p1); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, p3); out += out_stride;
+      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e));
+   }
+
+#undef dct_const
+#undef dct_rot
+#undef dct_widen
+#undef dct_wadd
+#undef dct_wsub
+#undef dct_bfly32o
+#undef dct_interleave8
+#undef dct_interleave16
+#undef dct_pass
+}
+
+#endif // STBI_SSE2
+
+#ifdef STBI_NEON
+
+// NEON integer IDCT. should produce bit-identical
+// results to the generic C version.
+static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
+{
+   int16x8_t row0, row1, row2, row3, row4, row5, row6, row7;
+
+   int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f));
+   int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f));
+   int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f));
+   int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f));
+   int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f));
+   int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f));
+   int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f));
+   int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f));
+   int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f));
+   int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f));
+   int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f));
+   int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f));
+
+#define dct_long_mul(out, inq, coeff) \
+   int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \
+   int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff)
+
+#define dct_long_mac(out, acc, inq, coeff) \
+   int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \
+   int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff)
+
+#define dct_widen(out, inq) \
+   int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \
+   int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12)
+
+// wide add
+#define dct_wadd(out, a, b) \
+   int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \
+   int32x4_t out##_h = vaddq_s32(a##_h, b##_h)
+
+// wide sub
+#define dct_wsub(out, a, b) \
+   int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \
+   int32x4_t out##_h = vsubq_s32(a##_h, b##_h)
+
+// butterfly a/b, then shift using "shiftop" by "s" and pack
+#define dct_bfly32o(out0,out1, a,b,shiftop,s) \
+   { \
+      dct_wadd(sum, a, b); \
+      dct_wsub(dif, a, b); \
+      out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \
+      out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \
+   }
+
+#define dct_pass(shiftop, shift) \
+   { \
+      /* even part */ \
+      int16x8_t sum26 = vaddq_s16(row2, row6); \
+      dct_long_mul(p1e, sum26, rot0_0); \
+      dct_long_mac(t2e, p1e, row6, rot0_1); \
+      dct_long_mac(t3e, p1e, row2, rot0_2); \
+      int16x8_t sum04 = vaddq_s16(row0, row4); \
+      int16x8_t dif04 = vsubq_s16(row0, row4); \
+      dct_widen(t0e, sum04); \
+      dct_widen(t1e, dif04); \
+      dct_wadd(x0, t0e, t3e); \
+      dct_wsub(x3, t0e, t3e); \
+      dct_wadd(x1, t1e, t2e); \
+      dct_wsub(x2, t1e, t2e); \
+      /* odd part */ \
+      int16x8_t sum15 = vaddq_s16(row1, row5); \
+      int16x8_t sum17 = vaddq_s16(row1, row7); \
+      int16x8_t sum35 = vaddq_s16(row3, row5); \
+      int16x8_t sum37 = vaddq_s16(row3, row7); \
+      int16x8_t sumodd = vaddq_s16(sum17, sum35); \
+      dct_long_mul(p5o, sumodd, rot1_0); \
+      dct_long_mac(p1o, p5o, sum17, rot1_1); \
+      dct_long_mac(p2o, p5o, sum35, rot1_2); \
+      dct_long_mul(p3o, sum37, rot2_0); \
+      dct_long_mul(p4o, sum15, rot2_1); \
+      dct_wadd(sump13o, p1o, p3o); \
+      dct_wadd(sump24o, p2o, p4o); \
+      dct_wadd(sump23o, p2o, p3o); \
+      dct_wadd(sump14o, p1o, p4o); \
+      dct_long_mac(x4, sump13o, row7, rot3_0); \
+      dct_long_mac(x5, sump24o, row5, rot3_1); \
+      dct_long_mac(x6, sump23o, row3, rot3_2); \
+      dct_long_mac(x7, sump14o, row1, rot3_3); \
+      dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \
+      dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \
+      dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \
+      dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \
+   }
+
+   // load
+   row0 = vld1q_s16(data + 0*8);
+   row1 = vld1q_s16(data + 1*8);
+   row2 = vld1q_s16(data + 2*8);
+   row3 = vld1q_s16(data + 3*8);
+   row4 = vld1q_s16(data + 4*8);
+   row5 = vld1q_s16(data + 5*8);
+   row6 = vld1q_s16(data + 6*8);
+   row7 = vld1q_s16(data + 7*8);
+
+   // add DC bias
+   row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0));
+
+   // column pass
+   dct_pass(vrshrn_n_s32, 10);
+
+   // 16bit 8x8 transpose
+   {
+// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively.
+// whether compilers actually get this is another story, sadly.
+#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; }
+#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); }
+#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); }
+
+      // pass 1
+      dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6
+      dct_trn16(row2, row3);
+      dct_trn16(row4, row5);
+      dct_trn16(row6, row7);
+
+      // pass 2
+      dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4
+      dct_trn32(row1, row3);
+      dct_trn32(row4, row6);
+      dct_trn32(row5, row7);
+
+      // pass 3
+      dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0
+      dct_trn64(row1, row5);
+      dct_trn64(row2, row6);
+      dct_trn64(row3, row7);
+
+#undef dct_trn16
+#undef dct_trn32
+#undef dct_trn64
+   }
+
+   // row pass
+   // vrshrn_n_s32 only supports shifts up to 16, we need
+   // 17. so do a non-rounding shift of 16 first then follow
+   // up with a rounding shift by 1.
+   dct_pass(vshrn_n_s32, 16);
+
+   {
+      // pack and round
+      uint8x8_t p0 = vqrshrun_n_s16(row0, 1);
+      uint8x8_t p1 = vqrshrun_n_s16(row1, 1);
+      uint8x8_t p2 = vqrshrun_n_s16(row2, 1);
+      uint8x8_t p3 = vqrshrun_n_s16(row3, 1);
+      uint8x8_t p4 = vqrshrun_n_s16(row4, 1);
+      uint8x8_t p5 = vqrshrun_n_s16(row5, 1);
+      uint8x8_t p6 = vqrshrun_n_s16(row6, 1);
+      uint8x8_t p7 = vqrshrun_n_s16(row7, 1);
+
+      // again, these can translate into one instruction, but often don't.
+#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; }
+#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); }
+#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); }
+
+      // sadly can't use interleaved stores here since we only write
+      // 8 bytes to each scan line!
+
+      // 8x8 8-bit transpose pass 1
+      dct_trn8_8(p0, p1);
+      dct_trn8_8(p2, p3);
+      dct_trn8_8(p4, p5);
+      dct_trn8_8(p6, p7);
+
+      // pass 2
+      dct_trn8_16(p0, p2);
+      dct_trn8_16(p1, p3);
+      dct_trn8_16(p4, p6);
+      dct_trn8_16(p5, p7);
+
+      // pass 3
+      dct_trn8_32(p0, p4);
+      dct_trn8_32(p1, p5);
+      dct_trn8_32(p2, p6);
+      dct_trn8_32(p3, p7);
+
+      // store
+      vst1_u8(out, p0); out += out_stride;
+      vst1_u8(out, p1); out += out_stride;
+      vst1_u8(out, p2); out += out_stride;
+      vst1_u8(out, p3); out += out_stride;
+      vst1_u8(out, p4); out += out_stride;
+      vst1_u8(out, p5); out += out_stride;
+      vst1_u8(out, p6); out += out_stride;
+      vst1_u8(out, p7);
+
+#undef dct_trn8_8
+#undef dct_trn8_16
+#undef dct_trn8_32
+   }
+
+#undef dct_long_mul
+#undef dct_long_mac
+#undef dct_widen
+#undef dct_wadd
+#undef dct_wsub
+#undef dct_bfly32o
+#undef dct_pass
+}
+
+#endif // STBI_NEON
+
+#define STBI__MARKER_none  0xff
+// if there's a pending marker from the entropy stream, return that
+// otherwise, fetch from the stream and get a marker. if there's no
+// marker, return 0xff, which is never a valid marker value
+static stbi_uc stbi__get_marker(stbi__jpeg *j)
+{
+   stbi_uc x;
+   if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; }
+   x = stbi__get8(j->s);
+   if (x != 0xff) return STBI__MARKER_none;
+   while (x == 0xff)
+      x = stbi__get8(j->s); // consume repeated 0xff fill bytes
+   return x;
+}
+
+// in each scan, we'll have scan_n components, and the order
+// of the components is specified by order[]
+#define STBI__RESTART(x)     ((x) >= 0xd0 && (x) <= 0xd7)
+
+// after a restart interval, stbi__jpeg_reset the entropy decoder and
+// the dc prediction
+static void stbi__jpeg_reset(stbi__jpeg *j)
+{
+   j->code_bits = 0;
+   j->code_buffer = 0;
+   j->nomore = 0;
+   j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0;
+   j->marker = STBI__MARKER_none;
+   j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff;
+   j->eob_run = 0;
+   // no more than 1<<31 MCUs if no restart_interal? that's plenty safe,
+   // since we don't even allow 1<<30 pixels
+}
+
+static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
+{
+   stbi__jpeg_reset(z);
+   if (!z->progressive) {
+      if (z->scan_n == 1) {
+         int i,j;
+         STBI_SIMD_ALIGN(short, data[64]);
+         int n = z->order[0];
+         // non-interleaved data, we just need to process one block at a time,
+         // in trivial scanline order
+         // number of blocks to do just depends on how many actual "pixels" this
+         // component has, independent of interleaved MCU blocking and such
+         int w = (z->img_comp[n].x+7) >> 3;
+         int h = (z->img_comp[n].y+7) >> 3;
+         for (j=0; j < h; ++j) {
+            for (i=0; i < w; ++i) {
+               int ha = z->img_comp[n].ha;
+               if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
+               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
+               // every data block is an MCU, so countdown the restart interval
+               if (--z->todo <= 0) {
+                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
+                  // if it's NOT a restart, then just bail, so we get corrupt data
+                  // rather than no data
+                  if (!STBI__RESTART(z->marker)) return 1;
+                  stbi__jpeg_reset(z);
+               }
+            }
+         }
+         return 1;
+      } else { // interleaved
+         int i,j,k,x,y;
+         STBI_SIMD_ALIGN(short, data[64]);
+         for (j=0; j < z->img_mcu_y; ++j) {
+            for (i=0; i < z->img_mcu_x; ++i) {
+               // scan an interleaved mcu... process scan_n components in order
+               for (k=0; k < z->scan_n; ++k) {
+                  int n = z->order[k];
+                  // scan out an mcu's worth of this component; that's just determined
+                  // by the basic H and V specified for the component
+                  for (y=0; y < z->img_comp[n].v; ++y) {
+                     for (x=0; x < z->img_comp[n].h; ++x) {
+                        int x2 = (i*z->img_comp[n].h + x)*8;
+                        int y2 = (j*z->img_comp[n].v + y)*8;
+                        int ha = z->img_comp[n].ha;
+                        if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
+                        z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data);
+                     }
+                  }
+               }
+               // after all interleaved components, that's an interleaved MCU,
+               // so now count down the restart interval
+               if (--z->todo <= 0) {
+                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
+                  if (!STBI__RESTART(z->marker)) return 1;
+                  stbi__jpeg_reset(z);
+               }
+            }
+         }
+         return 1;
+      }
+   } else {
+      if (z->scan_n == 1) {
+         int i,j;
+         int n = z->order[0];
+         // non-interleaved data, we just need to process one block at a time,
+         // in trivial scanline order
+         // number of blocks to do just depends on how many actual "pixels" this
+         // component has, independent of interleaved MCU blocking and such
+         int w = (z->img_comp[n].x+7) >> 3;
+         int h = (z->img_comp[n].y+7) >> 3;
+         for (j=0; j < h; ++j) {
+            for (i=0; i < w; ++i) {
+               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
+               if (z->spec_start == 0) {
+                  if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
+                     return 0;
+               } else {
+                  int ha = z->img_comp[n].ha;
+                  if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha]))
+                     return 0;
+               }
+               // every data block is an MCU, so countdown the restart interval
+               if (--z->todo <= 0) {
+                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
+                  if (!STBI__RESTART(z->marker)) return 1;
+                  stbi__jpeg_reset(z);
+               }
+            }
+         }
+         return 1;
+      } else { // interleaved
+         int i,j,k,x,y;
+         for (j=0; j < z->img_mcu_y; ++j) {
+            for (i=0; i < z->img_mcu_x; ++i) {
+               // scan an interleaved mcu... process scan_n components in order
+               for (k=0; k < z->scan_n; ++k) {
+                  int n = z->order[k];
+                  // scan out an mcu's worth of this component; that's just determined
+                  // by the basic H and V specified for the component
+                  for (y=0; y < z->img_comp[n].v; ++y) {
+                     for (x=0; x < z->img_comp[n].h; ++x) {
+                        int x2 = (i*z->img_comp[n].h + x);
+                        int y2 = (j*z->img_comp[n].v + y);
+                        short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w);
+                        if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
+                           return 0;
+                     }
+                  }
+               }
+               // after all interleaved components, that's an interleaved MCU,
+               // so now count down the restart interval
+               if (--z->todo <= 0) {
+                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
+                  if (!STBI__RESTART(z->marker)) return 1;
+                  stbi__jpeg_reset(z);
+               }
+            }
+         }
+         return 1;
+      }
+   }
+}
+
+static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)
+{
+   int i;
+   for (i=0; i < 64; ++i)
+      data[i] *= dequant[i];
+}
+
+static void stbi__jpeg_finish(stbi__jpeg *z)
+{
+   if (z->progressive) {
+      // dequantize and idct the data
+      int i,j,n;
+      for (n=0; n < z->s->img_n; ++n) {
+         int w = (z->img_comp[n].x+7) >> 3;
+         int h = (z->img_comp[n].y+7) >> 3;
+         for (j=0; j < h; ++j) {
+            for (i=0; i < w; ++i) {
+               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
+               stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]);
+               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
+            }
+         }
+      }
+   }
+}
+
+static int stbi__process_marker(stbi__jpeg *z, int m)
+{
+   int L;
+   switch (m) {
+      case STBI__MARKER_none: // no marker found
+         return stbi__err("expected marker","Corrupt JPEG");
+
+      case 0xDD: // DRI - specify restart interval
+         if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG");
+         z->restart_interval = stbi__get16be(z->s);
+         return 1;
+
+      case 0xDB: // DQT - define quantization table
+         L = stbi__get16be(z->s)-2;
+         while (L > 0) {
+            int q = stbi__get8(z->s);
+            int p = q >> 4, sixteen = (p != 0);
+            int t = q & 15,i;
+            if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");
+            if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
+
+            for (i=0; i < 64; ++i)
+               z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s));
+            L -= (sixteen ? 129 : 65);
+         }
+         return L==0;
+
+      case 0xC4: // DHT - define huffman table
+         L = stbi__get16be(z->s)-2;
+         while (L > 0) {
+            stbi_uc *v;
+            int sizes[16],i,n=0;
+            int q = stbi__get8(z->s);
+            int tc = q >> 4;
+            int th = q & 15;
+            if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG");
+            for (i=0; i < 16; ++i) {
+               sizes[i] = stbi__get8(z->s);
+               n += sizes[i];
+            }
+            if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values!
+            L -= 17;
+            if (tc == 0) {
+               if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
+               v = z->huff_dc[th].values;
+            } else {
+               if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0;
+               v = z->huff_ac[th].values;
+            }
+            for (i=0; i < n; ++i)
+               v[i] = stbi__get8(z->s);
+            if (tc != 0)
+               stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th);
+            L -= n;
+         }
+         return L==0;
+   }
+
+   // check for comment block or APP blocks
+   if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) {
+      L = stbi__get16be(z->s);
+      if (L < 2) {
+         if (m == 0xFE)
+            return stbi__err("bad COM len","Corrupt JPEG");
+         else
+            return stbi__err("bad APP len","Corrupt JPEG");
+      }
+      L -= 2;
+
+      if (m == 0xE0 && L >= 5) { // JFIF APP0 segment
+         static const unsigned char tag[5] = {'J','F','I','F','\0'};
+         int ok = 1;
+         int i;
+         for (i=0; i < 5; ++i)
+            if (stbi__get8(z->s) != tag[i])
+               ok = 0;
+         L -= 5;
+         if (ok)
+            z->jfif = 1;
+      } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment
+         static const unsigned char tag[6] = {'A','d','o','b','e','\0'};
+         int ok = 1;
+         int i;
+         for (i=0; i < 6; ++i)
+            if (stbi__get8(z->s) != tag[i])
+               ok = 0;
+         L -= 6;
+         if (ok) {
+            stbi__get8(z->s); // version
+            stbi__get16be(z->s); // flags0
+            stbi__get16be(z->s); // flags1
+            z->app14_color_transform = stbi__get8(z->s); // color transform
+            L -= 6;
+         }
+      }
+
+      stbi__skip(z->s, L);
+      return 1;
+   }
+
+   return stbi__err("unknown marker","Corrupt JPEG");
+}
+
+// after we see SOS
+static int stbi__process_scan_header(stbi__jpeg *z)
+{
+   int i;
+   int Ls = stbi__get16be(z->s);
+   z->scan_n = stbi__get8(z->s);
+   if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG");
+   if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG");
+   for (i=0; i < z->scan_n; ++i) {
+      int id = stbi__get8(z->s), which;
+      int q = stbi__get8(z->s);
+      for (which = 0; which < z->s->img_n; ++which)
+         if (z->img_comp[which].id == id)
+            break;
+      if (which == z->s->img_n) return 0; // no match
+      z->img_comp[which].hd = q >> 4;   if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG");
+      z->img_comp[which].ha = q & 15;   if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG");
+      z->order[i] = which;
+   }
+
+   {
+      int aa;
+      z->spec_start = stbi__get8(z->s);
+      z->spec_end   = stbi__get8(z->s); // should be 63, but might be 0
+      aa = stbi__get8(z->s);
+      z->succ_high = (aa >> 4);
+      z->succ_low  = (aa & 15);
+      if (z->progressive) {
+         if (z->spec_start > 63 || z->spec_end > 63  || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13)
+            return stbi__err("bad SOS", "Corrupt JPEG");
+      } else {
+         if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG");
+         if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG");
+         z->spec_end = 63;
+      }
+   }
+
+   return 1;
+}
+
+static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why)
+{
+   int i;
+   for (i=0; i < ncomp; ++i) {
+      if (z->img_comp[i].raw_data) {
+         STBI_FREE(z->img_comp[i].raw_data);
+         z->img_comp[i].raw_data = NULL;
+         z->img_comp[i].data = NULL;
+      }
+      if (z->img_comp[i].raw_coeff) {
+         STBI_FREE(z->img_comp[i].raw_coeff);
+         z->img_comp[i].raw_coeff = 0;
+         z->img_comp[i].coeff = 0;
+      }
+      if (z->img_comp[i].linebuf) {
+         STBI_FREE(z->img_comp[i].linebuf);
+         z->img_comp[i].linebuf = NULL;
+      }
+   }
+   return why;
+}
+
+static int stbi__process_frame_header(stbi__jpeg *z, int scan)
+{
+   stbi__context *s = z->s;
+   int Lf,p,i,q, h_max=1,v_max=1,c;
+   Lf = stbi__get16be(s);         if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG
+   p  = stbi__get8(s);            if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline
+   s->img_y = stbi__get16be(s);   if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG
+   s->img_x = stbi__get16be(s);   if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires
+   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+   c = stbi__get8(s);
+   if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG");
+   s->img_n = c;
+   for (i=0; i < c; ++i) {
+      z->img_comp[i].data = NULL;
+      z->img_comp[i].linebuf = NULL;
+   }
+
+   if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG");
+
+   z->rgb = 0;
+   for (i=0; i < s->img_n; ++i) {
+      static const unsigned char rgb[3] = { 'R', 'G', 'B' };
+      z->img_comp[i].id = stbi__get8(s);
+      if (s->img_n == 3 && z->img_comp[i].id == rgb[i])
+         ++z->rgb;
+      q = stbi__get8(s);
+      z->img_comp[i].h = (q >> 4);  if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG");
+      z->img_comp[i].v = q & 15;    if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG");
+      z->img_comp[i].tq = stbi__get8(s);  if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG");
+   }
+
+   if (scan != STBI__SCAN_load) return 1;
+
+   if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode");
+
+   for (i=0; i < s->img_n; ++i) {
+      if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;
+      if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
+   }
+
+   // check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios
+   // and I've never seen a non-corrupted JPEG file actually use them
+   for (i=0; i < s->img_n; ++i) {
+      if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG");
+      if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG");
+   }
+
+   // compute interleaved mcu info
+   z->img_h_max = h_max;
+   z->img_v_max = v_max;
+   z->img_mcu_w = h_max * 8;
+   z->img_mcu_h = v_max * 8;
+   // these sizes can't be more than 17 bits
+   z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w;
+   z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h;
+
+   for (i=0; i < s->img_n; ++i) {
+      // number of effective pixels (e.g. for non-interleaved MCU)
+      z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;
+      z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;
+      // to simplify generation, we'll allocate enough memory to decode
+      // the bogus oversized data from using interleaved MCUs and their
+      // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't
+      // discard the extra data until colorspace conversion
+      //
+      // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier)
+      // so these muls can't overflow with 32-bit ints (which we require)
+      z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
+      z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;
+      z->img_comp[i].coeff = 0;
+      z->img_comp[i].raw_coeff = 0;
+      z->img_comp[i].linebuf = NULL;
+      z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);
+      if (z->img_comp[i].raw_data == NULL)
+         return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
+      // align blocks for idct using mmx/sse
+      z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
+      if (z->progressive) {
+         // w2, h2 are multiples of 8 (see above)
+         z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8;
+         z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8;
+         z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15);
+         if (z->img_comp[i].raw_coeff == NULL)
+            return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
+         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);
+      }
+   }
+
+   return 1;
+}
+
+// use comparisons since in some cases we handle more than one case (e.g. SOF)
+#define stbi__DNL(x)         ((x) == 0xdc)
+#define stbi__SOI(x)         ((x) == 0xd8)
+#define stbi__EOI(x)         ((x) == 0xd9)
+#define stbi__SOF(x)         ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2)
+#define stbi__SOS(x)         ((x) == 0xda)
+
+#define stbi__SOF_progressive(x)   ((x) == 0xc2)
+
+static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)
+{
+   int m;
+   z->jfif = 0;
+   z->app14_color_transform = -1; // valid values are 0,1,2
+   z->marker = STBI__MARKER_none; // initialize cached marker to empty
+   m = stbi__get_marker(z);
+   if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG");
+   if (scan == STBI__SCAN_type) return 1;
+   m = stbi__get_marker(z);
+   while (!stbi__SOF(m)) {
+      if (!stbi__process_marker(z,m)) return 0;
+      m = stbi__get_marker(z);
+      while (m == STBI__MARKER_none) {
+         // some files have extra padding after their blocks, so ok, we'll scan
+         if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG");
+         m = stbi__get_marker(z);
+      }
+   }
+   z->progressive = stbi__SOF_progressive(m);
+   if (!stbi__process_frame_header(z, scan)) return 0;
+   return 1;
+}
+
+static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j)
+{
+   // some JPEGs have junk at end, skip over it but if we find what looks
+   // like a valid marker, resume there
+   while (!stbi__at_eof(j->s)) {
+      stbi_uc x = stbi__get8(j->s);
+      while (x == 0xff) { // might be a marker
+         if (stbi__at_eof(j->s)) return STBI__MARKER_none;
+         x = stbi__get8(j->s);
+         if (x != 0x00 && x != 0xff) {
+            // not a stuffed zero or lead-in to another marker, looks
+            // like an actual marker, return it
+            return x;
+         }
+         // stuffed zero has x=0 now which ends the loop, meaning we go
+         // back to regular scan loop.
+         // repeated 0xff keeps trying to read the next byte of the marker.
+      }
+   }
+   return STBI__MARKER_none;
+}
+
+// decode image to YCbCr format
+static int stbi__decode_jpeg_image(stbi__jpeg *j)
+{
+   int m;
+   for (m = 0; m < 4; m++) {
+      j->img_comp[m].raw_data = NULL;
+      j->img_comp[m].raw_coeff = NULL;
+   }
+   j->restart_interval = 0;
+   if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;
+   m = stbi__get_marker(j);
+   while (!stbi__EOI(m)) {
+      if (stbi__SOS(m)) {
+         if (!stbi__process_scan_header(j)) return 0;
+         if (!stbi__parse_entropy_coded_data(j)) return 0;
+         if (j->marker == STBI__MARKER_none ) {
+         j->marker = stbi__skip_jpeg_junk_at_end(j);
+            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
+         }
+         m = stbi__get_marker(j);
+         if (STBI__RESTART(m))
+            m = stbi__get_marker(j);
+      } else if (stbi__DNL(m)) {
+         int Ld = stbi__get16be(j->s);
+         stbi__uint32 NL = stbi__get16be(j->s);
+         if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
+         if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
+         m = stbi__get_marker(j);
+      } else {
+         if (!stbi__process_marker(j, m)) return 1;
+         m = stbi__get_marker(j);
+      }
+   }
+   if (j->progressive)
+      stbi__jpeg_finish(j);
+   return 1;
+}
+
+// static jfif-centered resampling (across block boundaries)
+
+typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1,
+                                    int w, int hs);
+
+#define stbi__div4(x) ((stbi_uc) ((x) >> 2))
+
+static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   STBI_NOTUSED(out);
+   STBI_NOTUSED(in_far);
+   STBI_NOTUSED(w);
+   STBI_NOTUSED(hs);
+   return in_near;
+}
+
+static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   // need to generate two samples vertically for every one in input
+   int i;
+   STBI_NOTUSED(hs);
+   for (i=0; i < w; ++i)
+      out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2);
+   return out;
+}
+
+static stbi_uc*  stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   // need to generate two samples horizontally for every one in input
+   int i;
+   stbi_uc *input = in_near;
+
+   if (w == 1) {
+      // if only one sample, can't do any interpolation
+      out[0] = out[1] = input[0];
+      return out;
+   }
+
+   out[0] = input[0];
+   out[1] = stbi__div4(input[0]*3 + input[1] + 2);
+   for (i=1; i < w-1; ++i) {
+      int n = 3*input[i]+2;
+      out[i*2+0] = stbi__div4(n+input[i-1]);
+      out[i*2+1] = stbi__div4(n+input[i+1]);
+   }
+   out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2);
+   out[i*2+1] = input[w-1];
+
+   STBI_NOTUSED(in_far);
+   STBI_NOTUSED(hs);
+
+   return out;
+}
+
+#define stbi__div16(x) ((stbi_uc) ((x) >> 4))
+
+static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   // need to generate 2x2 samples for every one in input
+   int i,t0,t1;
+   if (w == 1) {
+      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
+      return out;
+   }
+
+   t1 = 3*in_near[0] + in_far[0];
+   out[0] = stbi__div4(t1+2);
+   for (i=1; i < w; ++i) {
+      t0 = t1;
+      t1 = 3*in_near[i]+in_far[i];
+      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
+      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
+   }
+   out[w*2-1] = stbi__div4(t1+2);
+
+   STBI_NOTUSED(hs);
+
+   return out;
+}
+
+#if defined(STBI_SSE2) || defined(STBI_NEON)
+static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   // need to generate 2x2 samples for every one in input
+   int i=0,t0,t1;
+
+   if (w == 1) {
+      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
+      return out;
+   }
+
+   t1 = 3*in_near[0] + in_far[0];
+   // process groups of 8 pixels for as long as we can.
+   // note we can't handle the last pixel in a row in this loop
+   // because we need to handle the filter boundary conditions.
+   for (; i < ((w-1) & ~7); i += 8) {
+#if defined(STBI_SSE2)
+      // load and perform the vertical filtering pass
+      // this uses 3*x + y = 4*x + (y - x)
+      __m128i zero  = _mm_setzero_si128();
+      __m128i farb  = _mm_loadl_epi64((__m128i *) (in_far + i));
+      __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i));
+      __m128i farw  = _mm_unpacklo_epi8(farb, zero);
+      __m128i nearw = _mm_unpacklo_epi8(nearb, zero);
+      __m128i diff  = _mm_sub_epi16(farw, nearw);
+      __m128i nears = _mm_slli_epi16(nearw, 2);
+      __m128i curr  = _mm_add_epi16(nears, diff); // current row
+
+      // horizontal filter works the same based on shifted vers of current
+      // row. "prev" is current row shifted right by 1 pixel; we need to
+      // insert the previous pixel value (from t1).
+      // "next" is current row shifted left by 1 pixel, with first pixel
+      // of next block of 8 pixels added in.
+      __m128i prv0 = _mm_slli_si128(curr, 2);
+      __m128i nxt0 = _mm_srli_si128(curr, 2);
+      __m128i prev = _mm_insert_epi16(prv0, t1, 0);
+      __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7);
+
+      // horizontal filter, polyphase implementation since it's convenient:
+      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
+      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
+      // note the shared term.
+      __m128i bias  = _mm_set1_epi16(8);
+      __m128i curs = _mm_slli_epi16(curr, 2);
+      __m128i prvd = _mm_sub_epi16(prev, curr);
+      __m128i nxtd = _mm_sub_epi16(next, curr);
+      __m128i curb = _mm_add_epi16(curs, bias);
+      __m128i even = _mm_add_epi16(prvd, curb);
+      __m128i odd  = _mm_add_epi16(nxtd, curb);
+
+      // interleave even and odd pixels, then undo scaling.
+      __m128i int0 = _mm_unpacklo_epi16(even, odd);
+      __m128i int1 = _mm_unpackhi_epi16(even, odd);
+      __m128i de0  = _mm_srli_epi16(int0, 4);
+      __m128i de1  = _mm_srli_epi16(int1, 4);
+
+      // pack and write output
+      __m128i outv = _mm_packus_epi16(de0, de1);
+      _mm_storeu_si128((__m128i *) (out + i*2), outv);
+#elif defined(STBI_NEON)
+      // load and perform the vertical filtering pass
+      // this uses 3*x + y = 4*x + (y - x)
+      uint8x8_t farb  = vld1_u8(in_far + i);
+      uint8x8_t nearb = vld1_u8(in_near + i);
+      int16x8_t diff  = vreinterpretq_s16_u16(vsubl_u8(farb, nearb));
+      int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2));
+      int16x8_t curr  = vaddq_s16(nears, diff); // current row
+
+      // horizontal filter works the same based on shifted vers of current
+      // row. "prev" is current row shifted right by 1 pixel; we need to
+      // insert the previous pixel value (from t1).
+      // "next" is current row shifted left by 1 pixel, with first pixel
+      // of next block of 8 pixels added in.
+      int16x8_t prv0 = vextq_s16(curr, curr, 7);
+      int16x8_t nxt0 = vextq_s16(curr, curr, 1);
+      int16x8_t prev = vsetq_lane_s16(t1, prv0, 0);
+      int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7);
+
+      // horizontal filter, polyphase implementation since it's convenient:
+      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
+      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
+      // note the shared term.
+      int16x8_t curs = vshlq_n_s16(curr, 2);
+      int16x8_t prvd = vsubq_s16(prev, curr);
+      int16x8_t nxtd = vsubq_s16(next, curr);
+      int16x8_t even = vaddq_s16(curs, prvd);
+      int16x8_t odd  = vaddq_s16(curs, nxtd);
+
+      // undo scaling and round, then store with even/odd phases interleaved
+      uint8x8x2_t o;
+      o.val[0] = vqrshrun_n_s16(even, 4);
+      o.val[1] = vqrshrun_n_s16(odd,  4);
+      vst2_u8(out + i*2, o);
+#endif
+
+      // "previous" value for next iter
+      t1 = 3*in_near[i+7] + in_far[i+7];
+   }
+
+   t0 = t1;
+   t1 = 3*in_near[i] + in_far[i];
+   out[i*2] = stbi__div16(3*t1 + t0 + 8);
+
+   for (++i; i < w; ++i) {
+      t0 = t1;
+      t1 = 3*in_near[i]+in_far[i];
+      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
+      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
+   }
+   out[w*2-1] = stbi__div4(t1+2);
+
+   STBI_NOTUSED(hs);
+
+   return out;
+}
+#endif
+
+static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
+{
+   // resample with nearest-neighbor
+   int i,j;
+   STBI_NOTUSED(in_far);
+   for (i=0; i < w; ++i)
+      for (j=0; j < hs; ++j)
+         out[i*hs+j] = in_near[i];
+   return out;
+}
+
+// this is a reduced-precision calculation of YCbCr-to-RGB introduced
+// to make sure the code produces the same results in both SIMD and scalar
+#define stbi__float2fixed(x)  (((int) ((x) * 4096.0f + 0.5f)) << 8)
+static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
+{
+   int i;
+   for (i=0; i < count; ++i) {
+      int y_fixed = (y[i] << 20) + (1<<19); // rounding
+      int r,g,b;
+      int cr = pcr[i] - 128;
+      int cb = pcb[i] - 128;
+      r = y_fixed +  cr* stbi__float2fixed(1.40200f);
+      g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
+      b = y_fixed                                     +   cb* stbi__float2fixed(1.77200f);
+      r >>= 20;
+      g >>= 20;
+      b >>= 20;
+      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
+      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
+      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
+      out[0] = (stbi_uc)r;
+      out[1] = (stbi_uc)g;
+      out[2] = (stbi_uc)b;
+      out[3] = 255;
+      out += step;
+   }
+}
+
+#if defined(STBI_SSE2) || defined(STBI_NEON)
+static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)
+{
+   int i = 0;
+
+#ifdef STBI_SSE2
+   // step == 3 is pretty ugly on the final interleave, and i'm not convinced
+   // it's useful in practice (you wouldn't use it for textures, for example).
+   // so just accelerate step == 4 case.
+   if (step == 4) {
+      // this is a fairly straightforward implementation and not super-optimized.
+      __m128i signflip  = _mm_set1_epi8(-0x80);
+      __m128i cr_const0 = _mm_set1_epi16(   (short) ( 1.40200f*4096.0f+0.5f));
+      __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));
+      __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));
+      __m128i cb_const1 = _mm_set1_epi16(   (short) ( 1.77200f*4096.0f+0.5f));
+      __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);
+      __m128i xw = _mm_set1_epi16(255); // alpha channel
+
+      for (; i+7 < count; i += 8) {
+         // load
+         __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i));
+         __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i));
+         __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i));
+         __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128
+         __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128
+
+         // unpack to short (and left-shift cr, cb by 8)
+         __m128i yw  = _mm_unpacklo_epi8(y_bias, y_bytes);
+         __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased);
+         __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased);
+
+         // color transform
+         __m128i yws = _mm_srli_epi16(yw, 4);
+         __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw);
+         __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw);
+         __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1);
+         __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1);
+         __m128i rws = _mm_add_epi16(cr0, yws);
+         __m128i gwt = _mm_add_epi16(cb0, yws);
+         __m128i bws = _mm_add_epi16(yws, cb1);
+         __m128i gws = _mm_add_epi16(gwt, cr1);
+
+         // descale
+         __m128i rw = _mm_srai_epi16(rws, 4);
+         __m128i bw = _mm_srai_epi16(bws, 4);
+         __m128i gw = _mm_srai_epi16(gws, 4);
+
+         // back to byte, set up for transpose
+         __m128i brb = _mm_packus_epi16(rw, bw);
+         __m128i gxb = _mm_packus_epi16(gw, xw);
+
+         // transpose to interleave channels
+         __m128i t0 = _mm_unpacklo_epi8(brb, gxb);
+         __m128i t1 = _mm_unpackhi_epi8(brb, gxb);
+         __m128i o0 = _mm_unpacklo_epi16(t0, t1);
+         __m128i o1 = _mm_unpackhi_epi16(t0, t1);
+
+         // store
+         _mm_storeu_si128((__m128i *) (out + 0), o0);
+         _mm_storeu_si128((__m128i *) (out + 16), o1);
+         out += 32;
+      }
+   }
+#endif
+
+#ifdef STBI_NEON
+   // in this version, step=3 support would be easy to add. but is there demand?
+   if (step == 4) {
+      // this is a fairly straightforward implementation and not super-optimized.
+      uint8x8_t signflip = vdup_n_u8(0x80);
+      int16x8_t cr_const0 = vdupq_n_s16(   (short) ( 1.40200f*4096.0f+0.5f));
+      int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f));
+      int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f));
+      int16x8_t cb_const1 = vdupq_n_s16(   (short) ( 1.77200f*4096.0f+0.5f));
+
+      for (; i+7 < count; i += 8) {
+         // load
+         uint8x8_t y_bytes  = vld1_u8(y + i);
+         uint8x8_t cr_bytes = vld1_u8(pcr + i);
+         uint8x8_t cb_bytes = vld1_u8(pcb + i);
+         int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip));
+         int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip));
+
+         // expand to s16
+         int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4));
+         int16x8_t crw = vshll_n_s8(cr_biased, 7);
+         int16x8_t cbw = vshll_n_s8(cb_biased, 7);
+
+         // color transform
+         int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0);
+         int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0);
+         int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1);
+         int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1);
+         int16x8_t rws = vaddq_s16(yws, cr0);
+         int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1);
+         int16x8_t bws = vaddq_s16(yws, cb1);
+
+         // undo scaling, round, convert to byte
+         uint8x8x4_t o;
+         o.val[0] = vqrshrun_n_s16(rws, 4);
+         o.val[1] = vqrshrun_n_s16(gws, 4);
+         o.val[2] = vqrshrun_n_s16(bws, 4);
+         o.val[3] = vdup_n_u8(255);
+
+         // store, interleaving r/g/b/a
+         vst4_u8(out, o);
+         out += 8*4;
+      }
+   }
+#endif
+
+   for (; i < count; ++i) {
+      int y_fixed = (y[i] << 20) + (1<<19); // rounding
+      int r,g,b;
+      int cr = pcr[i] - 128;
+      int cb = pcb[i] - 128;
+      r = y_fixed + cr* stbi__float2fixed(1.40200f);
+      g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
+      b = y_fixed                                   +   cb* stbi__float2fixed(1.77200f);
+      r >>= 20;
+      g >>= 20;
+      b >>= 20;
+      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
+      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
+      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
+      out[0] = (stbi_uc)r;
+      out[1] = (stbi_uc)g;
+      out[2] = (stbi_uc)b;
+      out[3] = 255;
+      out += step;
+   }
+}
+#endif
+
+// set up the kernels
+static void stbi__setup_jpeg(stbi__jpeg *j)
+{
+   j->idct_block_kernel = stbi__idct_block;
+   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row;
+   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2;
+
+#ifdef STBI_SSE2
+   if (stbi__sse2_available()) {
+      j->idct_block_kernel = stbi__idct_simd;
+      j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
+      j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
+   }
+#endif
+
+#ifdef STBI_NEON
+   j->idct_block_kernel = stbi__idct_simd;
+   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
+   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
+#endif
+}
+
+// clean up the temporary component buffers
+static void stbi__cleanup_jpeg(stbi__jpeg *j)
+{
+   stbi__free_jpeg_components(j, j->s->img_n, 0);
+}
+
+typedef struct
+{
+   resample_row_func resample;
+   stbi_uc *line0,*line1;
+   int hs,vs;   // expansion factor in each axis
+   int w_lores; // horizontal pixels pre-expansion
+   int ystep;   // how far through vertical expansion we are
+   int ypos;    // which pre-expansion row we're on
+} stbi__resample;
+
+// fast 0..255 * 0..255 => 0..255 rounded multiplication
+static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y)
+{
+   unsigned int t = x*y + 128;
+   return (stbi_uc) ((t + (t >>8)) >> 8);
+}
+
+static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
+{
+   int n, decode_n, is_rgb;
+   z->s->img_n = 0; // make stbi__cleanup_jpeg safe
+
+   // validate req_comp
+   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
+
+   // load a jpeg image from whichever source, but leave in YCbCr format
+   if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; }
+
+   // determine actual number of components to generate
+   n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1;
+
+   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));
+
+   if (z->s->img_n == 3 && n < 3 && !is_rgb)
+      decode_n = 1;
+   else
+      decode_n = z->s->img_n;
+
+   // nothing to do if no components requested; check this now to avoid
+   // accessing uninitialized coutput[0] later
+   if (decode_n <= 0) { stbi__cleanup_jpeg(z); return NULL; }
+
+   // resample and color-convert
+   {
+      int k;
+      unsigned int i,j;
+      stbi_uc *output;
+      stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL };
+
+      stbi__resample res_comp[4];
+
+      for (k=0; k < decode_n; ++k) {
+         stbi__resample *r = &res_comp[k];
+
+         // allocate line buffer big enough for upsampling off the edges
+         // with upsample factor of 4
+         z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3);
+         if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
+
+         r->hs      = z->img_h_max / z->img_comp[k].h;
+         r->vs      = z->img_v_max / z->img_comp[k].v;
+         r->ystep   = r->vs >> 1;
+         r->w_lores = (z->s->img_x + r->hs-1) / r->hs;
+         r->ypos    = 0;
+         r->line0   = r->line1 = z->img_comp[k].data;
+
+         if      (r->hs == 1 && r->vs == 1) r->resample = resample_row_1;
+         else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2;
+         else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2;
+         else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel;
+         else                               r->resample = stbi__resample_row_generic;
+      }
+
+      // can't error after this so, this is safe
+      output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1);
+      if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
+
+      // now go ahead and resample
+      for (j=0; j < z->s->img_y; ++j) {
+         stbi_uc *out = output + n * z->s->img_x * j;
+         for (k=0; k < decode_n; ++k) {
+            stbi__resample *r = &res_comp[k];
+            int y_bot = r->ystep >= (r->vs >> 1);
+            coutput[k] = r->resample(z->img_comp[k].linebuf,
+                                     y_bot ? r->line1 : r->line0,
+                                     y_bot ? r->line0 : r->line1,
+                                     r->w_lores, r->hs);
+            if (++r->ystep >= r->vs) {
+               r->ystep = 0;
+               r->line0 = r->line1;
+               if (++r->ypos < z->img_comp[k].y)
+                  r->line1 += z->img_comp[k].w2;
+            }
+         }
+         if (n >= 3) {
+            stbi_uc *y = coutput[0];
+            if (z->s->img_n == 3) {
+               if (is_rgb) {
+                  for (i=0; i < z->s->img_x; ++i) {
+                     out[0] = y[i];
+                     out[1] = coutput[1][i];
+                     out[2] = coutput[2][i];
+                     out[3] = 255;
+                     out += n;
+                  }
+               } else {
+                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
+               }
+            } else if (z->s->img_n == 4) {
+               if (z->app14_color_transform == 0) { // CMYK
+                  for (i=0; i < z->s->img_x; ++i) {
+                     stbi_uc m = coutput[3][i];
+                     out[0] = stbi__blinn_8x8(coutput[0][i], m);
+                     out[1] = stbi__blinn_8x8(coutput[1][i], m);
+                     out[2] = stbi__blinn_8x8(coutput[2][i], m);
+                     out[3] = 255;
+                     out += n;
+                  }
+               } else if (z->app14_color_transform == 2) { // YCCK
+                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
+                  for (i=0; i < z->s->img_x; ++i) {
+                     stbi_uc m = coutput[3][i];
+                     out[0] = stbi__blinn_8x8(255 - out[0], m);
+                     out[1] = stbi__blinn_8x8(255 - out[1], m);
+                     out[2] = stbi__blinn_8x8(255 - out[2], m);
+                     out += n;
+                  }
+               } else { // YCbCr + alpha?  Ignore the fourth channel for now
+                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
+               }
+            } else
+               for (i=0; i < z->s->img_x; ++i) {
+                  out[0] = out[1] = out[2] = y[i];
+                  out[3] = 255; // not used if n==3
+                  out += n;
+               }
+         } else {
+            if (is_rgb) {
+               if (n == 1)
+                  for (i=0; i < z->s->img_x; ++i)
+                     *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
+               else {
+                  for (i=0; i < z->s->img_x; ++i, out += 2) {
+                     out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
+                     out[1] = 255;
+                  }
+               }
+            } else if (z->s->img_n == 4 && z->app14_color_transform == 0) {
+               for (i=0; i < z->s->img_x; ++i) {
+                  stbi_uc m = coutput[3][i];
+                  stbi_uc r = stbi__blinn_8x8(coutput[0][i], m);
+                  stbi_uc g = stbi__blinn_8x8(coutput[1][i], m);
+                  stbi_uc b = stbi__blinn_8x8(coutput[2][i], m);
+                  out[0] = stbi__compute_y(r, g, b);
+                  out[1] = 255;
+                  out += n;
+               }
+            } else if (z->s->img_n == 4 && z->app14_color_transform == 2) {
+               for (i=0; i < z->s->img_x; ++i) {
+                  out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]);
+                  out[1] = 255;
+                  out += n;
+               }
+            } else {
+               stbi_uc *y = coutput[0];
+               if (n == 1)
+                  for (i=0; i < z->s->img_x; ++i) out[i] = y[i];
+               else
+                  for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; }
+            }
+         }
+      }
+      stbi__cleanup_jpeg(z);
+      *out_x = z->s->img_x;
+      *out_y = z->s->img_y;
+      if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output
+      return output;
+   }
+}
+
+static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   unsigned char* result;
+   stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
+   if (!j) return stbi__errpuc("outofmem", "Out of memory");
+   memset(j, 0, sizeof(stbi__jpeg));
+   STBI_NOTUSED(ri);
+   j->s = s;
+   stbi__setup_jpeg(j);
+   result = load_jpeg_image(j, x,y,comp,req_comp);
+   STBI_FREE(j);
+   return result;
+}
+
+static int stbi__jpeg_test(stbi__context *s)
+{
+   int r;
+   stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
+   if (!j) return stbi__err("outofmem", "Out of memory");
+   memset(j, 0, sizeof(stbi__jpeg));
+   j->s = s;
+   stbi__setup_jpeg(j);
+   r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
+   stbi__rewind(s);
+   STBI_FREE(j);
+   return r;
+}
+
+static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp)
+{
+   if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) {
+      stbi__rewind( j->s );
+      return 0;
+   }
+   if (x) *x = j->s->img_x;
+   if (y) *y = j->s->img_y;
+   if (comp) *comp = j->s->img_n >= 3 ? 3 : 1;
+   return 1;
+}
+
+static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   int result;
+   stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
+   if (!j) return stbi__err("outofmem", "Out of memory");
+   memset(j, 0, sizeof(stbi__jpeg));
+   j->s = s;
+   result = stbi__jpeg_info_raw(j, x, y, comp);
+   STBI_FREE(j);
+   return result;
+}
+#endif
+
+// public domain zlib decode    v0.2  Sean Barrett 2006-11-18
+//    simple implementation
+//      - all input must be provided in an upfront buffer
+//      - all output is written to a single output buffer (can malloc/realloc)
+//    performance
+//      - fast huffman
+
+#ifndef STBI_NO_ZLIB
+
+// fast-way is faster to check than jpeg huffman, but slow way is slower
+#define STBI__ZFAST_BITS  9 // accelerate all cases in default tables
+#define STBI__ZFAST_MASK  ((1 << STBI__ZFAST_BITS) - 1)
+#define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet
+
+// zlib-style huffman encoding
+// (jpegs packs from left, zlib from right, so can't share code)
+typedef struct
+{
+   stbi__uint16 fast[1 << STBI__ZFAST_BITS];
+   stbi__uint16 firstcode[16];
+   int maxcode[17];
+   stbi__uint16 firstsymbol[16];
+   stbi_uc  size[STBI__ZNSYMS];
+   stbi__uint16 value[STBI__ZNSYMS];
+} stbi__zhuffman;
+
+stbi_inline static int stbi__bitreverse16(int n)
+{
+  n = ((n & 0xAAAA) >>  1) | ((n & 0x5555) << 1);
+  n = ((n & 0xCCCC) >>  2) | ((n & 0x3333) << 2);
+  n = ((n & 0xF0F0) >>  4) | ((n & 0x0F0F) << 4);
+  n = ((n & 0xFF00) >>  8) | ((n & 0x00FF) << 8);
+  return n;
+}
+
+stbi_inline static int stbi__bit_reverse(int v, int bits)
+{
+   STBI_ASSERT(bits <= 16);
+   // to bit reverse n bits, reverse 16 and shift
+   // e.g. 11 bits, bit reverse and shift away 5
+   return stbi__bitreverse16(v) >> (16-bits);
+}
+
+static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num)
+{
+   int i,k=0;
+   int code, next_code[16], sizes[17];
+
+   // DEFLATE spec for generating codes
+   memset(sizes, 0, sizeof(sizes));
+   memset(z->fast, 0, sizeof(z->fast));
+   for (i=0; i < num; ++i)
+      ++sizes[sizelist[i]];
+   sizes[0] = 0;
+   for (i=1; i < 16; ++i)
+      if (sizes[i] > (1 << i))
+         return stbi__err("bad sizes", "Corrupt PNG");
+   code = 0;
+   for (i=1; i < 16; ++i) {
+      next_code[i] = code;
+      z->firstcode[i] = (stbi__uint16) code;
+      z->firstsymbol[i] = (stbi__uint16) k;
+      code = (code + sizes[i]);
+      if (sizes[i])
+         if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG");
+      z->maxcode[i] = code << (16-i); // preshift for inner loop
+      code <<= 1;
+      k += sizes[i];
+   }
+   z->maxcode[16] = 0x10000; // sentinel
+   for (i=0; i < num; ++i) {
+      int s = sizelist[i];
+      if (s) {
+         int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];
+         stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i);
+         z->size [c] = (stbi_uc     ) s;
+         z->value[c] = (stbi__uint16) i;
+         if (s <= STBI__ZFAST_BITS) {
+            int j = stbi__bit_reverse(next_code[s],s);
+            while (j < (1 << STBI__ZFAST_BITS)) {
+               z->fast[j] = fastv;
+               j += (1 << s);
+            }
+         }
+         ++next_code[s];
+      }
+   }
+   return 1;
+}
+
+// zlib-from-memory implementation for PNG reading
+//    because PNG allows splitting the zlib stream arbitrarily,
+//    and it's annoying structurally to have PNG call ZLIB call PNG,
+//    we require PNG read all the IDATs and combine them into a single
+//    memory buffer
+
+typedef struct
+{
+   stbi_uc *zbuffer, *zbuffer_end;
+   int num_bits;
+   int hit_zeof_once;
+   stbi__uint32 code_buffer;
+
+   char *zout;
+   char *zout_start;
+   char *zout_end;
+   int   z_expandable;
+
+   stbi__zhuffman z_length, z_distance;
+} stbi__zbuf;
+
+stbi_inline static int stbi__zeof(stbi__zbuf *z)
+{
+   return (z->zbuffer >= z->zbuffer_end);
+}
+
+stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z)
+{
+   return stbi__zeof(z) ? 0 : *z->zbuffer++;
+}
+
+static void stbi__fill_bits(stbi__zbuf *z)
+{
+   do {
+      if (z->code_buffer >= (1U << z->num_bits)) {
+        z->zbuffer = z->zbuffer_end;  /* treat this as EOF so we fail. */
+        return;
+      }
+      z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits;
+      z->num_bits += 8;
+   } while (z->num_bits <= 24);
+}
+
+stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n)
+{
+   unsigned int k;
+   if (z->num_bits < n) stbi__fill_bits(z);
+   k = z->code_buffer & ((1 << n) - 1);
+   z->code_buffer >>= n;
+   z->num_bits -= n;
+   return k;
+}
+
+static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)
+{
+   int b,s,k;
+   // not resolved by fast table, so compute it the slow way
+   // use jpeg approach, which requires MSbits at top
+   k = stbi__bit_reverse(a->code_buffer, 16);
+   for (s=STBI__ZFAST_BITS+1; ; ++s)
+      if (k < z->maxcode[s])
+         break;
+   if (s >= 16) return -1; // invalid code!
+   // code size is s, so:
+   b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
+   if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere!
+   if (z->size[b] != s) return -1;  // was originally an assert, but report failure instead.
+   a->code_buffer >>= s;
+   a->num_bits -= s;
+   return z->value[b];
+}
+
+stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)
+{
+   int b,s;
+   if (a->num_bits < 16) {
+      if (stbi__zeof(a)) {
+         if (!a->hit_zeof_once) {
+            // This is the first time we hit eof, insert 16 extra padding btis
+            // to allow us to keep going; if we actually consume any of them
+            // though, that is invalid data. This is caught later.
+            a->hit_zeof_once = 1;
+            a->num_bits += 16; // add 16 implicit zero bits
+         } else {
+            // We already inserted our extra 16 padding bits and are again
+            // out, this stream is actually prematurely terminated.
+            return -1;
+         }
+      } else {
+         stbi__fill_bits(a);
+      }
+   }
+   b = z->fast[a->code_buffer & STBI__ZFAST_MASK];
+   if (b) {
+      s = b >> 9;
+      a->code_buffer >>= s;
+      a->num_bits -= s;
+      return b & 511;
+   }
+   return stbi__zhuffman_decode_slowpath(a, z);
+}
+
+static int stbi__zexpand(stbi__zbuf *z, char *zout, int n)  // need to make room for n bytes
+{
+   char *q;
+   unsigned int cur, limit, old_limit;
+   z->zout = zout;
+   if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG");
+   cur   = (unsigned int) (z->zout - z->zout_start);
+   limit = old_limit = (unsigned) (z->zout_end - z->zout_start);
+   if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory");
+   while (cur + n > limit) {
+      if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory");
+      limit *= 2;
+   }
+   q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);
+   STBI_NOTUSED(old_limit);
+   if (q == NULL) return stbi__err("outofmem", "Out of memory");
+   z->zout_start = q;
+   z->zout       = q + cur;
+   z->zout_end   = q + limit;
+   return 1;
+}
+
+static const int stbi__zlength_base[31] = {
+   3,4,5,6,7,8,9,10,11,13,
+   15,17,19,23,27,31,35,43,51,59,
+   67,83,99,115,131,163,195,227,258,0,0 };
+
+static const int stbi__zlength_extra[31]=
+{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };
+
+static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,
+257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};
+
+static const int stbi__zdist_extra[32] =
+{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+
+static int stbi__parse_huffman_block(stbi__zbuf *a)
+{
+   char *zout = a->zout;
+   for(;;) {
+      int z = stbi__zhuffman_decode(a, &a->z_length);
+      if (z < 256) {
+         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes
+         if (zout >= a->zout_end) {
+            if (!stbi__zexpand(a, zout, 1)) return 0;
+            zout = a->zout;
+         }
+         *zout++ = (char) z;
+      } else {
+         stbi_uc *p;
+         int len,dist;
+         if (z == 256) {
+            a->zout = zout;
+            if (a->hit_zeof_once && a->num_bits < 16) {
+               // The first time we hit zeof, we inserted 16 extra zero bits into our bit
+               // buffer so the decoder can just do its speculative decoding. But if we
+               // actually consumed any of those bits (which is the case when num_bits < 16),
+               // the stream actually read past the end so it is malformed.
+               return stbi__err("unexpected end","Corrupt PNG");
+            }
+            return 1;
+         }
+         if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data
+         z -= 257;
+         len = stbi__zlength_base[z];
+         if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);
+         z = stbi__zhuffman_decode(a, &a->z_distance);
+         if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data
+         dist = stbi__zdist_base[z];
+         if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);
+         if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG");
+         if (len > a->zout_end - zout) {
+            if (!stbi__zexpand(a, zout, len)) return 0;
+            zout = a->zout;
+         }
+         p = (stbi_uc *) (zout - dist);
+         if (dist == 1) { // run of one byte; common in images.
+            stbi_uc v = *p;
+            if (len) { do *zout++ = v; while (--len); }
+         } else {
+            if (len) { do *zout++ = *p++; while (--len); }
+         }
+      }
+   }
+}
+
+static int stbi__compute_huffman_codes(stbi__zbuf *a)
+{
+   static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
+   stbi__zhuffman z_codelength;
+   stbi_uc lencodes[286+32+137];//padding for maximum single op
+   stbi_uc codelength_sizes[19];
+   int i,n;
+
+   int hlit  = stbi__zreceive(a,5) + 257;
+   int hdist = stbi__zreceive(a,5) + 1;
+   int hclen = stbi__zreceive(a,4) + 4;
+   int ntot  = hlit + hdist;
+
+   memset(codelength_sizes, 0, sizeof(codelength_sizes));
+   for (i=0; i < hclen; ++i) {
+      int s = stbi__zreceive(a,3);
+      codelength_sizes[length_dezigzag[i]] = (stbi_uc) s;
+   }
+   if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;
+
+   n = 0;
+   while (n < ntot) {
+      int c = stbi__zhuffman_decode(a, &z_codelength);
+      if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG");
+      if (c < 16)
+         lencodes[n++] = (stbi_uc) c;
+      else {
+         stbi_uc fill = 0;
+         if (c == 16) {
+            c = stbi__zreceive(a,2)+3;
+            if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG");
+            fill = lencodes[n-1];
+         } else if (c == 17) {
+            c = stbi__zreceive(a,3)+3;
+         } else if (c == 18) {
+            c = stbi__zreceive(a,7)+11;
+         } else {
+            return stbi__err("bad codelengths", "Corrupt PNG");
+         }
+         if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG");
+         memset(lencodes+n, fill, c);
+         n += c;
+      }
+   }
+   if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG");
+   if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0;
+   if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0;
+   return 1;
+}
+
+static int stbi__parse_uncompressed_block(stbi__zbuf *a)
+{
+   stbi_uc header[4];
+   int len,nlen,k;
+   if (a->num_bits & 7)
+      stbi__zreceive(a, a->num_bits & 7); // discard
+   // drain the bit-packed data into header
+   k = 0;
+   while (a->num_bits > 0) {
+      header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check
+      a->code_buffer >>= 8;
+      a->num_bits -= 8;
+   }
+   if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG");
+   // now fill header the normal way
+   while (k < 4)
+      header[k++] = stbi__zget8(a);
+   len  = header[1] * 256 + header[0];
+   nlen = header[3] * 256 + header[2];
+   if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG");
+   if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG");
+   if (a->zout + len > a->zout_end)
+      if (!stbi__zexpand(a, a->zout, len)) return 0;
+   memcpy(a->zout, a->zbuffer, len);
+   a->zbuffer += len;
+   a->zout += len;
+   return 1;
+}
+
+static int stbi__parse_zlib_header(stbi__zbuf *a)
+{
+   int cmf   = stbi__zget8(a);
+   int cm    = cmf & 15;
+   /* int cinfo = cmf >> 4; */
+   int flg   = stbi__zget8(a);
+   if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
+   if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
+   if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
+   if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
+   // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
+   return 1;
+}
+
+static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] =
+{
+   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
+   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8
+};
+static const stbi_uc stbi__zdefault_distance[32] =
+{
+   5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
+};
+/*
+Init algorithm:
+{
+   int i;   // use <= to match clearly with spec
+   for (i=0; i <= 143; ++i)     stbi__zdefault_length[i]   = 8;
+   for (   ; i <= 255; ++i)     stbi__zdefault_length[i]   = 9;
+   for (   ; i <= 279; ++i)     stbi__zdefault_length[i]   = 7;
+   for (   ; i <= 287; ++i)     stbi__zdefault_length[i]   = 8;
+
+   for (i=0; i <=  31; ++i)     stbi__zdefault_distance[i] = 5;
+}
+*/
+
+static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
+{
+   int final, type;
+   if (parse_header)
+      if (!stbi__parse_zlib_header(a)) return 0;
+   a->num_bits = 0;
+   a->code_buffer = 0;
+   a->hit_zeof_once = 0;
+   do {
+      final = stbi__zreceive(a,1);
+      type = stbi__zreceive(a,2);
+      if (type == 0) {
+         if (!stbi__parse_uncompressed_block(a)) return 0;
+      } else if (type == 3) {
+         return 0;
+      } else {
+         if (type == 1) {
+            // use fixed code lengths
+            if (!stbi__zbuild_huffman(&a->z_length  , stbi__zdefault_length  , STBI__ZNSYMS)) return 0;
+            if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance,  32)) return 0;
+         } else {
+            if (!stbi__compute_huffman_codes(a)) return 0;
+         }
+         if (!stbi__parse_huffman_block(a)) return 0;
+      }
+   } while (!final);
+   return 1;
+}
+
+static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header)
+{
+   a->zout_start = obuf;
+   a->zout       = obuf;
+   a->zout_end   = obuf + olen;
+   a->z_expandable = exp;
+
+   return stbi__parse_zlib(a, parse_header);
+}
+
+STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen)
+{
+   stbi__zbuf a;
+   char *p = (char *) stbi__malloc(initial_size);
+   if (p == NULL) return NULL;
+   a.zbuffer = (stbi_uc *) buffer;
+   a.zbuffer_end = (stbi_uc *) buffer + len;
+   if (stbi__do_zlib(&a, p, initial_size, 1, 1)) {
+      if (outlen) *outlen = (int) (a.zout - a.zout_start);
+      return a.zout_start;
+   } else {
+      STBI_FREE(a.zout_start);
+      return NULL;
+   }
+}
+
+STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)
+{
+   return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen);
+}
+
+STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
+{
+   stbi__zbuf a;
+   char *p = (char *) stbi__malloc(initial_size);
+   if (p == NULL) return NULL;
+   a.zbuffer = (stbi_uc *) buffer;
+   a.zbuffer_end = (stbi_uc *) buffer + len;
+   if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) {
+      if (outlen) *outlen = (int) (a.zout - a.zout_start);
+      return a.zout_start;
+   } else {
+      STBI_FREE(a.zout_start);
+      return NULL;
+   }
+}
+
+STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
+{
+   stbi__zbuf a;
+   a.zbuffer = (stbi_uc *) ibuffer;
+   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
+   if (stbi__do_zlib(&a, obuffer, olen, 0, 1))
+      return (int) (a.zout - a.zout_start);
+   else
+      return -1;
+}
+
+STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
+{
+   stbi__zbuf a;
+   char *p = (char *) stbi__malloc(16384);
+   if (p == NULL) return NULL;
+   a.zbuffer = (stbi_uc *) buffer;
+   a.zbuffer_end = (stbi_uc *) buffer+len;
+   if (stbi__do_zlib(&a, p, 16384, 1, 0)) {
+      if (outlen) *outlen = (int) (a.zout - a.zout_start);
+      return a.zout_start;
+   } else {
+      STBI_FREE(a.zout_start);
+      return NULL;
+   }
+}
+
+STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen)
+{
+   stbi__zbuf a;
+   a.zbuffer = (stbi_uc *) ibuffer;
+   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
+   if (stbi__do_zlib(&a, obuffer, olen, 0, 0))
+      return (int) (a.zout - a.zout_start);
+   else
+      return -1;
+}
+#endif
+
+// public domain "baseline" PNG decoder   v0.10  Sean Barrett 2006-11-18
+//    simple implementation
+//      - only 8-bit samples
+//      - no CRC checking
+//      - allocates lots of intermediate memory
+//        - avoids problem of streaming data between subsystems
+//        - avoids explicit window management
+//    performance
+//      - uses stb_zlib, a PD zlib implementation with fast huffman decoding
+
+#ifndef STBI_NO_PNG
+typedef struct
+{
+   stbi__uint32 length;
+   stbi__uint32 type;
+} stbi__pngchunk;
+
+static stbi__pngchunk stbi__get_chunk_header(stbi__context *s)
+{
+   stbi__pngchunk c;
+   c.length = stbi__get32be(s);
+   c.type   = stbi__get32be(s);
+   return c;
+}
+
+static int stbi__check_png_header(stbi__context *s)
+{
+   static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 };
+   int i;
+   for (i=0; i < 8; ++i)
+      if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG");
+   return 1;
+}
+
+typedef struct
+{
+   stbi__context *s;
+   stbi_uc *idata, *expanded, *out;
+   int depth;
+} stbi__png;
+
+
+enum {
+   STBI__F_none=0,
+   STBI__F_sub=1,
+   STBI__F_up=2,
+   STBI__F_avg=3,
+   STBI__F_paeth=4,
+   // synthetic filter used for first scanline to avoid needing a dummy row of 0s
+   STBI__F_avg_first
+};
+
+static stbi_uc first_row_filter[5] =
+{
+   STBI__F_none,
+   STBI__F_sub,
+   STBI__F_none,
+   STBI__F_avg_first,
+   STBI__F_sub // Paeth with b=c=0 turns out to be equivalent to sub
+};
+
+static int stbi__paeth(int a, int b, int c)
+{
+   // This formulation looks very different from the reference in the PNG spec, but is
+   // actually equivalent and has favorable data dependencies and admits straightforward
+   // generation of branch-free code, which helps performance significantly.
+   int thresh = c*3 - (a + b);
+   int lo = a < b ? a : b;
+   int hi = a < b ? b : a;
+   int t0 = (hi <= thresh) ? lo : c;
+   int t1 = (thresh <= lo) ? hi : t0;
+   return t1;
+}
+
+static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 };
+
+// adds an extra all-255 alpha channel
+// dest == src is legal
+// img_n must be 1 or 3
+static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__uint32 x, int img_n)
+{
+   int i;
+   // must process data backwards since we allow dest==src
+   if (img_n == 1) {
+      for (i=x-1; i >= 0; --i) {
+         dest[i*2+1] = 255;
+         dest[i*2+0] = src[i];
+      }
+   } else {
+      STBI_ASSERT(img_n == 3);
+      for (i=x-1; i >= 0; --i) {
+         dest[i*4+3] = 255;
+         dest[i*4+2] = src[i*3+2];
+         dest[i*4+1] = src[i*3+1];
+         dest[i*4+0] = src[i*3+0];
+      }
+   }
+}
+
+// create the png data from post-deflated data
+static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color)
+{
+   int bytes = (depth == 16 ? 2 : 1);
+   stbi__context *s = a->s;
+   stbi__uint32 i,j,stride = x*out_n*bytes;
+   stbi__uint32 img_len, img_width_bytes;
+   stbi_uc *filter_buf;
+   int all_ok = 1;
+   int k;
+   int img_n = s->img_n; // copy it into a local for later
+
+   int output_bytes = out_n*bytes;
+   int filter_bytes = img_n*bytes;
+   int width = x;
+
+   STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1);
+   a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into
+   if (!a->out) return stbi__err("outofmem", "Out of memory");
+
+   // note: error exits here don't need to clean up a->out individually,
+   // stbi__do_png always does on error.
+   if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG");
+   img_width_bytes = (((img_n * x * depth) + 7) >> 3);
+   if (!stbi__mad2sizes_valid(img_width_bytes, y, img_width_bytes)) return stbi__err("too large", "Corrupt PNG");
+   img_len = (img_width_bytes + 1) * y;
+
+   // we used to check for exact match between raw_len and img_len on non-interlaced PNGs,
+   // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros),
+   // so just check for raw_len < img_len always.
+   if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG");
+
+   // Allocate two scan lines worth of filter workspace buffer.
+   filter_buf = (stbi_uc *) stbi__malloc_mad2(img_width_bytes, 2, 0);
+   if (!filter_buf) return stbi__err("outofmem", "Out of memory");
+
+   // Filtering for low-bit-depth images
+   if (depth < 8) {
+      filter_bytes = 1;
+      width = img_width_bytes;
+   }
+
+   for (j=0; j < y; ++j) {
+      // cur/prior filter buffers alternate
+      stbi_uc *cur = filter_buf + (j & 1)*img_width_bytes;
+      stbi_uc *prior = filter_buf + (~j & 1)*img_width_bytes;
+      stbi_uc *dest = a->out + stride*j;
+      int nk = width * filter_bytes;
+      int filter = *raw++;
+
+      // check filter type
+      if (filter > 4) {
+         all_ok = stbi__err("invalid filter","Corrupt PNG");
+         break;
+      }
+
+      // if first row, use special filter that doesn't sample previous row
+      if (j == 0) filter = first_row_filter[filter];
+
+      // perform actual filtering
+      switch (filter) {
+      case STBI__F_none:
+         memcpy(cur, raw, nk);
+         break;
+      case STBI__F_sub:
+         memcpy(cur, raw, filter_bytes);
+         for (k = filter_bytes; k < nk; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]);
+         break;
+      case STBI__F_up:
+         for (k = 0; k < nk; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + prior[k]);
+         break;
+      case STBI__F_avg:
+         for (k = 0; k < filter_bytes; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1));
+         for (k = filter_bytes; k < nk; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1));
+         break;
+      case STBI__F_paeth:
+         for (k = 0; k < filter_bytes; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + prior[k]); // prior[k] == stbi__paeth(0,prior[k],0)
+         for (k = filter_bytes; k < nk; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes], prior[k], prior[k-filter_bytes]));
+         break;
+      case STBI__F_avg_first:
+         memcpy(cur, raw, filter_bytes);
+         for (k = filter_bytes; k < nk; ++k)
+            cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1));
+         break;
+      }
+
+      raw += nk;
+
+      // expand decoded bits in cur to dest, also adding an extra alpha channel if desired
+      if (depth < 8) {
+         stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range
+         stbi_uc *in = cur;
+         stbi_uc *out = dest;
+         stbi_uc inb = 0;
+         stbi__uint32 nsmp = x*img_n;
+
+         // expand bits to bytes first
+         if (depth == 4) {
+            for (i=0; i < nsmp; ++i) {
+               if ((i & 1) == 0) inb = *in++;
+               *out++ = scale * (inb >> 4);
+               inb <<= 4;
+            }
+         } else if (depth == 2) {
+            for (i=0; i < nsmp; ++i) {
+               if ((i & 3) == 0) inb = *in++;
+               *out++ = scale * (inb >> 6);
+               inb <<= 2;
+            }
+         } else {
+            STBI_ASSERT(depth == 1);
+            for (i=0; i < nsmp; ++i) {
+               if ((i & 7) == 0) inb = *in++;
+               *out++ = scale * (inb >> 7);
+               inb <<= 1;
+            }
+         }
+
+         // insert alpha=255 values if desired
+         if (img_n != out_n)
+            stbi__create_png_alpha_expand8(dest, dest, x, img_n);
+      } else if (depth == 8) {
+         if (img_n == out_n)
+            memcpy(dest, cur, x*img_n);
+         else
+            stbi__create_png_alpha_expand8(dest, cur, x, img_n);
+      } else if (depth == 16) {
+         // convert the image data from big-endian to platform-native
+         stbi__uint16 *dest16 = (stbi__uint16*)dest;
+         stbi__uint32 nsmp = x*img_n;
+
+         if (img_n == out_n) {
+            for (i = 0; i < nsmp; ++i, ++dest16, cur += 2)
+               *dest16 = (cur[0] << 8) | cur[1];
+         } else {
+            STBI_ASSERT(img_n+1 == out_n);
+            if (img_n == 1) {
+               for (i = 0; i < x; ++i, dest16 += 2, cur += 2) {
+                  dest16[0] = (cur[0] << 8) | cur[1];
+                  dest16[1] = 0xffff;
+               }
+            } else {
+               STBI_ASSERT(img_n == 3);
+               for (i = 0; i < x; ++i, dest16 += 4, cur += 6) {
+                  dest16[0] = (cur[0] << 8) | cur[1];
+                  dest16[1] = (cur[2] << 8) | cur[3];
+                  dest16[2] = (cur[4] << 8) | cur[5];
+                  dest16[3] = 0xffff;
+               }
+            }
+         }
+      }
+   }
+
+   STBI_FREE(filter_buf);
+   if (!all_ok) return 0;
+
+   return 1;
+}
+
+static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced)
+{
+   int bytes = (depth == 16 ? 2 : 1);
+   int out_bytes = out_n * bytes;
+   stbi_uc *final;
+   int p;
+   if (!interlaced)
+      return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color);
+
+   // de-interlacing
+   final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
+   if (!final) return stbi__err("outofmem", "Out of memory");
+   for (p=0; p < 7; ++p) {
+      int xorig[] = { 0,4,0,2,0,1,0 };
+      int yorig[] = { 0,0,4,0,2,0,1 };
+      int xspc[]  = { 8,8,4,4,2,2,1 };
+      int yspc[]  = { 8,8,8,4,4,2,2 };
+      int i,j,x,y;
+      // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1
+      x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p];
+      y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p];
+      if (x && y) {
+         stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;
+         if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) {
+            STBI_FREE(final);
+            return 0;
+         }
+         for (j=0; j < y; ++j) {
+            for (i=0; i < x; ++i) {
+               int out_y = j*yspc[p]+yorig[p];
+               int out_x = i*xspc[p]+xorig[p];
+               memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes,
+                      a->out + (j*x+i)*out_bytes, out_bytes);
+            }
+         }
+         STBI_FREE(a->out);
+         image_data += img_len;
+         image_data_len -= img_len;
+      }
+   }
+   a->out = final;
+
+   return 1;
+}
+
+static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n)
+{
+   stbi__context *s = z->s;
+   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
+   stbi_uc *p = z->out;
+
+   // compute color-based transparency, assuming we've
+   // already got 255 as the alpha value in the output
+   STBI_ASSERT(out_n == 2 || out_n == 4);
+
+   if (out_n == 2) {
+      for (i=0; i < pixel_count; ++i) {
+         p[1] = (p[0] == tc[0] ? 0 : 255);
+         p += 2;
+      }
+   } else {
+      for (i=0; i < pixel_count; ++i) {
+         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
+            p[3] = 0;
+         p += 4;
+      }
+   }
+   return 1;
+}
+
+static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n)
+{
+   stbi__context *s = z->s;
+   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
+   stbi__uint16 *p = (stbi__uint16*) z->out;
+
+   // compute color-based transparency, assuming we've
+   // already got 65535 as the alpha value in the output
+   STBI_ASSERT(out_n == 2 || out_n == 4);
+
+   if (out_n == 2) {
+      for (i = 0; i < pixel_count; ++i) {
+         p[1] = (p[0] == tc[0] ? 0 : 65535);
+         p += 2;
+      }
+   } else {
+      for (i = 0; i < pixel_count; ++i) {
+         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
+            p[3] = 0;
+         p += 4;
+      }
+   }
+   return 1;
+}
+
+static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n)
+{
+   stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y;
+   stbi_uc *p, *temp_out, *orig = a->out;
+
+   p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0);
+   if (p == NULL) return stbi__err("outofmem", "Out of memory");
+
+   // between here and free(out) below, exitting would leak
+   temp_out = p;
+
+   if (pal_img_n == 3) {
+      for (i=0; i < pixel_count; ++i) {
+         int n = orig[i]*4;
+         p[0] = palette[n  ];
+         p[1] = palette[n+1];
+         p[2] = palette[n+2];
+         p += 3;
+      }
+   } else {
+      for (i=0; i < pixel_count; ++i) {
+         int n = orig[i]*4;
+         p[0] = palette[n  ];
+         p[1] = palette[n+1];
+         p[2] = palette[n+2];
+         p[3] = palette[n+3];
+         p += 4;
+      }
+   }
+   STBI_FREE(a->out);
+   a->out = temp_out;
+
+   STBI_NOTUSED(len);
+
+   return 1;
+}
+
+static int stbi__unpremultiply_on_load_global = 0;
+static int stbi__de_iphone_flag_global = 0;
+
+STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)
+{
+   stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply;
+}
+
+STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
+{
+   stbi__de_iphone_flag_global = flag_true_if_should_convert;
+}
+
+#ifndef STBI_THREAD_LOCAL
+#define stbi__unpremultiply_on_load  stbi__unpremultiply_on_load_global
+#define stbi__de_iphone_flag  stbi__de_iphone_flag_global
+#else
+static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set;
+static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set;
+
+STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply)
+{
+   stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply;
+   stbi__unpremultiply_on_load_set = 1;
+}
+
+STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert)
+{
+   stbi__de_iphone_flag_local = flag_true_if_should_convert;
+   stbi__de_iphone_flag_set = 1;
+}
+
+#define stbi__unpremultiply_on_load  (stbi__unpremultiply_on_load_set           \
+                                       ? stbi__unpremultiply_on_load_local      \
+                                       : stbi__unpremultiply_on_load_global)
+#define stbi__de_iphone_flag  (stbi__de_iphone_flag_set                         \
+                                ? stbi__de_iphone_flag_local                    \
+                                : stbi__de_iphone_flag_global)
+#endif // STBI_THREAD_LOCAL
+
+static void stbi__de_iphone(stbi__png *z)
+{
+   stbi__context *s = z->s;
+   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
+   stbi_uc *p = z->out;
+
+   if (s->img_out_n == 3) {  // convert bgr to rgb
+      for (i=0; i < pixel_count; ++i) {
+         stbi_uc t = p[0];
+         p[0] = p[2];
+         p[2] = t;
+         p += 3;
+      }
+   } else {
+      STBI_ASSERT(s->img_out_n == 4);
+      if (stbi__unpremultiply_on_load) {
+         // convert bgr to rgb and unpremultiply
+         for (i=0; i < pixel_count; ++i) {
+            stbi_uc a = p[3];
+            stbi_uc t = p[0];
+            if (a) {
+               stbi_uc half = a / 2;
+               p[0] = (p[2] * 255 + half) / a;
+               p[1] = (p[1] * 255 + half) / a;
+               p[2] = ( t   * 255 + half) / a;
+            } else {
+               p[0] = p[2];
+               p[2] = t;
+            }
+            p += 4;
+         }
+      } else {
+         // convert bgr to rgb
+         for (i=0; i < pixel_count; ++i) {
+            stbi_uc t = p[0];
+            p[0] = p[2];
+            p[2] = t;
+            p += 4;
+         }
+      }
+   }
+}
+
+#define STBI__PNG_TYPE(a,b,c,d)  (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d))
+
+static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
+{
+   stbi_uc palette[1024], pal_img_n=0;
+   stbi_uc has_trans=0, tc[3]={0};
+   stbi__uint16 tc16[3];
+   stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
+   int first=1,k,interlace=0, color=0, is_iphone=0;
+   stbi__context *s = z->s;
+
+   z->expanded = NULL;
+   z->idata = NULL;
+   z->out = NULL;
+
+   if (!stbi__check_png_header(s)) return 0;
+
+   if (scan == STBI__SCAN_type) return 1;
+
+   for (;;) {
+      stbi__pngchunk c = stbi__get_chunk_header(s);
+      switch (c.type) {
+         case STBI__PNG_TYPE('C','g','B','I'):
+            is_iphone = 1;
+            stbi__skip(s, c.length);
+            break;
+         case STBI__PNG_TYPE('I','H','D','R'): {
+            int comp,filter;
+            if (!first) return stbi__err("multiple IHDR","Corrupt PNG");
+            first = 0;
+            if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG");
+            s->img_x = stbi__get32be(s);
+            s->img_y = stbi__get32be(s);
+            if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+            if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+            z->depth = stbi__get8(s);  if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16)  return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only");
+            color = stbi__get8(s);  if (color > 6)         return stbi__err("bad ctype","Corrupt PNG");
+            if (color == 3 && z->depth == 16)                  return stbi__err("bad ctype","Corrupt PNG");
+            if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG");
+            comp  = stbi__get8(s);  if (comp) return stbi__err("bad comp method","Corrupt PNG");
+            filter= stbi__get8(s);  if (filter) return stbi__err("bad filter method","Corrupt PNG");
+            interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG");
+            if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG");
+            if (!pal_img_n) {
+               s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);
+               if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");
+            } else {
+               // if paletted, then pal_n is our final components, and
+               // img_n is # components to decompress/filter.
+               s->img_n = 1;
+               if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG");
+            }
+            // even with SCAN_header, have to scan to see if we have a tRNS
+            break;
+         }
+
+         case STBI__PNG_TYPE('P','L','T','E'):  {
+            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
+            if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG");
+            pal_len = c.length / 3;
+            if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG");
+            for (i=0; i < pal_len; ++i) {
+               palette[i*4+0] = stbi__get8(s);
+               palette[i*4+1] = stbi__get8(s);
+               palette[i*4+2] = stbi__get8(s);
+               palette[i*4+3] = 255;
+            }
+            break;
+         }
+
+         case STBI__PNG_TYPE('t','R','N','S'): {
+            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
+            if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG");
+            if (pal_img_n) {
+               if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; }
+               if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG");
+               if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG");
+               pal_img_n = 4;
+               for (i=0; i < c.length; ++i)
+                  palette[i*4+3] = stbi__get8(s);
+            } else {
+               if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG");
+               if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG");
+               has_trans = 1;
+               // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now.
+               if (scan == STBI__SCAN_header) { ++s->img_n; return 1; }
+               if (z->depth == 16) {
+                  for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning
+                     tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
+               } else {
+                  for (k = 0; k < s->img_n && k < 3; ++k)
+                     tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
+               }
+            }
+            break;
+         }
+
+         case STBI__PNG_TYPE('I','D','A','T'): {
+            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
+            if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG");
+            if (scan == STBI__SCAN_header) {
+               // header scan definitely stops at first IDAT
+               if (pal_img_n)
+                  s->img_n = pal_img_n;
+               return 1;
+            }
+            if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes");
+            if ((int)(ioff + c.length) < (int)ioff) return 0;
+            if (ioff + c.length > idata_limit) {
+               stbi__uint32 idata_limit_old = idata_limit;
+               stbi_uc *p;
+               if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096;
+               while (ioff + c.length > idata_limit)
+                  idata_limit *= 2;
+               STBI_NOTUSED(idata_limit_old);
+               p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory");
+               z->idata = p;
+            }
+            if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG");
+            ioff += c.length;
+            break;
+         }
+
+         case STBI__PNG_TYPE('I','E','N','D'): {
+            stbi__uint32 raw_len, bpl;
+            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
+            if (scan != STBI__SCAN_load) return 1;
+            if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG");
+            // initial guess for decoded data size to avoid unnecessary reallocs
+            bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component
+            raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */;
+            z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone);
+            if (z->expanded == NULL) return 0; // zlib should set error
+            STBI_FREE(z->idata); z->idata = NULL;
+            if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)
+               s->img_out_n = s->img_n+1;
+            else
+               s->img_out_n = s->img_n;
+            if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0;
+            if (has_trans) {
+               if (z->depth == 16) {
+                  if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0;
+               } else {
+                  if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0;
+               }
+            }
+            if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2)
+               stbi__de_iphone(z);
+            if (pal_img_n) {
+               // pal_img_n == 3 or 4
+               s->img_n = pal_img_n; // record the actual colors we had
+               s->img_out_n = pal_img_n;
+               if (req_comp >= 3) s->img_out_n = req_comp;
+               if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n))
+                  return 0;
+            } else if (has_trans) {
+               // non-paletted image with tRNS -> source image has (constant) alpha
+               ++s->img_n;
+            }
+            STBI_FREE(z->expanded); z->expanded = NULL;
+            // end of PNG chunk, read and skip CRC
+            stbi__get32be(s);
+            return 1;
+         }
+
+         default:
+            // if critical, fail
+            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
+            if ((c.type & (1 << 29)) == 0) {
+               #ifndef STBI_NO_FAILURE_STRINGS
+               // not threadsafe
+               static char invalid_chunk[] = "XXXX PNG chunk not known";
+               invalid_chunk[0] = STBI__BYTECAST(c.type >> 24);
+               invalid_chunk[1] = STBI__BYTECAST(c.type >> 16);
+               invalid_chunk[2] = STBI__BYTECAST(c.type >>  8);
+               invalid_chunk[3] = STBI__BYTECAST(c.type >>  0);
+               #endif
+               return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type");
+            }
+            stbi__skip(s, c.length);
+            break;
+      }
+      // end of PNG chunk, read and skip CRC
+      stbi__get32be(s);
+   }
+}
+
+static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri)
+{
+   void *result=NULL;
+   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
+   if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {
+      if (p->depth <= 8)
+         ri->bits_per_channel = 8;
+      else if (p->depth == 16)
+         ri->bits_per_channel = 16;
+      else
+         return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth");
+      result = p->out;
+      p->out = NULL;
+      if (req_comp && req_comp != p->s->img_out_n) {
+         if (ri->bits_per_channel == 8)
+            result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
+         else
+            result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
+         p->s->img_out_n = req_comp;
+         if (result == NULL) return result;
+      }
+      *x = p->s->img_x;
+      *y = p->s->img_y;
+      if (n) *n = p->s->img_n;
+   }
+   STBI_FREE(p->out);      p->out      = NULL;
+   STBI_FREE(p->expanded); p->expanded = NULL;
+   STBI_FREE(p->idata);    p->idata    = NULL;
+
+   return result;
+}
+
+static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   stbi__png p;
+   p.s = s;
+   return stbi__do_png(&p, x,y,comp,req_comp, ri);
+}
+
+static int stbi__png_test(stbi__context *s)
+{
+   int r;
+   r = stbi__check_png_header(s);
+   stbi__rewind(s);
+   return r;
+}
+
+static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp)
+{
+   if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) {
+      stbi__rewind( p->s );
+      return 0;
+   }
+   if (x) *x = p->s->img_x;
+   if (y) *y = p->s->img_y;
+   if (comp) *comp = p->s->img_n;
+   return 1;
+}
+
+static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   stbi__png p;
+   p.s = s;
+   return stbi__png_info_raw(&p, x, y, comp);
+}
+
+static int stbi__png_is16(stbi__context *s)
+{
+   stbi__png p;
+   p.s = s;
+   if (!stbi__png_info_raw(&p, NULL, NULL, NULL))
+	   return 0;
+   if (p.depth != 16) {
+      stbi__rewind(p.s);
+      return 0;
+   }
+   return 1;
+}
+#endif
+
+// Microsoft/Windows BMP image
+
+#ifndef STBI_NO_BMP
+static int stbi__bmp_test_raw(stbi__context *s)
+{
+   int r;
+   int sz;
+   if (stbi__get8(s) != 'B') return 0;
+   if (stbi__get8(s) != 'M') return 0;
+   stbi__get32le(s); // discard filesize
+   stbi__get16le(s); // discard reserved
+   stbi__get16le(s); // discard reserved
+   stbi__get32le(s); // discard data offset
+   sz = stbi__get32le(s);
+   r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124);
+   return r;
+}
+
+static int stbi__bmp_test(stbi__context *s)
+{
+   int r = stbi__bmp_test_raw(s);
+   stbi__rewind(s);
+   return r;
+}
+
+
+// returns 0..31 for the highest set bit
+static int stbi__high_bit(unsigned int z)
+{
+   int n=0;
+   if (z == 0) return -1;
+   if (z >= 0x10000) { n += 16; z >>= 16; }
+   if (z >= 0x00100) { n +=  8; z >>=  8; }
+   if (z >= 0x00010) { n +=  4; z >>=  4; }
+   if (z >= 0x00004) { n +=  2; z >>=  2; }
+   if (z >= 0x00002) { n +=  1;/* >>=  1;*/ }
+   return n;
+}
+
+static int stbi__bitcount(unsigned int a)
+{
+   a = (a & 0x55555555) + ((a >>  1) & 0x55555555); // max 2
+   a = (a & 0x33333333) + ((a >>  2) & 0x33333333); // max 4
+   a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits
+   a = (a + (a >> 8)); // max 16 per 8 bits
+   a = (a + (a >> 16)); // max 32 per 8 bits
+   return a & 0xff;
+}
+
+// extract an arbitrarily-aligned N-bit value (N=bits)
+// from v, and then make it 8-bits long and fractionally
+// extend it to full full range.
+static int stbi__shiftsigned(unsigned int v, int shift, int bits)
+{
+   static unsigned int mul_table[9] = {
+      0,
+      0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/,
+      0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/,
+   };
+   static unsigned int shift_table[9] = {
+      0, 0,0,1,0,2,4,6,0,
+   };
+   if (shift < 0)
+      v <<= -shift;
+   else
+      v >>= shift;
+   STBI_ASSERT(v < 256);
+   v >>= (8-bits);
+   STBI_ASSERT(bits >= 0 && bits <= 8);
+   return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits];
+}
+
+typedef struct
+{
+   int bpp, offset, hsz;
+   unsigned int mr,mg,mb,ma, all_a;
+   int extra_read;
+} stbi__bmp_data;
+
+static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress)
+{
+   // BI_BITFIELDS specifies masks explicitly, don't override
+   if (compress == 3)
+      return 1;
+
+   if (compress == 0) {
+      if (info->bpp == 16) {
+         info->mr = 31u << 10;
+         info->mg = 31u <<  5;
+         info->mb = 31u <<  0;
+      } else if (info->bpp == 32) {
+         info->mr = 0xffu << 16;
+         info->mg = 0xffu <<  8;
+         info->mb = 0xffu <<  0;
+         info->ma = 0xffu << 24;
+         info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
+      } else {
+         // otherwise, use defaults, which is all-0
+         info->mr = info->mg = info->mb = info->ma = 0;
+      }
+      return 1;
+   }
+   return 0; // error
+}
+
+static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
+{
+   int hsz;
+   if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP");
+   stbi__get32le(s); // discard filesize
+   stbi__get16le(s); // discard reserved
+   stbi__get16le(s); // discard reserved
+   info->offset = stbi__get32le(s);
+   info->hsz = hsz = stbi__get32le(s);
+   info->mr = info->mg = info->mb = info->ma = 0;
+   info->extra_read = 14;
+
+   if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP");
+
+   if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown");
+   if (hsz == 12) {
+      s->img_x = stbi__get16le(s);
+      s->img_y = stbi__get16le(s);
+   } else {
+      s->img_x = stbi__get32le(s);
+      s->img_y = stbi__get32le(s);
+   }
+   if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP");
+   info->bpp = stbi__get16le(s);
+   if (hsz != 12) {
+      int compress = stbi__get32le(s);
+      if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
+      if (compress >= 4) return stbi__errpuc("BMP JPEG/PNG", "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes
+      if (compress == 3 && info->bpp != 16 && info->bpp != 32) return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel
+      stbi__get32le(s); // discard sizeof
+      stbi__get32le(s); // discard hres
+      stbi__get32le(s); // discard vres
+      stbi__get32le(s); // discard colorsused
+      stbi__get32le(s); // discard max important
+      if (hsz == 40 || hsz == 56) {
+         if (hsz == 56) {
+            stbi__get32le(s);
+            stbi__get32le(s);
+            stbi__get32le(s);
+            stbi__get32le(s);
+         }
+         if (info->bpp == 16 || info->bpp == 32) {
+            if (compress == 0) {
+               stbi__bmp_set_mask_defaults(info, compress);
+            } else if (compress == 3) {
+               info->mr = stbi__get32le(s);
+               info->mg = stbi__get32le(s);
+               info->mb = stbi__get32le(s);
+               info->extra_read += 12;
+               // not documented, but generated by photoshop and handled by mspaint
+               if (info->mr == info->mg && info->mg == info->mb) {
+                  // ?!?!?
+                  return stbi__errpuc("bad BMP", "bad BMP");
+               }
+            } else
+               return stbi__errpuc("bad BMP", "bad BMP");
+         }
+      } else {
+         // V4/V5 header
+         int i;
+         if (hsz != 108 && hsz != 124)
+            return stbi__errpuc("bad BMP", "bad BMP");
+         info->mr = stbi__get32le(s);
+         info->mg = stbi__get32le(s);
+         info->mb = stbi__get32le(s);
+         info->ma = stbi__get32le(s);
+         if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs
+            stbi__bmp_set_mask_defaults(info, compress);
+         stbi__get32le(s); // discard color space
+         for (i=0; i < 12; ++i)
+            stbi__get32le(s); // discard color space parameters
+         if (hsz == 124) {
+            stbi__get32le(s); // discard rendering intent
+            stbi__get32le(s); // discard offset of profile data
+            stbi__get32le(s); // discard size of profile data
+            stbi__get32le(s); // discard reserved
+         }
+      }
+   }
+   return (void *) 1;
+}
+
+
+static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   stbi_uc *out;
+   unsigned int mr=0,mg=0,mb=0,ma=0, all_a;
+   stbi_uc pal[256][4];
+   int psize=0,i,j,width;
+   int flip_vertically, pad, target;
+   stbi__bmp_data info;
+   STBI_NOTUSED(ri);
+
+   info.all_a = 255;
+   if (stbi__bmp_parse_header(s, &info) == NULL)
+      return NULL; // error code already set
+
+   flip_vertically = ((int) s->img_y) > 0;
+   s->img_y = abs((int) s->img_y);
+
+   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+
+   mr = info.mr;
+   mg = info.mg;
+   mb = info.mb;
+   ma = info.ma;
+   all_a = info.all_a;
+
+   if (info.hsz == 12) {
+      if (info.bpp < 24)
+         psize = (info.offset - info.extra_read - 24) / 3;
+   } else {
+      if (info.bpp < 16)
+         psize = (info.offset - info.extra_read - info.hsz) >> 2;
+   }
+   if (psize == 0) {
+      // accept some number of extra bytes after the header, but if the offset points either to before
+      // the header ends or implies a large amount of extra data, reject the file as malformed
+      int bytes_read_so_far = s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original);
+      int header_limit = 1024; // max we actually read is below 256 bytes currently.
+      int extra_data_limit = 256*4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size.
+      if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) {
+         return stbi__errpuc("bad header", "Corrupt BMP");
+      }
+      // we established that bytes_read_so_far is positive and sensible.
+      // the first half of this test rejects offsets that are either too small positives, or
+      // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn
+      // ensures the number computed in the second half of the test can't overflow.
+      if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) {
+         return stbi__errpuc("bad offset", "Corrupt BMP");
+      } else {
+         stbi__skip(s, info.offset - bytes_read_so_far);
+      }
+   }
+
+   if (info.bpp == 24 && ma == 0xff000000)
+      s->img_n = 3;
+   else
+      s->img_n = ma ? 4 : 3;
+   if (req_comp && req_comp >= 3) // we can directly decode 3 or 4
+      target = req_comp;
+   else
+      target = s->img_n; // if they want monochrome, we'll post-convert
+
+   // sanity-check size
+   if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0))
+      return stbi__errpuc("too large", "Corrupt BMP");
+
+   out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0);
+   if (!out) return stbi__errpuc("outofmem", "Out of memory");
+   if (info.bpp < 16) {
+      int z=0;
+      if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); }
+      for (i=0; i < psize; ++i) {
+         pal[i][2] = stbi__get8(s);
+         pal[i][1] = stbi__get8(s);
+         pal[i][0] = stbi__get8(s);
+         if (info.hsz != 12) stbi__get8(s);
+         pal[i][3] = 255;
+      }
+      stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4));
+      if (info.bpp == 1) width = (s->img_x + 7) >> 3;
+      else if (info.bpp == 4) width = (s->img_x + 1) >> 1;
+      else if (info.bpp == 8) width = s->img_x;
+      else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); }
+      pad = (-width)&3;
+      if (info.bpp == 1) {
+         for (j=0; j < (int) s->img_y; ++j) {
+            int bit_offset = 7, v = stbi__get8(s);
+            for (i=0; i < (int) s->img_x; ++i) {
+               int color = (v>>bit_offset)&0x1;
+               out[z++] = pal[color][0];
+               out[z++] = pal[color][1];
+               out[z++] = pal[color][2];
+               if (target == 4) out[z++] = 255;
+               if (i+1 == (int) s->img_x) break;
+               if((--bit_offset) < 0) {
+                  bit_offset = 7;
+                  v = stbi__get8(s);
+               }
+            }
+            stbi__skip(s, pad);
+         }
+      } else {
+         for (j=0; j < (int) s->img_y; ++j) {
+            for (i=0; i < (int) s->img_x; i += 2) {
+               int v=stbi__get8(s),v2=0;
+               if (info.bpp == 4) {
+                  v2 = v & 15;
+                  v >>= 4;
+               }
+               out[z++] = pal[v][0];
+               out[z++] = pal[v][1];
+               out[z++] = pal[v][2];
+               if (target == 4) out[z++] = 255;
+               if (i+1 == (int) s->img_x) break;
+               v = (info.bpp == 8) ? stbi__get8(s) : v2;
+               out[z++] = pal[v][0];
+               out[z++] = pal[v][1];
+               out[z++] = pal[v][2];
+               if (target == 4) out[z++] = 255;
+            }
+            stbi__skip(s, pad);
+         }
+      }
+   } else {
+      int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0;
+      int z = 0;
+      int easy=0;
+      stbi__skip(s, info.offset - info.extra_read - info.hsz);
+      if (info.bpp == 24) width = 3 * s->img_x;
+      else if (info.bpp == 16) width = 2*s->img_x;
+      else /* bpp = 32 and pad = 0 */ width=0;
+      pad = (-width) & 3;
+      if (info.bpp == 24) {
+         easy = 1;
+      } else if (info.bpp == 32) {
+         if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000)
+            easy = 2;
+      }
+      if (!easy) {
+         if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
+         // right shift amt to put high bit in position #7
+         rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr);
+         gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg);
+         bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb);
+         ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma);
+         if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
+      }
+      for (j=0; j < (int) s->img_y; ++j) {
+         if (easy) {
+            for (i=0; i < (int) s->img_x; ++i) {
+               unsigned char a;
+               out[z+2] = stbi__get8(s);
+               out[z+1] = stbi__get8(s);
+               out[z+0] = stbi__get8(s);
+               z += 3;
+               a = (easy == 2 ? stbi__get8(s) : 255);
+               all_a |= a;
+               if (target == 4) out[z++] = a;
+            }
+         } else {
+            int bpp = info.bpp;
+            for (i=0; i < (int) s->img_x; ++i) {
+               stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s));
+               unsigned int a;
+               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount));
+               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount));
+               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount));
+               a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255);
+               all_a |= a;
+               if (target == 4) out[z++] = STBI__BYTECAST(a);
+            }
+         }
+         stbi__skip(s, pad);
+      }
+   }
+
+   // if alpha channel is all 0s, replace with all 255s
+   if (target == 4 && all_a == 0)
+      for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4)
+         out[i] = 255;
+
+   if (flip_vertically) {
+      stbi_uc t;
+      for (j=0; j < (int) s->img_y>>1; ++j) {
+         stbi_uc *p1 = out +      j     *s->img_x*target;
+         stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target;
+         for (i=0; i < (int) s->img_x*target; ++i) {
+            t = p1[i]; p1[i] = p2[i]; p2[i] = t;
+         }
+      }
+   }
+
+   if (req_comp && req_comp != target) {
+      out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y);
+      if (out == NULL) return out; // stbi__convert_format frees input on failure
+   }
+
+   *x = s->img_x;
+   *y = s->img_y;
+   if (comp) *comp = s->img_n;
+   return out;
+}
+#endif
+
+// Targa Truevision - TGA
+// by Jonathan Dummer
+#ifndef STBI_NO_TGA
+// returns STBI_rgb or whatever, 0 on error
+static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16)
+{
+   // only RGB or RGBA (incl. 16bit) or grey allowed
+   if (is_rgb16) *is_rgb16 = 0;
+   switch(bits_per_pixel) {
+      case 8:  return STBI_grey;
+      case 16: if(is_grey) return STBI_grey_alpha;
+               // fallthrough
+      case 15: if(is_rgb16) *is_rgb16 = 1;
+               return STBI_rgb;
+      case 24: // fallthrough
+      case 32: return bits_per_pixel/8;
+      default: return 0;
+   }
+}
+
+static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp)
+{
+    int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp;
+    int sz, tga_colormap_type;
+    stbi__get8(s);                   // discard Offset
+    tga_colormap_type = stbi__get8(s); // colormap type
+    if( tga_colormap_type > 1 ) {
+        stbi__rewind(s);
+        return 0;      // only RGB or indexed allowed
+    }
+    tga_image_type = stbi__get8(s); // image type
+    if ( tga_colormap_type == 1 ) { // colormapped (paletted) image
+        if (tga_image_type != 1 && tga_image_type != 9) {
+            stbi__rewind(s);
+            return 0;
+        }
+        stbi__skip(s,4);       // skip index of first colormap entry and number of entries
+        sz = stbi__get8(s);    //   check bits per palette color entry
+        if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) {
+            stbi__rewind(s);
+            return 0;
+        }
+        stbi__skip(s,4);       // skip image x and y origin
+        tga_colormap_bpp = sz;
+    } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE
+        if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) {
+            stbi__rewind(s);
+            return 0; // only RGB or grey allowed, +/- RLE
+        }
+        stbi__skip(s,9); // skip colormap specification and image x/y origin
+        tga_colormap_bpp = 0;
+    }
+    tga_w = stbi__get16le(s);
+    if( tga_w < 1 ) {
+        stbi__rewind(s);
+        return 0;   // test width
+    }
+    tga_h = stbi__get16le(s);
+    if( tga_h < 1 ) {
+        stbi__rewind(s);
+        return 0;   // test height
+    }
+    tga_bits_per_pixel = stbi__get8(s); // bits per pixel
+    stbi__get8(s); // ignore alpha bits
+    if (tga_colormap_bpp != 0) {
+        if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) {
+            // when using a colormap, tga_bits_per_pixel is the size of the indexes
+            // I don't think anything but 8 or 16bit indexes makes sense
+            stbi__rewind(s);
+            return 0;
+        }
+        tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL);
+    } else {
+        tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL);
+    }
+    if(!tga_comp) {
+      stbi__rewind(s);
+      return 0;
+    }
+    if (x) *x = tga_w;
+    if (y) *y = tga_h;
+    if (comp) *comp = tga_comp;
+    return 1;                   // seems to have passed everything
+}
+
+static int stbi__tga_test(stbi__context *s)
+{
+   int res = 0;
+   int sz, tga_color_type;
+   stbi__get8(s);      //   discard Offset
+   tga_color_type = stbi__get8(s);   //   color type
+   if ( tga_color_type > 1 ) goto errorEnd;   //   only RGB or indexed allowed
+   sz = stbi__get8(s);   //   image type
+   if ( tga_color_type == 1 ) { // colormapped (paletted) image
+      if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9
+      stbi__skip(s,4);       // skip index of first colormap entry and number of entries
+      sz = stbi__get8(s);    //   check bits per palette color entry
+      if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
+      stbi__skip(s,4);       // skip image x and y origin
+   } else { // "normal" image w/o colormap
+      if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE
+      stbi__skip(s,9); // skip colormap specification and image x/y origin
+   }
+   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test width
+   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test height
+   sz = stbi__get8(s);   //   bits per pixel
+   if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index
+   if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
+
+   res = 1; // if we got this far, everything's good and we can return 1 instead of 0
+
+errorEnd:
+   stbi__rewind(s);
+   return res;
+}
+
+// read 16bit value and convert to 24bit RGB
+static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out)
+{
+   stbi__uint16 px = (stbi__uint16)stbi__get16le(s);
+   stbi__uint16 fiveBitMask = 31;
+   // we have 3 channels with 5bits each
+   int r = (px >> 10) & fiveBitMask;
+   int g = (px >> 5) & fiveBitMask;
+   int b = px & fiveBitMask;
+   // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later
+   out[0] = (stbi_uc)((r * 255)/31);
+   out[1] = (stbi_uc)((g * 255)/31);
+   out[2] = (stbi_uc)((b * 255)/31);
+
+   // some people claim that the most significant bit might be used for alpha
+   // (possibly if an alpha-bit is set in the "image descriptor byte")
+   // but that only made 16bit test images completely translucent..
+   // so let's treat all 15 and 16bit TGAs as RGB with no alpha.
+}
+
+static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   //   read in the TGA header stuff
+   int tga_offset = stbi__get8(s);
+   int tga_indexed = stbi__get8(s);
+   int tga_image_type = stbi__get8(s);
+   int tga_is_RLE = 0;
+   int tga_palette_start = stbi__get16le(s);
+   int tga_palette_len = stbi__get16le(s);
+   int tga_palette_bits = stbi__get8(s);
+   int tga_x_origin = stbi__get16le(s);
+   int tga_y_origin = stbi__get16le(s);
+   int tga_width = stbi__get16le(s);
+   int tga_height = stbi__get16le(s);
+   int tga_bits_per_pixel = stbi__get8(s);
+   int tga_comp, tga_rgb16=0;
+   int tga_inverted = stbi__get8(s);
+   // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?)
+   //   image data
+   unsigned char *tga_data;
+   unsigned char *tga_palette = NULL;
+   int i, j;
+   unsigned char raw_data[4] = {0};
+   int RLE_count = 0;
+   int RLE_repeating = 0;
+   int read_next_pixel = 1;
+   STBI_NOTUSED(ri);
+   STBI_NOTUSED(tga_x_origin); // @TODO
+   STBI_NOTUSED(tga_y_origin); // @TODO
+
+   if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+   if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+
+   //   do a tiny bit of precessing
+   if ( tga_image_type >= 8 )
+   {
+      tga_image_type -= 8;
+      tga_is_RLE = 1;
+   }
+   tga_inverted = 1 - ((tga_inverted >> 5) & 1);
+
+   //   If I'm paletted, then I'll use the number of bits from the palette
+   if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16);
+   else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16);
+
+   if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency
+      return stbi__errpuc("bad format", "Can't find out TGA pixelformat");
+
+   //   tga info
+   *x = tga_width;
+   *y = tga_height;
+   if (comp) *comp = tga_comp;
+
+   if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0))
+      return stbi__errpuc("too large", "Corrupt TGA");
+
+   tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0);
+   if (!tga_data) return stbi__errpuc("outofmem", "Out of memory");
+
+   // skip to the data's starting position (offset usually = 0)
+   stbi__skip(s, tga_offset );
+
+   if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) {
+      for (i=0; i < tga_height; ++i) {
+         int row = tga_inverted ? tga_height -i - 1 : i;
+         stbi_uc *tga_row = tga_data + row*tga_width*tga_comp;
+         stbi__getn(s, tga_row, tga_width * tga_comp);
+      }
+   } else  {
+      //   do I need to load a palette?
+      if ( tga_indexed)
+      {
+         if (tga_palette_len == 0) {  /* you have to have at least one entry! */
+            STBI_FREE(tga_data);
+            return stbi__errpuc("bad palette", "Corrupt TGA");
+         }
+
+         //   any data to skip? (offset usually = 0)
+         stbi__skip(s, tga_palette_start );
+         //   load the palette
+         tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0);
+         if (!tga_palette) {
+            STBI_FREE(tga_data);
+            return stbi__errpuc("outofmem", "Out of memory");
+         }
+         if (tga_rgb16) {
+            stbi_uc *pal_entry = tga_palette;
+            STBI_ASSERT(tga_comp == STBI_rgb);
+            for (i=0; i < tga_palette_len; ++i) {
+               stbi__tga_read_rgb16(s, pal_entry);
+               pal_entry += tga_comp;
+            }
+         } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) {
+               STBI_FREE(tga_data);
+               STBI_FREE(tga_palette);
+               return stbi__errpuc("bad palette", "Corrupt TGA");
+         }
+      }
+      //   load the data
+      for (i=0; i < tga_width * tga_height; ++i)
+      {
+         //   if I'm in RLE mode, do I need to get a RLE stbi__pngchunk?
+         if ( tga_is_RLE )
+         {
+            if ( RLE_count == 0 )
+            {
+               //   yep, get the next byte as a RLE command
+               int RLE_cmd = stbi__get8(s);
+               RLE_count = 1 + (RLE_cmd & 127);
+               RLE_repeating = RLE_cmd >> 7;
+               read_next_pixel = 1;
+            } else if ( !RLE_repeating )
+            {
+               read_next_pixel = 1;
+            }
+         } else
+         {
+            read_next_pixel = 1;
+         }
+         //   OK, if I need to read a pixel, do it now
+         if ( read_next_pixel )
+         {
+            //   load however much data we did have
+            if ( tga_indexed )
+            {
+               // read in index, then perform the lookup
+               int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s);
+               if ( pal_idx >= tga_palette_len ) {
+                  // invalid index
+                  pal_idx = 0;
+               }
+               pal_idx *= tga_comp;
+               for (j = 0; j < tga_comp; ++j) {
+                  raw_data[j] = tga_palette[pal_idx+j];
+               }
+            } else if(tga_rgb16) {
+               STBI_ASSERT(tga_comp == STBI_rgb);
+               stbi__tga_read_rgb16(s, raw_data);
+            } else {
+               //   read in the data raw
+               for (j = 0; j < tga_comp; ++j) {
+                  raw_data[j] = stbi__get8(s);
+               }
+            }
+            //   clear the reading flag for the next pixel
+            read_next_pixel = 0;
+         } // end of reading a pixel
+
+         // copy data
+         for (j = 0; j < tga_comp; ++j)
+           tga_data[i*tga_comp+j] = raw_data[j];
+
+         //   in case we're in RLE mode, keep counting down
+         --RLE_count;
+      }
+      //   do I need to invert the image?
+      if ( tga_inverted )
+      {
+         for (j = 0; j*2 < tga_height; ++j)
+         {
+            int index1 = j * tga_width * tga_comp;
+            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
+            for (i = tga_width * tga_comp; i > 0; --i)
+            {
+               unsigned char temp = tga_data[index1];
+               tga_data[index1] = tga_data[index2];
+               tga_data[index2] = temp;
+               ++index1;
+               ++index2;
+            }
+         }
+      }
+      //   clear my palette, if I had one
+      if ( tga_palette != NULL )
+      {
+         STBI_FREE( tga_palette );
+      }
+   }
+
+   // swap RGB - if the source data was RGB16, it already is in the right order
+   if (tga_comp >= 3 && !tga_rgb16)
+   {
+      unsigned char* tga_pixel = tga_data;
+      for (i=0; i < tga_width * tga_height; ++i)
+      {
+         unsigned char temp = tga_pixel[0];
+         tga_pixel[0] = tga_pixel[2];
+         tga_pixel[2] = temp;
+         tga_pixel += tga_comp;
+      }
+   }
+
+   // convert to target component count
+   if (req_comp && req_comp != tga_comp)
+      tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height);
+
+   //   the things I do to get rid of an error message, and yet keep
+   //   Microsoft's C compilers happy... [8^(
+   tga_palette_start = tga_palette_len = tga_palette_bits =
+         tga_x_origin = tga_y_origin = 0;
+   STBI_NOTUSED(tga_palette_start);
+   //   OK, done
+   return tga_data;
+}
+#endif
+
+// *************************************************************************************************
+// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB
+
+#ifndef STBI_NO_PSD
+static int stbi__psd_test(stbi__context *s)
+{
+   int r = (stbi__get32be(s) == 0x38425053);
+   stbi__rewind(s);
+   return r;
+}
+
+static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount)
+{
+   int count, nleft, len;
+
+   count = 0;
+   while ((nleft = pixelCount - count) > 0) {
+      len = stbi__get8(s);
+      if (len == 128) {
+         // No-op.
+      } else if (len < 128) {
+         // Copy next len+1 bytes literally.
+         len++;
+         if (len > nleft) return 0; // corrupt data
+         count += len;
+         while (len) {
+            *p = stbi__get8(s);
+            p += 4;
+            len--;
+         }
+      } else if (len > 128) {
+         stbi_uc   val;
+         // Next -len+1 bytes in the dest are replicated from next source byte.
+         // (Interpret len as a negative 8-bit int.)
+         len = 257 - len;
+         if (len > nleft) return 0; // corrupt data
+         val = stbi__get8(s);
+         count += len;
+         while (len) {
+            *p = val;
+            p += 4;
+            len--;
+         }
+      }
+   }
+
+   return 1;
+}
+
+static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
+{
+   int pixelCount;
+   int channelCount, compression;
+   int channel, i;
+   int bitdepth;
+   int w,h;
+   stbi_uc *out;
+   STBI_NOTUSED(ri);
+
+   // Check identifier
+   if (stbi__get32be(s) != 0x38425053)   // "8BPS"
+      return stbi__errpuc("not PSD", "Corrupt PSD image");
+
+   // Check file type version.
+   if (stbi__get16be(s) != 1)
+      return stbi__errpuc("wrong version", "Unsupported version of PSD image");
+
+   // Skip 6 reserved bytes.
+   stbi__skip(s, 6 );
+
+   // Read the number of channels (R, G, B, A, etc).
+   channelCount = stbi__get16be(s);
+   if (channelCount < 0 || channelCount > 16)
+      return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");
+
+   // Read the rows and columns of the image.
+   h = stbi__get32be(s);
+   w = stbi__get32be(s);
+
+   if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+   if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+
+   // Make sure the depth is 8 bits.
+   bitdepth = stbi__get16be(s);
+   if (bitdepth != 8 && bitdepth != 16)
+      return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");
+
+   // Make sure the color mode is RGB.
+   // Valid options are:
+   //   0: Bitmap
+   //   1: Grayscale
+   //   2: Indexed color
+   //   3: RGB color
+   //   4: CMYK color
+   //   7: Multichannel
+   //   8: Duotone
+   //   9: Lab color
+   if (stbi__get16be(s) != 3)
+      return stbi__errpuc("wrong color format", "PSD is not in RGB color format");
+
+   // Skip the Mode Data.  (It's the palette for indexed color; other info for other modes.)
+   stbi__skip(s,stbi__get32be(s) );
+
+   // Skip the image resources.  (resolution, pen tool paths, etc)
+   stbi__skip(s, stbi__get32be(s) );
+
+   // Skip the reserved data.
+   stbi__skip(s, stbi__get32be(s) );
+
+   // Find out if the data is compressed.
+   // Known values:
+   //   0: no compression
+   //   1: RLE compressed
+   compression = stbi__get16be(s);
+   if (compression > 1)
+      return stbi__errpuc("bad compression", "PSD has an unknown compression format");
+
+   // Check size
+   if (!stbi__mad3sizes_valid(4, w, h, 0))
+      return stbi__errpuc("too large", "Corrupt PSD");
+
+   // Create the destination image.
+
+   if (!compression && bitdepth == 16 && bpc == 16) {
+      out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0);
+      ri->bits_per_channel = 16;
+   } else
+      out = (stbi_uc *) stbi__malloc(4 * w*h);
+
+   if (!out) return stbi__errpuc("outofmem", "Out of memory");
+   pixelCount = w*h;
+
+   // Initialize the data to zero.
+   //memset( out, 0, pixelCount * 4 );
+
+   // Finally, the image data.
+   if (compression) {
+      // RLE as used by .PSD and .TIFF
+      // Loop until you get the number of unpacked bytes you are expecting:
+      //     Read the next source byte into n.
+      //     If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
+      //     Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
+      //     Else if n is 128, noop.
+      // Endloop
+
+      // The RLE-compressed data is preceded by a 2-byte data count for each row in the data,
+      // which we're going to just skip.
+      stbi__skip(s, h * channelCount * 2 );
+
+      // Read the RLE data by channel.
+      for (channel = 0; channel < 4; channel++) {
+         stbi_uc *p;
+
+         p = out+channel;
+         if (channel >= channelCount) {
+            // Fill this channel with default data.
+            for (i = 0; i < pixelCount; i++, p += 4)
+               *p = (channel == 3 ? 255 : 0);
+         } else {
+            // Read the RLE data.
+            if (!stbi__psd_decode_rle(s, p, pixelCount)) {
+               STBI_FREE(out);
+               return stbi__errpuc("corrupt", "bad RLE data");
+            }
+         }
+      }
+
+   } else {
+      // We're at the raw image data.  It's each channel in order (Red, Green, Blue, Alpha, ...)
+      // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image.
+
+      // Read the data by channel.
+      for (channel = 0; channel < 4; channel++) {
+         if (channel >= channelCount) {
+            // Fill this channel with default data.
+            if (bitdepth == 16 && bpc == 16) {
+               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
+               stbi__uint16 val = channel == 3 ? 65535 : 0;
+               for (i = 0; i < pixelCount; i++, q += 4)
+                  *q = val;
+            } else {
+               stbi_uc *p = out+channel;
+               stbi_uc val = channel == 3 ? 255 : 0;
+               for (i = 0; i < pixelCount; i++, p += 4)
+                  *p = val;
+            }
+         } else {
+            if (ri->bits_per_channel == 16) {    // output bpc
+               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
+               for (i = 0; i < pixelCount; i++, q += 4)
+                  *q = (stbi__uint16) stbi__get16be(s);
+            } else {
+               stbi_uc *p = out+channel;
+               if (bitdepth == 16) {  // input bpc
+                  for (i = 0; i < pixelCount; i++, p += 4)
+                     *p = (stbi_uc) (stbi__get16be(s) >> 8);
+               } else {
+                  for (i = 0; i < pixelCount; i++, p += 4)
+                     *p = stbi__get8(s);
+               }
+            }
+         }
+      }
+   }
+
+   // remove weird white matte from PSD
+   if (channelCount >= 4) {
+      if (ri->bits_per_channel == 16) {
+         for (i=0; i < w*h; ++i) {
+            stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i;
+            if (pixel[3] != 0 && pixel[3] != 65535) {
+               float a = pixel[3] / 65535.0f;
+               float ra = 1.0f / a;
+               float inv_a = 65535.0f * (1 - ra);
+               pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a);
+               pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a);
+               pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a);
+            }
+         }
+      } else {
+         for (i=0; i < w*h; ++i) {
+            unsigned char *pixel = out + 4*i;
+            if (pixel[3] != 0 && pixel[3] != 255) {
+               float a = pixel[3] / 255.0f;
+               float ra = 1.0f / a;
+               float inv_a = 255.0f * (1 - ra);
+               pixel[0] = (unsigned char) (pixel[0]*ra + inv_a);
+               pixel[1] = (unsigned char) (pixel[1]*ra + inv_a);
+               pixel[2] = (unsigned char) (pixel[2]*ra + inv_a);
+            }
+         }
+      }
+   }
+
+   // convert to desired output format
+   if (req_comp && req_comp != 4) {
+      if (ri->bits_per_channel == 16)
+         out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h);
+      else
+         out = stbi__convert_format(out, 4, req_comp, w, h);
+      if (out == NULL) return out; // stbi__convert_format frees input on failure
+   }
+
+   if (comp) *comp = 4;
+   *y = h;
+   *x = w;
+
+   return out;
+}
+#endif
+
+// *************************************************************************************************
+// Softimage PIC loader
+// by Tom Seddon
+//
+// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format
+// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/
+
+#ifndef STBI_NO_PIC
+static int stbi__pic_is4(stbi__context *s,const char *str)
+{
+   int i;
+   for (i=0; i<4; ++i)
+      if (stbi__get8(s) != (stbi_uc)str[i])
+         return 0;
+
+   return 1;
+}
+
+static int stbi__pic_test_core(stbi__context *s)
+{
+   int i;
+
+   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34"))
+      return 0;
+
+   for(i=0;i<84;++i)
+      stbi__get8(s);
+
+   if (!stbi__pic_is4(s,"PICT"))
+      return 0;
+
+   return 1;
+}
+
+typedef struct
+{
+   stbi_uc size,type,channel;
+} stbi__pic_packet;
+
+static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest)
+{
+   int mask=0x80, i;
+
+   for (i=0; i<4; ++i, mask>>=1) {
+      if (channel & mask) {
+         if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short");
+         dest[i]=stbi__get8(s);
+      }
+   }
+
+   return dest;
+}
+
+static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src)
+{
+   int mask=0x80,i;
+
+   for (i=0;i<4; ++i, mask>>=1)
+      if (channel&mask)
+         dest[i]=src[i];
+}
+
+static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)
+{
+   int act_comp=0,num_packets=0,y,chained;
+   stbi__pic_packet packets[10];
+
+   // this will (should...) cater for even some bizarre stuff like having data
+    // for the same channel in multiple packets.
+   do {
+      stbi__pic_packet *packet;
+
+      if (num_packets==sizeof(packets)/sizeof(packets[0]))
+         return stbi__errpuc("bad format","too many packets");
+
+      packet = &packets[num_packets++];
+
+      chained = stbi__get8(s);
+      packet->size    = stbi__get8(s);
+      packet->type    = stbi__get8(s);
+      packet->channel = stbi__get8(s);
+
+      act_comp |= packet->channel;
+
+      if (stbi__at_eof(s))          return stbi__errpuc("bad file","file too short (reading packets)");
+      if (packet->size != 8)  return stbi__errpuc("bad format","packet isn't 8bpp");
+   } while (chained);
+
+   *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?
+
+   for(y=0; y<height; ++y) {
+      int packet_idx;
+
+      for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {
+         stbi__pic_packet *packet = &packets[packet_idx];
+         stbi_uc *dest = result+y*width*4;
+
+         switch (packet->type) {
+            default:
+               return stbi__errpuc("bad format","packet has bad compression type");
+
+            case 0: {//uncompressed
+               int x;
+
+               for(x=0;x<width;++x, dest+=4)
+                  if (!stbi__readval(s,packet->channel,dest))
+                     return 0;
+               break;
+            }
+
+            case 1://Pure RLE
+               {
+                  int left=width, i;
+
+                  while (left>0) {
+                     stbi_uc count,value[4];
+
+                     count=stbi__get8(s);
+                     if (stbi__at_eof(s))   return stbi__errpuc("bad file","file too short (pure read count)");
+
+                     if (count > left)
+                        count = (stbi_uc) left;
+
+                     if (!stbi__readval(s,packet->channel,value))  return 0;
+
+                     for(i=0; i<count; ++i,dest+=4)
+                        stbi__copyval(packet->channel,dest,value);
+                     left -= count;
+                  }
+               }
+               break;
+
+            case 2: {//Mixed RLE
+               int left=width;
+               while (left>0) {
+                  int count = stbi__get8(s), i;
+                  if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (mixed read count)");
+
+                  if (count >= 128) { // Repeated
+                     stbi_uc value[4];
+
+                     if (count==128)
+                        count = stbi__get16be(s);
+                     else
+                        count -= 127;
+                     if (count > left)
+                        return stbi__errpuc("bad file","scanline overrun");
+
+                     if (!stbi__readval(s,packet->channel,value))
+                        return 0;
+
+                     for(i=0;i<count;++i, dest += 4)
+                        stbi__copyval(packet->channel,dest,value);
+                  } else { // Raw
+                     ++count;
+                     if (count>left) return stbi__errpuc("bad file","scanline overrun");
+
+                     for(i=0;i<count;++i, dest+=4)
+                        if (!stbi__readval(s,packet->channel,dest))
+                           return 0;
+                  }
+                  left-=count;
+               }
+               break;
+            }
+         }
+      }
+   }
+
+   return result;
+}
+
+static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri)
+{
+   stbi_uc *result;
+   int i, x,y, internal_comp;
+   STBI_NOTUSED(ri);
+
+   if (!comp) comp = &internal_comp;
+
+   for (i=0; i<92; ++i)
+      stbi__get8(s);
+
+   x = stbi__get16be(s);
+   y = stbi__get16be(s);
+
+   if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+   if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+
+   if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (pic header)");
+   if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode");
+
+   stbi__get32be(s); //skip `ratio'
+   stbi__get16be(s); //skip `fields'
+   stbi__get16be(s); //skip `pad'
+
+   // intermediate buffer is RGBA
+   result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
+   if (!result) return stbi__errpuc("outofmem", "Out of memory");
+   memset(result, 0xff, x*y*4);
+
+   if (!stbi__pic_load_core(s,x,y,comp, result)) {
+      STBI_FREE(result);
+      result=0;
+   }
+   *px = x;
+   *py = y;
+   if (req_comp == 0) req_comp = *comp;
+   result=stbi__convert_format(result,4,req_comp,x,y);
+
+   return result;
+}
+
+static int stbi__pic_test(stbi__context *s)
+{
+   int r = stbi__pic_test_core(s);
+   stbi__rewind(s);
+   return r;
+}
+#endif
+
+// *************************************************************************************************
+// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
+
+#ifndef STBI_NO_GIF
+typedef struct
+{
+   stbi__int16 prefix;
+   stbi_uc first;
+   stbi_uc suffix;
+} stbi__gif_lzw;
+
+typedef struct
+{
+   int w,h;
+   stbi_uc *out;                 // output buffer (always 4 components)
+   stbi_uc *background;          // The current "background" as far as a gif is concerned
+   stbi_uc *history;
+   int flags, bgindex, ratio, transparent, eflags;
+   stbi_uc  pal[256][4];
+   stbi_uc lpal[256][4];
+   stbi__gif_lzw codes[8192];
+   stbi_uc *color_table;
+   int parse, step;
+   int lflags;
+   int start_x, start_y;
+   int max_x, max_y;
+   int cur_x, cur_y;
+   int line_size;
+   int delay;
+} stbi__gif;
+
+static int stbi__gif_test_raw(stbi__context *s)
+{
+   int sz;
+   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0;
+   sz = stbi__get8(s);
+   if (sz != '9' && sz != '7') return 0;
+   if (stbi__get8(s) != 'a') return 0;
+   return 1;
+}
+
+static int stbi__gif_test(stbi__context *s)
+{
+   int r = stbi__gif_test_raw(s);
+   stbi__rewind(s);
+   return r;
+}
+
+static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp)
+{
+   int i;
+   for (i=0; i < num_entries; ++i) {
+      pal[i][2] = stbi__get8(s);
+      pal[i][1] = stbi__get8(s);
+      pal[i][0] = stbi__get8(s);
+      pal[i][3] = transp == i ? 0 : 255;
+   }
+}
+
+static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info)
+{
+   stbi_uc version;
+   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8')
+      return stbi__err("not GIF", "Corrupt GIF");
+
+   version = stbi__get8(s);
+   if (version != '7' && version != '9')    return stbi__err("not GIF", "Corrupt GIF");
+   if (stbi__get8(s) != 'a')                return stbi__err("not GIF", "Corrupt GIF");
+
+   stbi__g_failure_reason = "";
+   g->w = stbi__get16le(s);
+   g->h = stbi__get16le(s);
+   g->flags = stbi__get8(s);
+   g->bgindex = stbi__get8(s);
+   g->ratio = stbi__get8(s);
+   g->transparent = -1;
+
+   if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+   if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
+
+   if (comp != 0) *comp = 4;  // can't actually tell whether it's 3 or 4 until we parse the comments
+
+   if (is_info) return 1;
+
+   if (g->flags & 0x80)
+      stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1);
+
+   return 1;
+}
+
+static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
+{
+   stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
+   if (!g) return stbi__err("outofmem", "Out of memory");
+   if (!stbi__gif_header(s, g, comp, 1)) {
+      STBI_FREE(g);
+      stbi__rewind( s );
+      return 0;
+   }
+   if (x) *x = g->w;
+   if (y) *y = g->h;
+   STBI_FREE(g);
+   return 1;
+}
+
+static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)
+{
+   stbi_uc *p, *c;
+   int idx;
+
+   // recurse to decode the prefixes, since the linked-list is backwards,
+   // and working backwards through an interleaved image would be nasty
+   if (g->codes[code].prefix >= 0)
+      stbi__out_gif_code(g, g->codes[code].prefix);
+
+   if (g->cur_y >= g->max_y) return;
+
+   idx = g->cur_x + g->cur_y;
+   p = &g->out[idx];
+   g->history[idx / 4] = 1;
+
+   c = &g->color_table[g->codes[code].suffix * 4];
+   if (c[3] > 128) { // don't render transparent pixels;
+      p[0] = c[2];
+      p[1] = c[1];
+      p[2] = c[0];
+      p[3] = c[3];
+   }
+   g->cur_x += 4;
+
+   if (g->cur_x >= g->max_x) {
+      g->cur_x = g->start_x;
+      g->cur_y += g->step;
+
+      while (g->cur_y >= g->max_y && g->parse > 0) {
+         g->step = (1 << g->parse) * g->line_size;
+         g->cur_y = g->start_y + (g->step >> 1);
+         --g->parse;
+      }
+   }
+}
+
+static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
+{
+   stbi_uc lzw_cs;
+   stbi__int32 len, init_code;
+   stbi__uint32 first;
+   stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;
+   stbi__gif_lzw *p;
+
+   lzw_cs = stbi__get8(s);
+   if (lzw_cs > 12) return NULL;
+   clear = 1 << lzw_cs;
+   first = 1;
+   codesize = lzw_cs + 1;
+   codemask = (1 << codesize) - 1;
+   bits = 0;
+   valid_bits = 0;
+   for (init_code = 0; init_code < clear; init_code++) {
+      g->codes[init_code].prefix = -1;
+      g->codes[init_code].first = (stbi_uc) init_code;
+      g->codes[init_code].suffix = (stbi_uc) init_code;
+   }
+
+   // support no starting clear code
+   avail = clear+2;
+   oldcode = -1;
+
+   len = 0;
+   for(;;) {
+      if (valid_bits < codesize) {
+         if (len == 0) {
+            len = stbi__get8(s); // start new block
+            if (len == 0)
+               return g->out;
+         }
+         --len;
+         bits |= (stbi__int32) stbi__get8(s) << valid_bits;
+         valid_bits += 8;
+      } else {
+         stbi__int32 code = bits & codemask;
+         bits >>= codesize;
+         valid_bits -= codesize;
+         // @OPTIMIZE: is there some way we can accelerate the non-clear path?
+         if (code == clear) {  // clear code
+            codesize = lzw_cs + 1;
+            codemask = (1 << codesize) - 1;
+            avail = clear + 2;
+            oldcode = -1;
+            first = 0;
+         } else if (code == clear + 1) { // end of stream code
+            stbi__skip(s, len);
+            while ((len = stbi__get8(s)) > 0)
+               stbi__skip(s,len);
+            return g->out;
+         } else if (code <= avail) {
+            if (first) {
+               return stbi__errpuc("no clear code", "Corrupt GIF");
+            }
+
+            if (oldcode >= 0) {
+               p = &g->codes[avail++];
+               if (avail > 8192) {
+                  return stbi__errpuc("too many codes", "Corrupt GIF");
+               }
+
+               p->prefix = (stbi__int16) oldcode;
+               p->first = g->codes[oldcode].first;
+               p->suffix = (code == avail) ? p->first : g->codes[code].first;
+            } else if (code == avail)
+               return stbi__errpuc("illegal code in raster", "Corrupt GIF");
+
+            stbi__out_gif_code(g, (stbi__uint16) code);
+
+            if ((avail & codemask) == 0 && avail <= 0x0FFF) {
+               codesize++;
+               codemask = (1 << codesize) - 1;
+            }
+
+            oldcode = code;
+         } else {
+            return stbi__errpuc("illegal code in raster", "Corrupt GIF");
+         }
+      }
+   }
+}
+
+// this function is designed to support animated gifs, although stb_image doesn't support it
+// two back is the image from two frames ago, used for a very specific disposal format
+static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
+{
+   int dispose;
+   int first_frame;
+   int pi;
+   int pcount;
+   STBI_NOTUSED(req_comp);
+
+   // on first frame, any non-written pixels get the background colour (non-transparent)
+   first_frame = 0;
+   if (g->out == 0) {
+      if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header
+      if (!stbi__mad3sizes_valid(4, g->w, g->h, 0))
+         return stbi__errpuc("too large", "GIF image is too large");
+      pcount = g->w * g->h;
+      g->out = (stbi_uc *) stbi__malloc(4 * pcount);
+      g->background = (stbi_uc *) stbi__malloc(4 * pcount);
+      g->history = (stbi_uc *) stbi__malloc(pcount);
+      if (!g->out || !g->background || !g->history)
+         return stbi__errpuc("outofmem", "Out of memory");
+
+      // image is treated as "transparent" at the start - ie, nothing overwrites the current background;
+      // background colour is only used for pixels that are not rendered first frame, after that "background"
+      // color refers to the color that was there the previous frame.
+      memset(g->out, 0x00, 4 * pcount);
+      memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent)
+      memset(g->history, 0x00, pcount);        // pixels that were affected previous frame
+      first_frame = 1;
+   } else {
+      // second frame - how do we dispose of the previous one?
+      dispose = (g->eflags & 0x1C) >> 2;
+      pcount = g->w * g->h;
+
+      if ((dispose == 3) && (two_back == 0)) {
+         dispose = 2; // if I don't have an image to revert back to, default to the old background
+      }
+
+      if (dispose == 3) { // use previous graphic
+         for (pi = 0; pi < pcount; ++pi) {
+            if (g->history[pi]) {
+               memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 );
+            }
+         }
+      } else if (dispose == 2) {
+         // restore what was changed last frame to background before that frame;
+         for (pi = 0; pi < pcount; ++pi) {
+            if (g->history[pi]) {
+               memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 );
+            }
+         }
+      } else {
+         // This is a non-disposal case eithe way, so just
+         // leave the pixels as is, and they will become the new background
+         // 1: do not dispose
+         // 0:  not specified.
+      }
+
+      // background is what out is after the undoing of the previou frame;
+      memcpy( g->background, g->out, 4 * g->w * g->h );
+   }
+
+   // clear my history;
+   memset( g->history, 0x00, g->w * g->h );        // pixels that were affected previous frame
+
+   for (;;) {
+      int tag = stbi__get8(s);
+      switch (tag) {
+         case 0x2C: /* Image Descriptor */
+         {
+            stbi__int32 x, y, w, h;
+            stbi_uc *o;
+
+            x = stbi__get16le(s);
+            y = stbi__get16le(s);
+            w = stbi__get16le(s);
+            h = stbi__get16le(s);
+            if (((x + w) > (g->w)) || ((y + h) > (g->h)))
+               return stbi__errpuc("bad Image Descriptor", "Corrupt GIF");
+
+            g->line_size = g->w * 4;
+            g->start_x = x * 4;
+            g->start_y = y * g->line_size;
+            g->max_x   = g->start_x + w * 4;
+            g->max_y   = g->start_y + h * g->line_size;
+            g->cur_x   = g->start_x;
+            g->cur_y   = g->start_y;
+
+            // if the width of the specified rectangle is 0, that means
+            // we may not see *any* pixels or the image is malformed;
+            // to make sure this is caught, move the current y down to
+            // max_y (which is what out_gif_code checks).
+            if (w == 0)
+               g->cur_y = g->max_y;
+
+            g->lflags = stbi__get8(s);
+
+            if (g->lflags & 0x40) {
+               g->step = 8 * g->line_size; // first interlaced spacing
+               g->parse = 3;
+            } else {
+               g->step = g->line_size;
+               g->parse = 0;
+            }
+
+            if (g->lflags & 0x80) {
+               stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
+               g->color_table = (stbi_uc *) g->lpal;
+            } else if (g->flags & 0x80) {
+               g->color_table = (stbi_uc *) g->pal;
+            } else
+               return stbi__errpuc("missing color table", "Corrupt GIF");
+
+            o = stbi__process_gif_raster(s, g);
+            if (!o) return NULL;
+
+            // if this was the first frame,
+            pcount = g->w * g->h;
+            if (first_frame && (g->bgindex > 0)) {
+               // if first frame, any pixel not drawn to gets the background color
+               for (pi = 0; pi < pcount; ++pi) {
+                  if (g->history[pi] == 0) {
+                     g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be;
+                     memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 );
+                  }
+               }
+            }
+
+            return o;
+         }
+
+         case 0x21: // Comment Extension.
+         {
+            int len;
+            int ext = stbi__get8(s);
+            if (ext == 0xF9) { // Graphic Control Extension.
+               len = stbi__get8(s);
+               if (len == 4) {
+                  g->eflags = stbi__get8(s);
+                  g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths.
+
+                  // unset old transparent
+                  if (g->transparent >= 0) {
+                     g->pal[g->transparent][3] = 255;
+                  }
+                  if (g->eflags & 0x01) {
+                     g->transparent = stbi__get8(s);
+                     if (g->transparent >= 0) {
+                        g->pal[g->transparent][3] = 0;
+                     }
+                  } else {
+                     // don't need transparent
+                     stbi__skip(s, 1);
+                     g->transparent = -1;
+                  }
+               } else {
+                  stbi__skip(s, len);
+                  break;
+               }
+            }
+            while ((len = stbi__get8(s)) != 0) {
+               stbi__skip(s, len);
+            }
+            break;
+         }
+
+         case 0x3B: // gif stream termination code
+            return (stbi_uc *) s; // using '1' causes warning on some compilers
+
+         default:
+            return stbi__errpuc("unknown code", "Corrupt GIF");
+      }
+   }
+}
+
+static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays)
+{
+   STBI_FREE(g->out);
+   STBI_FREE(g->history);
+   STBI_FREE(g->background);
+
+   if (out) STBI_FREE(out);
+   if (delays && *delays) STBI_FREE(*delays);
+   return stbi__errpuc("outofmem", "Out of memory");
+}
+
+static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
+{
+   if (stbi__gif_test(s)) {
+      int layers = 0;
+      stbi_uc *u = 0;
+      stbi_uc *out = 0;
+      stbi_uc *two_back = 0;
+      stbi__gif g;
+      int stride;
+      int out_size = 0;
+      int delays_size = 0;
+
+      STBI_NOTUSED(out_size);
+      STBI_NOTUSED(delays_size);
+
+      memset(&g, 0, sizeof(g));
+      if (delays) {
+         *delays = 0;
+      }
+
+      do {
+         u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);
+         if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
+
+         if (u) {
+            *x = g.w;
+            *y = g.h;
+            ++layers;
+            stride = g.w * g.h * 4;
+
+            if (out) {
+               void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
+               if (!tmp)
+                  return stbi__load_gif_main_outofmem(&g, out, delays);
+               else {
+                   out = (stbi_uc*) tmp;
+                   out_size = layers * stride;
+               }
+
+               if (delays) {
+                  int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
+                  if (!new_delays)
+                     return stbi__load_gif_main_outofmem(&g, out, delays);
+                  *delays = new_delays;
+                  delays_size = layers * sizeof(int);
+               }
+            } else {
+               out = (stbi_uc*)stbi__malloc( layers * stride );
+               if (!out)
+                  return stbi__load_gif_main_outofmem(&g, out, delays);
+               out_size = layers * stride;
+               if (delays) {
+                  *delays = (int*) stbi__malloc( layers * sizeof(int) );
+                  if (!*delays)
+                     return stbi__load_gif_main_outofmem(&g, out, delays);
+                  delays_size = layers * sizeof(int);
+               }
+            }
+            memcpy( out + ((layers - 1) * stride), u, stride );
+            if (layers >= 2) {
+               two_back = out - 2 * stride;
+            }
+
+            if (delays) {
+               (*delays)[layers - 1U] = g.delay;
+            }
+         }
+      } while (u != 0);
+
+      // free temp buffer;
+      STBI_FREE(g.out);
+      STBI_FREE(g.history);
+      STBI_FREE(g.background);
+
+      // do the final conversion after loading everything;
+      if (req_comp && req_comp != 4)
+         out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h);
+
+      *z = layers;
+      return out;
+   } else {
+      return stbi__errpuc("not GIF", "Image was not as a gif type.");
+   }
+}
+
+static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   stbi_uc *u = 0;
+   stbi__gif g;
+   memset(&g, 0, sizeof(g));
+   STBI_NOTUSED(ri);
+
+   u = stbi__gif_load_next(s, &g, comp, req_comp, 0);
+   if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
+   if (u) {
+      *x = g.w;
+      *y = g.h;
+
+      // moved conversion to after successful load so that the same
+      // can be done for multiple frames.
+      if (req_comp && req_comp != 4)
+         u = stbi__convert_format(u, 4, req_comp, g.w, g.h);
+   } else if (g.out) {
+      // if there was an error and we allocated an image buffer, free it!
+      STBI_FREE(g.out);
+   }
+
+   // free buffers needed for multiple frame loading;
+   STBI_FREE(g.history);
+   STBI_FREE(g.background);
+
+   return u;
+}
+
+static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   return stbi__gif_info_raw(s,x,y,comp);
+}
+#endif
+
+// *************************************************************************************************
+// Radiance RGBE HDR loader
+// originally by Nicolas Schulz
+#ifndef STBI_NO_HDR
+static int stbi__hdr_test_core(stbi__context *s, const char *signature)
+{
+   int i;
+   for (i=0; signature[i]; ++i)
+      if (stbi__get8(s) != signature[i])
+          return 0;
+   stbi__rewind(s);
+   return 1;
+}
+
+static int stbi__hdr_test(stbi__context* s)
+{
+   int r = stbi__hdr_test_core(s, "#?RADIANCE\n");
+   stbi__rewind(s);
+   if(!r) {
+       r = stbi__hdr_test_core(s, "#?RGBE\n");
+       stbi__rewind(s);
+   }
+   return r;
+}
+
+#define STBI__HDR_BUFLEN  1024
+static char *stbi__hdr_gettoken(stbi__context *z, char *buffer)
+{
+   int len=0;
+   char c = '\0';
+
+   c = (char) stbi__get8(z);
+
+   while (!stbi__at_eof(z) && c != '\n') {
+      buffer[len++] = c;
+      if (len == STBI__HDR_BUFLEN-1) {
+         // flush to end of line
+         while (!stbi__at_eof(z) && stbi__get8(z) != '\n')
+            ;
+         break;
+      }
+      c = (char) stbi__get8(z);
+   }
+
+   buffer[len] = 0;
+   return buffer;
+}
+
+static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)
+{
+   if ( input[3] != 0 ) {
+      float f1;
+      // Exponent
+      f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8));
+      if (req_comp <= 2)
+         output[0] = (input[0] + input[1] + input[2]) * f1 / 3;
+      else {
+         output[0] = input[0] * f1;
+         output[1] = input[1] * f1;
+         output[2] = input[2] * f1;
+      }
+      if (req_comp == 2) output[1] = 1;
+      if (req_comp == 4) output[3] = 1;
+   } else {
+      switch (req_comp) {
+         case 4: output[3] = 1; /* fallthrough */
+         case 3: output[0] = output[1] = output[2] = 0;
+                 break;
+         case 2: output[1] = 1; /* fallthrough */
+         case 1: output[0] = 0;
+                 break;
+      }
+   }
+}
+
+static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   char buffer[STBI__HDR_BUFLEN];
+   char *token;
+   int valid = 0;
+   int width, height;
+   stbi_uc *scanline;
+   float *hdr_data;
+   int len;
+   unsigned char count, value;
+   int i, j, k, c1,c2, z;
+   const char *headerToken;
+   STBI_NOTUSED(ri);
+
+   // Check identifier
+   headerToken = stbi__hdr_gettoken(s,buffer);
+   if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0)
+      return stbi__errpf("not HDR", "Corrupt HDR image");
+
+   // Parse header
+   for(;;) {
+      token = stbi__hdr_gettoken(s,buffer);
+      if (token[0] == 0) break;
+      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
+   }
+
+   if (!valid)    return stbi__errpf("unsupported format", "Unsupported HDR format");
+
+   // Parse width and height
+   // can't use sscanf() if we're not using stdio!
+   token = stbi__hdr_gettoken(s,buffer);
+   if (strncmp(token, "-Y ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
+   token += 3;
+   height = (int) strtol(token, &token, 10);
+   while (*token == ' ') ++token;
+   if (strncmp(token, "+X ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
+   token += 3;
+   width = (int) strtol(token, NULL, 10);
+
+   if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
+   if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
+
+   *x = width;
+   *y = height;
+
+   if (comp) *comp = 3;
+   if (req_comp == 0) req_comp = 3;
+
+   if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0))
+      return stbi__errpf("too large", "HDR image is too large");
+
+   // Read data
+   hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0);
+   if (!hdr_data)
+      return stbi__errpf("outofmem", "Out of memory");
+
+   // Load image data
+   // image data is stored as some number of sca
+   if ( width < 8 || width >= 32768) {
+      // Read flat data
+      for (j=0; j < height; ++j) {
+         for (i=0; i < width; ++i) {
+            stbi_uc rgbe[4];
+           main_decode_loop:
+            stbi__getn(s, rgbe, 4);
+            stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp);
+         }
+      }
+   } else {
+      // Read RLE-encoded data
+      scanline = NULL;
+
+      for (j = 0; j < height; ++j) {
+         c1 = stbi__get8(s);
+         c2 = stbi__get8(s);
+         len = stbi__get8(s);
+         if (c1 != 2 || c2 != 2 || (len & 0x80)) {
+            // not run-length encoded, so we have to actually use THIS data as a decoded
+            // pixel (note this can't be a valid pixel--one of RGB must be >= 128)
+            stbi_uc rgbe[4];
+            rgbe[0] = (stbi_uc) c1;
+            rgbe[1] = (stbi_uc) c2;
+            rgbe[2] = (stbi_uc) len;
+            rgbe[3] = (stbi_uc) stbi__get8(s);
+            stbi__hdr_convert(hdr_data, rgbe, req_comp);
+            i = 1;
+            j = 0;
+            STBI_FREE(scanline);
+            goto main_decode_loop; // yes, this makes no sense
+         }
+         len <<= 8;
+         len |= stbi__get8(s);
+         if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); }
+         if (scanline == NULL) {
+            scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0);
+            if (!scanline) {
+               STBI_FREE(hdr_data);
+               return stbi__errpf("outofmem", "Out of memory");
+            }
+         }
+
+         for (k = 0; k < 4; ++k) {
+            int nleft;
+            i = 0;
+            while ((nleft = width - i) > 0) {
+               count = stbi__get8(s);
+               if (count > 128) {
+                  // Run
+                  value = stbi__get8(s);
+                  count -= 128;
+                  if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
+                  for (z = 0; z < count; ++z)
+                     scanline[i++ * 4 + k] = value;
+               } else {
+                  // Dump
+                  if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
+                  for (z = 0; z < count; ++z)
+                     scanline[i++ * 4 + k] = stbi__get8(s);
+               }
+            }
+         }
+         for (i=0; i < width; ++i)
+            stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp);
+      }
+      if (scanline)
+         STBI_FREE(scanline);
+   }
+
+   return hdr_data;
+}
+
+static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   char buffer[STBI__HDR_BUFLEN];
+   char *token;
+   int valid = 0;
+   int dummy;
+
+   if (!x) x = &dummy;
+   if (!y) y = &dummy;
+   if (!comp) comp = &dummy;
+
+   if (stbi__hdr_test(s) == 0) {
+       stbi__rewind( s );
+       return 0;
+   }
+
+   for(;;) {
+      token = stbi__hdr_gettoken(s,buffer);
+      if (token[0] == 0) break;
+      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
+   }
+
+   if (!valid) {
+       stbi__rewind( s );
+       return 0;
+   }
+   token = stbi__hdr_gettoken(s,buffer);
+   if (strncmp(token, "-Y ", 3)) {
+       stbi__rewind( s );
+       return 0;
+   }
+   token += 3;
+   *y = (int) strtol(token, &token, 10);
+   while (*token == ' ') ++token;
+   if (strncmp(token, "+X ", 3)) {
+       stbi__rewind( s );
+       return 0;
+   }
+   token += 3;
+   *x = (int) strtol(token, NULL, 10);
+   *comp = 3;
+   return 1;
+}
+#endif // STBI_NO_HDR
+
+#ifndef STBI_NO_BMP
+static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   void *p;
+   stbi__bmp_data info;
+
+   info.all_a = 255;
+   p = stbi__bmp_parse_header(s, &info);
+   if (p == NULL) {
+      stbi__rewind( s );
+      return 0;
+   }
+   if (x) *x = s->img_x;
+   if (y) *y = s->img_y;
+   if (comp) {
+      if (info.bpp == 24 && info.ma == 0xff000000)
+         *comp = 3;
+      else
+         *comp = info.ma ? 4 : 3;
+   }
+   return 1;
+}
+#endif
+
+#ifndef STBI_NO_PSD
+static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   int channelCount, dummy, depth;
+   if (!x) x = &dummy;
+   if (!y) y = &dummy;
+   if (!comp) comp = &dummy;
+   if (stbi__get32be(s) != 0x38425053) {
+       stbi__rewind( s );
+       return 0;
+   }
+   if (stbi__get16be(s) != 1) {
+       stbi__rewind( s );
+       return 0;
+   }
+   stbi__skip(s, 6);
+   channelCount = stbi__get16be(s);
+   if (channelCount < 0 || channelCount > 16) {
+       stbi__rewind( s );
+       return 0;
+   }
+   *y = stbi__get32be(s);
+   *x = stbi__get32be(s);
+   depth = stbi__get16be(s);
+   if (depth != 8 && depth != 16) {
+       stbi__rewind( s );
+       return 0;
+   }
+   if (stbi__get16be(s) != 3) {
+       stbi__rewind( s );
+       return 0;
+   }
+   *comp = 4;
+   return 1;
+}
+
+static int stbi__psd_is16(stbi__context *s)
+{
+   int channelCount, depth;
+   if (stbi__get32be(s) != 0x38425053) {
+       stbi__rewind( s );
+       return 0;
+   }
+   if (stbi__get16be(s) != 1) {
+       stbi__rewind( s );
+       return 0;
+   }
+   stbi__skip(s, 6);
+   channelCount = stbi__get16be(s);
+   if (channelCount < 0 || channelCount > 16) {
+       stbi__rewind( s );
+       return 0;
+   }
+   STBI_NOTUSED(stbi__get32be(s));
+   STBI_NOTUSED(stbi__get32be(s));
+   depth = stbi__get16be(s);
+   if (depth != 16) {
+       stbi__rewind( s );
+       return 0;
+   }
+   return 1;
+}
+#endif
+
+#ifndef STBI_NO_PIC
+static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   int act_comp=0,num_packets=0,chained,dummy;
+   stbi__pic_packet packets[10];
+
+   if (!x) x = &dummy;
+   if (!y) y = &dummy;
+   if (!comp) comp = &dummy;
+
+   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) {
+      stbi__rewind(s);
+      return 0;
+   }
+
+   stbi__skip(s, 88);
+
+   *x = stbi__get16be(s);
+   *y = stbi__get16be(s);
+   if (stbi__at_eof(s)) {
+      stbi__rewind( s);
+      return 0;
+   }
+   if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) {
+      stbi__rewind( s );
+      return 0;
+   }
+
+   stbi__skip(s, 8);
+
+   do {
+      stbi__pic_packet *packet;
+
+      if (num_packets==sizeof(packets)/sizeof(packets[0]))
+         return 0;
+
+      packet = &packets[num_packets++];
+      chained = stbi__get8(s);
+      packet->size    = stbi__get8(s);
+      packet->type    = stbi__get8(s);
+      packet->channel = stbi__get8(s);
+      act_comp |= packet->channel;
+
+      if (stbi__at_eof(s)) {
+          stbi__rewind( s );
+          return 0;
+      }
+      if (packet->size != 8) {
+          stbi__rewind( s );
+          return 0;
+      }
+   } while (chained);
+
+   *comp = (act_comp & 0x10 ? 4 : 3);
+
+   return 1;
+}
+#endif
+
+// *************************************************************************************************
+// Portable Gray Map and Portable Pixel Map loader
+// by Ken Miller
+//
+// PGM: http://netpbm.sourceforge.net/doc/pgm.html
+// PPM: http://netpbm.sourceforge.net/doc/ppm.html
+//
+// Known limitations:
+//    Does not support comments in the header section
+//    Does not support ASCII image data (formats P2 and P3)
+
+#ifndef STBI_NO_PNM
+
+static int      stbi__pnm_test(stbi__context *s)
+{
+   char p, t;
+   p = (char) stbi__get8(s);
+   t = (char) stbi__get8(s);
+   if (p != 'P' || (t != '5' && t != '6')) {
+       stbi__rewind( s );
+       return 0;
+   }
+   return 1;
+}
+
+static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
+{
+   stbi_uc *out;
+   STBI_NOTUSED(ri);
+
+   ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n);
+   if (ri->bits_per_channel == 0)
+      return 0;
+
+   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
+
+   *x = s->img_x;
+   *y = s->img_y;
+   if (comp) *comp = s->img_n;
+
+   if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0))
+      return stbi__errpuc("too large", "PNM too large");
+
+   out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
+   if (!out) return stbi__errpuc("outofmem", "Out of memory");
+   if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) {
+      STBI_FREE(out);
+      return stbi__errpuc("bad PNM", "PNM file truncated");
+   }
+
+   if (req_comp && req_comp != s->img_n) {
+      if (ri->bits_per_channel == 16) {
+         out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y);
+      } else {
+         out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
+      }
+      if (out == NULL) return out; // stbi__convert_format frees input on failure
+   }
+   return out;
+}
+
+static int      stbi__pnm_isspace(char c)
+{
+   return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
+}
+
+static void     stbi__pnm_skip_whitespace(stbi__context *s, char *c)
+{
+   for (;;) {
+      while (!stbi__at_eof(s) && stbi__pnm_isspace(*c))
+         *c = (char) stbi__get8(s);
+
+      if (stbi__at_eof(s) || *c != '#')
+         break;
+
+      while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' )
+         *c = (char) stbi__get8(s);
+   }
+}
+
+static int      stbi__pnm_isdigit(char c)
+{
+   return c >= '0' && c <= '9';
+}
+
+static int      stbi__pnm_getinteger(stbi__context *s, char *c)
+{
+   int value = 0;
+
+   while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {
+      value = value*10 + (*c - '0');
+      *c = (char) stbi__get8(s);
+      if((value > 214748364) || (value == 214748364 && *c > '7'))
+          return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int");
+   }
+
+   return value;
+}
+
+static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
+{
+   int maxv, dummy;
+   char c, p, t;
+
+   if (!x) x = &dummy;
+   if (!y) y = &dummy;
+   if (!comp) comp = &dummy;
+
+   stbi__rewind(s);
+
+   // Get identifier
+   p = (char) stbi__get8(s);
+   t = (char) stbi__get8(s);
+   if (p != 'P' || (t != '5' && t != '6')) {
+       stbi__rewind(s);
+       return 0;
+   }
+
+   *comp = (t == '6') ? 3 : 1;  // '5' is 1-component .pgm; '6' is 3-component .ppm
+
+   c = (char) stbi__get8(s);
+   stbi__pnm_skip_whitespace(s, &c);
+
+   *x = stbi__pnm_getinteger(s, &c); // read width
+   if(*x == 0)
+       return stbi__err("invalid width", "PPM image header had zero or overflowing width");
+   stbi__pnm_skip_whitespace(s, &c);
+
+   *y = stbi__pnm_getinteger(s, &c); // read height
+   if (*y == 0)
+       return stbi__err("invalid width", "PPM image header had zero or overflowing width");
+   stbi__pnm_skip_whitespace(s, &c);
+
+   maxv = stbi__pnm_getinteger(s, &c);  // read max value
+   if (maxv > 65535)
+      return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images");
+   else if (maxv > 255)
+      return 16;
+   else
+      return 8;
+}
+
+static int stbi__pnm_is16(stbi__context *s)
+{
+   if (stbi__pnm_info(s, NULL, NULL, NULL) == 16)
+	   return 1;
+   return 0;
+}
+#endif
+
+static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp)
+{
+   #ifndef STBI_NO_JPEG
+   if (stbi__jpeg_info(s, x, y, comp)) return 1;
+   #endif
+
+   #ifndef STBI_NO_PNG
+   if (stbi__png_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_GIF
+   if (stbi__gif_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_BMP
+   if (stbi__bmp_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_PSD
+   if (stbi__psd_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_PIC
+   if (stbi__pic_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_PNM
+   if (stbi__pnm_info(s, x, y, comp))  return 1;
+   #endif
+
+   #ifndef STBI_NO_HDR
+   if (stbi__hdr_info(s, x, y, comp))  return 1;
+   #endif
+
+   // test tga last because it's a crappy test!
+   #ifndef STBI_NO_TGA
+   if (stbi__tga_info(s, x, y, comp))
+       return 1;
+   #endif
+   return stbi__err("unknown image type", "Image not of any known type, or corrupt");
+}
+
+static int stbi__is_16_main(stbi__context *s)
+{
+   #ifndef STBI_NO_PNG
+   if (stbi__png_is16(s))  return 1;
+   #endif
+
+   #ifndef STBI_NO_PSD
+   if (stbi__psd_is16(s))  return 1;
+   #endif
+
+   #ifndef STBI_NO_PNM
+   if (stbi__pnm_is16(s))  return 1;
+   #endif
+   return 0;
+}
+
+#ifndef STBI_NO_STDIO
+STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp)
+{
+    FILE *f = stbi__fopen(filename, "rb");
+    int result;
+    if (!f) return stbi__err("can't fopen", "Unable to open file");
+    result = stbi_info_from_file(f, x, y, comp);
+    fclose(f);
+    return result;
+}
+
+STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp)
+{
+   int r;
+   stbi__context s;
+   long pos = ftell(f);
+   stbi__start_file(&s, f);
+   r = stbi__info_main(&s,x,y,comp);
+   fseek(f,pos,SEEK_SET);
+   return r;
+}
+
+STBIDEF int stbi_is_16_bit(char const *filename)
+{
+    FILE *f = stbi__fopen(filename, "rb");
+    int result;
+    if (!f) return stbi__err("can't fopen", "Unable to open file");
+    result = stbi_is_16_bit_from_file(f);
+    fclose(f);
+    return result;
+}
+
+STBIDEF int stbi_is_16_bit_from_file(FILE *f)
+{
+   int r;
+   stbi__context s;
+   long pos = ftell(f);
+   stbi__start_file(&s, f);
+   r = stbi__is_16_main(&s);
+   fseek(f,pos,SEEK_SET);
+   return r;
+}
+#endif // !STBI_NO_STDIO
+
+STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
+{
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__info_main(&s,x,y,comp);
+}
+
+STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp)
+{
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
+   return stbi__info_main(&s,x,y,comp);
+}
+
+STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len)
+{
+   stbi__context s;
+   stbi__start_mem(&s,buffer,len);
+   return stbi__is_16_main(&s);
+}
+
+STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user)
+{
+   stbi__context s;
+   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
+   return stbi__is_16_main(&s);
+}
+
+#endif // STB_IMAGE_IMPLEMENTATION
+
+/*
+   revision history:
+      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
+      2.19  (2018-02-11) fix warning
+      2.18  (2018-01-30) fix warnings
+      2.17  (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug
+                         1-bit BMP
+                         *_is_16_bit api
+                         avoid warnings
+      2.16  (2017-07-23) all functions have 16-bit variants;
+                         STBI_NO_STDIO works again;
+                         compilation fixes;
+                         fix rounding in unpremultiply;
+                         optimize vertical flip;
+                         disable raw_len validation;
+                         documentation fixes
+      2.15  (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode;
+                         warning fixes; disable run-time SSE detection on gcc;
+                         uniform handling of optional "return" values;
+                         thread-safe initialization of zlib tables
+      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
+      2.13  (2016-11-29) add 16-bit API, only supported for PNG right now
+      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
+      2.11  (2016-04-02) allocate large structures on the stack
+                         remove white matting for transparent PSD
+                         fix reported channel count for PNG & BMP
+                         re-enable SSE2 in non-gcc 64-bit
+                         support RGB-formatted JPEG
+                         read 16-bit PNGs (only as 8-bit)
+      2.10  (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED
+      2.09  (2016-01-16) allow comments in PNM files
+                         16-bit-per-pixel TGA (not bit-per-component)
+                         info() for TGA could break due to .hdr handling
+                         info() for BMP to shares code instead of sloppy parse
+                         can use STBI_REALLOC_SIZED if allocator doesn't support realloc
+                         code cleanup
+      2.08  (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA
+      2.07  (2015-09-13) fix compiler warnings
+                         partial animated GIF support
+                         limited 16-bpc PSD support
+                         #ifdef unused functions
+                         bug with < 92 byte PIC,PNM,HDR,TGA
+      2.06  (2015-04-19) fix bug where PSD returns wrong '*comp' value
+      2.05  (2015-04-19) fix bug in progressive JPEG handling, fix warning
+      2.04  (2015-04-15) try to re-enable SIMD on MinGW 64-bit
+      2.03  (2015-04-12) extra corruption checking (mmozeiko)
+                         stbi_set_flip_vertically_on_load (nguillemot)
+                         fix NEON support; fix mingw support
+      2.02  (2015-01-19) fix incorrect assert, fix warning
+      2.01  (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2
+      2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG
+      2.00  (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg)
+                         progressive JPEG (stb)
+                         PGM/PPM support (Ken Miller)
+                         STBI_MALLOC,STBI_REALLOC,STBI_FREE
+                         GIF bugfix -- seemingly never worked
+                         STBI_NO_*, STBI_ONLY_*
+      1.48  (2014-12-14) fix incorrectly-named assert()
+      1.47  (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb)
+                         optimize PNG (ryg)
+                         fix bug in interlaced PNG with user-specified channel count (stb)
+      1.46  (2014-08-26)
+              fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG
+      1.45  (2014-08-16)
+              fix MSVC-ARM internal compiler error by wrapping malloc
+      1.44  (2014-08-07)
+              various warning fixes from Ronny Chevalier
+      1.43  (2014-07-15)
+              fix MSVC-only compiler problem in code changed in 1.42
+      1.42  (2014-07-09)
+              don't define _CRT_SECURE_NO_WARNINGS (affects user code)
+              fixes to stbi__cleanup_jpeg path
+              added STBI_ASSERT to avoid requiring assert.h
+      1.41  (2014-06-25)
+              fix search&replace from 1.36 that messed up comments/error messages
+      1.40  (2014-06-22)
+              fix gcc struct-initialization warning
+      1.39  (2014-06-15)
+              fix to TGA optimization when req_comp != number of components in TGA;
+              fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite)
+              add support for BMP version 5 (more ignored fields)
+      1.38  (2014-06-06)
+              suppress MSVC warnings on integer casts truncating values
+              fix accidental rename of 'skip' field of I/O
+      1.37  (2014-06-04)
+              remove duplicate typedef
+      1.36  (2014-06-03)
+              convert to header file single-file library
+              if de-iphone isn't set, load iphone images color-swapped instead of returning NULL
+      1.35  (2014-05-27)
+              various warnings
+              fix broken STBI_SIMD path
+              fix bug where stbi_load_from_file no longer left file pointer in correct place
+              fix broken non-easy path for 32-bit BMP (possibly never used)
+              TGA optimization by Arseny Kapoulkine
+      1.34  (unknown)
+              use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case
+      1.33  (2011-07-14)
+              make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements
+      1.32  (2011-07-13)
+              support for "info" function for all supported filetypes (SpartanJ)
+      1.31  (2011-06-20)
+              a few more leak fixes, bug in PNG handling (SpartanJ)
+      1.30  (2011-06-11)
+              added ability to load files via callbacks to accomidate custom input streams (Ben Wenger)
+              removed deprecated format-specific test/load functions
+              removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway
+              error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha)
+              fix inefficiency in decoding 32-bit BMP (David Woo)
+      1.29  (2010-08-16)
+              various warning fixes from Aurelien Pocheville
+      1.28  (2010-08-01)
+              fix bug in GIF palette transparency (SpartanJ)
+      1.27  (2010-08-01)
+              cast-to-stbi_uc to fix warnings
+      1.26  (2010-07-24)
+              fix bug in file buffering for PNG reported by SpartanJ
+      1.25  (2010-07-17)
+              refix trans_data warning (Won Chun)
+      1.24  (2010-07-12)
+              perf improvements reading from files on platforms with lock-heavy fgetc()
+              minor perf improvements for jpeg
+              deprecated type-specific functions so we'll get feedback if they're needed
+              attempt to fix trans_data warning (Won Chun)
+      1.23    fixed bug in iPhone support
+      1.22  (2010-07-10)
+              removed image *writing* support
+              stbi_info support from Jetro Lauha
+              GIF support from Jean-Marc Lienher
+              iPhone PNG-extensions from James Brown
+              warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva)
+      1.21    fix use of 'stbi_uc' in header (reported by jon blow)
+      1.20    added support for Softimage PIC, by Tom Seddon
+      1.19    bug in interlaced PNG corruption check (found by ryg)
+      1.18  (2008-08-02)
+              fix a threading bug (local mutable static)
+      1.17    support interlaced PNG
+      1.16    major bugfix - stbi__convert_format converted one too many pixels
+      1.15    initialize some fields for thread safety
+      1.14    fix threadsafe conversion bug
+              header-file-only version (#define STBI_HEADER_FILE_ONLY before including)
+      1.13    threadsafe
+      1.12    const qualifiers in the API
+      1.11    Support installable IDCT, colorspace conversion routines
+      1.10    Fixes for 64-bit (don't use "unsigned long")
+              optimized upsampling by Fabian "ryg" Giesen
+      1.09    Fix format-conversion for PSD code (bad global variables!)
+      1.08    Thatcher Ulrich's PSD code integrated by Nicolas Schulz
+      1.07    attempt to fix C++ warning/errors again
+      1.06    attempt to fix C++ warning/errors again
+      1.05    fix TGA loading to return correct *comp and use good luminance calc
+      1.04    default float alpha is 1, not 255; use 'void *' for stbi_image_free
+      1.03    bugfixes to STBI_NO_STDIO, STBI_NO_HDR
+      1.02    support for (subset of) HDR files, float interface for preferred access to them
+      1.01    fix bug: possible bug in handling right-side up bmps... not sure
+              fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all
+      1.00    interface to zlib that skips zlib header
+      0.99    correct handling of alpha in palette
+      0.98    TGA loader by lonesock; dynamically add loaders (untested)
+      0.97    jpeg errors on too large a file; also catch another malloc failure
+      0.96    fix detection of invalid v value - particleman@mollyrocket forum
+      0.95    during header scan, seek to markers in case of padding
+      0.94    STBI_NO_STDIO to disable stdio usage; rename all #defines the same
+      0.93    handle jpegtran output; verbose errors
+      0.92    read 4,8,16,24,32-bit BMP files of several formats
+      0.91    output 24-bit Windows 3.0 BMP files
+      0.90    fix a few more warnings; bump version number to approach 1.0
+      0.61    bugfixes due to Marc LeBlanc, Christopher Lloyd
+      0.60    fix compiling as c++
+      0.59    fix warnings: merge Dave Moore's -Wall fixes
+      0.58    fix bug: zlib uncompressed mode len/nlen was wrong endian
+      0.57    fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available
+      0.56    fix bug: zlib uncompressed mode len vs. nlen
+      0.55    fix bug: restart_interval not initialized to 0
+      0.54    allow NULL for 'int *comp'
+      0.53    fix bug in png 3->4; speedup png decoding
+      0.52    png handles req_comp=3,4 directly; minor cleanup; jpeg comments
+      0.51    obey req_comp requests, 1-component jpegs return as 1-component,
+              on 'test' only check type, not whether we support this variant
+      0.50  (2006-11-19)
+              first released version
+*/
+
+
+/*
+------------------------------------------------------------------------------
+This software is available under 2 licenses -- choose whichever you prefer.
+------------------------------------------------------------------------------
+ALTERNATIVE A - MIT License
+Copyright (c) 2017 Sean Barrett
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+------------------------------------------------------------------------------
+ALTERNATIVE B - Public Domain (www.unlicense.org)
+This is free and unencumbered software released into the public domain.
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
+software, either in source code form or as a compiled binary, for any purpose,
+commercial or non-commercial, and by any means.
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and to
+the detriment of our heirs and successors. We intend this dedication to be an
+overt act of relinquishment in perpetuity of all present and future rights to
+this software under copyright law.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+------------------------------------------------------------------------------
+*/
+
ADD · third-party/volk.c +4285 -0
--- a/third-party/volk.c
+++ b/third-party/volk.c
@@ -0,0 +1,4285 @@
+
+/* This file is part of volk library; see volk.h for version/license details */
+/* clang-format off */
+#include "volk.h"
+
+#ifdef _WIN32
+	typedef const char* LPCSTR;
+	typedef struct HINSTANCE__* HINSTANCE;
+	typedef HINSTANCE HMODULE;
+	#if defined(_MINWINDEF_)
+		/* minwindef.h defines FARPROC, and attempting to redefine it may conflict with -Wstrict-prototypes */
+	#elif defined(_WIN64)
+		typedef __int64 (__stdcall* FARPROC)(void);
+	#else
+		typedef int (__stdcall* FARPROC)(void);
+	#endif
+#else
+#	include <dlfcn.h>
+#endif
+
+#ifdef __APPLE__
+#	include <stdlib.h>
+#endif
+
+#include <string.h>
+
+#ifdef _WIN32
+#ifdef __cplusplus
+extern "C" {
+#endif
+__declspec(dllimport) HMODULE __stdcall LoadLibraryA(LPCSTR);
+__declspec(dllimport) FARPROC __stdcall GetProcAddress(HMODULE, LPCSTR);
+__declspec(dllimport) int __stdcall FreeLibrary(HMODULE);
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#ifdef __cplusplus
+#ifdef VOLK_NAMESPACE
+namespace volk {
+#else
+extern "C" {
+#endif
+#endif
+
+#if defined(__GNUC__)
+#    define VOLK_DISABLE_GCC_PEDANTIC_WARNINGS \
+		_Pragma("GCC diagnostic push") \
+		_Pragma("GCC diagnostic ignored \"-Wpedantic\"")
+#    define VOLK_RESTORE_GCC_PEDANTIC_WARNINGS \
+		_Pragma("GCC diagnostic pop")
+#else
+#    define VOLK_DISABLE_GCC_PEDANTIC_WARNINGS
+#    define VOLK_RESTORE_GCC_PEDANTIC_WARNINGS
+#endif
+
+static void* loadedModule = NULL;
+static VkInstance loadedInstance = VK_NULL_HANDLE;
+static VkDevice loadedDevice = VK_NULL_HANDLE;
+
+static void volkGenLoadLoader(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
+static void volkGenLoadInstance(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
+static void volkGenLoadInstanceTable(struct VolkInstanceTable* table, void* context, PFN_vkVoidFunction (*load)(void*, const char*));
+static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, const char*));
+static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context, PFN_vkVoidFunction (*load)(void*, const char*));
+
+static PFN_vkVoidFunction vkGetInstanceProcAddrStub(void* context, const char* name)
+{
+	return vkGetInstanceProcAddr((VkInstance)context, name);
+}
+
+static PFN_vkVoidFunction vkGetDeviceProcAddrStub(void* context, const char* name)
+{
+	return vkGetDeviceProcAddr((VkDevice)context, name);
+}
+
+static PFN_vkVoidFunction nullProcAddrStub(void* context, const char* name)
+{
+	(void)context;
+	(void)name;
+	return NULL;
+}
+
+VkResult volkInitialize(void)
+{
+#if defined(_WIN32)
+	HMODULE module = LoadLibraryA("vulkan-1.dll");
+	if (!module)
+		return VK_ERROR_INITIALIZATION_FAILED;
+
+	// note: function pointer is cast through void function pointer to silence cast-function-type warning on gcc8
+	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)(void(*)(void))GetProcAddress(module, "vkGetInstanceProcAddr");
+#elif defined(__APPLE__)
+	void* module = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		module = dlopen("libvulkan.1.dylib", RTLD_NOW | RTLD_LOCAL);
+	// modern versions of macOS don't search /usr/local/lib automatically contrary to what man dlopen says
+	// Vulkan SDK uses this as the system-wide installation location, so we're going to fallback to this if all else fails
+	if (!module && getenv("DYLD_FALLBACK_LIBRARY_PATH") == NULL)
+		module = dlopen("/usr/local/lib/libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		module = dlopen("libMoltenVK.dylib", RTLD_NOW | RTLD_LOCAL);
+	// Add support for using Vulkan and MoltenVK in a Framework. App store rules for iOS
+	// strictly enforce no .dylib's. If they aren't found it just falls through
+	if (!module)
+		module = dlopen("vulkan.framework/vulkan", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		module = dlopen("MoltenVK.framework/MoltenVK", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		return VK_ERROR_INITIALIZATION_FAILED;
+
+	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
+#elif defined(__ANDROID__)
+	void* module = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		module = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
+	if (!module)
+		return VK_ERROR_INITIALIZATION_FAILED;
+	VOLK_DISABLE_GCC_PEDANTIC_WARNINGS
+	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
+	VOLK_RESTORE_GCC_PEDANTIC_WARNINGS
+#else
+	int flags = RTLD_NOW | RTLD_LOCAL;
+#ifdef VOLK_USE_DEEPBIND
+	flags |= RTLD_DEEPBIND; // Prevent libvulkan.so from resolving Vulkan symbols via volk's own exports
+#endif
+	void* module = dlopen("libvulkan.so.1", flags);
+	if (!module)
+		module = dlopen("libvulkan.so", flags);
+	if (!module)
+		return VK_ERROR_INITIALIZATION_FAILED;
+	VOLK_DISABLE_GCC_PEDANTIC_WARNINGS
+	vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(module, "vkGetInstanceProcAddr");
+	VOLK_RESTORE_GCC_PEDANTIC_WARNINGS
+#endif
+
+	loadedModule = module;
+	volkGenLoadLoader(NULL, vkGetInstanceProcAddrStub);
+
+	return VK_SUCCESS;
+}
+
+void volkInitializeCustom(PFN_vkGetInstanceProcAddr handler)
+{
+	vkGetInstanceProcAddr = handler;
+
+	loadedModule = NULL;
+	volkGenLoadLoader(NULL, vkGetInstanceProcAddrStub);
+}
+
+void volkFinalize(void)
+{
+	if (loadedModule)
+	{
+#if defined(_WIN32)
+		FreeLibrary((HMODULE)loadedModule);
+#else
+		dlclose(loadedModule);
+#endif
+	}
+
+	vkGetInstanceProcAddr = NULL;
+	volkGenLoadLoader(NULL, nullProcAddrStub);
+	volkGenLoadInstance(NULL, nullProcAddrStub);
+	volkGenLoadDevice(NULL, nullProcAddrStub);
+
+	loadedModule = NULL;
+	loadedInstance = VK_NULL_HANDLE;
+	loadedDevice = VK_NULL_HANDLE;
+}
+
+uint32_t volkGetInstanceVersion(void)
+{
+#if defined(VK_VERSION_1_1)
+	uint32_t apiVersion = 0;
+	if (vkEnumerateInstanceVersion && vkEnumerateInstanceVersion(&apiVersion) == VK_SUCCESS)
+		return apiVersion;
+#endif
+
+	if (vkCreateInstance)
+		return VK_API_VERSION_1_0;
+
+	return 0;
+}
+
+void volkLoadInstance(VkInstance instance)
+{
+	loadedInstance = instance;
+	volkGenLoadInstance(instance, vkGetInstanceProcAddrStub);
+	volkGenLoadDevice(instance, vkGetInstanceProcAddrStub);
+}
+
+void volkLoadInstanceOnly(VkInstance instance)
+{
+	loadedInstance = instance;
+	volkGenLoadInstance(instance, vkGetInstanceProcAddrStub);
+}
+
+VkInstance volkGetLoadedInstance(void)
+{
+	return loadedInstance;
+}
+
+void volkLoadDevice(VkDevice device)
+{
+	loadedDevice = device;
+	volkGenLoadDevice(device, vkGetDeviceProcAddrStub);
+}
+
+VkDevice volkGetLoadedDevice(void)
+{
+	return loadedDevice;
+}
+
+void volkLoadInstanceTable(struct VolkInstanceTable* table, VkInstance instance)
+{
+	/* vkGetDeviceProcAddr is used by volkLoadDeviceTable; for now we load this global pointer even though it might be instance-specific */
+	vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(instance, "vkGetDeviceProcAddr");
+
+	memset(table, 0, sizeof(*table));
+	volkGenLoadInstanceTable(table, instance, vkGetInstanceProcAddrStub);
+}
+
+void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device)
+{
+	memset(table, 0, sizeof(*table));
+	volkGenLoadDeviceTable(table, device, vkGetDeviceProcAddrStub);
+}
+
+static void volkGenLoadLoader(void* context, PFN_vkVoidFunction (*load)(void*, const char*))
+{
+	/* VOLK_GENERATE_LOAD_LOADER */
+#if defined(VK_VERSION_1_0)
+	vkCreateInstance = (PFN_vkCreateInstance)load(context, "vkCreateInstance");
+	vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)load(context, "vkEnumerateInstanceExtensionProperties");
+	vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties)load(context, "vkEnumerateInstanceLayerProperties");
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)load(context, "vkEnumerateInstanceVersion");
+#endif /* defined(VK_VERSION_1_1) */
+	/* VOLK_GENERATE_LOAD_LOADER */
+}
+
+static void volkGenLoadInstance(void* context, PFN_vkVoidFunction (*load)(void*, const char*))
+{
+	/* VOLK_GENERATE_LOAD_INSTANCE */
+#if defined(VK_VERSION_1_0)
+	vkCreateDevice = (PFN_vkCreateDevice)load(context, "vkCreateDevice");
+	vkDestroyInstance = (PFN_vkDestroyInstance)load(context, "vkDestroyInstance");
+	vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties)load(context, "vkEnumerateDeviceExtensionProperties");
+	vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties)load(context, "vkEnumerateDeviceLayerProperties");
+	vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)load(context, "vkEnumeratePhysicalDevices");
+	vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)load(context, "vkGetDeviceProcAddr");
+	vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures)load(context, "vkGetPhysicalDeviceFeatures");
+	vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties)load(context, "vkGetPhysicalDeviceFormatProperties");
+	vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties)load(context, "vkGetPhysicalDeviceImageFormatProperties");
+	vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties)load(context, "vkGetPhysicalDeviceMemoryProperties");
+	vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)load(context, "vkGetPhysicalDeviceProperties");
+	vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties)load(context, "vkGetPhysicalDeviceQueueFamilyProperties");
+	vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties");
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups)load(context, "vkEnumeratePhysicalDeviceGroups");
+	vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties)load(context, "vkGetPhysicalDeviceExternalBufferProperties");
+	vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties)load(context, "vkGetPhysicalDeviceExternalFenceProperties");
+	vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)load(context, "vkGetPhysicalDeviceExternalSemaphoreProperties");
+	vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2)load(context, "vkGetPhysicalDeviceFeatures2");
+	vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2)load(context, "vkGetPhysicalDeviceFormatProperties2");
+	vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2)load(context, "vkGetPhysicalDeviceImageFormatProperties2");
+	vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2)load(context, "vkGetPhysicalDeviceMemoryProperties2");
+	vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2)load(context, "vkGetPhysicalDeviceProperties2");
+	vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2)load(context, "vkGetPhysicalDeviceQueueFamilyProperties2");
+	vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties2");
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_3)
+	vkGetPhysicalDeviceToolProperties = (PFN_vkGetPhysicalDeviceToolProperties)load(context, "vkGetPhysicalDeviceToolProperties");
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_ARM_data_graph)
+	vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM");
+	vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM");
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_data_graph_optical_flow)
+	vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM");
+#endif /* defined(VK_ARM_data_graph_optical_flow) */
+#if defined(VK_ARM_performance_counters_by_region)
+	vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM = (PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM)load(context, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM");
+#endif /* defined(VK_ARM_performance_counters_by_region) */
+#if defined(VK_ARM_shader_instrumentation)
+	vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM = (PFN_vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM)load(context, "vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM");
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	vkGetPhysicalDeviceExternalTensorPropertiesARM = (PFN_vkGetPhysicalDeviceExternalTensorPropertiesARM)load(context, "vkGetPhysicalDeviceExternalTensorPropertiesARM");
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_EXT_acquire_drm_display)
+	vkAcquireDrmDisplayEXT = (PFN_vkAcquireDrmDisplayEXT)load(context, "vkAcquireDrmDisplayEXT");
+	vkGetDrmDisplayEXT = (PFN_vkGetDrmDisplayEXT)load(context, "vkGetDrmDisplayEXT");
+#endif /* defined(VK_EXT_acquire_drm_display) */
+#if defined(VK_EXT_acquire_xlib_display)
+	vkAcquireXlibDisplayEXT = (PFN_vkAcquireXlibDisplayEXT)load(context, "vkAcquireXlibDisplayEXT");
+	vkGetRandROutputDisplayEXT = (PFN_vkGetRandROutputDisplayEXT)load(context, "vkGetRandROutputDisplayEXT");
+#endif /* defined(VK_EXT_acquire_xlib_display) */
+#if defined(VK_EXT_calibrated_timestamps)
+	vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)load(context, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT");
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_cooperative_matrix_maintenance1)
+	vkGetPhysicalDeviceCooperativeMatrixProperties2EXT = (PFN_vkGetPhysicalDeviceCooperativeMatrixProperties2EXT)load(context, "vkGetPhysicalDeviceCooperativeMatrixProperties2EXT");
+#endif /* defined(VK_EXT_cooperative_matrix_maintenance1) */
+#if defined(VK_EXT_debug_report)
+	vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)load(context, "vkCreateDebugReportCallbackEXT");
+	vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT)load(context, "vkDebugReportMessageEXT");
+	vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)load(context, "vkDestroyDebugReportCallbackEXT");
+#endif /* defined(VK_EXT_debug_report) */
+#if defined(VK_EXT_debug_utils)
+	vkCmdBeginDebugUtilsLabelEXT = (PFN_vkCmdBeginDebugUtilsLabelEXT)load(context, "vkCmdBeginDebugUtilsLabelEXT");
+	vkCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)load(context, "vkCmdEndDebugUtilsLabelEXT");
+	vkCmdInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT)load(context, "vkCmdInsertDebugUtilsLabelEXT");
+	vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)load(context, "vkCreateDebugUtilsMessengerEXT");
+	vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT)load(context, "vkDestroyDebugUtilsMessengerEXT");
+	vkQueueBeginDebugUtilsLabelEXT = (PFN_vkQueueBeginDebugUtilsLabelEXT)load(context, "vkQueueBeginDebugUtilsLabelEXT");
+	vkQueueEndDebugUtilsLabelEXT = (PFN_vkQueueEndDebugUtilsLabelEXT)load(context, "vkQueueEndDebugUtilsLabelEXT");
+	vkQueueInsertDebugUtilsLabelEXT = (PFN_vkQueueInsertDebugUtilsLabelEXT)load(context, "vkQueueInsertDebugUtilsLabelEXT");
+	vkSetDebugUtilsObjectNameEXT = (PFN_vkSetDebugUtilsObjectNameEXT)load(context, "vkSetDebugUtilsObjectNameEXT");
+	vkSetDebugUtilsObjectTagEXT = (PFN_vkSetDebugUtilsObjectTagEXT)load(context, "vkSetDebugUtilsObjectTagEXT");
+	vkSubmitDebugUtilsMessageEXT = (PFN_vkSubmitDebugUtilsMessageEXT)load(context, "vkSubmitDebugUtilsMessageEXT");
+#endif /* defined(VK_EXT_debug_utils) */
+#if defined(VK_EXT_descriptor_heap)
+	vkGetPhysicalDeviceDescriptorSizeEXT = (PFN_vkGetPhysicalDeviceDescriptorSizeEXT)load(context, "vkGetPhysicalDeviceDescriptorSizeEXT");
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_direct_mode_display)
+	vkReleaseDisplayEXT = (PFN_vkReleaseDisplayEXT)load(context, "vkReleaseDisplayEXT");
+#endif /* defined(VK_EXT_direct_mode_display) */
+#if defined(VK_EXT_directfb_surface)
+	vkCreateDirectFBSurfaceEXT = (PFN_vkCreateDirectFBSurfaceEXT)load(context, "vkCreateDirectFBSurfaceEXT");
+	vkGetPhysicalDeviceDirectFBPresentationSupportEXT = (PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)load(context, "vkGetPhysicalDeviceDirectFBPresentationSupportEXT");
+#endif /* defined(VK_EXT_directfb_surface) */
+#if defined(VK_EXT_display_surface_counter)
+	vkGetPhysicalDeviceSurfaceCapabilities2EXT = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)load(context, "vkGetPhysicalDeviceSurfaceCapabilities2EXT");
+#endif /* defined(VK_EXT_display_surface_counter) */
+#if defined(VK_EXT_full_screen_exclusive)
+	vkGetPhysicalDeviceSurfacePresentModes2EXT = (PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)load(context, "vkGetPhysicalDeviceSurfacePresentModes2EXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_headless_surface)
+	vkCreateHeadlessSurfaceEXT = (PFN_vkCreateHeadlessSurfaceEXT)load(context, "vkCreateHeadlessSurfaceEXT");
+#endif /* defined(VK_EXT_headless_surface) */
+#if defined(VK_EXT_metal_surface)
+	vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)load(context, "vkCreateMetalSurfaceEXT");
+#endif /* defined(VK_EXT_metal_surface) */
+#if defined(VK_EXT_sample_locations)
+	vkGetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)load(context, "vkGetPhysicalDeviceMultisamplePropertiesEXT");
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_tooling_info)
+	vkGetPhysicalDeviceToolPropertiesEXT = (PFN_vkGetPhysicalDeviceToolPropertiesEXT)load(context, "vkGetPhysicalDeviceToolPropertiesEXT");
+#endif /* defined(VK_EXT_tooling_info) */
+#if defined(VK_FUCHSIA_imagepipe_surface)
+	vkCreateImagePipeSurfaceFUCHSIA = (PFN_vkCreateImagePipeSurfaceFUCHSIA)load(context, "vkCreateImagePipeSurfaceFUCHSIA");
+#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
+#if defined(VK_GGP_stream_descriptor_surface)
+	vkCreateStreamDescriptorSurfaceGGP = (PFN_vkCreateStreamDescriptorSurfaceGGP)load(context, "vkCreateStreamDescriptorSurfaceGGP");
+#endif /* defined(VK_GGP_stream_descriptor_surface) */
+#if defined(VK_KHR_android_surface)
+	vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)load(context, "vkCreateAndroidSurfaceKHR");
+#endif /* defined(VK_KHR_android_surface) */
+#if defined(VK_KHR_calibrated_timestamps)
+	vkGetPhysicalDeviceCalibrateableTimeDomainsKHR = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR)load(context, "vkGetPhysicalDeviceCalibrateableTimeDomainsKHR");
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_cooperative_matrix)
+	vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR)load(context, "vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR");
+#endif /* defined(VK_KHR_cooperative_matrix) */
+#if defined(VK_KHR_device_group_creation)
+	vkEnumeratePhysicalDeviceGroupsKHR = (PFN_vkEnumeratePhysicalDeviceGroupsKHR)load(context, "vkEnumeratePhysicalDeviceGroupsKHR");
+#endif /* defined(VK_KHR_device_group_creation) */
+#if defined(VK_KHR_display)
+	vkCreateDisplayModeKHR = (PFN_vkCreateDisplayModeKHR)load(context, "vkCreateDisplayModeKHR");
+	vkCreateDisplayPlaneSurfaceKHR = (PFN_vkCreateDisplayPlaneSurfaceKHR)load(context, "vkCreateDisplayPlaneSurfaceKHR");
+	vkGetDisplayModePropertiesKHR = (PFN_vkGetDisplayModePropertiesKHR)load(context, "vkGetDisplayModePropertiesKHR");
+	vkGetDisplayPlaneCapabilitiesKHR = (PFN_vkGetDisplayPlaneCapabilitiesKHR)load(context, "vkGetDisplayPlaneCapabilitiesKHR");
+	vkGetDisplayPlaneSupportedDisplaysKHR = (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)load(context, "vkGetDisplayPlaneSupportedDisplaysKHR");
+	vkGetPhysicalDeviceDisplayPlanePropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)load(context, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
+	vkGetPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)load(context, "vkGetPhysicalDeviceDisplayPropertiesKHR");
+#endif /* defined(VK_KHR_display) */
+#if defined(VK_KHR_external_fence_capabilities)
+	vkGetPhysicalDeviceExternalFencePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)load(context, "vkGetPhysicalDeviceExternalFencePropertiesKHR");
+#endif /* defined(VK_KHR_external_fence_capabilities) */
+#if defined(VK_KHR_external_memory_capabilities)
+	vkGetPhysicalDeviceExternalBufferPropertiesKHR = (PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)load(context, "vkGetPhysicalDeviceExternalBufferPropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_capabilities) */
+#if defined(VK_KHR_external_semaphore_capabilities)
+	vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)load(context, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR");
+#endif /* defined(VK_KHR_external_semaphore_capabilities) */
+#if defined(VK_KHR_fragment_shading_rate)
+	vkGetPhysicalDeviceFragmentShadingRatesKHR = (PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR)load(context, "vkGetPhysicalDeviceFragmentShadingRatesKHR");
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_display_properties2)
+	vkGetDisplayModeProperties2KHR = (PFN_vkGetDisplayModeProperties2KHR)load(context, "vkGetDisplayModeProperties2KHR");
+	vkGetDisplayPlaneCapabilities2KHR = (PFN_vkGetDisplayPlaneCapabilities2KHR)load(context, "vkGetDisplayPlaneCapabilities2KHR");
+	vkGetPhysicalDeviceDisplayPlaneProperties2KHR = (PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR)load(context, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR");
+	vkGetPhysicalDeviceDisplayProperties2KHR = (PFN_vkGetPhysicalDeviceDisplayProperties2KHR)load(context, "vkGetPhysicalDeviceDisplayProperties2KHR");
+#endif /* defined(VK_KHR_get_display_properties2) */
+#if defined(VK_KHR_get_physical_device_properties2)
+	vkGetPhysicalDeviceFeatures2KHR = (PFN_vkGetPhysicalDeviceFeatures2KHR)load(context, "vkGetPhysicalDeviceFeatures2KHR");
+	vkGetPhysicalDeviceFormatProperties2KHR = (PFN_vkGetPhysicalDeviceFormatProperties2KHR)load(context, "vkGetPhysicalDeviceFormatProperties2KHR");
+	vkGetPhysicalDeviceImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)load(context, "vkGetPhysicalDeviceImageFormatProperties2KHR");
+	vkGetPhysicalDeviceMemoryProperties2KHR = (PFN_vkGetPhysicalDeviceMemoryProperties2KHR)load(context, "vkGetPhysicalDeviceMemoryProperties2KHR");
+	vkGetPhysicalDeviceProperties2KHR = (PFN_vkGetPhysicalDeviceProperties2KHR)load(context, "vkGetPhysicalDeviceProperties2KHR");
+	vkGetPhysicalDeviceQueueFamilyProperties2KHR = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)load(context, "vkGetPhysicalDeviceQueueFamilyProperties2KHR");
+	vkGetPhysicalDeviceSparseImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR");
+#endif /* defined(VK_KHR_get_physical_device_properties2) */
+#if defined(VK_KHR_get_surface_capabilities2)
+	vkGetPhysicalDeviceSurfaceCapabilities2KHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilities2KHR");
+	vkGetPhysicalDeviceSurfaceFormats2KHR = (PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)load(context, "vkGetPhysicalDeviceSurfaceFormats2KHR");
+#endif /* defined(VK_KHR_get_surface_capabilities2) */
+#if defined(VK_KHR_performance_query)
+	vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = (PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)load(context, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR");
+	vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = (PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR)load(context, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR");
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_surface)
+	vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)load(context, "vkDestroySurfaceKHR");
+	vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
+	vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)load(context, "vkGetPhysicalDeviceSurfaceFormatsKHR");
+	vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)load(context, "vkGetPhysicalDeviceSurfacePresentModesKHR");
+	vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)load(context, "vkGetPhysicalDeviceSurfaceSupportKHR");
+#endif /* defined(VK_KHR_surface) */
+#if defined(VK_KHR_video_encode_queue)
+	vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR = (PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR)load(context, "vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR");
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	vkGetPhysicalDeviceVideoCapabilitiesKHR = (PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)load(context, "vkGetPhysicalDeviceVideoCapabilitiesKHR");
+	vkGetPhysicalDeviceVideoFormatPropertiesKHR = (PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)load(context, "vkGetPhysicalDeviceVideoFormatPropertiesKHR");
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_KHR_wayland_surface)
+	vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)load(context, "vkCreateWaylandSurfaceKHR");
+	vkGetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)load(context, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif /* defined(VK_KHR_wayland_surface) */
+#if defined(VK_KHR_win32_surface)
+	vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)load(context, "vkCreateWin32SurfaceKHR");
+	vkGetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)load(context, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
+#endif /* defined(VK_KHR_win32_surface) */
+#if defined(VK_KHR_xcb_surface)
+	vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)load(context, "vkCreateXcbSurfaceKHR");
+	vkGetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)load(context, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+#endif /* defined(VK_KHR_xcb_surface) */
+#if defined(VK_KHR_xlib_surface)
+	vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)load(context, "vkCreateXlibSurfaceKHR");
+	vkGetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)load(context, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif /* defined(VK_KHR_xlib_surface) */
+#if defined(VK_MVK_ios_surface)
+	vkCreateIOSSurfaceMVK = (PFN_vkCreateIOSSurfaceMVK)load(context, "vkCreateIOSSurfaceMVK");
+#endif /* defined(VK_MVK_ios_surface) */
+#if defined(VK_MVK_macos_surface)
+	vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)load(context, "vkCreateMacOSSurfaceMVK");
+#endif /* defined(VK_MVK_macos_surface) */
+#if defined(VK_NN_vi_surface)
+	vkCreateViSurfaceNN = (PFN_vkCreateViSurfaceNN)load(context, "vkCreateViSurfaceNN");
+#endif /* defined(VK_NN_vi_surface) */
+#if defined(VK_NV_acquire_winrt_display)
+	vkAcquireWinrtDisplayNV = (PFN_vkAcquireWinrtDisplayNV)load(context, "vkAcquireWinrtDisplayNV");
+	vkGetWinrtDisplayNV = (PFN_vkGetWinrtDisplayNV)load(context, "vkGetWinrtDisplayNV");
+#endif /* defined(VK_NV_acquire_winrt_display) */
+#if defined(VK_NV_cooperative_matrix)
+	vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV");
+#endif /* defined(VK_NV_cooperative_matrix) */
+#if defined(VK_NV_cooperative_matrix2)
+	vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV");
+#endif /* defined(VK_NV_cooperative_matrix2) */
+#if defined(VK_NV_cooperative_vector)
+	vkGetPhysicalDeviceCooperativeVectorPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeVectorPropertiesNV");
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_coverage_reduction_mode)
+	vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = (PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)load(context, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV");
+#endif /* defined(VK_NV_coverage_reduction_mode) */
+#if defined(VK_NV_external_memory_capabilities)
+	vkGetPhysicalDeviceExternalImageFormatPropertiesNV = (PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)load(context, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV");
+#endif /* defined(VK_NV_external_memory_capabilities) */
+#if defined(VK_NV_optical_flow)
+	vkGetPhysicalDeviceOpticalFlowImageFormatsNV = (PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV)load(context, "vkGetPhysicalDeviceOpticalFlowImageFormatsNV");
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_OHOS_surface)
+	vkCreateSurfaceOHOS = (PFN_vkCreateSurfaceOHOS)load(context, "vkCreateSurfaceOHOS");
+#endif /* defined(VK_OHOS_surface) */
+#if defined(VK_QNX_screen_surface)
+	vkCreateScreenSurfaceQNX = (PFN_vkCreateScreenSurfaceQNX)load(context, "vkCreateScreenSurfaceQNX");
+	vkGetPhysicalDeviceScreenPresentationSupportQNX = (PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX)load(context, "vkGetPhysicalDeviceScreenPresentationSupportQNX");
+#endif /* defined(VK_QNX_screen_surface) */
+#if defined(VK_SEC_ubm_surface)
+	vkCreateUbmSurfaceSEC = (PFN_vkCreateUbmSurfaceSEC)load(context, "vkCreateUbmSurfaceSEC");
+	vkGetPhysicalDeviceUbmPresentationSupportSEC = (PFN_vkGetPhysicalDeviceUbmPresentationSupportSEC)load(context, "vkGetPhysicalDeviceUbmPresentationSupportSEC");
+#endif /* defined(VK_SEC_ubm_surface) */
+#if (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow))
+	vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM");
+#endif /* (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR)load(context, "vkGetPhysicalDevicePresentRectanglesKHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_LOAD_INSTANCE */
+}
+
+static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, const char*))
+{
+	/* VOLK_GENERATE_LOAD_DEVICE */
+#if defined(VK_VERSION_1_0)
+	vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers)load(context, "vkAllocateCommandBuffers");
+	vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets)load(context, "vkAllocateDescriptorSets");
+	vkAllocateMemory = (PFN_vkAllocateMemory)load(context, "vkAllocateMemory");
+	vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer)load(context, "vkBeginCommandBuffer");
+	vkBindBufferMemory = (PFN_vkBindBufferMemory)load(context, "vkBindBufferMemory");
+	vkBindImageMemory = (PFN_vkBindImageMemory)load(context, "vkBindImageMemory");
+	vkCmdBeginQuery = (PFN_vkCmdBeginQuery)load(context, "vkCmdBeginQuery");
+	vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass)load(context, "vkCmdBeginRenderPass");
+	vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets)load(context, "vkCmdBindDescriptorSets");
+	vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer)load(context, "vkCmdBindIndexBuffer");
+	vkCmdBindPipeline = (PFN_vkCmdBindPipeline)load(context, "vkCmdBindPipeline");
+	vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers)load(context, "vkCmdBindVertexBuffers");
+	vkCmdBlitImage = (PFN_vkCmdBlitImage)load(context, "vkCmdBlitImage");
+	vkCmdClearAttachments = (PFN_vkCmdClearAttachments)load(context, "vkCmdClearAttachments");
+	vkCmdClearColorImage = (PFN_vkCmdClearColorImage)load(context, "vkCmdClearColorImage");
+	vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage)load(context, "vkCmdClearDepthStencilImage");
+	vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer)load(context, "vkCmdCopyBuffer");
+	vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage)load(context, "vkCmdCopyBufferToImage");
+	vkCmdCopyImage = (PFN_vkCmdCopyImage)load(context, "vkCmdCopyImage");
+	vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer)load(context, "vkCmdCopyImageToBuffer");
+	vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults)load(context, "vkCmdCopyQueryPoolResults");
+	vkCmdDispatch = (PFN_vkCmdDispatch)load(context, "vkCmdDispatch");
+	vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect)load(context, "vkCmdDispatchIndirect");
+	vkCmdDraw = (PFN_vkCmdDraw)load(context, "vkCmdDraw");
+	vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed)load(context, "vkCmdDrawIndexed");
+	vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect)load(context, "vkCmdDrawIndexedIndirect");
+	vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect)load(context, "vkCmdDrawIndirect");
+	vkCmdEndQuery = (PFN_vkCmdEndQuery)load(context, "vkCmdEndQuery");
+	vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass)load(context, "vkCmdEndRenderPass");
+	vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands)load(context, "vkCmdExecuteCommands");
+	vkCmdFillBuffer = (PFN_vkCmdFillBuffer)load(context, "vkCmdFillBuffer");
+	vkCmdNextSubpass = (PFN_vkCmdNextSubpass)load(context, "vkCmdNextSubpass");
+	vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier)load(context, "vkCmdPipelineBarrier");
+	vkCmdPushConstants = (PFN_vkCmdPushConstants)load(context, "vkCmdPushConstants");
+	vkCmdResetEvent = (PFN_vkCmdResetEvent)load(context, "vkCmdResetEvent");
+	vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool)load(context, "vkCmdResetQueryPool");
+	vkCmdResolveImage = (PFN_vkCmdResolveImage)load(context, "vkCmdResolveImage");
+	vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants)load(context, "vkCmdSetBlendConstants");
+	vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias)load(context, "vkCmdSetDepthBias");
+	vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds)load(context, "vkCmdSetDepthBounds");
+	vkCmdSetEvent = (PFN_vkCmdSetEvent)load(context, "vkCmdSetEvent");
+	vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth)load(context, "vkCmdSetLineWidth");
+	vkCmdSetScissor = (PFN_vkCmdSetScissor)load(context, "vkCmdSetScissor");
+	vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask)load(context, "vkCmdSetStencilCompareMask");
+	vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference)load(context, "vkCmdSetStencilReference");
+	vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask)load(context, "vkCmdSetStencilWriteMask");
+	vkCmdSetViewport = (PFN_vkCmdSetViewport)load(context, "vkCmdSetViewport");
+	vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer)load(context, "vkCmdUpdateBuffer");
+	vkCmdWaitEvents = (PFN_vkCmdWaitEvents)load(context, "vkCmdWaitEvents");
+	vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp)load(context, "vkCmdWriteTimestamp");
+	vkCreateBuffer = (PFN_vkCreateBuffer)load(context, "vkCreateBuffer");
+	vkCreateBufferView = (PFN_vkCreateBufferView)load(context, "vkCreateBufferView");
+	vkCreateCommandPool = (PFN_vkCreateCommandPool)load(context, "vkCreateCommandPool");
+	vkCreateComputePipelines = (PFN_vkCreateComputePipelines)load(context, "vkCreateComputePipelines");
+	vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool)load(context, "vkCreateDescriptorPool");
+	vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout)load(context, "vkCreateDescriptorSetLayout");
+	vkCreateEvent = (PFN_vkCreateEvent)load(context, "vkCreateEvent");
+	vkCreateFence = (PFN_vkCreateFence)load(context, "vkCreateFence");
+	vkCreateFramebuffer = (PFN_vkCreateFramebuffer)load(context, "vkCreateFramebuffer");
+	vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines)load(context, "vkCreateGraphicsPipelines");
+	vkCreateImage = (PFN_vkCreateImage)load(context, "vkCreateImage");
+	vkCreateImageView = (PFN_vkCreateImageView)load(context, "vkCreateImageView");
+	vkCreatePipelineCache = (PFN_vkCreatePipelineCache)load(context, "vkCreatePipelineCache");
+	vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout)load(context, "vkCreatePipelineLayout");
+	vkCreateQueryPool = (PFN_vkCreateQueryPool)load(context, "vkCreateQueryPool");
+	vkCreateRenderPass = (PFN_vkCreateRenderPass)load(context, "vkCreateRenderPass");
+	vkCreateSampler = (PFN_vkCreateSampler)load(context, "vkCreateSampler");
+	vkCreateSemaphore = (PFN_vkCreateSemaphore)load(context, "vkCreateSemaphore");
+	vkCreateShaderModule = (PFN_vkCreateShaderModule)load(context, "vkCreateShaderModule");
+	vkDestroyBuffer = (PFN_vkDestroyBuffer)load(context, "vkDestroyBuffer");
+	vkDestroyBufferView = (PFN_vkDestroyBufferView)load(context, "vkDestroyBufferView");
+	vkDestroyCommandPool = (PFN_vkDestroyCommandPool)load(context, "vkDestroyCommandPool");
+	vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool)load(context, "vkDestroyDescriptorPool");
+	vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout)load(context, "vkDestroyDescriptorSetLayout");
+	vkDestroyDevice = (PFN_vkDestroyDevice)load(context, "vkDestroyDevice");
+	vkDestroyEvent = (PFN_vkDestroyEvent)load(context, "vkDestroyEvent");
+	vkDestroyFence = (PFN_vkDestroyFence)load(context, "vkDestroyFence");
+	vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer)load(context, "vkDestroyFramebuffer");
+	vkDestroyImage = (PFN_vkDestroyImage)load(context, "vkDestroyImage");
+	vkDestroyImageView = (PFN_vkDestroyImageView)load(context, "vkDestroyImageView");
+	vkDestroyPipeline = (PFN_vkDestroyPipeline)load(context, "vkDestroyPipeline");
+	vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache)load(context, "vkDestroyPipelineCache");
+	vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout)load(context, "vkDestroyPipelineLayout");
+	vkDestroyQueryPool = (PFN_vkDestroyQueryPool)load(context, "vkDestroyQueryPool");
+	vkDestroyRenderPass = (PFN_vkDestroyRenderPass)load(context, "vkDestroyRenderPass");
+	vkDestroySampler = (PFN_vkDestroySampler)load(context, "vkDestroySampler");
+	vkDestroySemaphore = (PFN_vkDestroySemaphore)load(context, "vkDestroySemaphore");
+	vkDestroyShaderModule = (PFN_vkDestroyShaderModule)load(context, "vkDestroyShaderModule");
+	vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle)load(context, "vkDeviceWaitIdle");
+	vkEndCommandBuffer = (PFN_vkEndCommandBuffer)load(context, "vkEndCommandBuffer");
+	vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges)load(context, "vkFlushMappedMemoryRanges");
+	vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers)load(context, "vkFreeCommandBuffers");
+	vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets)load(context, "vkFreeDescriptorSets");
+	vkFreeMemory = (PFN_vkFreeMemory)load(context, "vkFreeMemory");
+	vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)load(context, "vkGetBufferMemoryRequirements");
+	vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment)load(context, "vkGetDeviceMemoryCommitment");
+	vkGetDeviceQueue = (PFN_vkGetDeviceQueue)load(context, "vkGetDeviceQueue");
+	vkGetEventStatus = (PFN_vkGetEventStatus)load(context, "vkGetEventStatus");
+	vkGetFenceStatus = (PFN_vkGetFenceStatus)load(context, "vkGetFenceStatus");
+	vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)load(context, "vkGetImageMemoryRequirements");
+	vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements)load(context, "vkGetImageSparseMemoryRequirements");
+	vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout)load(context, "vkGetImageSubresourceLayout");
+	vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData)load(context, "vkGetPipelineCacheData");
+	vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults)load(context, "vkGetQueryPoolResults");
+	vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity)load(context, "vkGetRenderAreaGranularity");
+	vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges)load(context, "vkInvalidateMappedMemoryRanges");
+	vkMapMemory = (PFN_vkMapMemory)load(context, "vkMapMemory");
+	vkMergePipelineCaches = (PFN_vkMergePipelineCaches)load(context, "vkMergePipelineCaches");
+	vkQueueBindSparse = (PFN_vkQueueBindSparse)load(context, "vkQueueBindSparse");
+	vkQueueSubmit = (PFN_vkQueueSubmit)load(context, "vkQueueSubmit");
+	vkQueueWaitIdle = (PFN_vkQueueWaitIdle)load(context, "vkQueueWaitIdle");
+	vkResetCommandBuffer = (PFN_vkResetCommandBuffer)load(context, "vkResetCommandBuffer");
+	vkResetCommandPool = (PFN_vkResetCommandPool)load(context, "vkResetCommandPool");
+	vkResetDescriptorPool = (PFN_vkResetDescriptorPool)load(context, "vkResetDescriptorPool");
+	vkResetEvent = (PFN_vkResetEvent)load(context, "vkResetEvent");
+	vkResetFences = (PFN_vkResetFences)load(context, "vkResetFences");
+	vkSetEvent = (PFN_vkSetEvent)load(context, "vkSetEvent");
+	vkUnmapMemory = (PFN_vkUnmapMemory)load(context, "vkUnmapMemory");
+	vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets)load(context, "vkUpdateDescriptorSets");
+	vkWaitForFences = (PFN_vkWaitForFences)load(context, "vkWaitForFences");
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	vkBindBufferMemory2 = (PFN_vkBindBufferMemory2)load(context, "vkBindBufferMemory2");
+	vkBindImageMemory2 = (PFN_vkBindImageMemory2)load(context, "vkBindImageMemory2");
+	vkCmdDispatchBase = (PFN_vkCmdDispatchBase)load(context, "vkCmdDispatchBase");
+	vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask)load(context, "vkCmdSetDeviceMask");
+	vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate)load(context, "vkCreateDescriptorUpdateTemplate");
+	vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion)load(context, "vkCreateSamplerYcbcrConversion");
+	vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate)load(context, "vkDestroyDescriptorUpdateTemplate");
+	vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion)load(context, "vkDestroySamplerYcbcrConversion");
+	vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2)load(context, "vkGetBufferMemoryRequirements2");
+	vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport)load(context, "vkGetDescriptorSetLayoutSupport");
+	vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures)load(context, "vkGetDeviceGroupPeerMemoryFeatures");
+	vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2)load(context, "vkGetDeviceQueue2");
+	vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2)load(context, "vkGetImageMemoryRequirements2");
+	vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2)load(context, "vkGetImageSparseMemoryRequirements2");
+	vkTrimCommandPool = (PFN_vkTrimCommandPool)load(context, "vkTrimCommandPool");
+	vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate)load(context, "vkUpdateDescriptorSetWithTemplate");
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_2)
+	vkCmdBeginRenderPass2 = (PFN_vkCmdBeginRenderPass2)load(context, "vkCmdBeginRenderPass2");
+	vkCmdDrawIndexedIndirectCount = (PFN_vkCmdDrawIndexedIndirectCount)load(context, "vkCmdDrawIndexedIndirectCount");
+	vkCmdDrawIndirectCount = (PFN_vkCmdDrawIndirectCount)load(context, "vkCmdDrawIndirectCount");
+	vkCmdEndRenderPass2 = (PFN_vkCmdEndRenderPass2)load(context, "vkCmdEndRenderPass2");
+	vkCmdNextSubpass2 = (PFN_vkCmdNextSubpass2)load(context, "vkCmdNextSubpass2");
+	vkCreateRenderPass2 = (PFN_vkCreateRenderPass2)load(context, "vkCreateRenderPass2");
+	vkGetBufferDeviceAddress = (PFN_vkGetBufferDeviceAddress)load(context, "vkGetBufferDeviceAddress");
+	vkGetBufferOpaqueCaptureAddress = (PFN_vkGetBufferOpaqueCaptureAddress)load(context, "vkGetBufferOpaqueCaptureAddress");
+	vkGetDeviceMemoryOpaqueCaptureAddress = (PFN_vkGetDeviceMemoryOpaqueCaptureAddress)load(context, "vkGetDeviceMemoryOpaqueCaptureAddress");
+	vkGetSemaphoreCounterValue = (PFN_vkGetSemaphoreCounterValue)load(context, "vkGetSemaphoreCounterValue");
+	vkResetQueryPool = (PFN_vkResetQueryPool)load(context, "vkResetQueryPool");
+	vkSignalSemaphore = (PFN_vkSignalSemaphore)load(context, "vkSignalSemaphore");
+	vkWaitSemaphores = (PFN_vkWaitSemaphores)load(context, "vkWaitSemaphores");
+#endif /* defined(VK_VERSION_1_2) */
+#if defined(VK_VERSION_1_3)
+	vkCmdBeginRendering = (PFN_vkCmdBeginRendering)load(context, "vkCmdBeginRendering");
+	vkCmdBindVertexBuffers2 = (PFN_vkCmdBindVertexBuffers2)load(context, "vkCmdBindVertexBuffers2");
+	vkCmdBlitImage2 = (PFN_vkCmdBlitImage2)load(context, "vkCmdBlitImage2");
+	vkCmdCopyBuffer2 = (PFN_vkCmdCopyBuffer2)load(context, "vkCmdCopyBuffer2");
+	vkCmdCopyBufferToImage2 = (PFN_vkCmdCopyBufferToImage2)load(context, "vkCmdCopyBufferToImage2");
+	vkCmdCopyImage2 = (PFN_vkCmdCopyImage2)load(context, "vkCmdCopyImage2");
+	vkCmdCopyImageToBuffer2 = (PFN_vkCmdCopyImageToBuffer2)load(context, "vkCmdCopyImageToBuffer2");
+	vkCmdEndRendering = (PFN_vkCmdEndRendering)load(context, "vkCmdEndRendering");
+	vkCmdPipelineBarrier2 = (PFN_vkCmdPipelineBarrier2)load(context, "vkCmdPipelineBarrier2");
+	vkCmdResetEvent2 = (PFN_vkCmdResetEvent2)load(context, "vkCmdResetEvent2");
+	vkCmdResolveImage2 = (PFN_vkCmdResolveImage2)load(context, "vkCmdResolveImage2");
+	vkCmdSetCullMode = (PFN_vkCmdSetCullMode)load(context, "vkCmdSetCullMode");
+	vkCmdSetDepthBiasEnable = (PFN_vkCmdSetDepthBiasEnable)load(context, "vkCmdSetDepthBiasEnable");
+	vkCmdSetDepthBoundsTestEnable = (PFN_vkCmdSetDepthBoundsTestEnable)load(context, "vkCmdSetDepthBoundsTestEnable");
+	vkCmdSetDepthCompareOp = (PFN_vkCmdSetDepthCompareOp)load(context, "vkCmdSetDepthCompareOp");
+	vkCmdSetDepthTestEnable = (PFN_vkCmdSetDepthTestEnable)load(context, "vkCmdSetDepthTestEnable");
+	vkCmdSetDepthWriteEnable = (PFN_vkCmdSetDepthWriteEnable)load(context, "vkCmdSetDepthWriteEnable");
+	vkCmdSetEvent2 = (PFN_vkCmdSetEvent2)load(context, "vkCmdSetEvent2");
+	vkCmdSetFrontFace = (PFN_vkCmdSetFrontFace)load(context, "vkCmdSetFrontFace");
+	vkCmdSetPrimitiveRestartEnable = (PFN_vkCmdSetPrimitiveRestartEnable)load(context, "vkCmdSetPrimitiveRestartEnable");
+	vkCmdSetPrimitiveTopology = (PFN_vkCmdSetPrimitiveTopology)load(context, "vkCmdSetPrimitiveTopology");
+	vkCmdSetRasterizerDiscardEnable = (PFN_vkCmdSetRasterizerDiscardEnable)load(context, "vkCmdSetRasterizerDiscardEnable");
+	vkCmdSetScissorWithCount = (PFN_vkCmdSetScissorWithCount)load(context, "vkCmdSetScissorWithCount");
+	vkCmdSetStencilOp = (PFN_vkCmdSetStencilOp)load(context, "vkCmdSetStencilOp");
+	vkCmdSetStencilTestEnable = (PFN_vkCmdSetStencilTestEnable)load(context, "vkCmdSetStencilTestEnable");
+	vkCmdSetViewportWithCount = (PFN_vkCmdSetViewportWithCount)load(context, "vkCmdSetViewportWithCount");
+	vkCmdWaitEvents2 = (PFN_vkCmdWaitEvents2)load(context, "vkCmdWaitEvents2");
+	vkCmdWriteTimestamp2 = (PFN_vkCmdWriteTimestamp2)load(context, "vkCmdWriteTimestamp2");
+	vkCreatePrivateDataSlot = (PFN_vkCreatePrivateDataSlot)load(context, "vkCreatePrivateDataSlot");
+	vkDestroyPrivateDataSlot = (PFN_vkDestroyPrivateDataSlot)load(context, "vkDestroyPrivateDataSlot");
+	vkGetDeviceBufferMemoryRequirements = (PFN_vkGetDeviceBufferMemoryRequirements)load(context, "vkGetDeviceBufferMemoryRequirements");
+	vkGetDeviceImageMemoryRequirements = (PFN_vkGetDeviceImageMemoryRequirements)load(context, "vkGetDeviceImageMemoryRequirements");
+	vkGetDeviceImageSparseMemoryRequirements = (PFN_vkGetDeviceImageSparseMemoryRequirements)load(context, "vkGetDeviceImageSparseMemoryRequirements");
+	vkGetPrivateData = (PFN_vkGetPrivateData)load(context, "vkGetPrivateData");
+	vkQueueSubmit2 = (PFN_vkQueueSubmit2)load(context, "vkQueueSubmit2");
+	vkSetPrivateData = (PFN_vkSetPrivateData)load(context, "vkSetPrivateData");
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_VERSION_1_4)
+	vkCmdBindDescriptorSets2 = (PFN_vkCmdBindDescriptorSets2)load(context, "vkCmdBindDescriptorSets2");
+	vkCmdBindIndexBuffer2 = (PFN_vkCmdBindIndexBuffer2)load(context, "vkCmdBindIndexBuffer2");
+	vkCmdPushConstants2 = (PFN_vkCmdPushConstants2)load(context, "vkCmdPushConstants2");
+	vkCmdPushDescriptorSet = (PFN_vkCmdPushDescriptorSet)load(context, "vkCmdPushDescriptorSet");
+	vkCmdPushDescriptorSet2 = (PFN_vkCmdPushDescriptorSet2)load(context, "vkCmdPushDescriptorSet2");
+	vkCmdPushDescriptorSetWithTemplate = (PFN_vkCmdPushDescriptorSetWithTemplate)load(context, "vkCmdPushDescriptorSetWithTemplate");
+	vkCmdPushDescriptorSetWithTemplate2 = (PFN_vkCmdPushDescriptorSetWithTemplate2)load(context, "vkCmdPushDescriptorSetWithTemplate2");
+	vkCmdSetLineStipple = (PFN_vkCmdSetLineStipple)load(context, "vkCmdSetLineStipple");
+	vkCmdSetRenderingAttachmentLocations = (PFN_vkCmdSetRenderingAttachmentLocations)load(context, "vkCmdSetRenderingAttachmentLocations");
+	vkCmdSetRenderingInputAttachmentIndices = (PFN_vkCmdSetRenderingInputAttachmentIndices)load(context, "vkCmdSetRenderingInputAttachmentIndices");
+	vkCopyImageToImage = (PFN_vkCopyImageToImage)load(context, "vkCopyImageToImage");
+	vkCopyImageToMemory = (PFN_vkCopyImageToMemory)load(context, "vkCopyImageToMemory");
+	vkCopyMemoryToImage = (PFN_vkCopyMemoryToImage)load(context, "vkCopyMemoryToImage");
+	vkGetDeviceImageSubresourceLayout = (PFN_vkGetDeviceImageSubresourceLayout)load(context, "vkGetDeviceImageSubresourceLayout");
+	vkGetImageSubresourceLayout2 = (PFN_vkGetImageSubresourceLayout2)load(context, "vkGetImageSubresourceLayout2");
+	vkGetRenderingAreaGranularity = (PFN_vkGetRenderingAreaGranularity)load(context, "vkGetRenderingAreaGranularity");
+	vkMapMemory2 = (PFN_vkMapMemory2)load(context, "vkMapMemory2");
+	vkTransitionImageLayout = (PFN_vkTransitionImageLayout)load(context, "vkTransitionImageLayout");
+	vkUnmapMemory2 = (PFN_vkUnmapMemory2)load(context, "vkUnmapMemory2");
+#endif /* defined(VK_VERSION_1_4) */
+#if defined(VK_AMDX_shader_enqueue)
+	vkCmdDispatchGraphAMDX = (PFN_vkCmdDispatchGraphAMDX)load(context, "vkCmdDispatchGraphAMDX");
+	vkCmdDispatchGraphIndirectAMDX = (PFN_vkCmdDispatchGraphIndirectAMDX)load(context, "vkCmdDispatchGraphIndirectAMDX");
+	vkCmdDispatchGraphIndirectCountAMDX = (PFN_vkCmdDispatchGraphIndirectCountAMDX)load(context, "vkCmdDispatchGraphIndirectCountAMDX");
+	vkCmdInitializeGraphScratchMemoryAMDX = (PFN_vkCmdInitializeGraphScratchMemoryAMDX)load(context, "vkCmdInitializeGraphScratchMemoryAMDX");
+	vkCreateExecutionGraphPipelinesAMDX = (PFN_vkCreateExecutionGraphPipelinesAMDX)load(context, "vkCreateExecutionGraphPipelinesAMDX");
+	vkGetExecutionGraphPipelineNodeIndexAMDX = (PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)load(context, "vkGetExecutionGraphPipelineNodeIndexAMDX");
+	vkGetExecutionGraphPipelineScratchSizeAMDX = (PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)load(context, "vkGetExecutionGraphPipelineScratchSizeAMDX");
+#endif /* defined(VK_AMDX_shader_enqueue) */
+#if defined(VK_AMD_anti_lag)
+	vkAntiLagUpdateAMD = (PFN_vkAntiLagUpdateAMD)load(context, "vkAntiLagUpdateAMD");
+#endif /* defined(VK_AMD_anti_lag) */
+#if defined(VK_AMD_buffer_marker)
+	vkCmdWriteBufferMarkerAMD = (PFN_vkCmdWriteBufferMarkerAMD)load(context, "vkCmdWriteBufferMarkerAMD");
+#endif /* defined(VK_AMD_buffer_marker) */
+#if defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	vkCmdWriteBufferMarker2AMD = (PFN_vkCmdWriteBufferMarker2AMD)load(context, "vkCmdWriteBufferMarker2AMD");
+#endif /* defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_AMD_display_native_hdr)
+	vkSetLocalDimmingAMD = (PFN_vkSetLocalDimmingAMD)load(context, "vkSetLocalDimmingAMD");
+#endif /* defined(VK_AMD_display_native_hdr) */
+#if defined(VK_AMD_draw_indirect_count)
+	vkCmdDrawIndexedIndirectCountAMD = (PFN_vkCmdDrawIndexedIndirectCountAMD)load(context, "vkCmdDrawIndexedIndirectCountAMD");
+	vkCmdDrawIndirectCountAMD = (PFN_vkCmdDrawIndirectCountAMD)load(context, "vkCmdDrawIndirectCountAMD");
+#endif /* defined(VK_AMD_draw_indirect_count) */
+#if defined(VK_AMD_gpa_interface)
+	vkCmdBeginGpaSampleAMD = (PFN_vkCmdBeginGpaSampleAMD)load(context, "vkCmdBeginGpaSampleAMD");
+	vkCmdBeginGpaSessionAMD = (PFN_vkCmdBeginGpaSessionAMD)load(context, "vkCmdBeginGpaSessionAMD");
+	vkCmdCopyGpaSessionResultsAMD = (PFN_vkCmdCopyGpaSessionResultsAMD)load(context, "vkCmdCopyGpaSessionResultsAMD");
+	vkCmdEndGpaSampleAMD = (PFN_vkCmdEndGpaSampleAMD)load(context, "vkCmdEndGpaSampleAMD");
+	vkCmdEndGpaSessionAMD = (PFN_vkCmdEndGpaSessionAMD)load(context, "vkCmdEndGpaSessionAMD");
+	vkCreateGpaSessionAMD = (PFN_vkCreateGpaSessionAMD)load(context, "vkCreateGpaSessionAMD");
+	vkDestroyGpaSessionAMD = (PFN_vkDestroyGpaSessionAMD)load(context, "vkDestroyGpaSessionAMD");
+	vkGetGpaDeviceClockInfoAMD = (PFN_vkGetGpaDeviceClockInfoAMD)load(context, "vkGetGpaDeviceClockInfoAMD");
+	vkGetGpaSessionResultsAMD = (PFN_vkGetGpaSessionResultsAMD)load(context, "vkGetGpaSessionResultsAMD");
+	vkGetGpaSessionStatusAMD = (PFN_vkGetGpaSessionStatusAMD)load(context, "vkGetGpaSessionStatusAMD");
+	vkResetGpaSessionAMD = (PFN_vkResetGpaSessionAMD)load(context, "vkResetGpaSessionAMD");
+	vkSetGpaDeviceClockModeAMD = (PFN_vkSetGpaDeviceClockModeAMD)load(context, "vkSetGpaDeviceClockModeAMD");
+#endif /* defined(VK_AMD_gpa_interface) */
+#if defined(VK_AMD_shader_info)
+	vkGetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)load(context, "vkGetShaderInfoAMD");
+#endif /* defined(VK_AMD_shader_info) */
+#if defined(VK_ANDROID_external_memory_android_hardware_buffer)
+	vkGetAndroidHardwareBufferPropertiesANDROID = (PFN_vkGetAndroidHardwareBufferPropertiesANDROID)load(context, "vkGetAndroidHardwareBufferPropertiesANDROID");
+	vkGetMemoryAndroidHardwareBufferANDROID = (PFN_vkGetMemoryAndroidHardwareBufferANDROID)load(context, "vkGetMemoryAndroidHardwareBufferANDROID");
+#endif /* defined(VK_ANDROID_external_memory_android_hardware_buffer) */
+#if defined(VK_ARM_data_graph)
+	vkBindDataGraphPipelineSessionMemoryARM = (PFN_vkBindDataGraphPipelineSessionMemoryARM)load(context, "vkBindDataGraphPipelineSessionMemoryARM");
+	vkCmdDispatchDataGraphARM = (PFN_vkCmdDispatchDataGraphARM)load(context, "vkCmdDispatchDataGraphARM");
+	vkCreateDataGraphPipelineSessionARM = (PFN_vkCreateDataGraphPipelineSessionARM)load(context, "vkCreateDataGraphPipelineSessionARM");
+	vkCreateDataGraphPipelinesARM = (PFN_vkCreateDataGraphPipelinesARM)load(context, "vkCreateDataGraphPipelinesARM");
+	vkDestroyDataGraphPipelineSessionARM = (PFN_vkDestroyDataGraphPipelineSessionARM)load(context, "vkDestroyDataGraphPipelineSessionARM");
+	vkGetDataGraphPipelineAvailablePropertiesARM = (PFN_vkGetDataGraphPipelineAvailablePropertiesARM)load(context, "vkGetDataGraphPipelineAvailablePropertiesARM");
+	vkGetDataGraphPipelinePropertiesARM = (PFN_vkGetDataGraphPipelinePropertiesARM)load(context, "vkGetDataGraphPipelinePropertiesARM");
+	vkGetDataGraphPipelineSessionBindPointRequirementsARM = (PFN_vkGetDataGraphPipelineSessionBindPointRequirementsARM)load(context, "vkGetDataGraphPipelineSessionBindPointRequirementsARM");
+	vkGetDataGraphPipelineSessionMemoryRequirementsARM = (PFN_vkGetDataGraphPipelineSessionMemoryRequirementsARM)load(context, "vkGetDataGraphPipelineSessionMemoryRequirementsARM");
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2
+	vkCmdSetDispatchParametersARM = (PFN_vkCmdSetDispatchParametersARM)load(context, "vkCmdSetDispatchParametersARM");
+#endif /* defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2 */
+#if defined(VK_ARM_shader_instrumentation)
+	vkClearShaderInstrumentationMetricsARM = (PFN_vkClearShaderInstrumentationMetricsARM)load(context, "vkClearShaderInstrumentationMetricsARM");
+	vkCmdBeginShaderInstrumentationARM = (PFN_vkCmdBeginShaderInstrumentationARM)load(context, "vkCmdBeginShaderInstrumentationARM");
+	vkCmdEndShaderInstrumentationARM = (PFN_vkCmdEndShaderInstrumentationARM)load(context, "vkCmdEndShaderInstrumentationARM");
+	vkCreateShaderInstrumentationARM = (PFN_vkCreateShaderInstrumentationARM)load(context, "vkCreateShaderInstrumentationARM");
+	vkDestroyShaderInstrumentationARM = (PFN_vkDestroyShaderInstrumentationARM)load(context, "vkDestroyShaderInstrumentationARM");
+	vkGetShaderInstrumentationValuesARM = (PFN_vkGetShaderInstrumentationValuesARM)load(context, "vkGetShaderInstrumentationValuesARM");
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	vkBindTensorMemoryARM = (PFN_vkBindTensorMemoryARM)load(context, "vkBindTensorMemoryARM");
+	vkCmdCopyTensorARM = (PFN_vkCmdCopyTensorARM)load(context, "vkCmdCopyTensorARM");
+	vkCreateTensorARM = (PFN_vkCreateTensorARM)load(context, "vkCreateTensorARM");
+	vkCreateTensorViewARM = (PFN_vkCreateTensorViewARM)load(context, "vkCreateTensorViewARM");
+	vkDestroyTensorARM = (PFN_vkDestroyTensorARM)load(context, "vkDestroyTensorARM");
+	vkDestroyTensorViewARM = (PFN_vkDestroyTensorViewARM)load(context, "vkDestroyTensorViewARM");
+	vkGetDeviceTensorMemoryRequirementsARM = (PFN_vkGetDeviceTensorMemoryRequirementsARM)load(context, "vkGetDeviceTensorMemoryRequirementsARM");
+	vkGetTensorMemoryRequirementsARM = (PFN_vkGetTensorMemoryRequirementsARM)load(context, "vkGetTensorMemoryRequirementsARM");
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer)
+	vkGetTensorOpaqueCaptureDescriptorDataARM = (PFN_vkGetTensorOpaqueCaptureDescriptorDataARM)load(context, "vkGetTensorOpaqueCaptureDescriptorDataARM");
+	vkGetTensorViewOpaqueCaptureDescriptorDataARM = (PFN_vkGetTensorViewOpaqueCaptureDescriptorDataARM)load(context, "vkGetTensorViewOpaqueCaptureDescriptorDataARM");
+#endif /* defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_attachment_feedback_loop_dynamic_state)
+	vkCmdSetAttachmentFeedbackLoopEnableEXT = (PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT)load(context, "vkCmdSetAttachmentFeedbackLoopEnableEXT");
+#endif /* defined(VK_EXT_attachment_feedback_loop_dynamic_state) */
+#if defined(VK_EXT_buffer_device_address)
+	vkGetBufferDeviceAddressEXT = (PFN_vkGetBufferDeviceAddressEXT)load(context, "vkGetBufferDeviceAddressEXT");
+#endif /* defined(VK_EXT_buffer_device_address) */
+#if defined(VK_EXT_calibrated_timestamps)
+	vkGetCalibratedTimestampsEXT = (PFN_vkGetCalibratedTimestampsEXT)load(context, "vkGetCalibratedTimestampsEXT");
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_color_write_enable)
+	vkCmdSetColorWriteEnableEXT = (PFN_vkCmdSetColorWriteEnableEXT)load(context, "vkCmdSetColorWriteEnableEXT");
+#endif /* defined(VK_EXT_color_write_enable) */
+#if defined(VK_EXT_conditional_rendering)
+	vkCmdBeginConditionalRenderingEXT = (PFN_vkCmdBeginConditionalRenderingEXT)load(context, "vkCmdBeginConditionalRenderingEXT");
+	vkCmdEndConditionalRenderingEXT = (PFN_vkCmdEndConditionalRenderingEXT)load(context, "vkCmdEndConditionalRenderingEXT");
+#endif /* defined(VK_EXT_conditional_rendering) */
+#if defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3))
+	vkCmdBeginCustomResolveEXT = (PFN_vkCmdBeginCustomResolveEXT)load(context, "vkCmdBeginCustomResolveEXT");
+#endif /* defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3)) */
+#if defined(VK_EXT_debug_marker)
+	vkCmdDebugMarkerBeginEXT = (PFN_vkCmdDebugMarkerBeginEXT)load(context, "vkCmdDebugMarkerBeginEXT");
+	vkCmdDebugMarkerEndEXT = (PFN_vkCmdDebugMarkerEndEXT)load(context, "vkCmdDebugMarkerEndEXT");
+	vkCmdDebugMarkerInsertEXT = (PFN_vkCmdDebugMarkerInsertEXT)load(context, "vkCmdDebugMarkerInsertEXT");
+	vkDebugMarkerSetObjectNameEXT = (PFN_vkDebugMarkerSetObjectNameEXT)load(context, "vkDebugMarkerSetObjectNameEXT");
+	vkDebugMarkerSetObjectTagEXT = (PFN_vkDebugMarkerSetObjectTagEXT)load(context, "vkDebugMarkerSetObjectTagEXT");
+#endif /* defined(VK_EXT_debug_marker) */
+#if defined(VK_EXT_depth_bias_control)
+	vkCmdSetDepthBias2EXT = (PFN_vkCmdSetDepthBias2EXT)load(context, "vkCmdSetDepthBias2EXT");
+#endif /* defined(VK_EXT_depth_bias_control) */
+#if defined(VK_EXT_descriptor_buffer)
+	vkCmdBindDescriptorBufferEmbeddedSamplersEXT = (PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT)load(context, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT");
+	vkCmdBindDescriptorBuffersEXT = (PFN_vkCmdBindDescriptorBuffersEXT)load(context, "vkCmdBindDescriptorBuffersEXT");
+	vkCmdSetDescriptorBufferOffsetsEXT = (PFN_vkCmdSetDescriptorBufferOffsetsEXT)load(context, "vkCmdSetDescriptorBufferOffsetsEXT");
+	vkGetBufferOpaqueCaptureDescriptorDataEXT = (PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT)load(context, "vkGetBufferOpaqueCaptureDescriptorDataEXT");
+	vkGetDescriptorEXT = (PFN_vkGetDescriptorEXT)load(context, "vkGetDescriptorEXT");
+	vkGetDescriptorSetLayoutBindingOffsetEXT = (PFN_vkGetDescriptorSetLayoutBindingOffsetEXT)load(context, "vkGetDescriptorSetLayoutBindingOffsetEXT");
+	vkGetDescriptorSetLayoutSizeEXT = (PFN_vkGetDescriptorSetLayoutSizeEXT)load(context, "vkGetDescriptorSetLayoutSizeEXT");
+	vkGetImageOpaqueCaptureDescriptorDataEXT = (PFN_vkGetImageOpaqueCaptureDescriptorDataEXT)load(context, "vkGetImageOpaqueCaptureDescriptorDataEXT");
+	vkGetImageViewOpaqueCaptureDescriptorDataEXT = (PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT)load(context, "vkGetImageViewOpaqueCaptureDescriptorDataEXT");
+	vkGetSamplerOpaqueCaptureDescriptorDataEXT = (PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT)load(context, "vkGetSamplerOpaqueCaptureDescriptorDataEXT");
+#endif /* defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing))
+	vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT = (PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT)load(context, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT");
+#endif /* defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing)) */
+#if defined(VK_EXT_descriptor_heap)
+	vkCmdBindResourceHeapEXT = (PFN_vkCmdBindResourceHeapEXT)load(context, "vkCmdBindResourceHeapEXT");
+	vkCmdBindSamplerHeapEXT = (PFN_vkCmdBindSamplerHeapEXT)load(context, "vkCmdBindSamplerHeapEXT");
+	vkCmdPushDataEXT = (PFN_vkCmdPushDataEXT)load(context, "vkCmdPushDataEXT");
+	vkGetImageOpaqueCaptureDataEXT = (PFN_vkGetImageOpaqueCaptureDataEXT)load(context, "vkGetImageOpaqueCaptureDataEXT");
+	vkWriteResourceDescriptorsEXT = (PFN_vkWriteResourceDescriptorsEXT)load(context, "vkWriteResourceDescriptorsEXT");
+	vkWriteSamplerDescriptorsEXT = (PFN_vkWriteSamplerDescriptorsEXT)load(context, "vkWriteSamplerDescriptorsEXT");
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color)
+	vkRegisterCustomBorderColorEXT = (PFN_vkRegisterCustomBorderColorEXT)load(context, "vkRegisterCustomBorderColorEXT");
+	vkUnregisterCustomBorderColorEXT = (PFN_vkUnregisterCustomBorderColorEXT)load(context, "vkUnregisterCustomBorderColorEXT");
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors)
+	vkGetTensorOpaqueCaptureDataARM = (PFN_vkGetTensorOpaqueCaptureDataARM)load(context, "vkGetTensorOpaqueCaptureDataARM");
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors) */
+#if defined(VK_EXT_device_fault)
+	vkGetDeviceFaultInfoEXT = (PFN_vkGetDeviceFaultInfoEXT)load(context, "vkGetDeviceFaultInfoEXT");
+#endif /* defined(VK_EXT_device_fault) */
+#if defined(VK_EXT_device_generated_commands)
+	vkCmdExecuteGeneratedCommandsEXT = (PFN_vkCmdExecuteGeneratedCommandsEXT)load(context, "vkCmdExecuteGeneratedCommandsEXT");
+	vkCmdPreprocessGeneratedCommandsEXT = (PFN_vkCmdPreprocessGeneratedCommandsEXT)load(context, "vkCmdPreprocessGeneratedCommandsEXT");
+	vkCreateIndirectCommandsLayoutEXT = (PFN_vkCreateIndirectCommandsLayoutEXT)load(context, "vkCreateIndirectCommandsLayoutEXT");
+	vkCreateIndirectExecutionSetEXT = (PFN_vkCreateIndirectExecutionSetEXT)load(context, "vkCreateIndirectExecutionSetEXT");
+	vkDestroyIndirectCommandsLayoutEXT = (PFN_vkDestroyIndirectCommandsLayoutEXT)load(context, "vkDestroyIndirectCommandsLayoutEXT");
+	vkDestroyIndirectExecutionSetEXT = (PFN_vkDestroyIndirectExecutionSetEXT)load(context, "vkDestroyIndirectExecutionSetEXT");
+	vkGetGeneratedCommandsMemoryRequirementsEXT = (PFN_vkGetGeneratedCommandsMemoryRequirementsEXT)load(context, "vkGetGeneratedCommandsMemoryRequirementsEXT");
+	vkUpdateIndirectExecutionSetPipelineEXT = (PFN_vkUpdateIndirectExecutionSetPipelineEXT)load(context, "vkUpdateIndirectExecutionSetPipelineEXT");
+	vkUpdateIndirectExecutionSetShaderEXT = (PFN_vkUpdateIndirectExecutionSetShaderEXT)load(context, "vkUpdateIndirectExecutionSetShaderEXT");
+#endif /* defined(VK_EXT_device_generated_commands) */
+#if defined(VK_EXT_discard_rectangles)
+	vkCmdSetDiscardRectangleEXT = (PFN_vkCmdSetDiscardRectangleEXT)load(context, "vkCmdSetDiscardRectangleEXT");
+#endif /* defined(VK_EXT_discard_rectangles) */
+#if defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2
+	vkCmdSetDiscardRectangleEnableEXT = (PFN_vkCmdSetDiscardRectangleEnableEXT)load(context, "vkCmdSetDiscardRectangleEnableEXT");
+	vkCmdSetDiscardRectangleModeEXT = (PFN_vkCmdSetDiscardRectangleModeEXT)load(context, "vkCmdSetDiscardRectangleModeEXT");
+#endif /* defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2 */
+#if defined(VK_EXT_display_control)
+	vkDisplayPowerControlEXT = (PFN_vkDisplayPowerControlEXT)load(context, "vkDisplayPowerControlEXT");
+	vkGetSwapchainCounterEXT = (PFN_vkGetSwapchainCounterEXT)load(context, "vkGetSwapchainCounterEXT");
+	vkRegisterDeviceEventEXT = (PFN_vkRegisterDeviceEventEXT)load(context, "vkRegisterDeviceEventEXT");
+	vkRegisterDisplayEventEXT = (PFN_vkRegisterDisplayEventEXT)load(context, "vkRegisterDisplayEventEXT");
+#endif /* defined(VK_EXT_display_control) */
+#if defined(VK_EXT_external_memory_host)
+	vkGetMemoryHostPointerPropertiesEXT = (PFN_vkGetMemoryHostPointerPropertiesEXT)load(context, "vkGetMemoryHostPointerPropertiesEXT");
+#endif /* defined(VK_EXT_external_memory_host) */
+#if defined(VK_EXT_external_memory_metal)
+	vkGetMemoryMetalHandleEXT = (PFN_vkGetMemoryMetalHandleEXT)load(context, "vkGetMemoryMetalHandleEXT");
+	vkGetMemoryMetalHandlePropertiesEXT = (PFN_vkGetMemoryMetalHandlePropertiesEXT)load(context, "vkGetMemoryMetalHandlePropertiesEXT");
+#endif /* defined(VK_EXT_external_memory_metal) */
+#if defined(VK_EXT_fragment_density_map_offset)
+	vkCmdEndRendering2EXT = (PFN_vkCmdEndRendering2EXT)load(context, "vkCmdEndRendering2EXT");
+#endif /* defined(VK_EXT_fragment_density_map_offset) */
+#if defined(VK_EXT_full_screen_exclusive)
+	vkAcquireFullScreenExclusiveModeEXT = (PFN_vkAcquireFullScreenExclusiveModeEXT)load(context, "vkAcquireFullScreenExclusiveModeEXT");
+	vkReleaseFullScreenExclusiveModeEXT = (PFN_vkReleaseFullScreenExclusiveModeEXT)load(context, "vkReleaseFullScreenExclusiveModeEXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1))
+	vkGetDeviceGroupSurfacePresentModes2EXT = (PFN_vkGetDeviceGroupSurfacePresentModes2EXT)load(context, "vkGetDeviceGroupSurfacePresentModes2EXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1)) */
+#if defined(VK_EXT_hdr_metadata)
+	vkSetHdrMetadataEXT = (PFN_vkSetHdrMetadataEXT)load(context, "vkSetHdrMetadataEXT");
+#endif /* defined(VK_EXT_hdr_metadata) */
+#if defined(VK_EXT_host_image_copy)
+	vkCopyImageToImageEXT = (PFN_vkCopyImageToImageEXT)load(context, "vkCopyImageToImageEXT");
+	vkCopyImageToMemoryEXT = (PFN_vkCopyImageToMemoryEXT)load(context, "vkCopyImageToMemoryEXT");
+	vkCopyMemoryToImageEXT = (PFN_vkCopyMemoryToImageEXT)load(context, "vkCopyMemoryToImageEXT");
+	vkTransitionImageLayoutEXT = (PFN_vkTransitionImageLayoutEXT)load(context, "vkTransitionImageLayoutEXT");
+#endif /* defined(VK_EXT_host_image_copy) */
+#if defined(VK_EXT_host_query_reset)
+	vkResetQueryPoolEXT = (PFN_vkResetQueryPoolEXT)load(context, "vkResetQueryPoolEXT");
+#endif /* defined(VK_EXT_host_query_reset) */
+#if defined(VK_EXT_image_drm_format_modifier)
+	vkGetImageDrmFormatModifierPropertiesEXT = (PFN_vkGetImageDrmFormatModifierPropertiesEXT)load(context, "vkGetImageDrmFormatModifierPropertiesEXT");
+#endif /* defined(VK_EXT_image_drm_format_modifier) */
+#if defined(VK_EXT_line_rasterization)
+	vkCmdSetLineStippleEXT = (PFN_vkCmdSetLineStippleEXT)load(context, "vkCmdSetLineStippleEXT");
+#endif /* defined(VK_EXT_line_rasterization) */
+#if defined(VK_EXT_memory_decompression)
+	vkCmdDecompressMemoryEXT = (PFN_vkCmdDecompressMemoryEXT)load(context, "vkCmdDecompressMemoryEXT");
+	vkCmdDecompressMemoryIndirectCountEXT = (PFN_vkCmdDecompressMemoryIndirectCountEXT)load(context, "vkCmdDecompressMemoryIndirectCountEXT");
+#endif /* defined(VK_EXT_memory_decompression) */
+#if defined(VK_EXT_mesh_shader)
+	vkCmdDrawMeshTasksEXT = (PFN_vkCmdDrawMeshTasksEXT)load(context, "vkCmdDrawMeshTasksEXT");
+	vkCmdDrawMeshTasksIndirectEXT = (PFN_vkCmdDrawMeshTasksIndirectEXT)load(context, "vkCmdDrawMeshTasksIndirectEXT");
+#endif /* defined(VK_EXT_mesh_shader) */
+#if defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	vkCmdDrawMeshTasksIndirectCountEXT = (PFN_vkCmdDrawMeshTasksIndirectCountEXT)load(context, "vkCmdDrawMeshTasksIndirectCountEXT");
+#endif /* defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_EXT_metal_objects)
+	vkExportMetalObjectsEXT = (PFN_vkExportMetalObjectsEXT)load(context, "vkExportMetalObjectsEXT");
+#endif /* defined(VK_EXT_metal_objects) */
+#if defined(VK_EXT_multi_draw)
+	vkCmdDrawMultiEXT = (PFN_vkCmdDrawMultiEXT)load(context, "vkCmdDrawMultiEXT");
+	vkCmdDrawMultiIndexedEXT = (PFN_vkCmdDrawMultiIndexedEXT)load(context, "vkCmdDrawMultiIndexedEXT");
+#endif /* defined(VK_EXT_multi_draw) */
+#if defined(VK_EXT_opacity_micromap)
+	vkBuildMicromapsEXT = (PFN_vkBuildMicromapsEXT)load(context, "vkBuildMicromapsEXT");
+	vkCmdBuildMicromapsEXT = (PFN_vkCmdBuildMicromapsEXT)load(context, "vkCmdBuildMicromapsEXT");
+	vkCmdCopyMemoryToMicromapEXT = (PFN_vkCmdCopyMemoryToMicromapEXT)load(context, "vkCmdCopyMemoryToMicromapEXT");
+	vkCmdCopyMicromapEXT = (PFN_vkCmdCopyMicromapEXT)load(context, "vkCmdCopyMicromapEXT");
+	vkCmdCopyMicromapToMemoryEXT = (PFN_vkCmdCopyMicromapToMemoryEXT)load(context, "vkCmdCopyMicromapToMemoryEXT");
+	vkCmdWriteMicromapsPropertiesEXT = (PFN_vkCmdWriteMicromapsPropertiesEXT)load(context, "vkCmdWriteMicromapsPropertiesEXT");
+	vkCopyMemoryToMicromapEXT = (PFN_vkCopyMemoryToMicromapEXT)load(context, "vkCopyMemoryToMicromapEXT");
+	vkCopyMicromapEXT = (PFN_vkCopyMicromapEXT)load(context, "vkCopyMicromapEXT");
+	vkCopyMicromapToMemoryEXT = (PFN_vkCopyMicromapToMemoryEXT)load(context, "vkCopyMicromapToMemoryEXT");
+	vkCreateMicromapEXT = (PFN_vkCreateMicromapEXT)load(context, "vkCreateMicromapEXT");
+	vkDestroyMicromapEXT = (PFN_vkDestroyMicromapEXT)load(context, "vkDestroyMicromapEXT");
+	vkGetDeviceMicromapCompatibilityEXT = (PFN_vkGetDeviceMicromapCompatibilityEXT)load(context, "vkGetDeviceMicromapCompatibilityEXT");
+	vkGetMicromapBuildSizesEXT = (PFN_vkGetMicromapBuildSizesEXT)load(context, "vkGetMicromapBuildSizesEXT");
+	vkWriteMicromapsPropertiesEXT = (PFN_vkWriteMicromapsPropertiesEXT)load(context, "vkWriteMicromapsPropertiesEXT");
+#endif /* defined(VK_EXT_opacity_micromap) */
+#if defined(VK_EXT_pageable_device_local_memory)
+	vkSetDeviceMemoryPriorityEXT = (PFN_vkSetDeviceMemoryPriorityEXT)load(context, "vkSetDeviceMemoryPriorityEXT");
+#endif /* defined(VK_EXT_pageable_device_local_memory) */
+#if defined(VK_EXT_pipeline_properties)
+	vkGetPipelinePropertiesEXT = (PFN_vkGetPipelinePropertiesEXT)load(context, "vkGetPipelinePropertiesEXT");
+#endif /* defined(VK_EXT_pipeline_properties) */
+#if defined(VK_EXT_present_timing)
+	vkGetPastPresentationTimingEXT = (PFN_vkGetPastPresentationTimingEXT)load(context, "vkGetPastPresentationTimingEXT");
+	vkGetSwapchainTimeDomainPropertiesEXT = (PFN_vkGetSwapchainTimeDomainPropertiesEXT)load(context, "vkGetSwapchainTimeDomainPropertiesEXT");
+	vkGetSwapchainTimingPropertiesEXT = (PFN_vkGetSwapchainTimingPropertiesEXT)load(context, "vkGetSwapchainTimingPropertiesEXT");
+	vkSetSwapchainPresentTimingQueueSizeEXT = (PFN_vkSetSwapchainPresentTimingQueueSizeEXT)load(context, "vkSetSwapchainPresentTimingQueueSizeEXT");
+#endif /* defined(VK_EXT_present_timing) */
+#if defined(VK_EXT_primitive_restart_index)
+	vkCmdSetPrimitiveRestartIndexEXT = (PFN_vkCmdSetPrimitiveRestartIndexEXT)load(context, "vkCmdSetPrimitiveRestartIndexEXT");
+#endif /* defined(VK_EXT_primitive_restart_index) */
+#if defined(VK_EXT_private_data)
+	vkCreatePrivateDataSlotEXT = (PFN_vkCreatePrivateDataSlotEXT)load(context, "vkCreatePrivateDataSlotEXT");
+	vkDestroyPrivateDataSlotEXT = (PFN_vkDestroyPrivateDataSlotEXT)load(context, "vkDestroyPrivateDataSlotEXT");
+	vkGetPrivateDataEXT = (PFN_vkGetPrivateDataEXT)load(context, "vkGetPrivateDataEXT");
+	vkSetPrivateDataEXT = (PFN_vkSetPrivateDataEXT)load(context, "vkSetPrivateDataEXT");
+#endif /* defined(VK_EXT_private_data) */
+#if defined(VK_EXT_sample_locations)
+	vkCmdSetSampleLocationsEXT = (PFN_vkCmdSetSampleLocationsEXT)load(context, "vkCmdSetSampleLocationsEXT");
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_shader_module_identifier)
+	vkGetShaderModuleCreateInfoIdentifierEXT = (PFN_vkGetShaderModuleCreateInfoIdentifierEXT)load(context, "vkGetShaderModuleCreateInfoIdentifierEXT");
+	vkGetShaderModuleIdentifierEXT = (PFN_vkGetShaderModuleIdentifierEXT)load(context, "vkGetShaderModuleIdentifierEXT");
+#endif /* defined(VK_EXT_shader_module_identifier) */
+#if defined(VK_EXT_shader_object)
+	vkCmdBindShadersEXT = (PFN_vkCmdBindShadersEXT)load(context, "vkCmdBindShadersEXT");
+	vkCreateShadersEXT = (PFN_vkCreateShadersEXT)load(context, "vkCreateShadersEXT");
+	vkDestroyShaderEXT = (PFN_vkDestroyShaderEXT)load(context, "vkDestroyShaderEXT");
+	vkGetShaderBinaryDataEXT = (PFN_vkGetShaderBinaryDataEXT)load(context, "vkGetShaderBinaryDataEXT");
+#endif /* defined(VK_EXT_shader_object) */
+#if defined(VK_EXT_swapchain_maintenance1)
+	vkReleaseSwapchainImagesEXT = (PFN_vkReleaseSwapchainImagesEXT)load(context, "vkReleaseSwapchainImagesEXT");
+#endif /* defined(VK_EXT_swapchain_maintenance1) */
+#if defined(VK_EXT_transform_feedback)
+	vkCmdBeginQueryIndexedEXT = (PFN_vkCmdBeginQueryIndexedEXT)load(context, "vkCmdBeginQueryIndexedEXT");
+	vkCmdBeginTransformFeedbackEXT = (PFN_vkCmdBeginTransformFeedbackEXT)load(context, "vkCmdBeginTransformFeedbackEXT");
+	vkCmdBindTransformFeedbackBuffersEXT = (PFN_vkCmdBindTransformFeedbackBuffersEXT)load(context, "vkCmdBindTransformFeedbackBuffersEXT");
+	vkCmdDrawIndirectByteCountEXT = (PFN_vkCmdDrawIndirectByteCountEXT)load(context, "vkCmdDrawIndirectByteCountEXT");
+	vkCmdEndQueryIndexedEXT = (PFN_vkCmdEndQueryIndexedEXT)load(context, "vkCmdEndQueryIndexedEXT");
+	vkCmdEndTransformFeedbackEXT = (PFN_vkCmdEndTransformFeedbackEXT)load(context, "vkCmdEndTransformFeedbackEXT");
+#endif /* defined(VK_EXT_transform_feedback) */
+#if defined(VK_EXT_validation_cache)
+	vkCreateValidationCacheEXT = (PFN_vkCreateValidationCacheEXT)load(context, "vkCreateValidationCacheEXT");
+	vkDestroyValidationCacheEXT = (PFN_vkDestroyValidationCacheEXT)load(context, "vkDestroyValidationCacheEXT");
+	vkGetValidationCacheDataEXT = (PFN_vkGetValidationCacheDataEXT)load(context, "vkGetValidationCacheDataEXT");
+	vkMergeValidationCachesEXT = (PFN_vkMergeValidationCachesEXT)load(context, "vkMergeValidationCachesEXT");
+#endif /* defined(VK_EXT_validation_cache) */
+#if defined(VK_FUCHSIA_buffer_collection)
+	vkCreateBufferCollectionFUCHSIA = (PFN_vkCreateBufferCollectionFUCHSIA)load(context, "vkCreateBufferCollectionFUCHSIA");
+	vkDestroyBufferCollectionFUCHSIA = (PFN_vkDestroyBufferCollectionFUCHSIA)load(context, "vkDestroyBufferCollectionFUCHSIA");
+	vkGetBufferCollectionPropertiesFUCHSIA = (PFN_vkGetBufferCollectionPropertiesFUCHSIA)load(context, "vkGetBufferCollectionPropertiesFUCHSIA");
+	vkSetBufferCollectionBufferConstraintsFUCHSIA = (PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)load(context, "vkSetBufferCollectionBufferConstraintsFUCHSIA");
+	vkSetBufferCollectionImageConstraintsFUCHSIA = (PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)load(context, "vkSetBufferCollectionImageConstraintsFUCHSIA");
+#endif /* defined(VK_FUCHSIA_buffer_collection) */
+#if defined(VK_FUCHSIA_external_memory)
+	vkGetMemoryZirconHandleFUCHSIA = (PFN_vkGetMemoryZirconHandleFUCHSIA)load(context, "vkGetMemoryZirconHandleFUCHSIA");
+	vkGetMemoryZirconHandlePropertiesFUCHSIA = (PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)load(context, "vkGetMemoryZirconHandlePropertiesFUCHSIA");
+#endif /* defined(VK_FUCHSIA_external_memory) */
+#if defined(VK_FUCHSIA_external_semaphore)
+	vkGetSemaphoreZirconHandleFUCHSIA = (PFN_vkGetSemaphoreZirconHandleFUCHSIA)load(context, "vkGetSemaphoreZirconHandleFUCHSIA");
+	vkImportSemaphoreZirconHandleFUCHSIA = (PFN_vkImportSemaphoreZirconHandleFUCHSIA)load(context, "vkImportSemaphoreZirconHandleFUCHSIA");
+#endif /* defined(VK_FUCHSIA_external_semaphore) */
+#if defined(VK_GOOGLE_display_timing)
+	vkGetPastPresentationTimingGOOGLE = (PFN_vkGetPastPresentationTimingGOOGLE)load(context, "vkGetPastPresentationTimingGOOGLE");
+	vkGetRefreshCycleDurationGOOGLE = (PFN_vkGetRefreshCycleDurationGOOGLE)load(context, "vkGetRefreshCycleDurationGOOGLE");
+#endif /* defined(VK_GOOGLE_display_timing) */
+#if defined(VK_HUAWEI_cluster_culling_shader)
+	vkCmdDrawClusterHUAWEI = (PFN_vkCmdDrawClusterHUAWEI)load(context, "vkCmdDrawClusterHUAWEI");
+	vkCmdDrawClusterIndirectHUAWEI = (PFN_vkCmdDrawClusterIndirectHUAWEI)load(context, "vkCmdDrawClusterIndirectHUAWEI");
+#endif /* defined(VK_HUAWEI_cluster_culling_shader) */
+#if defined(VK_HUAWEI_invocation_mask)
+	vkCmdBindInvocationMaskHUAWEI = (PFN_vkCmdBindInvocationMaskHUAWEI)load(context, "vkCmdBindInvocationMaskHUAWEI");
+#endif /* defined(VK_HUAWEI_invocation_mask) */
+#if defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2
+	vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = (PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI)load(context, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI");
+#endif /* defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2 */
+#if defined(VK_HUAWEI_subpass_shading)
+	vkCmdSubpassShadingHUAWEI = (PFN_vkCmdSubpassShadingHUAWEI)load(context, "vkCmdSubpassShadingHUAWEI");
+#endif /* defined(VK_HUAWEI_subpass_shading) */
+#if defined(VK_INTEL_performance_query)
+	vkAcquirePerformanceConfigurationINTEL = (PFN_vkAcquirePerformanceConfigurationINTEL)load(context, "vkAcquirePerformanceConfigurationINTEL");
+	vkCmdSetPerformanceMarkerINTEL = (PFN_vkCmdSetPerformanceMarkerINTEL)load(context, "vkCmdSetPerformanceMarkerINTEL");
+	vkCmdSetPerformanceOverrideINTEL = (PFN_vkCmdSetPerformanceOverrideINTEL)load(context, "vkCmdSetPerformanceOverrideINTEL");
+	vkCmdSetPerformanceStreamMarkerINTEL = (PFN_vkCmdSetPerformanceStreamMarkerINTEL)load(context, "vkCmdSetPerformanceStreamMarkerINTEL");
+	vkGetPerformanceParameterINTEL = (PFN_vkGetPerformanceParameterINTEL)load(context, "vkGetPerformanceParameterINTEL");
+	vkInitializePerformanceApiINTEL = (PFN_vkInitializePerformanceApiINTEL)load(context, "vkInitializePerformanceApiINTEL");
+	vkQueueSetPerformanceConfigurationINTEL = (PFN_vkQueueSetPerformanceConfigurationINTEL)load(context, "vkQueueSetPerformanceConfigurationINTEL");
+	vkReleasePerformanceConfigurationINTEL = (PFN_vkReleasePerformanceConfigurationINTEL)load(context, "vkReleasePerformanceConfigurationINTEL");
+	vkUninitializePerformanceApiINTEL = (PFN_vkUninitializePerformanceApiINTEL)load(context, "vkUninitializePerformanceApiINTEL");
+#endif /* defined(VK_INTEL_performance_query) */
+#if defined(VK_KHR_acceleration_structure)
+	vkBuildAccelerationStructuresKHR = (PFN_vkBuildAccelerationStructuresKHR)load(context, "vkBuildAccelerationStructuresKHR");
+	vkCmdBuildAccelerationStructuresIndirectKHR = (PFN_vkCmdBuildAccelerationStructuresIndirectKHR)load(context, "vkCmdBuildAccelerationStructuresIndirectKHR");
+	vkCmdBuildAccelerationStructuresKHR = (PFN_vkCmdBuildAccelerationStructuresKHR)load(context, "vkCmdBuildAccelerationStructuresKHR");
+	vkCmdCopyAccelerationStructureKHR = (PFN_vkCmdCopyAccelerationStructureKHR)load(context, "vkCmdCopyAccelerationStructureKHR");
+	vkCmdCopyAccelerationStructureToMemoryKHR = (PFN_vkCmdCopyAccelerationStructureToMemoryKHR)load(context, "vkCmdCopyAccelerationStructureToMemoryKHR");
+	vkCmdCopyMemoryToAccelerationStructureKHR = (PFN_vkCmdCopyMemoryToAccelerationStructureKHR)load(context, "vkCmdCopyMemoryToAccelerationStructureKHR");
+	vkCmdWriteAccelerationStructuresPropertiesKHR = (PFN_vkCmdWriteAccelerationStructuresPropertiesKHR)load(context, "vkCmdWriteAccelerationStructuresPropertiesKHR");
+	vkCopyAccelerationStructureKHR = (PFN_vkCopyAccelerationStructureKHR)load(context, "vkCopyAccelerationStructureKHR");
+	vkCopyAccelerationStructureToMemoryKHR = (PFN_vkCopyAccelerationStructureToMemoryKHR)load(context, "vkCopyAccelerationStructureToMemoryKHR");
+	vkCopyMemoryToAccelerationStructureKHR = (PFN_vkCopyMemoryToAccelerationStructureKHR)load(context, "vkCopyMemoryToAccelerationStructureKHR");
+	vkCreateAccelerationStructureKHR = (PFN_vkCreateAccelerationStructureKHR)load(context, "vkCreateAccelerationStructureKHR");
+	vkDestroyAccelerationStructureKHR = (PFN_vkDestroyAccelerationStructureKHR)load(context, "vkDestroyAccelerationStructureKHR");
+	vkGetAccelerationStructureBuildSizesKHR = (PFN_vkGetAccelerationStructureBuildSizesKHR)load(context, "vkGetAccelerationStructureBuildSizesKHR");
+	vkGetAccelerationStructureDeviceAddressKHR = (PFN_vkGetAccelerationStructureDeviceAddressKHR)load(context, "vkGetAccelerationStructureDeviceAddressKHR");
+	vkGetDeviceAccelerationStructureCompatibilityKHR = (PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)load(context, "vkGetDeviceAccelerationStructureCompatibilityKHR");
+	vkWriteAccelerationStructuresPropertiesKHR = (PFN_vkWriteAccelerationStructuresPropertiesKHR)load(context, "vkWriteAccelerationStructuresPropertiesKHR");
+#endif /* defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_bind_memory2)
+	vkBindBufferMemory2KHR = (PFN_vkBindBufferMemory2KHR)load(context, "vkBindBufferMemory2KHR");
+	vkBindImageMemory2KHR = (PFN_vkBindImageMemory2KHR)load(context, "vkBindImageMemory2KHR");
+#endif /* defined(VK_KHR_bind_memory2) */
+#if defined(VK_KHR_buffer_device_address)
+	vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)load(context, "vkGetBufferDeviceAddressKHR");
+	vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)load(context, "vkGetBufferOpaqueCaptureAddressKHR");
+	vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)load(context, "vkGetDeviceMemoryOpaqueCaptureAddressKHR");
+#endif /* defined(VK_KHR_buffer_device_address) */
+#if defined(VK_KHR_calibrated_timestamps)
+	vkGetCalibratedTimestampsKHR = (PFN_vkGetCalibratedTimestampsKHR)load(context, "vkGetCalibratedTimestampsKHR");
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_copy_commands2)
+	vkCmdBlitImage2KHR = (PFN_vkCmdBlitImage2KHR)load(context, "vkCmdBlitImage2KHR");
+	vkCmdCopyBuffer2KHR = (PFN_vkCmdCopyBuffer2KHR)load(context, "vkCmdCopyBuffer2KHR");
+	vkCmdCopyBufferToImage2KHR = (PFN_vkCmdCopyBufferToImage2KHR)load(context, "vkCmdCopyBufferToImage2KHR");
+	vkCmdCopyImage2KHR = (PFN_vkCmdCopyImage2KHR)load(context, "vkCmdCopyImage2KHR");
+	vkCmdCopyImageToBuffer2KHR = (PFN_vkCmdCopyImageToBuffer2KHR)load(context, "vkCmdCopyImageToBuffer2KHR");
+	vkCmdResolveImage2KHR = (PFN_vkCmdResolveImage2KHR)load(context, "vkCmdResolveImage2KHR");
+#endif /* defined(VK_KHR_copy_commands2) */
+#if defined(VK_KHR_copy_memory_indirect)
+	vkCmdCopyMemoryIndirectKHR = (PFN_vkCmdCopyMemoryIndirectKHR)load(context, "vkCmdCopyMemoryIndirectKHR");
+	vkCmdCopyMemoryToImageIndirectKHR = (PFN_vkCmdCopyMemoryToImageIndirectKHR)load(context, "vkCmdCopyMemoryToImageIndirectKHR");
+#endif /* defined(VK_KHR_copy_memory_indirect) */
+#if defined(VK_KHR_create_renderpass2)
+	vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)load(context, "vkCmdBeginRenderPass2KHR");
+	vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)load(context, "vkCmdEndRenderPass2KHR");
+	vkCmdNextSubpass2KHR = (PFN_vkCmdNextSubpass2KHR)load(context, "vkCmdNextSubpass2KHR");
+	vkCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)load(context, "vkCreateRenderPass2KHR");
+#endif /* defined(VK_KHR_create_renderpass2) */
+#if defined(VK_KHR_deferred_host_operations)
+	vkCreateDeferredOperationKHR = (PFN_vkCreateDeferredOperationKHR)load(context, "vkCreateDeferredOperationKHR");
+	vkDeferredOperationJoinKHR = (PFN_vkDeferredOperationJoinKHR)load(context, "vkDeferredOperationJoinKHR");
+	vkDestroyDeferredOperationKHR = (PFN_vkDestroyDeferredOperationKHR)load(context, "vkDestroyDeferredOperationKHR");
+	vkGetDeferredOperationMaxConcurrencyKHR = (PFN_vkGetDeferredOperationMaxConcurrencyKHR)load(context, "vkGetDeferredOperationMaxConcurrencyKHR");
+	vkGetDeferredOperationResultKHR = (PFN_vkGetDeferredOperationResultKHR)load(context, "vkGetDeferredOperationResultKHR");
+#endif /* defined(VK_KHR_deferred_host_operations) */
+#if defined(VK_KHR_descriptor_update_template)
+	vkCreateDescriptorUpdateTemplateKHR = (PFN_vkCreateDescriptorUpdateTemplateKHR)load(context, "vkCreateDescriptorUpdateTemplateKHR");
+	vkDestroyDescriptorUpdateTemplateKHR = (PFN_vkDestroyDescriptorUpdateTemplateKHR)load(context, "vkDestroyDescriptorUpdateTemplateKHR");
+	vkUpdateDescriptorSetWithTemplateKHR = (PFN_vkUpdateDescriptorSetWithTemplateKHR)load(context, "vkUpdateDescriptorSetWithTemplateKHR");
+#endif /* defined(VK_KHR_descriptor_update_template) */
+#if defined(VK_KHR_device_address_commands)
+	vkCmdBindIndexBuffer3KHR = (PFN_vkCmdBindIndexBuffer3KHR)load(context, "vkCmdBindIndexBuffer3KHR");
+	vkCmdBindVertexBuffers3KHR = (PFN_vkCmdBindVertexBuffers3KHR)load(context, "vkCmdBindVertexBuffers3KHR");
+	vkCmdCopyImageToMemoryKHR = (PFN_vkCmdCopyImageToMemoryKHR)load(context, "vkCmdCopyImageToMemoryKHR");
+	vkCmdCopyMemoryKHR = (PFN_vkCmdCopyMemoryKHR)load(context, "vkCmdCopyMemoryKHR");
+	vkCmdCopyMemoryToImageKHR = (PFN_vkCmdCopyMemoryToImageKHR)load(context, "vkCmdCopyMemoryToImageKHR");
+	vkCmdCopyQueryPoolResultsToMemoryKHR = (PFN_vkCmdCopyQueryPoolResultsToMemoryKHR)load(context, "vkCmdCopyQueryPoolResultsToMemoryKHR");
+	vkCmdDispatchIndirect2KHR = (PFN_vkCmdDispatchIndirect2KHR)load(context, "vkCmdDispatchIndirect2KHR");
+	vkCmdDrawIndexedIndirect2KHR = (PFN_vkCmdDrawIndexedIndirect2KHR)load(context, "vkCmdDrawIndexedIndirect2KHR");
+	vkCmdDrawIndirect2KHR = (PFN_vkCmdDrawIndirect2KHR)load(context, "vkCmdDrawIndirect2KHR");
+	vkCmdFillMemoryKHR = (PFN_vkCmdFillMemoryKHR)load(context, "vkCmdFillMemoryKHR");
+	vkCmdUpdateMemoryKHR = (PFN_vkCmdUpdateMemoryKHR)load(context, "vkCmdUpdateMemoryKHR");
+#endif /* defined(VK_KHR_device_address_commands) */
+#if defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2))
+	vkCmdDrawIndexedIndirectCount2KHR = (PFN_vkCmdDrawIndexedIndirectCount2KHR)load(context, "vkCmdDrawIndexedIndirectCount2KHR");
+	vkCmdDrawIndirectCount2KHR = (PFN_vkCmdDrawIndirectCount2KHR)load(context, "vkCmdDrawIndirectCount2KHR");
+#endif /* defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering)
+	vkCmdBeginConditionalRendering2EXT = (PFN_vkCmdBeginConditionalRendering2EXT)load(context, "vkCmdBeginConditionalRendering2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback)
+	vkCmdBeginTransformFeedback2EXT = (PFN_vkCmdBeginTransformFeedback2EXT)load(context, "vkCmdBeginTransformFeedback2EXT");
+	vkCmdBindTransformFeedbackBuffers2EXT = (PFN_vkCmdBindTransformFeedbackBuffers2EXT)load(context, "vkCmdBindTransformFeedbackBuffers2EXT");
+	vkCmdDrawIndirectByteCount2EXT = (PFN_vkCmdDrawIndirectByteCount2EXT)load(context, "vkCmdDrawIndirectByteCount2EXT");
+	vkCmdEndTransformFeedback2EXT = (PFN_vkCmdEndTransformFeedback2EXT)load(context, "vkCmdEndTransformFeedback2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader)
+	vkCmdDrawMeshTasksIndirect2EXT = (PFN_vkCmdDrawMeshTasksIndirect2EXT)load(context, "vkCmdDrawMeshTasksIndirect2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader) */
+#if defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader))
+	vkCmdDrawMeshTasksIndirectCount2EXT = (PFN_vkCmdDrawMeshTasksIndirectCount2EXT)load(context, "vkCmdDrawMeshTasksIndirectCount2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker)
+	vkCmdWriteMarkerToMemoryAMD = (PFN_vkCmdWriteMarkerToMemoryAMD)load(context, "vkCmdWriteMarkerToMemoryAMD");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure)
+	vkCreateAccelerationStructure2KHR = (PFN_vkCreateAccelerationStructure2KHR)load(context, "vkCreateAccelerationStructure2KHR");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_device_fault)
+	vkGetDeviceFaultDebugInfoKHR = (PFN_vkGetDeviceFaultDebugInfoKHR)load(context, "vkGetDeviceFaultDebugInfoKHR");
+	vkGetDeviceFaultReportsKHR = (PFN_vkGetDeviceFaultReportsKHR)load(context, "vkGetDeviceFaultReportsKHR");
+#endif /* defined(VK_KHR_device_fault) */
+#if defined(VK_KHR_device_group)
+	vkCmdDispatchBaseKHR = (PFN_vkCmdDispatchBaseKHR)load(context, "vkCmdDispatchBaseKHR");
+	vkCmdSetDeviceMaskKHR = (PFN_vkCmdSetDeviceMaskKHR)load(context, "vkCmdSetDeviceMaskKHR");
+	vkGetDeviceGroupPeerMemoryFeaturesKHR = (PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR)load(context, "vkGetDeviceGroupPeerMemoryFeaturesKHR");
+#endif /* defined(VK_KHR_device_group) */
+#if defined(VK_KHR_display_swapchain)
+	vkCreateSharedSwapchainsKHR = (PFN_vkCreateSharedSwapchainsKHR)load(context, "vkCreateSharedSwapchainsKHR");
+#endif /* defined(VK_KHR_display_swapchain) */
+#if defined(VK_KHR_draw_indirect_count)
+	vkCmdDrawIndexedIndirectCountKHR = (PFN_vkCmdDrawIndexedIndirectCountKHR)load(context, "vkCmdDrawIndexedIndirectCountKHR");
+	vkCmdDrawIndirectCountKHR = (PFN_vkCmdDrawIndirectCountKHR)load(context, "vkCmdDrawIndirectCountKHR");
+#endif /* defined(VK_KHR_draw_indirect_count) */
+#if defined(VK_KHR_dynamic_rendering)
+	vkCmdBeginRenderingKHR = (PFN_vkCmdBeginRenderingKHR)load(context, "vkCmdBeginRenderingKHR");
+	vkCmdEndRenderingKHR = (PFN_vkCmdEndRenderingKHR)load(context, "vkCmdEndRenderingKHR");
+#endif /* defined(VK_KHR_dynamic_rendering) */
+#if defined(VK_KHR_dynamic_rendering_local_read)
+	vkCmdSetRenderingAttachmentLocationsKHR = (PFN_vkCmdSetRenderingAttachmentLocationsKHR)load(context, "vkCmdSetRenderingAttachmentLocationsKHR");
+	vkCmdSetRenderingInputAttachmentIndicesKHR = (PFN_vkCmdSetRenderingInputAttachmentIndicesKHR)load(context, "vkCmdSetRenderingInputAttachmentIndicesKHR");
+#endif /* defined(VK_KHR_dynamic_rendering_local_read) */
+#if defined(VK_KHR_external_fence_fd)
+	vkGetFenceFdKHR = (PFN_vkGetFenceFdKHR)load(context, "vkGetFenceFdKHR");
+	vkImportFenceFdKHR = (PFN_vkImportFenceFdKHR)load(context, "vkImportFenceFdKHR");
+#endif /* defined(VK_KHR_external_fence_fd) */
+#if defined(VK_KHR_external_fence_win32)
+	vkGetFenceWin32HandleKHR = (PFN_vkGetFenceWin32HandleKHR)load(context, "vkGetFenceWin32HandleKHR");
+	vkImportFenceWin32HandleKHR = (PFN_vkImportFenceWin32HandleKHR)load(context, "vkImportFenceWin32HandleKHR");
+#endif /* defined(VK_KHR_external_fence_win32) */
+#if defined(VK_KHR_external_memory_fd)
+	vkGetMemoryFdKHR = (PFN_vkGetMemoryFdKHR)load(context, "vkGetMemoryFdKHR");
+	vkGetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)load(context, "vkGetMemoryFdPropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_fd) */
+#if defined(VK_KHR_external_memory_win32)
+	vkGetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)load(context, "vkGetMemoryWin32HandleKHR");
+	vkGetMemoryWin32HandlePropertiesKHR = (PFN_vkGetMemoryWin32HandlePropertiesKHR)load(context, "vkGetMemoryWin32HandlePropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_win32) */
+#if defined(VK_KHR_external_semaphore_fd)
+	vkGetSemaphoreFdKHR = (PFN_vkGetSemaphoreFdKHR)load(context, "vkGetSemaphoreFdKHR");
+	vkImportSemaphoreFdKHR = (PFN_vkImportSemaphoreFdKHR)load(context, "vkImportSemaphoreFdKHR");
+#endif /* defined(VK_KHR_external_semaphore_fd) */
+#if defined(VK_KHR_external_semaphore_win32)
+	vkGetSemaphoreWin32HandleKHR = (PFN_vkGetSemaphoreWin32HandleKHR)load(context, "vkGetSemaphoreWin32HandleKHR");
+	vkImportSemaphoreWin32HandleKHR = (PFN_vkImportSemaphoreWin32HandleKHR)load(context, "vkImportSemaphoreWin32HandleKHR");
+#endif /* defined(VK_KHR_external_semaphore_win32) */
+#if defined(VK_KHR_fragment_shading_rate)
+	vkCmdSetFragmentShadingRateKHR = (PFN_vkCmdSetFragmentShadingRateKHR)load(context, "vkCmdSetFragmentShadingRateKHR");
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_memory_requirements2)
+	vkGetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)load(context, "vkGetBufferMemoryRequirements2KHR");
+	vkGetImageMemoryRequirements2KHR = (PFN_vkGetImageMemoryRequirements2KHR)load(context, "vkGetImageMemoryRequirements2KHR");
+	vkGetImageSparseMemoryRequirements2KHR = (PFN_vkGetImageSparseMemoryRequirements2KHR)load(context, "vkGetImageSparseMemoryRequirements2KHR");
+#endif /* defined(VK_KHR_get_memory_requirements2) */
+#if defined(VK_KHR_line_rasterization)
+	vkCmdSetLineStippleKHR = (PFN_vkCmdSetLineStippleKHR)load(context, "vkCmdSetLineStippleKHR");
+#endif /* defined(VK_KHR_line_rasterization) */
+#if defined(VK_KHR_maintenance1)
+	vkTrimCommandPoolKHR = (PFN_vkTrimCommandPoolKHR)load(context, "vkTrimCommandPoolKHR");
+#endif /* defined(VK_KHR_maintenance1) */
+#if defined(VK_KHR_maintenance10)
+	vkCmdEndRendering2KHR = (PFN_vkCmdEndRendering2KHR)load(context, "vkCmdEndRendering2KHR");
+#endif /* defined(VK_KHR_maintenance10) */
+#if defined(VK_KHR_maintenance3)
+	vkGetDescriptorSetLayoutSupportKHR = (PFN_vkGetDescriptorSetLayoutSupportKHR)load(context, "vkGetDescriptorSetLayoutSupportKHR");
+#endif /* defined(VK_KHR_maintenance3) */
+#if defined(VK_KHR_maintenance4)
+	vkGetDeviceBufferMemoryRequirementsKHR = (PFN_vkGetDeviceBufferMemoryRequirementsKHR)load(context, "vkGetDeviceBufferMemoryRequirementsKHR");
+	vkGetDeviceImageMemoryRequirementsKHR = (PFN_vkGetDeviceImageMemoryRequirementsKHR)load(context, "vkGetDeviceImageMemoryRequirementsKHR");
+	vkGetDeviceImageSparseMemoryRequirementsKHR = (PFN_vkGetDeviceImageSparseMemoryRequirementsKHR)load(context, "vkGetDeviceImageSparseMemoryRequirementsKHR");
+#endif /* defined(VK_KHR_maintenance4) */
+#if defined(VK_KHR_maintenance5)
+	vkCmdBindIndexBuffer2KHR = (PFN_vkCmdBindIndexBuffer2KHR)load(context, "vkCmdBindIndexBuffer2KHR");
+	vkGetDeviceImageSubresourceLayoutKHR = (PFN_vkGetDeviceImageSubresourceLayoutKHR)load(context, "vkGetDeviceImageSubresourceLayoutKHR");
+	vkGetImageSubresourceLayout2KHR = (PFN_vkGetImageSubresourceLayout2KHR)load(context, "vkGetImageSubresourceLayout2KHR");
+	vkGetRenderingAreaGranularityKHR = (PFN_vkGetRenderingAreaGranularityKHR)load(context, "vkGetRenderingAreaGranularityKHR");
+#endif /* defined(VK_KHR_maintenance5) */
+#if defined(VK_KHR_maintenance6)
+	vkCmdBindDescriptorSets2KHR = (PFN_vkCmdBindDescriptorSets2KHR)load(context, "vkCmdBindDescriptorSets2KHR");
+	vkCmdPushConstants2KHR = (PFN_vkCmdPushConstants2KHR)load(context, "vkCmdPushConstants2KHR");
+#endif /* defined(VK_KHR_maintenance6) */
+#if defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor)
+	vkCmdPushDescriptorSet2KHR = (PFN_vkCmdPushDescriptorSet2KHR)load(context, "vkCmdPushDescriptorSet2KHR");
+	vkCmdPushDescriptorSetWithTemplate2KHR = (PFN_vkCmdPushDescriptorSetWithTemplate2KHR)load(context, "vkCmdPushDescriptorSetWithTemplate2KHR");
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer)
+	vkCmdBindDescriptorBufferEmbeddedSamplers2EXT = (PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT)load(context, "vkCmdBindDescriptorBufferEmbeddedSamplers2EXT");
+	vkCmdSetDescriptorBufferOffsets2EXT = (PFN_vkCmdSetDescriptorBufferOffsets2EXT)load(context, "vkCmdSetDescriptorBufferOffsets2EXT");
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_KHR_map_memory2)
+	vkMapMemory2KHR = (PFN_vkMapMemory2KHR)load(context, "vkMapMemory2KHR");
+	vkUnmapMemory2KHR = (PFN_vkUnmapMemory2KHR)load(context, "vkUnmapMemory2KHR");
+#endif /* defined(VK_KHR_map_memory2) */
+#if defined(VK_KHR_performance_query)
+	vkAcquireProfilingLockKHR = (PFN_vkAcquireProfilingLockKHR)load(context, "vkAcquireProfilingLockKHR");
+	vkReleaseProfilingLockKHR = (PFN_vkReleaseProfilingLockKHR)load(context, "vkReleaseProfilingLockKHR");
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_pipeline_binary)
+	vkCreatePipelineBinariesKHR = (PFN_vkCreatePipelineBinariesKHR)load(context, "vkCreatePipelineBinariesKHR");
+	vkDestroyPipelineBinaryKHR = (PFN_vkDestroyPipelineBinaryKHR)load(context, "vkDestroyPipelineBinaryKHR");
+	vkGetPipelineBinaryDataKHR = (PFN_vkGetPipelineBinaryDataKHR)load(context, "vkGetPipelineBinaryDataKHR");
+	vkGetPipelineKeyKHR = (PFN_vkGetPipelineKeyKHR)load(context, "vkGetPipelineKeyKHR");
+	vkReleaseCapturedPipelineDataKHR = (PFN_vkReleaseCapturedPipelineDataKHR)load(context, "vkReleaseCapturedPipelineDataKHR");
+#endif /* defined(VK_KHR_pipeline_binary) */
+#if defined(VK_KHR_pipeline_executable_properties)
+	vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)load(context, "vkGetPipelineExecutableInternalRepresentationsKHR");
+	vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)load(context, "vkGetPipelineExecutablePropertiesKHR");
+	vkGetPipelineExecutableStatisticsKHR = (PFN_vkGetPipelineExecutableStatisticsKHR)load(context, "vkGetPipelineExecutableStatisticsKHR");
+#endif /* defined(VK_KHR_pipeline_executable_properties) */
+#if defined(VK_KHR_present_wait)
+	vkWaitForPresentKHR = (PFN_vkWaitForPresentKHR)load(context, "vkWaitForPresentKHR");
+#endif /* defined(VK_KHR_present_wait) */
+#if defined(VK_KHR_present_wait2)
+	vkWaitForPresent2KHR = (PFN_vkWaitForPresent2KHR)load(context, "vkWaitForPresent2KHR");
+#endif /* defined(VK_KHR_present_wait2) */
+#if defined(VK_KHR_push_descriptor)
+	vkCmdPushDescriptorSetKHR = (PFN_vkCmdPushDescriptorSetKHR)load(context, "vkCmdPushDescriptorSetKHR");
+#endif /* defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline)
+	vkCmdTraceRaysIndirect2KHR = (PFN_vkCmdTraceRaysIndirect2KHR)load(context, "vkCmdTraceRaysIndirect2KHR");
+#endif /* defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_ray_tracing_pipeline)
+	vkCmdSetRayTracingPipelineStackSizeKHR = (PFN_vkCmdSetRayTracingPipelineStackSizeKHR)load(context, "vkCmdSetRayTracingPipelineStackSizeKHR");
+	vkCmdTraceRaysIndirectKHR = (PFN_vkCmdTraceRaysIndirectKHR)load(context, "vkCmdTraceRaysIndirectKHR");
+	vkCmdTraceRaysKHR = (PFN_vkCmdTraceRaysKHR)load(context, "vkCmdTraceRaysKHR");
+	vkCreateRayTracingPipelinesKHR = (PFN_vkCreateRayTracingPipelinesKHR)load(context, "vkCreateRayTracingPipelinesKHR");
+	vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = (PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)load(context, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR");
+	vkGetRayTracingShaderGroupHandlesKHR = (PFN_vkGetRayTracingShaderGroupHandlesKHR)load(context, "vkGetRayTracingShaderGroupHandlesKHR");
+	vkGetRayTracingShaderGroupStackSizeKHR = (PFN_vkGetRayTracingShaderGroupStackSizeKHR)load(context, "vkGetRayTracingShaderGroupStackSizeKHR");
+#endif /* defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_sampler_ycbcr_conversion)
+	vkCreateSamplerYcbcrConversionKHR = (PFN_vkCreateSamplerYcbcrConversionKHR)load(context, "vkCreateSamplerYcbcrConversionKHR");
+	vkDestroySamplerYcbcrConversionKHR = (PFN_vkDestroySamplerYcbcrConversionKHR)load(context, "vkDestroySamplerYcbcrConversionKHR");
+#endif /* defined(VK_KHR_sampler_ycbcr_conversion) */
+#if defined(VK_KHR_shared_presentable_image)
+	vkGetSwapchainStatusKHR = (PFN_vkGetSwapchainStatusKHR)load(context, "vkGetSwapchainStatusKHR");
+#endif /* defined(VK_KHR_shared_presentable_image) */
+#if defined(VK_KHR_swapchain)
+	vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)load(context, "vkAcquireNextImageKHR");
+	vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)load(context, "vkCreateSwapchainKHR");
+	vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)load(context, "vkDestroySwapchainKHR");
+	vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)load(context, "vkGetSwapchainImagesKHR");
+	vkQueuePresentKHR = (PFN_vkQueuePresentKHR)load(context, "vkQueuePresentKHR");
+#endif /* defined(VK_KHR_swapchain) */
+#if defined(VK_KHR_swapchain_maintenance1)
+	vkReleaseSwapchainImagesKHR = (PFN_vkReleaseSwapchainImagesKHR)load(context, "vkReleaseSwapchainImagesKHR");
+#endif /* defined(VK_KHR_swapchain_maintenance1) */
+#if defined(VK_KHR_synchronization2)
+	vkCmdPipelineBarrier2KHR = (PFN_vkCmdPipelineBarrier2KHR)load(context, "vkCmdPipelineBarrier2KHR");
+	vkCmdResetEvent2KHR = (PFN_vkCmdResetEvent2KHR)load(context, "vkCmdResetEvent2KHR");
+	vkCmdSetEvent2KHR = (PFN_vkCmdSetEvent2KHR)load(context, "vkCmdSetEvent2KHR");
+	vkCmdWaitEvents2KHR = (PFN_vkCmdWaitEvents2KHR)load(context, "vkCmdWaitEvents2KHR");
+	vkCmdWriteTimestamp2KHR = (PFN_vkCmdWriteTimestamp2KHR)load(context, "vkCmdWriteTimestamp2KHR");
+	vkQueueSubmit2KHR = (PFN_vkQueueSubmit2KHR)load(context, "vkQueueSubmit2KHR");
+#endif /* defined(VK_KHR_synchronization2) */
+#if defined(VK_KHR_timeline_semaphore)
+	vkGetSemaphoreCounterValueKHR = (PFN_vkGetSemaphoreCounterValueKHR)load(context, "vkGetSemaphoreCounterValueKHR");
+	vkSignalSemaphoreKHR = (PFN_vkSignalSemaphoreKHR)load(context, "vkSignalSemaphoreKHR");
+	vkWaitSemaphoresKHR = (PFN_vkWaitSemaphoresKHR)load(context, "vkWaitSemaphoresKHR");
+#endif /* defined(VK_KHR_timeline_semaphore) */
+#if defined(VK_KHR_video_decode_queue)
+	vkCmdDecodeVideoKHR = (PFN_vkCmdDecodeVideoKHR)load(context, "vkCmdDecodeVideoKHR");
+#endif /* defined(VK_KHR_video_decode_queue) */
+#if defined(VK_KHR_video_encode_queue)
+	vkCmdEncodeVideoKHR = (PFN_vkCmdEncodeVideoKHR)load(context, "vkCmdEncodeVideoKHR");
+	vkGetEncodedVideoSessionParametersKHR = (PFN_vkGetEncodedVideoSessionParametersKHR)load(context, "vkGetEncodedVideoSessionParametersKHR");
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	vkBindVideoSessionMemoryKHR = (PFN_vkBindVideoSessionMemoryKHR)load(context, "vkBindVideoSessionMemoryKHR");
+	vkCmdBeginVideoCodingKHR = (PFN_vkCmdBeginVideoCodingKHR)load(context, "vkCmdBeginVideoCodingKHR");
+	vkCmdControlVideoCodingKHR = (PFN_vkCmdControlVideoCodingKHR)load(context, "vkCmdControlVideoCodingKHR");
+	vkCmdEndVideoCodingKHR = (PFN_vkCmdEndVideoCodingKHR)load(context, "vkCmdEndVideoCodingKHR");
+	vkCreateVideoSessionKHR = (PFN_vkCreateVideoSessionKHR)load(context, "vkCreateVideoSessionKHR");
+	vkCreateVideoSessionParametersKHR = (PFN_vkCreateVideoSessionParametersKHR)load(context, "vkCreateVideoSessionParametersKHR");
+	vkDestroyVideoSessionKHR = (PFN_vkDestroyVideoSessionKHR)load(context, "vkDestroyVideoSessionKHR");
+	vkDestroyVideoSessionParametersKHR = (PFN_vkDestroyVideoSessionParametersKHR)load(context, "vkDestroyVideoSessionParametersKHR");
+	vkGetVideoSessionMemoryRequirementsKHR = (PFN_vkGetVideoSessionMemoryRequirementsKHR)load(context, "vkGetVideoSessionMemoryRequirementsKHR");
+	vkUpdateVideoSessionParametersKHR = (PFN_vkUpdateVideoSessionParametersKHR)load(context, "vkUpdateVideoSessionParametersKHR");
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_NVX_binary_import)
+	vkCmdCuLaunchKernelNVX = (PFN_vkCmdCuLaunchKernelNVX)load(context, "vkCmdCuLaunchKernelNVX");
+	vkCreateCuFunctionNVX = (PFN_vkCreateCuFunctionNVX)load(context, "vkCreateCuFunctionNVX");
+	vkCreateCuModuleNVX = (PFN_vkCreateCuModuleNVX)load(context, "vkCreateCuModuleNVX");
+	vkDestroyCuFunctionNVX = (PFN_vkDestroyCuFunctionNVX)load(context, "vkDestroyCuFunctionNVX");
+	vkDestroyCuModuleNVX = (PFN_vkDestroyCuModuleNVX)load(context, "vkDestroyCuModuleNVX");
+#endif /* defined(VK_NVX_binary_import) */
+#if defined(VK_NVX_image_view_handle)
+	vkGetImageViewHandleNVX = (PFN_vkGetImageViewHandleNVX)load(context, "vkGetImageViewHandleNVX");
+#endif /* defined(VK_NVX_image_view_handle) */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3
+	vkGetImageViewHandle64NVX = (PFN_vkGetImageViewHandle64NVX)load(context, "vkGetImageViewHandle64NVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2
+	vkGetImageViewAddressNVX = (PFN_vkGetImageViewAddressNVX)load(context, "vkGetImageViewAddressNVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4
+	vkGetDeviceCombinedImageSamplerIndexNVX = (PFN_vkGetDeviceCombinedImageSamplerIndexNVX)load(context, "vkGetDeviceCombinedImageSamplerIndexNVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4 */
+#if defined(VK_NV_clip_space_w_scaling)
+	vkCmdSetViewportWScalingNV = (PFN_vkCmdSetViewportWScalingNV)load(context, "vkCmdSetViewportWScalingNV");
+#endif /* defined(VK_NV_clip_space_w_scaling) */
+#if defined(VK_NV_cluster_acceleration_structure)
+	vkCmdBuildClusterAccelerationStructureIndirectNV = (PFN_vkCmdBuildClusterAccelerationStructureIndirectNV)load(context, "vkCmdBuildClusterAccelerationStructureIndirectNV");
+	vkGetClusterAccelerationStructureBuildSizesNV = (PFN_vkGetClusterAccelerationStructureBuildSizesNV)load(context, "vkGetClusterAccelerationStructureBuildSizesNV");
+#endif /* defined(VK_NV_cluster_acceleration_structure) */
+#if defined(VK_NV_compute_occupancy_priority)
+	vkCmdSetComputeOccupancyPriorityNV = (PFN_vkCmdSetComputeOccupancyPriorityNV)load(context, "vkCmdSetComputeOccupancyPriorityNV");
+#endif /* defined(VK_NV_compute_occupancy_priority) */
+#if defined(VK_NV_cooperative_vector)
+	vkCmdConvertCooperativeVectorMatrixNV = (PFN_vkCmdConvertCooperativeVectorMatrixNV)load(context, "vkCmdConvertCooperativeVectorMatrixNV");
+	vkConvertCooperativeVectorMatrixNV = (PFN_vkConvertCooperativeVectorMatrixNV)load(context, "vkConvertCooperativeVectorMatrixNV");
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_copy_memory_indirect)
+	vkCmdCopyMemoryIndirectNV = (PFN_vkCmdCopyMemoryIndirectNV)load(context, "vkCmdCopyMemoryIndirectNV");
+	vkCmdCopyMemoryToImageIndirectNV = (PFN_vkCmdCopyMemoryToImageIndirectNV)load(context, "vkCmdCopyMemoryToImageIndirectNV");
+#endif /* defined(VK_NV_copy_memory_indirect) */
+#if defined(VK_NV_cuda_kernel_launch)
+	vkCmdCudaLaunchKernelNV = (PFN_vkCmdCudaLaunchKernelNV)load(context, "vkCmdCudaLaunchKernelNV");
+	vkCreateCudaFunctionNV = (PFN_vkCreateCudaFunctionNV)load(context, "vkCreateCudaFunctionNV");
+	vkCreateCudaModuleNV = (PFN_vkCreateCudaModuleNV)load(context, "vkCreateCudaModuleNV");
+	vkDestroyCudaFunctionNV = (PFN_vkDestroyCudaFunctionNV)load(context, "vkDestroyCudaFunctionNV");
+	vkDestroyCudaModuleNV = (PFN_vkDestroyCudaModuleNV)load(context, "vkDestroyCudaModuleNV");
+	vkGetCudaModuleCacheNV = (PFN_vkGetCudaModuleCacheNV)load(context, "vkGetCudaModuleCacheNV");
+#endif /* defined(VK_NV_cuda_kernel_launch) */
+#if defined(VK_NV_device_diagnostic_checkpoints)
+	vkCmdSetCheckpointNV = (PFN_vkCmdSetCheckpointNV)load(context, "vkCmdSetCheckpointNV");
+	vkGetQueueCheckpointDataNV = (PFN_vkGetQueueCheckpointDataNV)load(context, "vkGetQueueCheckpointDataNV");
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) */
+#if defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	vkGetQueueCheckpointData2NV = (PFN_vkGetQueueCheckpointData2NV)load(context, "vkGetQueueCheckpointData2NV");
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_NV_device_generated_commands)
+	vkCmdBindPipelineShaderGroupNV = (PFN_vkCmdBindPipelineShaderGroupNV)load(context, "vkCmdBindPipelineShaderGroupNV");
+	vkCmdExecuteGeneratedCommandsNV = (PFN_vkCmdExecuteGeneratedCommandsNV)load(context, "vkCmdExecuteGeneratedCommandsNV");
+	vkCmdPreprocessGeneratedCommandsNV = (PFN_vkCmdPreprocessGeneratedCommandsNV)load(context, "vkCmdPreprocessGeneratedCommandsNV");
+	vkCreateIndirectCommandsLayoutNV = (PFN_vkCreateIndirectCommandsLayoutNV)load(context, "vkCreateIndirectCommandsLayoutNV");
+	vkDestroyIndirectCommandsLayoutNV = (PFN_vkDestroyIndirectCommandsLayoutNV)load(context, "vkDestroyIndirectCommandsLayoutNV");
+	vkGetGeneratedCommandsMemoryRequirementsNV = (PFN_vkGetGeneratedCommandsMemoryRequirementsNV)load(context, "vkGetGeneratedCommandsMemoryRequirementsNV");
+#endif /* defined(VK_NV_device_generated_commands) */
+#if defined(VK_NV_device_generated_commands_compute)
+	vkCmdUpdatePipelineIndirectBufferNV = (PFN_vkCmdUpdatePipelineIndirectBufferNV)load(context, "vkCmdUpdatePipelineIndirectBufferNV");
+	vkGetPipelineIndirectDeviceAddressNV = (PFN_vkGetPipelineIndirectDeviceAddressNV)load(context, "vkGetPipelineIndirectDeviceAddressNV");
+	vkGetPipelineIndirectMemoryRequirementsNV = (PFN_vkGetPipelineIndirectMemoryRequirementsNV)load(context, "vkGetPipelineIndirectMemoryRequirementsNV");
+#endif /* defined(VK_NV_device_generated_commands_compute) */
+#if defined(VK_NV_external_compute_queue)
+	vkCreateExternalComputeQueueNV = (PFN_vkCreateExternalComputeQueueNV)load(context, "vkCreateExternalComputeQueueNV");
+	vkDestroyExternalComputeQueueNV = (PFN_vkDestroyExternalComputeQueueNV)load(context, "vkDestroyExternalComputeQueueNV");
+	vkGetExternalComputeQueueDataNV = (PFN_vkGetExternalComputeQueueDataNV)load(context, "vkGetExternalComputeQueueDataNV");
+#endif /* defined(VK_NV_external_compute_queue) */
+#if defined(VK_NV_external_memory_rdma)
+	vkGetMemoryRemoteAddressNV = (PFN_vkGetMemoryRemoteAddressNV)load(context, "vkGetMemoryRemoteAddressNV");
+#endif /* defined(VK_NV_external_memory_rdma) */
+#if defined(VK_NV_external_memory_win32)
+	vkGetMemoryWin32HandleNV = (PFN_vkGetMemoryWin32HandleNV)load(context, "vkGetMemoryWin32HandleNV");
+#endif /* defined(VK_NV_external_memory_win32) */
+#if defined(VK_NV_fragment_shading_rate_enums)
+	vkCmdSetFragmentShadingRateEnumNV = (PFN_vkCmdSetFragmentShadingRateEnumNV)load(context, "vkCmdSetFragmentShadingRateEnumNV");
+#endif /* defined(VK_NV_fragment_shading_rate_enums) */
+#if defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2
+	vkGetLatencyTimingsLegacyNV = (PFN_vkGetLatencyTimingsLegacyNV)load(context, "vkGetLatencyTimingsLegacyNV");
+	vkGetSleepStatusLegacyNV = (PFN_vkGetSleepStatusLegacyNV)load(context, "vkGetSleepStatusLegacyNV");
+	vkLatencySleepLegacyNV = (PFN_vkLatencySleepLegacyNV)load(context, "vkLatencySleepLegacyNV");
+	vkQueueNotifyOutOfBandLegacyNV = (PFN_vkQueueNotifyOutOfBandLegacyNV)load(context, "vkQueueNotifyOutOfBandLegacyNV");
+	vkSetLatencyMarkerLegacyNV = (PFN_vkSetLatencyMarkerLegacyNV)load(context, "vkSetLatencyMarkerLegacyNV");
+	vkSetLatencySleepModeLegacyNV = (PFN_vkSetLatencySleepModeLegacyNV)load(context, "vkSetLatencySleepModeLegacyNV");
+	vkShutdownLatencyDeviceLegacyNV = (PFN_vkShutdownLatencyDeviceLegacyNV)load(context, "vkShutdownLatencyDeviceLegacyNV");
+#endif /* defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2 */
+#if defined(VK_NV_low_latency2)
+	vkGetLatencyTimingsNV = (PFN_vkGetLatencyTimingsNV)load(context, "vkGetLatencyTimingsNV");
+	vkLatencySleepNV = (PFN_vkLatencySleepNV)load(context, "vkLatencySleepNV");
+	vkQueueNotifyOutOfBandNV = (PFN_vkQueueNotifyOutOfBandNV)load(context, "vkQueueNotifyOutOfBandNV");
+	vkSetLatencyMarkerNV = (PFN_vkSetLatencyMarkerNV)load(context, "vkSetLatencyMarkerNV");
+	vkSetLatencySleepModeNV = (PFN_vkSetLatencySleepModeNV)load(context, "vkSetLatencySleepModeNV");
+#endif /* defined(VK_NV_low_latency2) */
+#if defined(VK_NV_memory_decompression)
+	vkCmdDecompressMemoryIndirectCountNV = (PFN_vkCmdDecompressMemoryIndirectCountNV)load(context, "vkCmdDecompressMemoryIndirectCountNV");
+	vkCmdDecompressMemoryNV = (PFN_vkCmdDecompressMemoryNV)load(context, "vkCmdDecompressMemoryNV");
+#endif /* defined(VK_NV_memory_decompression) */
+#if defined(VK_NV_mesh_shader)
+	vkCmdDrawMeshTasksIndirectNV = (PFN_vkCmdDrawMeshTasksIndirectNV)load(context, "vkCmdDrawMeshTasksIndirectNV");
+	vkCmdDrawMeshTasksNV = (PFN_vkCmdDrawMeshTasksNV)load(context, "vkCmdDrawMeshTasksNV");
+#endif /* defined(VK_NV_mesh_shader) */
+#if defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	vkCmdDrawMeshTasksIndirectCountNV = (PFN_vkCmdDrawMeshTasksIndirectCountNV)load(context, "vkCmdDrawMeshTasksIndirectCountNV");
+#endif /* defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_NV_optical_flow)
+	vkBindOpticalFlowSessionImageNV = (PFN_vkBindOpticalFlowSessionImageNV)load(context, "vkBindOpticalFlowSessionImageNV");
+	vkCmdOpticalFlowExecuteNV = (PFN_vkCmdOpticalFlowExecuteNV)load(context, "vkCmdOpticalFlowExecuteNV");
+	vkCreateOpticalFlowSessionNV = (PFN_vkCreateOpticalFlowSessionNV)load(context, "vkCreateOpticalFlowSessionNV");
+	vkDestroyOpticalFlowSessionNV = (PFN_vkDestroyOpticalFlowSessionNV)load(context, "vkDestroyOpticalFlowSessionNV");
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_NV_partitioned_acceleration_structure)
+	vkCmdBuildPartitionedAccelerationStructuresNV = (PFN_vkCmdBuildPartitionedAccelerationStructuresNV)load(context, "vkCmdBuildPartitionedAccelerationStructuresNV");
+	vkGetPartitionedAccelerationStructuresBuildSizesNV = (PFN_vkGetPartitionedAccelerationStructuresBuildSizesNV)load(context, "vkGetPartitionedAccelerationStructuresBuildSizesNV");
+#endif /* defined(VK_NV_partitioned_acceleration_structure) */
+#if defined(VK_NV_ray_tracing)
+	vkBindAccelerationStructureMemoryNV = (PFN_vkBindAccelerationStructureMemoryNV)load(context, "vkBindAccelerationStructureMemoryNV");
+	vkCmdBuildAccelerationStructureNV = (PFN_vkCmdBuildAccelerationStructureNV)load(context, "vkCmdBuildAccelerationStructureNV");
+	vkCmdCopyAccelerationStructureNV = (PFN_vkCmdCopyAccelerationStructureNV)load(context, "vkCmdCopyAccelerationStructureNV");
+	vkCmdTraceRaysNV = (PFN_vkCmdTraceRaysNV)load(context, "vkCmdTraceRaysNV");
+	vkCmdWriteAccelerationStructuresPropertiesNV = (PFN_vkCmdWriteAccelerationStructuresPropertiesNV)load(context, "vkCmdWriteAccelerationStructuresPropertiesNV");
+	vkCompileDeferredNV = (PFN_vkCompileDeferredNV)load(context, "vkCompileDeferredNV");
+	vkCreateAccelerationStructureNV = (PFN_vkCreateAccelerationStructureNV)load(context, "vkCreateAccelerationStructureNV");
+	vkCreateRayTracingPipelinesNV = (PFN_vkCreateRayTracingPipelinesNV)load(context, "vkCreateRayTracingPipelinesNV");
+	vkDestroyAccelerationStructureNV = (PFN_vkDestroyAccelerationStructureNV)load(context, "vkDestroyAccelerationStructureNV");
+	vkGetAccelerationStructureHandleNV = (PFN_vkGetAccelerationStructureHandleNV)load(context, "vkGetAccelerationStructureHandleNV");
+	vkGetAccelerationStructureMemoryRequirementsNV = (PFN_vkGetAccelerationStructureMemoryRequirementsNV)load(context, "vkGetAccelerationStructureMemoryRequirementsNV");
+	vkGetRayTracingShaderGroupHandlesNV = (PFN_vkGetRayTracingShaderGroupHandlesNV)load(context, "vkGetRayTracingShaderGroupHandlesNV");
+#endif /* defined(VK_NV_ray_tracing) */
+#if defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2
+	vkCmdSetExclusiveScissorEnableNV = (PFN_vkCmdSetExclusiveScissorEnableNV)load(context, "vkCmdSetExclusiveScissorEnableNV");
+#endif /* defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2 */
+#if defined(VK_NV_scissor_exclusive)
+	vkCmdSetExclusiveScissorNV = (PFN_vkCmdSetExclusiveScissorNV)load(context, "vkCmdSetExclusiveScissorNV");
+#endif /* defined(VK_NV_scissor_exclusive) */
+#if defined(VK_NV_shading_rate_image)
+	vkCmdBindShadingRateImageNV = (PFN_vkCmdBindShadingRateImageNV)load(context, "vkCmdBindShadingRateImageNV");
+	vkCmdSetCoarseSampleOrderNV = (PFN_vkCmdSetCoarseSampleOrderNV)load(context, "vkCmdSetCoarseSampleOrderNV");
+	vkCmdSetViewportShadingRatePaletteNV = (PFN_vkCmdSetViewportShadingRatePaletteNV)load(context, "vkCmdSetViewportShadingRatePaletteNV");
+#endif /* defined(VK_NV_shading_rate_image) */
+#if defined(VK_OHOS_external_memory)
+	vkGetMemoryNativeBufferOHOS = (PFN_vkGetMemoryNativeBufferOHOS)load(context, "vkGetMemoryNativeBufferOHOS");
+	vkGetNativeBufferPropertiesOHOS = (PFN_vkGetNativeBufferPropertiesOHOS)load(context, "vkGetNativeBufferPropertiesOHOS");
+#endif /* defined(VK_OHOS_external_memory) */
+#if defined(VK_QCOM_queue_perf_hint)
+	vkQueueSetPerfHintQCOM = (PFN_vkQueueSetPerfHintQCOM)load(context, "vkQueueSetPerfHintQCOM");
+#endif /* defined(VK_QCOM_queue_perf_hint) */
+#if defined(VK_QCOM_tile_memory_heap)
+	vkCmdBindTileMemoryQCOM = (PFN_vkCmdBindTileMemoryQCOM)load(context, "vkCmdBindTileMemoryQCOM");
+#endif /* defined(VK_QCOM_tile_memory_heap) */
+#if defined(VK_QCOM_tile_properties)
+	vkGetDynamicRenderingTilePropertiesQCOM = (PFN_vkGetDynamicRenderingTilePropertiesQCOM)load(context, "vkGetDynamicRenderingTilePropertiesQCOM");
+	vkGetFramebufferTilePropertiesQCOM = (PFN_vkGetFramebufferTilePropertiesQCOM)load(context, "vkGetFramebufferTilePropertiesQCOM");
+#endif /* defined(VK_QCOM_tile_properties) */
+#if defined(VK_QCOM_tile_shading)
+	vkCmdBeginPerTileExecutionQCOM = (PFN_vkCmdBeginPerTileExecutionQCOM)load(context, "vkCmdBeginPerTileExecutionQCOM");
+	vkCmdDispatchTileQCOM = (PFN_vkCmdDispatchTileQCOM)load(context, "vkCmdDispatchTileQCOM");
+	vkCmdEndPerTileExecutionQCOM = (PFN_vkCmdEndPerTileExecutionQCOM)load(context, "vkCmdEndPerTileExecutionQCOM");
+#endif /* defined(VK_QCOM_tile_shading) */
+#if defined(VK_QNX_external_memory_screen_buffer)
+	vkGetScreenBufferPropertiesQNX = (PFN_vkGetScreenBufferPropertiesQNX)load(context, "vkGetScreenBufferPropertiesQNX");
+#endif /* defined(VK_QNX_external_memory_screen_buffer) */
+#if defined(VK_VALVE_descriptor_set_host_mapping)
+	vkGetDescriptorSetHostMappingVALVE = (PFN_vkGetDescriptorSetHostMappingVALVE)load(context, "vkGetDescriptorSetHostMappingVALVE");
+	vkGetDescriptorSetLayoutHostMappingInfoVALVE = (PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE)load(context, "vkGetDescriptorSetLayoutHostMappingInfoVALVE");
+#endif /* defined(VK_VALVE_descriptor_set_host_mapping) */
+#if (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control))
+	vkCmdSetDepthClampRangeEXT = (PFN_vkCmdSetDepthClampRangeEXT)load(context, "vkCmdSetDepthClampRangeEXT");
+#endif /* (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control)) */
+#if (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object))
+	vkCmdBindVertexBuffers2EXT = (PFN_vkCmdBindVertexBuffers2EXT)load(context, "vkCmdBindVertexBuffers2EXT");
+	vkCmdSetCullModeEXT = (PFN_vkCmdSetCullModeEXT)load(context, "vkCmdSetCullModeEXT");
+	vkCmdSetDepthBoundsTestEnableEXT = (PFN_vkCmdSetDepthBoundsTestEnableEXT)load(context, "vkCmdSetDepthBoundsTestEnableEXT");
+	vkCmdSetDepthCompareOpEXT = (PFN_vkCmdSetDepthCompareOpEXT)load(context, "vkCmdSetDepthCompareOpEXT");
+	vkCmdSetDepthTestEnableEXT = (PFN_vkCmdSetDepthTestEnableEXT)load(context, "vkCmdSetDepthTestEnableEXT");
+	vkCmdSetDepthWriteEnableEXT = (PFN_vkCmdSetDepthWriteEnableEXT)load(context, "vkCmdSetDepthWriteEnableEXT");
+	vkCmdSetFrontFaceEXT = (PFN_vkCmdSetFrontFaceEXT)load(context, "vkCmdSetFrontFaceEXT");
+	vkCmdSetPrimitiveTopologyEXT = (PFN_vkCmdSetPrimitiveTopologyEXT)load(context, "vkCmdSetPrimitiveTopologyEXT");
+	vkCmdSetScissorWithCountEXT = (PFN_vkCmdSetScissorWithCountEXT)load(context, "vkCmdSetScissorWithCountEXT");
+	vkCmdSetStencilOpEXT = (PFN_vkCmdSetStencilOpEXT)load(context, "vkCmdSetStencilOpEXT");
+	vkCmdSetStencilTestEnableEXT = (PFN_vkCmdSetStencilTestEnableEXT)load(context, "vkCmdSetStencilTestEnableEXT");
+	vkCmdSetViewportWithCountEXT = (PFN_vkCmdSetViewportWithCountEXT)load(context, "vkCmdSetViewportWithCountEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object))
+	vkCmdSetDepthBiasEnableEXT = (PFN_vkCmdSetDepthBiasEnableEXT)load(context, "vkCmdSetDepthBiasEnableEXT");
+	vkCmdSetLogicOpEXT = (PFN_vkCmdSetLogicOpEXT)load(context, "vkCmdSetLogicOpEXT");
+	vkCmdSetPatchControlPointsEXT = (PFN_vkCmdSetPatchControlPointsEXT)load(context, "vkCmdSetPatchControlPointsEXT");
+	vkCmdSetPrimitiveRestartEnableEXT = (PFN_vkCmdSetPrimitiveRestartEnableEXT)load(context, "vkCmdSetPrimitiveRestartEnableEXT");
+	vkCmdSetRasterizerDiscardEnableEXT = (PFN_vkCmdSetRasterizerDiscardEnableEXT)load(context, "vkCmdSetRasterizerDiscardEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object))
+	vkCmdSetAlphaToCoverageEnableEXT = (PFN_vkCmdSetAlphaToCoverageEnableEXT)load(context, "vkCmdSetAlphaToCoverageEnableEXT");
+	vkCmdSetAlphaToOneEnableEXT = (PFN_vkCmdSetAlphaToOneEnableEXT)load(context, "vkCmdSetAlphaToOneEnableEXT");
+	vkCmdSetColorBlendEnableEXT = (PFN_vkCmdSetColorBlendEnableEXT)load(context, "vkCmdSetColorBlendEnableEXT");
+	vkCmdSetColorBlendEquationEXT = (PFN_vkCmdSetColorBlendEquationEXT)load(context, "vkCmdSetColorBlendEquationEXT");
+	vkCmdSetColorWriteMaskEXT = (PFN_vkCmdSetColorWriteMaskEXT)load(context, "vkCmdSetColorWriteMaskEXT");
+	vkCmdSetDepthClampEnableEXT = (PFN_vkCmdSetDepthClampEnableEXT)load(context, "vkCmdSetDepthClampEnableEXT");
+	vkCmdSetLogicOpEnableEXT = (PFN_vkCmdSetLogicOpEnableEXT)load(context, "vkCmdSetLogicOpEnableEXT");
+	vkCmdSetPolygonModeEXT = (PFN_vkCmdSetPolygonModeEXT)load(context, "vkCmdSetPolygonModeEXT");
+	vkCmdSetRasterizationSamplesEXT = (PFN_vkCmdSetRasterizationSamplesEXT)load(context, "vkCmdSetRasterizationSamplesEXT");
+	vkCmdSetSampleMaskEXT = (PFN_vkCmdSetSampleMaskEXT)load(context, "vkCmdSetSampleMaskEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object))
+	vkCmdSetTessellationDomainOriginEXT = (PFN_vkCmdSetTessellationDomainOriginEXT)load(context, "vkCmdSetTessellationDomainOriginEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback))
+	vkCmdSetRasterizationStreamEXT = (PFN_vkCmdSetRasterizationStreamEXT)load(context, "vkCmdSetRasterizationStreamEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization))
+	vkCmdSetConservativeRasterizationModeEXT = (PFN_vkCmdSetConservativeRasterizationModeEXT)load(context, "vkCmdSetConservativeRasterizationModeEXT");
+	vkCmdSetExtraPrimitiveOverestimationSizeEXT = (PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT)load(context, "vkCmdSetExtraPrimitiveOverestimationSizeEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable))
+	vkCmdSetDepthClipEnableEXT = (PFN_vkCmdSetDepthClipEnableEXT)load(context, "vkCmdSetDepthClipEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations))
+	vkCmdSetSampleLocationsEnableEXT = (PFN_vkCmdSetSampleLocationsEnableEXT)load(context, "vkCmdSetSampleLocationsEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced))
+	vkCmdSetColorBlendAdvancedEXT = (PFN_vkCmdSetColorBlendAdvancedEXT)load(context, "vkCmdSetColorBlendAdvancedEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex))
+	vkCmdSetProvokingVertexModeEXT = (PFN_vkCmdSetProvokingVertexModeEXT)load(context, "vkCmdSetProvokingVertexModeEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization)))
+	vkCmdSetLineRasterizationModeEXT = (PFN_vkCmdSetLineRasterizationModeEXT)load(context, "vkCmdSetLineRasterizationModeEXT");
+	vkCmdSetLineStippleEnableEXT = (PFN_vkCmdSetLineStippleEnableEXT)load(context, "vkCmdSetLineStippleEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control))
+	vkCmdSetDepthClipNegativeOneToOneEXT = (PFN_vkCmdSetDepthClipNegativeOneToOneEXT)load(context, "vkCmdSetDepthClipNegativeOneToOneEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling))
+	vkCmdSetViewportWScalingEnableNV = (PFN_vkCmdSetViewportWScalingEnableNV)load(context, "vkCmdSetViewportWScalingEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle))
+	vkCmdSetViewportSwizzleNV = (PFN_vkCmdSetViewportSwizzleNV)load(context, "vkCmdSetViewportSwizzleNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color))
+	vkCmdSetCoverageToColorEnableNV = (PFN_vkCmdSetCoverageToColorEnableNV)load(context, "vkCmdSetCoverageToColorEnableNV");
+	vkCmdSetCoverageToColorLocationNV = (PFN_vkCmdSetCoverageToColorLocationNV)load(context, "vkCmdSetCoverageToColorLocationNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples))
+	vkCmdSetCoverageModulationModeNV = (PFN_vkCmdSetCoverageModulationModeNV)load(context, "vkCmdSetCoverageModulationModeNV");
+	vkCmdSetCoverageModulationTableEnableNV = (PFN_vkCmdSetCoverageModulationTableEnableNV)load(context, "vkCmdSetCoverageModulationTableEnableNV");
+	vkCmdSetCoverageModulationTableNV = (PFN_vkCmdSetCoverageModulationTableNV)load(context, "vkCmdSetCoverageModulationTableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image))
+	vkCmdSetShadingRateImageEnableNV = (PFN_vkCmdSetShadingRateImageEnableNV)load(context, "vkCmdSetShadingRateImageEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test))
+	vkCmdSetRepresentativeFragmentTestEnableNV = (PFN_vkCmdSetRepresentativeFragmentTestEnableNV)load(context, "vkCmdSetRepresentativeFragmentTestEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode))
+	vkCmdSetCoverageReductionModeNV = (PFN_vkCmdSetCoverageReductionModeNV)load(context, "vkCmdSetCoverageReductionModeNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode)) */
+#if (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control))
+	vkGetImageSubresourceLayout2EXT = (PFN_vkGetImageSubresourceLayout2EXT)load(context, "vkGetImageSubresourceLayout2EXT");
+#endif /* (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control)) */
+#if (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state))
+	vkCmdSetVertexInputEXT = (PFN_vkCmdSetVertexInputEXT)load(context, "vkCmdSetVertexInputEXT");
+#endif /* (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state)) */
+#if (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template)))
+	vkCmdPushDescriptorSetWithTemplateKHR = (PFN_vkCmdPushDescriptorSetWithTemplateKHR)load(context, "vkCmdPushDescriptorSetWithTemplateKHR");
+#endif /* (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template))) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR)load(context, "vkGetDeviceGroupPresentCapabilitiesKHR");
+	vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR)load(context, "vkGetDeviceGroupSurfacePresentModesKHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR)load(context, "vkAcquireNextImage2KHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_LOAD_DEVICE */
+}
+
+static void volkGenLoadInstanceTable(struct VolkInstanceTable* table, void* context, PFN_vkVoidFunction (*load)(void*, const char*))
+{
+	/* VOLK_GENERATE_LOAD_INSTANCE_TABLE */
+#if defined(VK_VERSION_1_0)
+	table->vkCreateDevice = (PFN_vkCreateDevice)load(context, "vkCreateDevice");
+	table->vkDestroyInstance = (PFN_vkDestroyInstance)load(context, "vkDestroyInstance");
+	table->vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties)load(context, "vkEnumerateDeviceExtensionProperties");
+	table->vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties)load(context, "vkEnumerateDeviceLayerProperties");
+	table->vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)load(context, "vkEnumeratePhysicalDevices");
+	table->vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)load(context, "vkGetDeviceProcAddr");
+	table->vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures)load(context, "vkGetPhysicalDeviceFeatures");
+	table->vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties)load(context, "vkGetPhysicalDeviceFormatProperties");
+	table->vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties)load(context, "vkGetPhysicalDeviceImageFormatProperties");
+	table->vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties)load(context, "vkGetPhysicalDeviceMemoryProperties");
+	table->vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)load(context, "vkGetPhysicalDeviceProperties");
+	table->vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties)load(context, "vkGetPhysicalDeviceQueueFamilyProperties");
+	table->vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties");
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	table->vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups)load(context, "vkEnumeratePhysicalDeviceGroups");
+	table->vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties)load(context, "vkGetPhysicalDeviceExternalBufferProperties");
+	table->vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties)load(context, "vkGetPhysicalDeviceExternalFenceProperties");
+	table->vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)load(context, "vkGetPhysicalDeviceExternalSemaphoreProperties");
+	table->vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2)load(context, "vkGetPhysicalDeviceFeatures2");
+	table->vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2)load(context, "vkGetPhysicalDeviceFormatProperties2");
+	table->vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2)load(context, "vkGetPhysicalDeviceImageFormatProperties2");
+	table->vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2)load(context, "vkGetPhysicalDeviceMemoryProperties2");
+	table->vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2)load(context, "vkGetPhysicalDeviceProperties2");
+	table->vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2)load(context, "vkGetPhysicalDeviceQueueFamilyProperties2");
+	table->vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties2");
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_3)
+	table->vkGetPhysicalDeviceToolProperties = (PFN_vkGetPhysicalDeviceToolProperties)load(context, "vkGetPhysicalDeviceToolProperties");
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_ARM_data_graph)
+	table->vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM");
+	table->vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM");
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_data_graph_optical_flow)
+	table->vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM");
+#endif /* defined(VK_ARM_data_graph_optical_flow) */
+#if defined(VK_ARM_performance_counters_by_region)
+	table->vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM = (PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM)load(context, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM");
+#endif /* defined(VK_ARM_performance_counters_by_region) */
+#if defined(VK_ARM_shader_instrumentation)
+	table->vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM = (PFN_vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM)load(context, "vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM");
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	table->vkGetPhysicalDeviceExternalTensorPropertiesARM = (PFN_vkGetPhysicalDeviceExternalTensorPropertiesARM)load(context, "vkGetPhysicalDeviceExternalTensorPropertiesARM");
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_EXT_acquire_drm_display)
+	table->vkAcquireDrmDisplayEXT = (PFN_vkAcquireDrmDisplayEXT)load(context, "vkAcquireDrmDisplayEXT");
+	table->vkGetDrmDisplayEXT = (PFN_vkGetDrmDisplayEXT)load(context, "vkGetDrmDisplayEXT");
+#endif /* defined(VK_EXT_acquire_drm_display) */
+#if defined(VK_EXT_acquire_xlib_display)
+	table->vkAcquireXlibDisplayEXT = (PFN_vkAcquireXlibDisplayEXT)load(context, "vkAcquireXlibDisplayEXT");
+	table->vkGetRandROutputDisplayEXT = (PFN_vkGetRandROutputDisplayEXT)load(context, "vkGetRandROutputDisplayEXT");
+#endif /* defined(VK_EXT_acquire_xlib_display) */
+#if defined(VK_EXT_calibrated_timestamps)
+	table->vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)load(context, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT");
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_cooperative_matrix_maintenance1)
+	table->vkGetPhysicalDeviceCooperativeMatrixProperties2EXT = (PFN_vkGetPhysicalDeviceCooperativeMatrixProperties2EXT)load(context, "vkGetPhysicalDeviceCooperativeMatrixProperties2EXT");
+#endif /* defined(VK_EXT_cooperative_matrix_maintenance1) */
+#if defined(VK_EXT_debug_report)
+	table->vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)load(context, "vkCreateDebugReportCallbackEXT");
+	table->vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT)load(context, "vkDebugReportMessageEXT");
+	table->vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)load(context, "vkDestroyDebugReportCallbackEXT");
+#endif /* defined(VK_EXT_debug_report) */
+#if defined(VK_EXT_debug_utils)
+	table->vkCmdBeginDebugUtilsLabelEXT = (PFN_vkCmdBeginDebugUtilsLabelEXT)load(context, "vkCmdBeginDebugUtilsLabelEXT");
+	table->vkCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)load(context, "vkCmdEndDebugUtilsLabelEXT");
+	table->vkCmdInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT)load(context, "vkCmdInsertDebugUtilsLabelEXT");
+	table->vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)load(context, "vkCreateDebugUtilsMessengerEXT");
+	table->vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT)load(context, "vkDestroyDebugUtilsMessengerEXT");
+	table->vkQueueBeginDebugUtilsLabelEXT = (PFN_vkQueueBeginDebugUtilsLabelEXT)load(context, "vkQueueBeginDebugUtilsLabelEXT");
+	table->vkQueueEndDebugUtilsLabelEXT = (PFN_vkQueueEndDebugUtilsLabelEXT)load(context, "vkQueueEndDebugUtilsLabelEXT");
+	table->vkQueueInsertDebugUtilsLabelEXT = (PFN_vkQueueInsertDebugUtilsLabelEXT)load(context, "vkQueueInsertDebugUtilsLabelEXT");
+	table->vkSetDebugUtilsObjectNameEXT = (PFN_vkSetDebugUtilsObjectNameEXT)load(context, "vkSetDebugUtilsObjectNameEXT");
+	table->vkSetDebugUtilsObjectTagEXT = (PFN_vkSetDebugUtilsObjectTagEXT)load(context, "vkSetDebugUtilsObjectTagEXT");
+	table->vkSubmitDebugUtilsMessageEXT = (PFN_vkSubmitDebugUtilsMessageEXT)load(context, "vkSubmitDebugUtilsMessageEXT");
+#endif /* defined(VK_EXT_debug_utils) */
+#if defined(VK_EXT_descriptor_heap)
+	table->vkGetPhysicalDeviceDescriptorSizeEXT = (PFN_vkGetPhysicalDeviceDescriptorSizeEXT)load(context, "vkGetPhysicalDeviceDescriptorSizeEXT");
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_direct_mode_display)
+	table->vkReleaseDisplayEXT = (PFN_vkReleaseDisplayEXT)load(context, "vkReleaseDisplayEXT");
+#endif /* defined(VK_EXT_direct_mode_display) */
+#if defined(VK_EXT_directfb_surface)
+	table->vkCreateDirectFBSurfaceEXT = (PFN_vkCreateDirectFBSurfaceEXT)load(context, "vkCreateDirectFBSurfaceEXT");
+	table->vkGetPhysicalDeviceDirectFBPresentationSupportEXT = (PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)load(context, "vkGetPhysicalDeviceDirectFBPresentationSupportEXT");
+#endif /* defined(VK_EXT_directfb_surface) */
+#if defined(VK_EXT_display_surface_counter)
+	table->vkGetPhysicalDeviceSurfaceCapabilities2EXT = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)load(context, "vkGetPhysicalDeviceSurfaceCapabilities2EXT");
+#endif /* defined(VK_EXT_display_surface_counter) */
+#if defined(VK_EXT_full_screen_exclusive)
+	table->vkGetPhysicalDeviceSurfacePresentModes2EXT = (PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)load(context, "vkGetPhysicalDeviceSurfacePresentModes2EXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_headless_surface)
+	table->vkCreateHeadlessSurfaceEXT = (PFN_vkCreateHeadlessSurfaceEXT)load(context, "vkCreateHeadlessSurfaceEXT");
+#endif /* defined(VK_EXT_headless_surface) */
+#if defined(VK_EXT_metal_surface)
+	table->vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)load(context, "vkCreateMetalSurfaceEXT");
+#endif /* defined(VK_EXT_metal_surface) */
+#if defined(VK_EXT_sample_locations)
+	table->vkGetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)load(context, "vkGetPhysicalDeviceMultisamplePropertiesEXT");
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_tooling_info)
+	table->vkGetPhysicalDeviceToolPropertiesEXT = (PFN_vkGetPhysicalDeviceToolPropertiesEXT)load(context, "vkGetPhysicalDeviceToolPropertiesEXT");
+#endif /* defined(VK_EXT_tooling_info) */
+#if defined(VK_FUCHSIA_imagepipe_surface)
+	table->vkCreateImagePipeSurfaceFUCHSIA = (PFN_vkCreateImagePipeSurfaceFUCHSIA)load(context, "vkCreateImagePipeSurfaceFUCHSIA");
+#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
+#if defined(VK_GGP_stream_descriptor_surface)
+	table->vkCreateStreamDescriptorSurfaceGGP = (PFN_vkCreateStreamDescriptorSurfaceGGP)load(context, "vkCreateStreamDescriptorSurfaceGGP");
+#endif /* defined(VK_GGP_stream_descriptor_surface) */
+#if defined(VK_KHR_android_surface)
+	table->vkCreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)load(context, "vkCreateAndroidSurfaceKHR");
+#endif /* defined(VK_KHR_android_surface) */
+#if defined(VK_KHR_calibrated_timestamps)
+	table->vkGetPhysicalDeviceCalibrateableTimeDomainsKHR = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR)load(context, "vkGetPhysicalDeviceCalibrateableTimeDomainsKHR");
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_cooperative_matrix)
+	table->vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR)load(context, "vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR");
+#endif /* defined(VK_KHR_cooperative_matrix) */
+#if defined(VK_KHR_device_group_creation)
+	table->vkEnumeratePhysicalDeviceGroupsKHR = (PFN_vkEnumeratePhysicalDeviceGroupsKHR)load(context, "vkEnumeratePhysicalDeviceGroupsKHR");
+#endif /* defined(VK_KHR_device_group_creation) */
+#if defined(VK_KHR_display)
+	table->vkCreateDisplayModeKHR = (PFN_vkCreateDisplayModeKHR)load(context, "vkCreateDisplayModeKHR");
+	table->vkCreateDisplayPlaneSurfaceKHR = (PFN_vkCreateDisplayPlaneSurfaceKHR)load(context, "vkCreateDisplayPlaneSurfaceKHR");
+	table->vkGetDisplayModePropertiesKHR = (PFN_vkGetDisplayModePropertiesKHR)load(context, "vkGetDisplayModePropertiesKHR");
+	table->vkGetDisplayPlaneCapabilitiesKHR = (PFN_vkGetDisplayPlaneCapabilitiesKHR)load(context, "vkGetDisplayPlaneCapabilitiesKHR");
+	table->vkGetDisplayPlaneSupportedDisplaysKHR = (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)load(context, "vkGetDisplayPlaneSupportedDisplaysKHR");
+	table->vkGetPhysicalDeviceDisplayPlanePropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)load(context, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
+	table->vkGetPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)load(context, "vkGetPhysicalDeviceDisplayPropertiesKHR");
+#endif /* defined(VK_KHR_display) */
+#if defined(VK_KHR_external_fence_capabilities)
+	table->vkGetPhysicalDeviceExternalFencePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)load(context, "vkGetPhysicalDeviceExternalFencePropertiesKHR");
+#endif /* defined(VK_KHR_external_fence_capabilities) */
+#if defined(VK_KHR_external_memory_capabilities)
+	table->vkGetPhysicalDeviceExternalBufferPropertiesKHR = (PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)load(context, "vkGetPhysicalDeviceExternalBufferPropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_capabilities) */
+#if defined(VK_KHR_external_semaphore_capabilities)
+	table->vkGetPhysicalDeviceExternalSemaphorePropertiesKHR = (PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)load(context, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR");
+#endif /* defined(VK_KHR_external_semaphore_capabilities) */
+#if defined(VK_KHR_fragment_shading_rate)
+	table->vkGetPhysicalDeviceFragmentShadingRatesKHR = (PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR)load(context, "vkGetPhysicalDeviceFragmentShadingRatesKHR");
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_display_properties2)
+	table->vkGetDisplayModeProperties2KHR = (PFN_vkGetDisplayModeProperties2KHR)load(context, "vkGetDisplayModeProperties2KHR");
+	table->vkGetDisplayPlaneCapabilities2KHR = (PFN_vkGetDisplayPlaneCapabilities2KHR)load(context, "vkGetDisplayPlaneCapabilities2KHR");
+	table->vkGetPhysicalDeviceDisplayPlaneProperties2KHR = (PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR)load(context, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR");
+	table->vkGetPhysicalDeviceDisplayProperties2KHR = (PFN_vkGetPhysicalDeviceDisplayProperties2KHR)load(context, "vkGetPhysicalDeviceDisplayProperties2KHR");
+#endif /* defined(VK_KHR_get_display_properties2) */
+#if defined(VK_KHR_get_physical_device_properties2)
+	table->vkGetPhysicalDeviceFeatures2KHR = (PFN_vkGetPhysicalDeviceFeatures2KHR)load(context, "vkGetPhysicalDeviceFeatures2KHR");
+	table->vkGetPhysicalDeviceFormatProperties2KHR = (PFN_vkGetPhysicalDeviceFormatProperties2KHR)load(context, "vkGetPhysicalDeviceFormatProperties2KHR");
+	table->vkGetPhysicalDeviceImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)load(context, "vkGetPhysicalDeviceImageFormatProperties2KHR");
+	table->vkGetPhysicalDeviceMemoryProperties2KHR = (PFN_vkGetPhysicalDeviceMemoryProperties2KHR)load(context, "vkGetPhysicalDeviceMemoryProperties2KHR");
+	table->vkGetPhysicalDeviceProperties2KHR = (PFN_vkGetPhysicalDeviceProperties2KHR)load(context, "vkGetPhysicalDeviceProperties2KHR");
+	table->vkGetPhysicalDeviceQueueFamilyProperties2KHR = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)load(context, "vkGetPhysicalDeviceQueueFamilyProperties2KHR");
+	table->vkGetPhysicalDeviceSparseImageFormatProperties2KHR = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)load(context, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR");
+#endif /* defined(VK_KHR_get_physical_device_properties2) */
+#if defined(VK_KHR_get_surface_capabilities2)
+	table->vkGetPhysicalDeviceSurfaceCapabilities2KHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilities2KHR");
+	table->vkGetPhysicalDeviceSurfaceFormats2KHR = (PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)load(context, "vkGetPhysicalDeviceSurfaceFormats2KHR");
+#endif /* defined(VK_KHR_get_surface_capabilities2) */
+#if defined(VK_KHR_performance_query)
+	table->vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = (PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)load(context, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR");
+	table->vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = (PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR)load(context, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR");
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_surface)
+	table->vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)load(context, "vkDestroySurfaceKHR");
+	table->vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)load(context, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
+	table->vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)load(context, "vkGetPhysicalDeviceSurfaceFormatsKHR");
+	table->vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)load(context, "vkGetPhysicalDeviceSurfacePresentModesKHR");
+	table->vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)load(context, "vkGetPhysicalDeviceSurfaceSupportKHR");
+#endif /* defined(VK_KHR_surface) */
+#if defined(VK_KHR_video_encode_queue)
+	table->vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR = (PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR)load(context, "vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR");
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	table->vkGetPhysicalDeviceVideoCapabilitiesKHR = (PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)load(context, "vkGetPhysicalDeviceVideoCapabilitiesKHR");
+	table->vkGetPhysicalDeviceVideoFormatPropertiesKHR = (PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)load(context, "vkGetPhysicalDeviceVideoFormatPropertiesKHR");
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_KHR_wayland_surface)
+	table->vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)load(context, "vkCreateWaylandSurfaceKHR");
+	table->vkGetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)load(context, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
+#endif /* defined(VK_KHR_wayland_surface) */
+#if defined(VK_KHR_win32_surface)
+	table->vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)load(context, "vkCreateWin32SurfaceKHR");
+	table->vkGetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)load(context, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
+#endif /* defined(VK_KHR_win32_surface) */
+#if defined(VK_KHR_xcb_surface)
+	table->vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)load(context, "vkCreateXcbSurfaceKHR");
+	table->vkGetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)load(context, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
+#endif /* defined(VK_KHR_xcb_surface) */
+#if defined(VK_KHR_xlib_surface)
+	table->vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)load(context, "vkCreateXlibSurfaceKHR");
+	table->vkGetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)load(context, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
+#endif /* defined(VK_KHR_xlib_surface) */
+#if defined(VK_MVK_ios_surface)
+	table->vkCreateIOSSurfaceMVK = (PFN_vkCreateIOSSurfaceMVK)load(context, "vkCreateIOSSurfaceMVK");
+#endif /* defined(VK_MVK_ios_surface) */
+#if defined(VK_MVK_macos_surface)
+	table->vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)load(context, "vkCreateMacOSSurfaceMVK");
+#endif /* defined(VK_MVK_macos_surface) */
+#if defined(VK_NN_vi_surface)
+	table->vkCreateViSurfaceNN = (PFN_vkCreateViSurfaceNN)load(context, "vkCreateViSurfaceNN");
+#endif /* defined(VK_NN_vi_surface) */
+#if defined(VK_NV_acquire_winrt_display)
+	table->vkAcquireWinrtDisplayNV = (PFN_vkAcquireWinrtDisplayNV)load(context, "vkAcquireWinrtDisplayNV");
+	table->vkGetWinrtDisplayNV = (PFN_vkGetWinrtDisplayNV)load(context, "vkGetWinrtDisplayNV");
+#endif /* defined(VK_NV_acquire_winrt_display) */
+#if defined(VK_NV_cooperative_matrix)
+	table->vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV");
+#endif /* defined(VK_NV_cooperative_matrix) */
+#if defined(VK_NV_cooperative_matrix2)
+	table->vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV");
+#endif /* defined(VK_NV_cooperative_matrix2) */
+#if defined(VK_NV_cooperative_vector)
+	table->vkGetPhysicalDeviceCooperativeVectorPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV)load(context, "vkGetPhysicalDeviceCooperativeVectorPropertiesNV");
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_coverage_reduction_mode)
+	table->vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = (PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)load(context, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV");
+#endif /* defined(VK_NV_coverage_reduction_mode) */
+#if defined(VK_NV_external_memory_capabilities)
+	table->vkGetPhysicalDeviceExternalImageFormatPropertiesNV = (PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)load(context, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV");
+#endif /* defined(VK_NV_external_memory_capabilities) */
+#if defined(VK_NV_optical_flow)
+	table->vkGetPhysicalDeviceOpticalFlowImageFormatsNV = (PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV)load(context, "vkGetPhysicalDeviceOpticalFlowImageFormatsNV");
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_OHOS_surface)
+	table->vkCreateSurfaceOHOS = (PFN_vkCreateSurfaceOHOS)load(context, "vkCreateSurfaceOHOS");
+#endif /* defined(VK_OHOS_surface) */
+#if defined(VK_QNX_screen_surface)
+	table->vkCreateScreenSurfaceQNX = (PFN_vkCreateScreenSurfaceQNX)load(context, "vkCreateScreenSurfaceQNX");
+	table->vkGetPhysicalDeviceScreenPresentationSupportQNX = (PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX)load(context, "vkGetPhysicalDeviceScreenPresentationSupportQNX");
+#endif /* defined(VK_QNX_screen_surface) */
+#if defined(VK_SEC_ubm_surface)
+	table->vkCreateUbmSurfaceSEC = (PFN_vkCreateUbmSurfaceSEC)load(context, "vkCreateUbmSurfaceSEC");
+	table->vkGetPhysicalDeviceUbmPresentationSupportSEC = (PFN_vkGetPhysicalDeviceUbmPresentationSupportSEC)load(context, "vkGetPhysicalDeviceUbmPresentationSupportSEC");
+#endif /* defined(VK_SEC_ubm_surface) */
+#if (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow))
+	table->vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM = (PFN_vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM)load(context, "vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM");
+#endif /* (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	table->vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR)load(context, "vkGetPhysicalDevicePresentRectanglesKHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_LOAD_INSTANCE_TABLE */
+}
+
+static void volkGenLoadDeviceTable(struct VolkDeviceTable* table, void* context, PFN_vkVoidFunction (*load)(void*, const char*))
+{
+	/* VOLK_GENERATE_LOAD_DEVICE_TABLE */
+#if defined(VK_VERSION_1_0)
+	table->vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers)load(context, "vkAllocateCommandBuffers");
+	table->vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets)load(context, "vkAllocateDescriptorSets");
+	table->vkAllocateMemory = (PFN_vkAllocateMemory)load(context, "vkAllocateMemory");
+	table->vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer)load(context, "vkBeginCommandBuffer");
+	table->vkBindBufferMemory = (PFN_vkBindBufferMemory)load(context, "vkBindBufferMemory");
+	table->vkBindImageMemory = (PFN_vkBindImageMemory)load(context, "vkBindImageMemory");
+	table->vkCmdBeginQuery = (PFN_vkCmdBeginQuery)load(context, "vkCmdBeginQuery");
+	table->vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass)load(context, "vkCmdBeginRenderPass");
+	table->vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets)load(context, "vkCmdBindDescriptorSets");
+	table->vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer)load(context, "vkCmdBindIndexBuffer");
+	table->vkCmdBindPipeline = (PFN_vkCmdBindPipeline)load(context, "vkCmdBindPipeline");
+	table->vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers)load(context, "vkCmdBindVertexBuffers");
+	table->vkCmdBlitImage = (PFN_vkCmdBlitImage)load(context, "vkCmdBlitImage");
+	table->vkCmdClearAttachments = (PFN_vkCmdClearAttachments)load(context, "vkCmdClearAttachments");
+	table->vkCmdClearColorImage = (PFN_vkCmdClearColorImage)load(context, "vkCmdClearColorImage");
+	table->vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage)load(context, "vkCmdClearDepthStencilImage");
+	table->vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer)load(context, "vkCmdCopyBuffer");
+	table->vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage)load(context, "vkCmdCopyBufferToImage");
+	table->vkCmdCopyImage = (PFN_vkCmdCopyImage)load(context, "vkCmdCopyImage");
+	table->vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer)load(context, "vkCmdCopyImageToBuffer");
+	table->vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults)load(context, "vkCmdCopyQueryPoolResults");
+	table->vkCmdDispatch = (PFN_vkCmdDispatch)load(context, "vkCmdDispatch");
+	table->vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect)load(context, "vkCmdDispatchIndirect");
+	table->vkCmdDraw = (PFN_vkCmdDraw)load(context, "vkCmdDraw");
+	table->vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed)load(context, "vkCmdDrawIndexed");
+	table->vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect)load(context, "vkCmdDrawIndexedIndirect");
+	table->vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect)load(context, "vkCmdDrawIndirect");
+	table->vkCmdEndQuery = (PFN_vkCmdEndQuery)load(context, "vkCmdEndQuery");
+	table->vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass)load(context, "vkCmdEndRenderPass");
+	table->vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands)load(context, "vkCmdExecuteCommands");
+	table->vkCmdFillBuffer = (PFN_vkCmdFillBuffer)load(context, "vkCmdFillBuffer");
+	table->vkCmdNextSubpass = (PFN_vkCmdNextSubpass)load(context, "vkCmdNextSubpass");
+	table->vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier)load(context, "vkCmdPipelineBarrier");
+	table->vkCmdPushConstants = (PFN_vkCmdPushConstants)load(context, "vkCmdPushConstants");
+	table->vkCmdResetEvent = (PFN_vkCmdResetEvent)load(context, "vkCmdResetEvent");
+	table->vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool)load(context, "vkCmdResetQueryPool");
+	table->vkCmdResolveImage = (PFN_vkCmdResolveImage)load(context, "vkCmdResolveImage");
+	table->vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants)load(context, "vkCmdSetBlendConstants");
+	table->vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias)load(context, "vkCmdSetDepthBias");
+	table->vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds)load(context, "vkCmdSetDepthBounds");
+	table->vkCmdSetEvent = (PFN_vkCmdSetEvent)load(context, "vkCmdSetEvent");
+	table->vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth)load(context, "vkCmdSetLineWidth");
+	table->vkCmdSetScissor = (PFN_vkCmdSetScissor)load(context, "vkCmdSetScissor");
+	table->vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask)load(context, "vkCmdSetStencilCompareMask");
+	table->vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference)load(context, "vkCmdSetStencilReference");
+	table->vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask)load(context, "vkCmdSetStencilWriteMask");
+	table->vkCmdSetViewport = (PFN_vkCmdSetViewport)load(context, "vkCmdSetViewport");
+	table->vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer)load(context, "vkCmdUpdateBuffer");
+	table->vkCmdWaitEvents = (PFN_vkCmdWaitEvents)load(context, "vkCmdWaitEvents");
+	table->vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp)load(context, "vkCmdWriteTimestamp");
+	table->vkCreateBuffer = (PFN_vkCreateBuffer)load(context, "vkCreateBuffer");
+	table->vkCreateBufferView = (PFN_vkCreateBufferView)load(context, "vkCreateBufferView");
+	table->vkCreateCommandPool = (PFN_vkCreateCommandPool)load(context, "vkCreateCommandPool");
+	table->vkCreateComputePipelines = (PFN_vkCreateComputePipelines)load(context, "vkCreateComputePipelines");
+	table->vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool)load(context, "vkCreateDescriptorPool");
+	table->vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout)load(context, "vkCreateDescriptorSetLayout");
+	table->vkCreateEvent = (PFN_vkCreateEvent)load(context, "vkCreateEvent");
+	table->vkCreateFence = (PFN_vkCreateFence)load(context, "vkCreateFence");
+	table->vkCreateFramebuffer = (PFN_vkCreateFramebuffer)load(context, "vkCreateFramebuffer");
+	table->vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines)load(context, "vkCreateGraphicsPipelines");
+	table->vkCreateImage = (PFN_vkCreateImage)load(context, "vkCreateImage");
+	table->vkCreateImageView = (PFN_vkCreateImageView)load(context, "vkCreateImageView");
+	table->vkCreatePipelineCache = (PFN_vkCreatePipelineCache)load(context, "vkCreatePipelineCache");
+	table->vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout)load(context, "vkCreatePipelineLayout");
+	table->vkCreateQueryPool = (PFN_vkCreateQueryPool)load(context, "vkCreateQueryPool");
+	table->vkCreateRenderPass = (PFN_vkCreateRenderPass)load(context, "vkCreateRenderPass");
+	table->vkCreateSampler = (PFN_vkCreateSampler)load(context, "vkCreateSampler");
+	table->vkCreateSemaphore = (PFN_vkCreateSemaphore)load(context, "vkCreateSemaphore");
+	table->vkCreateShaderModule = (PFN_vkCreateShaderModule)load(context, "vkCreateShaderModule");
+	table->vkDestroyBuffer = (PFN_vkDestroyBuffer)load(context, "vkDestroyBuffer");
+	table->vkDestroyBufferView = (PFN_vkDestroyBufferView)load(context, "vkDestroyBufferView");
+	table->vkDestroyCommandPool = (PFN_vkDestroyCommandPool)load(context, "vkDestroyCommandPool");
+	table->vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool)load(context, "vkDestroyDescriptorPool");
+	table->vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout)load(context, "vkDestroyDescriptorSetLayout");
+	table->vkDestroyDevice = (PFN_vkDestroyDevice)load(context, "vkDestroyDevice");
+	table->vkDestroyEvent = (PFN_vkDestroyEvent)load(context, "vkDestroyEvent");
+	table->vkDestroyFence = (PFN_vkDestroyFence)load(context, "vkDestroyFence");
+	table->vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer)load(context, "vkDestroyFramebuffer");
+	table->vkDestroyImage = (PFN_vkDestroyImage)load(context, "vkDestroyImage");
+	table->vkDestroyImageView = (PFN_vkDestroyImageView)load(context, "vkDestroyImageView");
+	table->vkDestroyPipeline = (PFN_vkDestroyPipeline)load(context, "vkDestroyPipeline");
+	table->vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache)load(context, "vkDestroyPipelineCache");
+	table->vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout)load(context, "vkDestroyPipelineLayout");
+	table->vkDestroyQueryPool = (PFN_vkDestroyQueryPool)load(context, "vkDestroyQueryPool");
+	table->vkDestroyRenderPass = (PFN_vkDestroyRenderPass)load(context, "vkDestroyRenderPass");
+	table->vkDestroySampler = (PFN_vkDestroySampler)load(context, "vkDestroySampler");
+	table->vkDestroySemaphore = (PFN_vkDestroySemaphore)load(context, "vkDestroySemaphore");
+	table->vkDestroyShaderModule = (PFN_vkDestroyShaderModule)load(context, "vkDestroyShaderModule");
+	table->vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle)load(context, "vkDeviceWaitIdle");
+	table->vkEndCommandBuffer = (PFN_vkEndCommandBuffer)load(context, "vkEndCommandBuffer");
+	table->vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges)load(context, "vkFlushMappedMemoryRanges");
+	table->vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers)load(context, "vkFreeCommandBuffers");
+	table->vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets)load(context, "vkFreeDescriptorSets");
+	table->vkFreeMemory = (PFN_vkFreeMemory)load(context, "vkFreeMemory");
+	table->vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)load(context, "vkGetBufferMemoryRequirements");
+	table->vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment)load(context, "vkGetDeviceMemoryCommitment");
+	table->vkGetDeviceQueue = (PFN_vkGetDeviceQueue)load(context, "vkGetDeviceQueue");
+	table->vkGetEventStatus = (PFN_vkGetEventStatus)load(context, "vkGetEventStatus");
+	table->vkGetFenceStatus = (PFN_vkGetFenceStatus)load(context, "vkGetFenceStatus");
+	table->vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)load(context, "vkGetImageMemoryRequirements");
+	table->vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements)load(context, "vkGetImageSparseMemoryRequirements");
+	table->vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout)load(context, "vkGetImageSubresourceLayout");
+	table->vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData)load(context, "vkGetPipelineCacheData");
+	table->vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults)load(context, "vkGetQueryPoolResults");
+	table->vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity)load(context, "vkGetRenderAreaGranularity");
+	table->vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges)load(context, "vkInvalidateMappedMemoryRanges");
+	table->vkMapMemory = (PFN_vkMapMemory)load(context, "vkMapMemory");
+	table->vkMergePipelineCaches = (PFN_vkMergePipelineCaches)load(context, "vkMergePipelineCaches");
+	table->vkQueueBindSparse = (PFN_vkQueueBindSparse)load(context, "vkQueueBindSparse");
+	table->vkQueueSubmit = (PFN_vkQueueSubmit)load(context, "vkQueueSubmit");
+	table->vkQueueWaitIdle = (PFN_vkQueueWaitIdle)load(context, "vkQueueWaitIdle");
+	table->vkResetCommandBuffer = (PFN_vkResetCommandBuffer)load(context, "vkResetCommandBuffer");
+	table->vkResetCommandPool = (PFN_vkResetCommandPool)load(context, "vkResetCommandPool");
+	table->vkResetDescriptorPool = (PFN_vkResetDescriptorPool)load(context, "vkResetDescriptorPool");
+	table->vkResetEvent = (PFN_vkResetEvent)load(context, "vkResetEvent");
+	table->vkResetFences = (PFN_vkResetFences)load(context, "vkResetFences");
+	table->vkSetEvent = (PFN_vkSetEvent)load(context, "vkSetEvent");
+	table->vkUnmapMemory = (PFN_vkUnmapMemory)load(context, "vkUnmapMemory");
+	table->vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets)load(context, "vkUpdateDescriptorSets");
+	table->vkWaitForFences = (PFN_vkWaitForFences)load(context, "vkWaitForFences");
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	table->vkBindBufferMemory2 = (PFN_vkBindBufferMemory2)load(context, "vkBindBufferMemory2");
+	table->vkBindImageMemory2 = (PFN_vkBindImageMemory2)load(context, "vkBindImageMemory2");
+	table->vkCmdDispatchBase = (PFN_vkCmdDispatchBase)load(context, "vkCmdDispatchBase");
+	table->vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask)load(context, "vkCmdSetDeviceMask");
+	table->vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate)load(context, "vkCreateDescriptorUpdateTemplate");
+	table->vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion)load(context, "vkCreateSamplerYcbcrConversion");
+	table->vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate)load(context, "vkDestroyDescriptorUpdateTemplate");
+	table->vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion)load(context, "vkDestroySamplerYcbcrConversion");
+	table->vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2)load(context, "vkGetBufferMemoryRequirements2");
+	table->vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport)load(context, "vkGetDescriptorSetLayoutSupport");
+	table->vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures)load(context, "vkGetDeviceGroupPeerMemoryFeatures");
+	table->vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2)load(context, "vkGetDeviceQueue2");
+	table->vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2)load(context, "vkGetImageMemoryRequirements2");
+	table->vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2)load(context, "vkGetImageSparseMemoryRequirements2");
+	table->vkTrimCommandPool = (PFN_vkTrimCommandPool)load(context, "vkTrimCommandPool");
+	table->vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate)load(context, "vkUpdateDescriptorSetWithTemplate");
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_2)
+	table->vkCmdBeginRenderPass2 = (PFN_vkCmdBeginRenderPass2)load(context, "vkCmdBeginRenderPass2");
+	table->vkCmdDrawIndexedIndirectCount = (PFN_vkCmdDrawIndexedIndirectCount)load(context, "vkCmdDrawIndexedIndirectCount");
+	table->vkCmdDrawIndirectCount = (PFN_vkCmdDrawIndirectCount)load(context, "vkCmdDrawIndirectCount");
+	table->vkCmdEndRenderPass2 = (PFN_vkCmdEndRenderPass2)load(context, "vkCmdEndRenderPass2");
+	table->vkCmdNextSubpass2 = (PFN_vkCmdNextSubpass2)load(context, "vkCmdNextSubpass2");
+	table->vkCreateRenderPass2 = (PFN_vkCreateRenderPass2)load(context, "vkCreateRenderPass2");
+	table->vkGetBufferDeviceAddress = (PFN_vkGetBufferDeviceAddress)load(context, "vkGetBufferDeviceAddress");
+	table->vkGetBufferOpaqueCaptureAddress = (PFN_vkGetBufferOpaqueCaptureAddress)load(context, "vkGetBufferOpaqueCaptureAddress");
+	table->vkGetDeviceMemoryOpaqueCaptureAddress = (PFN_vkGetDeviceMemoryOpaqueCaptureAddress)load(context, "vkGetDeviceMemoryOpaqueCaptureAddress");
+	table->vkGetSemaphoreCounterValue = (PFN_vkGetSemaphoreCounterValue)load(context, "vkGetSemaphoreCounterValue");
+	table->vkResetQueryPool = (PFN_vkResetQueryPool)load(context, "vkResetQueryPool");
+	table->vkSignalSemaphore = (PFN_vkSignalSemaphore)load(context, "vkSignalSemaphore");
+	table->vkWaitSemaphores = (PFN_vkWaitSemaphores)load(context, "vkWaitSemaphores");
+#endif /* defined(VK_VERSION_1_2) */
+#if defined(VK_VERSION_1_3)
+	table->vkCmdBeginRendering = (PFN_vkCmdBeginRendering)load(context, "vkCmdBeginRendering");
+	table->vkCmdBindVertexBuffers2 = (PFN_vkCmdBindVertexBuffers2)load(context, "vkCmdBindVertexBuffers2");
+	table->vkCmdBlitImage2 = (PFN_vkCmdBlitImage2)load(context, "vkCmdBlitImage2");
+	table->vkCmdCopyBuffer2 = (PFN_vkCmdCopyBuffer2)load(context, "vkCmdCopyBuffer2");
+	table->vkCmdCopyBufferToImage2 = (PFN_vkCmdCopyBufferToImage2)load(context, "vkCmdCopyBufferToImage2");
+	table->vkCmdCopyImage2 = (PFN_vkCmdCopyImage2)load(context, "vkCmdCopyImage2");
+	table->vkCmdCopyImageToBuffer2 = (PFN_vkCmdCopyImageToBuffer2)load(context, "vkCmdCopyImageToBuffer2");
+	table->vkCmdEndRendering = (PFN_vkCmdEndRendering)load(context, "vkCmdEndRendering");
+	table->vkCmdPipelineBarrier2 = (PFN_vkCmdPipelineBarrier2)load(context, "vkCmdPipelineBarrier2");
+	table->vkCmdResetEvent2 = (PFN_vkCmdResetEvent2)load(context, "vkCmdResetEvent2");
+	table->vkCmdResolveImage2 = (PFN_vkCmdResolveImage2)load(context, "vkCmdResolveImage2");
+	table->vkCmdSetCullMode = (PFN_vkCmdSetCullMode)load(context, "vkCmdSetCullMode");
+	table->vkCmdSetDepthBiasEnable = (PFN_vkCmdSetDepthBiasEnable)load(context, "vkCmdSetDepthBiasEnable");
+	table->vkCmdSetDepthBoundsTestEnable = (PFN_vkCmdSetDepthBoundsTestEnable)load(context, "vkCmdSetDepthBoundsTestEnable");
+	table->vkCmdSetDepthCompareOp = (PFN_vkCmdSetDepthCompareOp)load(context, "vkCmdSetDepthCompareOp");
+	table->vkCmdSetDepthTestEnable = (PFN_vkCmdSetDepthTestEnable)load(context, "vkCmdSetDepthTestEnable");
+	table->vkCmdSetDepthWriteEnable = (PFN_vkCmdSetDepthWriteEnable)load(context, "vkCmdSetDepthWriteEnable");
+	table->vkCmdSetEvent2 = (PFN_vkCmdSetEvent2)load(context, "vkCmdSetEvent2");
+	table->vkCmdSetFrontFace = (PFN_vkCmdSetFrontFace)load(context, "vkCmdSetFrontFace");
+	table->vkCmdSetPrimitiveRestartEnable = (PFN_vkCmdSetPrimitiveRestartEnable)load(context, "vkCmdSetPrimitiveRestartEnable");
+	table->vkCmdSetPrimitiveTopology = (PFN_vkCmdSetPrimitiveTopology)load(context, "vkCmdSetPrimitiveTopology");
+	table->vkCmdSetRasterizerDiscardEnable = (PFN_vkCmdSetRasterizerDiscardEnable)load(context, "vkCmdSetRasterizerDiscardEnable");
+	table->vkCmdSetScissorWithCount = (PFN_vkCmdSetScissorWithCount)load(context, "vkCmdSetScissorWithCount");
+	table->vkCmdSetStencilOp = (PFN_vkCmdSetStencilOp)load(context, "vkCmdSetStencilOp");
+	table->vkCmdSetStencilTestEnable = (PFN_vkCmdSetStencilTestEnable)load(context, "vkCmdSetStencilTestEnable");
+	table->vkCmdSetViewportWithCount = (PFN_vkCmdSetViewportWithCount)load(context, "vkCmdSetViewportWithCount");
+	table->vkCmdWaitEvents2 = (PFN_vkCmdWaitEvents2)load(context, "vkCmdWaitEvents2");
+	table->vkCmdWriteTimestamp2 = (PFN_vkCmdWriteTimestamp2)load(context, "vkCmdWriteTimestamp2");
+	table->vkCreatePrivateDataSlot = (PFN_vkCreatePrivateDataSlot)load(context, "vkCreatePrivateDataSlot");
+	table->vkDestroyPrivateDataSlot = (PFN_vkDestroyPrivateDataSlot)load(context, "vkDestroyPrivateDataSlot");
+	table->vkGetDeviceBufferMemoryRequirements = (PFN_vkGetDeviceBufferMemoryRequirements)load(context, "vkGetDeviceBufferMemoryRequirements");
+	table->vkGetDeviceImageMemoryRequirements = (PFN_vkGetDeviceImageMemoryRequirements)load(context, "vkGetDeviceImageMemoryRequirements");
+	table->vkGetDeviceImageSparseMemoryRequirements = (PFN_vkGetDeviceImageSparseMemoryRequirements)load(context, "vkGetDeviceImageSparseMemoryRequirements");
+	table->vkGetPrivateData = (PFN_vkGetPrivateData)load(context, "vkGetPrivateData");
+	table->vkQueueSubmit2 = (PFN_vkQueueSubmit2)load(context, "vkQueueSubmit2");
+	table->vkSetPrivateData = (PFN_vkSetPrivateData)load(context, "vkSetPrivateData");
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_VERSION_1_4)
+	table->vkCmdBindDescriptorSets2 = (PFN_vkCmdBindDescriptorSets2)load(context, "vkCmdBindDescriptorSets2");
+	table->vkCmdBindIndexBuffer2 = (PFN_vkCmdBindIndexBuffer2)load(context, "vkCmdBindIndexBuffer2");
+	table->vkCmdPushConstants2 = (PFN_vkCmdPushConstants2)load(context, "vkCmdPushConstants2");
+	table->vkCmdPushDescriptorSet = (PFN_vkCmdPushDescriptorSet)load(context, "vkCmdPushDescriptorSet");
+	table->vkCmdPushDescriptorSet2 = (PFN_vkCmdPushDescriptorSet2)load(context, "vkCmdPushDescriptorSet2");
+	table->vkCmdPushDescriptorSetWithTemplate = (PFN_vkCmdPushDescriptorSetWithTemplate)load(context, "vkCmdPushDescriptorSetWithTemplate");
+	table->vkCmdPushDescriptorSetWithTemplate2 = (PFN_vkCmdPushDescriptorSetWithTemplate2)load(context, "vkCmdPushDescriptorSetWithTemplate2");
+	table->vkCmdSetLineStipple = (PFN_vkCmdSetLineStipple)load(context, "vkCmdSetLineStipple");
+	table->vkCmdSetRenderingAttachmentLocations = (PFN_vkCmdSetRenderingAttachmentLocations)load(context, "vkCmdSetRenderingAttachmentLocations");
+	table->vkCmdSetRenderingInputAttachmentIndices = (PFN_vkCmdSetRenderingInputAttachmentIndices)load(context, "vkCmdSetRenderingInputAttachmentIndices");
+	table->vkCopyImageToImage = (PFN_vkCopyImageToImage)load(context, "vkCopyImageToImage");
+	table->vkCopyImageToMemory = (PFN_vkCopyImageToMemory)load(context, "vkCopyImageToMemory");
+	table->vkCopyMemoryToImage = (PFN_vkCopyMemoryToImage)load(context, "vkCopyMemoryToImage");
+	table->vkGetDeviceImageSubresourceLayout = (PFN_vkGetDeviceImageSubresourceLayout)load(context, "vkGetDeviceImageSubresourceLayout");
+	table->vkGetImageSubresourceLayout2 = (PFN_vkGetImageSubresourceLayout2)load(context, "vkGetImageSubresourceLayout2");
+	table->vkGetRenderingAreaGranularity = (PFN_vkGetRenderingAreaGranularity)load(context, "vkGetRenderingAreaGranularity");
+	table->vkMapMemory2 = (PFN_vkMapMemory2)load(context, "vkMapMemory2");
+	table->vkTransitionImageLayout = (PFN_vkTransitionImageLayout)load(context, "vkTransitionImageLayout");
+	table->vkUnmapMemory2 = (PFN_vkUnmapMemory2)load(context, "vkUnmapMemory2");
+#endif /* defined(VK_VERSION_1_4) */
+#if defined(VK_AMDX_shader_enqueue)
+	table->vkCmdDispatchGraphAMDX = (PFN_vkCmdDispatchGraphAMDX)load(context, "vkCmdDispatchGraphAMDX");
+	table->vkCmdDispatchGraphIndirectAMDX = (PFN_vkCmdDispatchGraphIndirectAMDX)load(context, "vkCmdDispatchGraphIndirectAMDX");
+	table->vkCmdDispatchGraphIndirectCountAMDX = (PFN_vkCmdDispatchGraphIndirectCountAMDX)load(context, "vkCmdDispatchGraphIndirectCountAMDX");
+	table->vkCmdInitializeGraphScratchMemoryAMDX = (PFN_vkCmdInitializeGraphScratchMemoryAMDX)load(context, "vkCmdInitializeGraphScratchMemoryAMDX");
+	table->vkCreateExecutionGraphPipelinesAMDX = (PFN_vkCreateExecutionGraphPipelinesAMDX)load(context, "vkCreateExecutionGraphPipelinesAMDX");
+	table->vkGetExecutionGraphPipelineNodeIndexAMDX = (PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)load(context, "vkGetExecutionGraphPipelineNodeIndexAMDX");
+	table->vkGetExecutionGraphPipelineScratchSizeAMDX = (PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)load(context, "vkGetExecutionGraphPipelineScratchSizeAMDX");
+#endif /* defined(VK_AMDX_shader_enqueue) */
+#if defined(VK_AMD_anti_lag)
+	table->vkAntiLagUpdateAMD = (PFN_vkAntiLagUpdateAMD)load(context, "vkAntiLagUpdateAMD");
+#endif /* defined(VK_AMD_anti_lag) */
+#if defined(VK_AMD_buffer_marker)
+	table->vkCmdWriteBufferMarkerAMD = (PFN_vkCmdWriteBufferMarkerAMD)load(context, "vkCmdWriteBufferMarkerAMD");
+#endif /* defined(VK_AMD_buffer_marker) */
+#if defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	table->vkCmdWriteBufferMarker2AMD = (PFN_vkCmdWriteBufferMarker2AMD)load(context, "vkCmdWriteBufferMarker2AMD");
+#endif /* defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_AMD_display_native_hdr)
+	table->vkSetLocalDimmingAMD = (PFN_vkSetLocalDimmingAMD)load(context, "vkSetLocalDimmingAMD");
+#endif /* defined(VK_AMD_display_native_hdr) */
+#if defined(VK_AMD_draw_indirect_count)
+	table->vkCmdDrawIndexedIndirectCountAMD = (PFN_vkCmdDrawIndexedIndirectCountAMD)load(context, "vkCmdDrawIndexedIndirectCountAMD");
+	table->vkCmdDrawIndirectCountAMD = (PFN_vkCmdDrawIndirectCountAMD)load(context, "vkCmdDrawIndirectCountAMD");
+#endif /* defined(VK_AMD_draw_indirect_count) */
+#if defined(VK_AMD_gpa_interface)
+	table->vkCmdBeginGpaSampleAMD = (PFN_vkCmdBeginGpaSampleAMD)load(context, "vkCmdBeginGpaSampleAMD");
+	table->vkCmdBeginGpaSessionAMD = (PFN_vkCmdBeginGpaSessionAMD)load(context, "vkCmdBeginGpaSessionAMD");
+	table->vkCmdCopyGpaSessionResultsAMD = (PFN_vkCmdCopyGpaSessionResultsAMD)load(context, "vkCmdCopyGpaSessionResultsAMD");
+	table->vkCmdEndGpaSampleAMD = (PFN_vkCmdEndGpaSampleAMD)load(context, "vkCmdEndGpaSampleAMD");
+	table->vkCmdEndGpaSessionAMD = (PFN_vkCmdEndGpaSessionAMD)load(context, "vkCmdEndGpaSessionAMD");
+	table->vkCreateGpaSessionAMD = (PFN_vkCreateGpaSessionAMD)load(context, "vkCreateGpaSessionAMD");
+	table->vkDestroyGpaSessionAMD = (PFN_vkDestroyGpaSessionAMD)load(context, "vkDestroyGpaSessionAMD");
+	table->vkGetGpaDeviceClockInfoAMD = (PFN_vkGetGpaDeviceClockInfoAMD)load(context, "vkGetGpaDeviceClockInfoAMD");
+	table->vkGetGpaSessionResultsAMD = (PFN_vkGetGpaSessionResultsAMD)load(context, "vkGetGpaSessionResultsAMD");
+	table->vkGetGpaSessionStatusAMD = (PFN_vkGetGpaSessionStatusAMD)load(context, "vkGetGpaSessionStatusAMD");
+	table->vkResetGpaSessionAMD = (PFN_vkResetGpaSessionAMD)load(context, "vkResetGpaSessionAMD");
+	table->vkSetGpaDeviceClockModeAMD = (PFN_vkSetGpaDeviceClockModeAMD)load(context, "vkSetGpaDeviceClockModeAMD");
+#endif /* defined(VK_AMD_gpa_interface) */
+#if defined(VK_AMD_shader_info)
+	table->vkGetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)load(context, "vkGetShaderInfoAMD");
+#endif /* defined(VK_AMD_shader_info) */
+#if defined(VK_ANDROID_external_memory_android_hardware_buffer)
+	table->vkGetAndroidHardwareBufferPropertiesANDROID = (PFN_vkGetAndroidHardwareBufferPropertiesANDROID)load(context, "vkGetAndroidHardwareBufferPropertiesANDROID");
+	table->vkGetMemoryAndroidHardwareBufferANDROID = (PFN_vkGetMemoryAndroidHardwareBufferANDROID)load(context, "vkGetMemoryAndroidHardwareBufferANDROID");
+#endif /* defined(VK_ANDROID_external_memory_android_hardware_buffer) */
+#if defined(VK_ARM_data_graph)
+	table->vkBindDataGraphPipelineSessionMemoryARM = (PFN_vkBindDataGraphPipelineSessionMemoryARM)load(context, "vkBindDataGraphPipelineSessionMemoryARM");
+	table->vkCmdDispatchDataGraphARM = (PFN_vkCmdDispatchDataGraphARM)load(context, "vkCmdDispatchDataGraphARM");
+	table->vkCreateDataGraphPipelineSessionARM = (PFN_vkCreateDataGraphPipelineSessionARM)load(context, "vkCreateDataGraphPipelineSessionARM");
+	table->vkCreateDataGraphPipelinesARM = (PFN_vkCreateDataGraphPipelinesARM)load(context, "vkCreateDataGraphPipelinesARM");
+	table->vkDestroyDataGraphPipelineSessionARM = (PFN_vkDestroyDataGraphPipelineSessionARM)load(context, "vkDestroyDataGraphPipelineSessionARM");
+	table->vkGetDataGraphPipelineAvailablePropertiesARM = (PFN_vkGetDataGraphPipelineAvailablePropertiesARM)load(context, "vkGetDataGraphPipelineAvailablePropertiesARM");
+	table->vkGetDataGraphPipelinePropertiesARM = (PFN_vkGetDataGraphPipelinePropertiesARM)load(context, "vkGetDataGraphPipelinePropertiesARM");
+	table->vkGetDataGraphPipelineSessionBindPointRequirementsARM = (PFN_vkGetDataGraphPipelineSessionBindPointRequirementsARM)load(context, "vkGetDataGraphPipelineSessionBindPointRequirementsARM");
+	table->vkGetDataGraphPipelineSessionMemoryRequirementsARM = (PFN_vkGetDataGraphPipelineSessionMemoryRequirementsARM)load(context, "vkGetDataGraphPipelineSessionMemoryRequirementsARM");
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2
+	table->vkCmdSetDispatchParametersARM = (PFN_vkCmdSetDispatchParametersARM)load(context, "vkCmdSetDispatchParametersARM");
+#endif /* defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2 */
+#if defined(VK_ARM_shader_instrumentation)
+	table->vkClearShaderInstrumentationMetricsARM = (PFN_vkClearShaderInstrumentationMetricsARM)load(context, "vkClearShaderInstrumentationMetricsARM");
+	table->vkCmdBeginShaderInstrumentationARM = (PFN_vkCmdBeginShaderInstrumentationARM)load(context, "vkCmdBeginShaderInstrumentationARM");
+	table->vkCmdEndShaderInstrumentationARM = (PFN_vkCmdEndShaderInstrumentationARM)load(context, "vkCmdEndShaderInstrumentationARM");
+	table->vkCreateShaderInstrumentationARM = (PFN_vkCreateShaderInstrumentationARM)load(context, "vkCreateShaderInstrumentationARM");
+	table->vkDestroyShaderInstrumentationARM = (PFN_vkDestroyShaderInstrumentationARM)load(context, "vkDestroyShaderInstrumentationARM");
+	table->vkGetShaderInstrumentationValuesARM = (PFN_vkGetShaderInstrumentationValuesARM)load(context, "vkGetShaderInstrumentationValuesARM");
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	table->vkBindTensorMemoryARM = (PFN_vkBindTensorMemoryARM)load(context, "vkBindTensorMemoryARM");
+	table->vkCmdCopyTensorARM = (PFN_vkCmdCopyTensorARM)load(context, "vkCmdCopyTensorARM");
+	table->vkCreateTensorARM = (PFN_vkCreateTensorARM)load(context, "vkCreateTensorARM");
+	table->vkCreateTensorViewARM = (PFN_vkCreateTensorViewARM)load(context, "vkCreateTensorViewARM");
+	table->vkDestroyTensorARM = (PFN_vkDestroyTensorARM)load(context, "vkDestroyTensorARM");
+	table->vkDestroyTensorViewARM = (PFN_vkDestroyTensorViewARM)load(context, "vkDestroyTensorViewARM");
+	table->vkGetDeviceTensorMemoryRequirementsARM = (PFN_vkGetDeviceTensorMemoryRequirementsARM)load(context, "vkGetDeviceTensorMemoryRequirementsARM");
+	table->vkGetTensorMemoryRequirementsARM = (PFN_vkGetTensorMemoryRequirementsARM)load(context, "vkGetTensorMemoryRequirementsARM");
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer)
+	table->vkGetTensorOpaqueCaptureDescriptorDataARM = (PFN_vkGetTensorOpaqueCaptureDescriptorDataARM)load(context, "vkGetTensorOpaqueCaptureDescriptorDataARM");
+	table->vkGetTensorViewOpaqueCaptureDescriptorDataARM = (PFN_vkGetTensorViewOpaqueCaptureDescriptorDataARM)load(context, "vkGetTensorViewOpaqueCaptureDescriptorDataARM");
+#endif /* defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_attachment_feedback_loop_dynamic_state)
+	table->vkCmdSetAttachmentFeedbackLoopEnableEXT = (PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT)load(context, "vkCmdSetAttachmentFeedbackLoopEnableEXT");
+#endif /* defined(VK_EXT_attachment_feedback_loop_dynamic_state) */
+#if defined(VK_EXT_buffer_device_address)
+	table->vkGetBufferDeviceAddressEXT = (PFN_vkGetBufferDeviceAddressEXT)load(context, "vkGetBufferDeviceAddressEXT");
+#endif /* defined(VK_EXT_buffer_device_address) */
+#if defined(VK_EXT_calibrated_timestamps)
+	table->vkGetCalibratedTimestampsEXT = (PFN_vkGetCalibratedTimestampsEXT)load(context, "vkGetCalibratedTimestampsEXT");
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_color_write_enable)
+	table->vkCmdSetColorWriteEnableEXT = (PFN_vkCmdSetColorWriteEnableEXT)load(context, "vkCmdSetColorWriteEnableEXT");
+#endif /* defined(VK_EXT_color_write_enable) */
+#if defined(VK_EXT_conditional_rendering)
+	table->vkCmdBeginConditionalRenderingEXT = (PFN_vkCmdBeginConditionalRenderingEXT)load(context, "vkCmdBeginConditionalRenderingEXT");
+	table->vkCmdEndConditionalRenderingEXT = (PFN_vkCmdEndConditionalRenderingEXT)load(context, "vkCmdEndConditionalRenderingEXT");
+#endif /* defined(VK_EXT_conditional_rendering) */
+#if defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3))
+	table->vkCmdBeginCustomResolveEXT = (PFN_vkCmdBeginCustomResolveEXT)load(context, "vkCmdBeginCustomResolveEXT");
+#endif /* defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3)) */
+#if defined(VK_EXT_debug_marker)
+	table->vkCmdDebugMarkerBeginEXT = (PFN_vkCmdDebugMarkerBeginEXT)load(context, "vkCmdDebugMarkerBeginEXT");
+	table->vkCmdDebugMarkerEndEXT = (PFN_vkCmdDebugMarkerEndEXT)load(context, "vkCmdDebugMarkerEndEXT");
+	table->vkCmdDebugMarkerInsertEXT = (PFN_vkCmdDebugMarkerInsertEXT)load(context, "vkCmdDebugMarkerInsertEXT");
+	table->vkDebugMarkerSetObjectNameEXT = (PFN_vkDebugMarkerSetObjectNameEXT)load(context, "vkDebugMarkerSetObjectNameEXT");
+	table->vkDebugMarkerSetObjectTagEXT = (PFN_vkDebugMarkerSetObjectTagEXT)load(context, "vkDebugMarkerSetObjectTagEXT");
+#endif /* defined(VK_EXT_debug_marker) */
+#if defined(VK_EXT_depth_bias_control)
+	table->vkCmdSetDepthBias2EXT = (PFN_vkCmdSetDepthBias2EXT)load(context, "vkCmdSetDepthBias2EXT");
+#endif /* defined(VK_EXT_depth_bias_control) */
+#if defined(VK_EXT_descriptor_buffer)
+	table->vkCmdBindDescriptorBufferEmbeddedSamplersEXT = (PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT)load(context, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT");
+	table->vkCmdBindDescriptorBuffersEXT = (PFN_vkCmdBindDescriptorBuffersEXT)load(context, "vkCmdBindDescriptorBuffersEXT");
+	table->vkCmdSetDescriptorBufferOffsetsEXT = (PFN_vkCmdSetDescriptorBufferOffsetsEXT)load(context, "vkCmdSetDescriptorBufferOffsetsEXT");
+	table->vkGetBufferOpaqueCaptureDescriptorDataEXT = (PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT)load(context, "vkGetBufferOpaqueCaptureDescriptorDataEXT");
+	table->vkGetDescriptorEXT = (PFN_vkGetDescriptorEXT)load(context, "vkGetDescriptorEXT");
+	table->vkGetDescriptorSetLayoutBindingOffsetEXT = (PFN_vkGetDescriptorSetLayoutBindingOffsetEXT)load(context, "vkGetDescriptorSetLayoutBindingOffsetEXT");
+	table->vkGetDescriptorSetLayoutSizeEXT = (PFN_vkGetDescriptorSetLayoutSizeEXT)load(context, "vkGetDescriptorSetLayoutSizeEXT");
+	table->vkGetImageOpaqueCaptureDescriptorDataEXT = (PFN_vkGetImageOpaqueCaptureDescriptorDataEXT)load(context, "vkGetImageOpaqueCaptureDescriptorDataEXT");
+	table->vkGetImageViewOpaqueCaptureDescriptorDataEXT = (PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT)load(context, "vkGetImageViewOpaqueCaptureDescriptorDataEXT");
+	table->vkGetSamplerOpaqueCaptureDescriptorDataEXT = (PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT)load(context, "vkGetSamplerOpaqueCaptureDescriptorDataEXT");
+#endif /* defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing))
+	table->vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT = (PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT)load(context, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT");
+#endif /* defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing)) */
+#if defined(VK_EXT_descriptor_heap)
+	table->vkCmdBindResourceHeapEXT = (PFN_vkCmdBindResourceHeapEXT)load(context, "vkCmdBindResourceHeapEXT");
+	table->vkCmdBindSamplerHeapEXT = (PFN_vkCmdBindSamplerHeapEXT)load(context, "vkCmdBindSamplerHeapEXT");
+	table->vkCmdPushDataEXT = (PFN_vkCmdPushDataEXT)load(context, "vkCmdPushDataEXT");
+	table->vkGetImageOpaqueCaptureDataEXT = (PFN_vkGetImageOpaqueCaptureDataEXT)load(context, "vkGetImageOpaqueCaptureDataEXT");
+	table->vkWriteResourceDescriptorsEXT = (PFN_vkWriteResourceDescriptorsEXT)load(context, "vkWriteResourceDescriptorsEXT");
+	table->vkWriteSamplerDescriptorsEXT = (PFN_vkWriteSamplerDescriptorsEXT)load(context, "vkWriteSamplerDescriptorsEXT");
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color)
+	table->vkRegisterCustomBorderColorEXT = (PFN_vkRegisterCustomBorderColorEXT)load(context, "vkRegisterCustomBorderColorEXT");
+	table->vkUnregisterCustomBorderColorEXT = (PFN_vkUnregisterCustomBorderColorEXT)load(context, "vkUnregisterCustomBorderColorEXT");
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors)
+	table->vkGetTensorOpaqueCaptureDataARM = (PFN_vkGetTensorOpaqueCaptureDataARM)load(context, "vkGetTensorOpaqueCaptureDataARM");
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors) */
+#if defined(VK_EXT_device_fault)
+	table->vkGetDeviceFaultInfoEXT = (PFN_vkGetDeviceFaultInfoEXT)load(context, "vkGetDeviceFaultInfoEXT");
+#endif /* defined(VK_EXT_device_fault) */
+#if defined(VK_EXT_device_generated_commands)
+	table->vkCmdExecuteGeneratedCommandsEXT = (PFN_vkCmdExecuteGeneratedCommandsEXT)load(context, "vkCmdExecuteGeneratedCommandsEXT");
+	table->vkCmdPreprocessGeneratedCommandsEXT = (PFN_vkCmdPreprocessGeneratedCommandsEXT)load(context, "vkCmdPreprocessGeneratedCommandsEXT");
+	table->vkCreateIndirectCommandsLayoutEXT = (PFN_vkCreateIndirectCommandsLayoutEXT)load(context, "vkCreateIndirectCommandsLayoutEXT");
+	table->vkCreateIndirectExecutionSetEXT = (PFN_vkCreateIndirectExecutionSetEXT)load(context, "vkCreateIndirectExecutionSetEXT");
+	table->vkDestroyIndirectCommandsLayoutEXT = (PFN_vkDestroyIndirectCommandsLayoutEXT)load(context, "vkDestroyIndirectCommandsLayoutEXT");
+	table->vkDestroyIndirectExecutionSetEXT = (PFN_vkDestroyIndirectExecutionSetEXT)load(context, "vkDestroyIndirectExecutionSetEXT");
+	table->vkGetGeneratedCommandsMemoryRequirementsEXT = (PFN_vkGetGeneratedCommandsMemoryRequirementsEXT)load(context, "vkGetGeneratedCommandsMemoryRequirementsEXT");
+	table->vkUpdateIndirectExecutionSetPipelineEXT = (PFN_vkUpdateIndirectExecutionSetPipelineEXT)load(context, "vkUpdateIndirectExecutionSetPipelineEXT");
+	table->vkUpdateIndirectExecutionSetShaderEXT = (PFN_vkUpdateIndirectExecutionSetShaderEXT)load(context, "vkUpdateIndirectExecutionSetShaderEXT");
+#endif /* defined(VK_EXT_device_generated_commands) */
+#if defined(VK_EXT_discard_rectangles)
+	table->vkCmdSetDiscardRectangleEXT = (PFN_vkCmdSetDiscardRectangleEXT)load(context, "vkCmdSetDiscardRectangleEXT");
+#endif /* defined(VK_EXT_discard_rectangles) */
+#if defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2
+	table->vkCmdSetDiscardRectangleEnableEXT = (PFN_vkCmdSetDiscardRectangleEnableEXT)load(context, "vkCmdSetDiscardRectangleEnableEXT");
+	table->vkCmdSetDiscardRectangleModeEXT = (PFN_vkCmdSetDiscardRectangleModeEXT)load(context, "vkCmdSetDiscardRectangleModeEXT");
+#endif /* defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2 */
+#if defined(VK_EXT_display_control)
+	table->vkDisplayPowerControlEXT = (PFN_vkDisplayPowerControlEXT)load(context, "vkDisplayPowerControlEXT");
+	table->vkGetSwapchainCounterEXT = (PFN_vkGetSwapchainCounterEXT)load(context, "vkGetSwapchainCounterEXT");
+	table->vkRegisterDeviceEventEXT = (PFN_vkRegisterDeviceEventEXT)load(context, "vkRegisterDeviceEventEXT");
+	table->vkRegisterDisplayEventEXT = (PFN_vkRegisterDisplayEventEXT)load(context, "vkRegisterDisplayEventEXT");
+#endif /* defined(VK_EXT_display_control) */
+#if defined(VK_EXT_external_memory_host)
+	table->vkGetMemoryHostPointerPropertiesEXT = (PFN_vkGetMemoryHostPointerPropertiesEXT)load(context, "vkGetMemoryHostPointerPropertiesEXT");
+#endif /* defined(VK_EXT_external_memory_host) */
+#if defined(VK_EXT_external_memory_metal)
+	table->vkGetMemoryMetalHandleEXT = (PFN_vkGetMemoryMetalHandleEXT)load(context, "vkGetMemoryMetalHandleEXT");
+	table->vkGetMemoryMetalHandlePropertiesEXT = (PFN_vkGetMemoryMetalHandlePropertiesEXT)load(context, "vkGetMemoryMetalHandlePropertiesEXT");
+#endif /* defined(VK_EXT_external_memory_metal) */
+#if defined(VK_EXT_fragment_density_map_offset)
+	table->vkCmdEndRendering2EXT = (PFN_vkCmdEndRendering2EXT)load(context, "vkCmdEndRendering2EXT");
+#endif /* defined(VK_EXT_fragment_density_map_offset) */
+#if defined(VK_EXT_full_screen_exclusive)
+	table->vkAcquireFullScreenExclusiveModeEXT = (PFN_vkAcquireFullScreenExclusiveModeEXT)load(context, "vkAcquireFullScreenExclusiveModeEXT");
+	table->vkReleaseFullScreenExclusiveModeEXT = (PFN_vkReleaseFullScreenExclusiveModeEXT)load(context, "vkReleaseFullScreenExclusiveModeEXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1))
+	table->vkGetDeviceGroupSurfacePresentModes2EXT = (PFN_vkGetDeviceGroupSurfacePresentModes2EXT)load(context, "vkGetDeviceGroupSurfacePresentModes2EXT");
+#endif /* defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1)) */
+#if defined(VK_EXT_hdr_metadata)
+	table->vkSetHdrMetadataEXT = (PFN_vkSetHdrMetadataEXT)load(context, "vkSetHdrMetadataEXT");
+#endif /* defined(VK_EXT_hdr_metadata) */
+#if defined(VK_EXT_host_image_copy)
+	table->vkCopyImageToImageEXT = (PFN_vkCopyImageToImageEXT)load(context, "vkCopyImageToImageEXT");
+	table->vkCopyImageToMemoryEXT = (PFN_vkCopyImageToMemoryEXT)load(context, "vkCopyImageToMemoryEXT");
+	table->vkCopyMemoryToImageEXT = (PFN_vkCopyMemoryToImageEXT)load(context, "vkCopyMemoryToImageEXT");
+	table->vkTransitionImageLayoutEXT = (PFN_vkTransitionImageLayoutEXT)load(context, "vkTransitionImageLayoutEXT");
+#endif /* defined(VK_EXT_host_image_copy) */
+#if defined(VK_EXT_host_query_reset)
+	table->vkResetQueryPoolEXT = (PFN_vkResetQueryPoolEXT)load(context, "vkResetQueryPoolEXT");
+#endif /* defined(VK_EXT_host_query_reset) */
+#if defined(VK_EXT_image_drm_format_modifier)
+	table->vkGetImageDrmFormatModifierPropertiesEXT = (PFN_vkGetImageDrmFormatModifierPropertiesEXT)load(context, "vkGetImageDrmFormatModifierPropertiesEXT");
+#endif /* defined(VK_EXT_image_drm_format_modifier) */
+#if defined(VK_EXT_line_rasterization)
+	table->vkCmdSetLineStippleEXT = (PFN_vkCmdSetLineStippleEXT)load(context, "vkCmdSetLineStippleEXT");
+#endif /* defined(VK_EXT_line_rasterization) */
+#if defined(VK_EXT_memory_decompression)
+	table->vkCmdDecompressMemoryEXT = (PFN_vkCmdDecompressMemoryEXT)load(context, "vkCmdDecompressMemoryEXT");
+	table->vkCmdDecompressMemoryIndirectCountEXT = (PFN_vkCmdDecompressMemoryIndirectCountEXT)load(context, "vkCmdDecompressMemoryIndirectCountEXT");
+#endif /* defined(VK_EXT_memory_decompression) */
+#if defined(VK_EXT_mesh_shader)
+	table->vkCmdDrawMeshTasksEXT = (PFN_vkCmdDrawMeshTasksEXT)load(context, "vkCmdDrawMeshTasksEXT");
+	table->vkCmdDrawMeshTasksIndirectEXT = (PFN_vkCmdDrawMeshTasksIndirectEXT)load(context, "vkCmdDrawMeshTasksIndirectEXT");
+#endif /* defined(VK_EXT_mesh_shader) */
+#if defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	table->vkCmdDrawMeshTasksIndirectCountEXT = (PFN_vkCmdDrawMeshTasksIndirectCountEXT)load(context, "vkCmdDrawMeshTasksIndirectCountEXT");
+#endif /* defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_EXT_metal_objects)
+	table->vkExportMetalObjectsEXT = (PFN_vkExportMetalObjectsEXT)load(context, "vkExportMetalObjectsEXT");
+#endif /* defined(VK_EXT_metal_objects) */
+#if defined(VK_EXT_multi_draw)
+	table->vkCmdDrawMultiEXT = (PFN_vkCmdDrawMultiEXT)load(context, "vkCmdDrawMultiEXT");
+	table->vkCmdDrawMultiIndexedEXT = (PFN_vkCmdDrawMultiIndexedEXT)load(context, "vkCmdDrawMultiIndexedEXT");
+#endif /* defined(VK_EXT_multi_draw) */
+#if defined(VK_EXT_opacity_micromap)
+	table->vkBuildMicromapsEXT = (PFN_vkBuildMicromapsEXT)load(context, "vkBuildMicromapsEXT");
+	table->vkCmdBuildMicromapsEXT = (PFN_vkCmdBuildMicromapsEXT)load(context, "vkCmdBuildMicromapsEXT");
+	table->vkCmdCopyMemoryToMicromapEXT = (PFN_vkCmdCopyMemoryToMicromapEXT)load(context, "vkCmdCopyMemoryToMicromapEXT");
+	table->vkCmdCopyMicromapEXT = (PFN_vkCmdCopyMicromapEXT)load(context, "vkCmdCopyMicromapEXT");
+	table->vkCmdCopyMicromapToMemoryEXT = (PFN_vkCmdCopyMicromapToMemoryEXT)load(context, "vkCmdCopyMicromapToMemoryEXT");
+	table->vkCmdWriteMicromapsPropertiesEXT = (PFN_vkCmdWriteMicromapsPropertiesEXT)load(context, "vkCmdWriteMicromapsPropertiesEXT");
+	table->vkCopyMemoryToMicromapEXT = (PFN_vkCopyMemoryToMicromapEXT)load(context, "vkCopyMemoryToMicromapEXT");
+	table->vkCopyMicromapEXT = (PFN_vkCopyMicromapEXT)load(context, "vkCopyMicromapEXT");
+	table->vkCopyMicromapToMemoryEXT = (PFN_vkCopyMicromapToMemoryEXT)load(context, "vkCopyMicromapToMemoryEXT");
+	table->vkCreateMicromapEXT = (PFN_vkCreateMicromapEXT)load(context, "vkCreateMicromapEXT");
+	table->vkDestroyMicromapEXT = (PFN_vkDestroyMicromapEXT)load(context, "vkDestroyMicromapEXT");
+	table->vkGetDeviceMicromapCompatibilityEXT = (PFN_vkGetDeviceMicromapCompatibilityEXT)load(context, "vkGetDeviceMicromapCompatibilityEXT");
+	table->vkGetMicromapBuildSizesEXT = (PFN_vkGetMicromapBuildSizesEXT)load(context, "vkGetMicromapBuildSizesEXT");
+	table->vkWriteMicromapsPropertiesEXT = (PFN_vkWriteMicromapsPropertiesEXT)load(context, "vkWriteMicromapsPropertiesEXT");
+#endif /* defined(VK_EXT_opacity_micromap) */
+#if defined(VK_EXT_pageable_device_local_memory)
+	table->vkSetDeviceMemoryPriorityEXT = (PFN_vkSetDeviceMemoryPriorityEXT)load(context, "vkSetDeviceMemoryPriorityEXT");
+#endif /* defined(VK_EXT_pageable_device_local_memory) */
+#if defined(VK_EXT_pipeline_properties)
+	table->vkGetPipelinePropertiesEXT = (PFN_vkGetPipelinePropertiesEXT)load(context, "vkGetPipelinePropertiesEXT");
+#endif /* defined(VK_EXT_pipeline_properties) */
+#if defined(VK_EXT_present_timing)
+	table->vkGetPastPresentationTimingEXT = (PFN_vkGetPastPresentationTimingEXT)load(context, "vkGetPastPresentationTimingEXT");
+	table->vkGetSwapchainTimeDomainPropertiesEXT = (PFN_vkGetSwapchainTimeDomainPropertiesEXT)load(context, "vkGetSwapchainTimeDomainPropertiesEXT");
+	table->vkGetSwapchainTimingPropertiesEXT = (PFN_vkGetSwapchainTimingPropertiesEXT)load(context, "vkGetSwapchainTimingPropertiesEXT");
+	table->vkSetSwapchainPresentTimingQueueSizeEXT = (PFN_vkSetSwapchainPresentTimingQueueSizeEXT)load(context, "vkSetSwapchainPresentTimingQueueSizeEXT");
+#endif /* defined(VK_EXT_present_timing) */
+#if defined(VK_EXT_primitive_restart_index)
+	table->vkCmdSetPrimitiveRestartIndexEXT = (PFN_vkCmdSetPrimitiveRestartIndexEXT)load(context, "vkCmdSetPrimitiveRestartIndexEXT");
+#endif /* defined(VK_EXT_primitive_restart_index) */
+#if defined(VK_EXT_private_data)
+	table->vkCreatePrivateDataSlotEXT = (PFN_vkCreatePrivateDataSlotEXT)load(context, "vkCreatePrivateDataSlotEXT");
+	table->vkDestroyPrivateDataSlotEXT = (PFN_vkDestroyPrivateDataSlotEXT)load(context, "vkDestroyPrivateDataSlotEXT");
+	table->vkGetPrivateDataEXT = (PFN_vkGetPrivateDataEXT)load(context, "vkGetPrivateDataEXT");
+	table->vkSetPrivateDataEXT = (PFN_vkSetPrivateDataEXT)load(context, "vkSetPrivateDataEXT");
+#endif /* defined(VK_EXT_private_data) */
+#if defined(VK_EXT_sample_locations)
+	table->vkCmdSetSampleLocationsEXT = (PFN_vkCmdSetSampleLocationsEXT)load(context, "vkCmdSetSampleLocationsEXT");
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_shader_module_identifier)
+	table->vkGetShaderModuleCreateInfoIdentifierEXT = (PFN_vkGetShaderModuleCreateInfoIdentifierEXT)load(context, "vkGetShaderModuleCreateInfoIdentifierEXT");
+	table->vkGetShaderModuleIdentifierEXT = (PFN_vkGetShaderModuleIdentifierEXT)load(context, "vkGetShaderModuleIdentifierEXT");
+#endif /* defined(VK_EXT_shader_module_identifier) */
+#if defined(VK_EXT_shader_object)
+	table->vkCmdBindShadersEXT = (PFN_vkCmdBindShadersEXT)load(context, "vkCmdBindShadersEXT");
+	table->vkCreateShadersEXT = (PFN_vkCreateShadersEXT)load(context, "vkCreateShadersEXT");
+	table->vkDestroyShaderEXT = (PFN_vkDestroyShaderEXT)load(context, "vkDestroyShaderEXT");
+	table->vkGetShaderBinaryDataEXT = (PFN_vkGetShaderBinaryDataEXT)load(context, "vkGetShaderBinaryDataEXT");
+#endif /* defined(VK_EXT_shader_object) */
+#if defined(VK_EXT_swapchain_maintenance1)
+	table->vkReleaseSwapchainImagesEXT = (PFN_vkReleaseSwapchainImagesEXT)load(context, "vkReleaseSwapchainImagesEXT");
+#endif /* defined(VK_EXT_swapchain_maintenance1) */
+#if defined(VK_EXT_transform_feedback)
+	table->vkCmdBeginQueryIndexedEXT = (PFN_vkCmdBeginQueryIndexedEXT)load(context, "vkCmdBeginQueryIndexedEXT");
+	table->vkCmdBeginTransformFeedbackEXT = (PFN_vkCmdBeginTransformFeedbackEXT)load(context, "vkCmdBeginTransformFeedbackEXT");
+	table->vkCmdBindTransformFeedbackBuffersEXT = (PFN_vkCmdBindTransformFeedbackBuffersEXT)load(context, "vkCmdBindTransformFeedbackBuffersEXT");
+	table->vkCmdDrawIndirectByteCountEXT = (PFN_vkCmdDrawIndirectByteCountEXT)load(context, "vkCmdDrawIndirectByteCountEXT");
+	table->vkCmdEndQueryIndexedEXT = (PFN_vkCmdEndQueryIndexedEXT)load(context, "vkCmdEndQueryIndexedEXT");
+	table->vkCmdEndTransformFeedbackEXT = (PFN_vkCmdEndTransformFeedbackEXT)load(context, "vkCmdEndTransformFeedbackEXT");
+#endif /* defined(VK_EXT_transform_feedback) */
+#if defined(VK_EXT_validation_cache)
+	table->vkCreateValidationCacheEXT = (PFN_vkCreateValidationCacheEXT)load(context, "vkCreateValidationCacheEXT");
+	table->vkDestroyValidationCacheEXT = (PFN_vkDestroyValidationCacheEXT)load(context, "vkDestroyValidationCacheEXT");
+	table->vkGetValidationCacheDataEXT = (PFN_vkGetValidationCacheDataEXT)load(context, "vkGetValidationCacheDataEXT");
+	table->vkMergeValidationCachesEXT = (PFN_vkMergeValidationCachesEXT)load(context, "vkMergeValidationCachesEXT");
+#endif /* defined(VK_EXT_validation_cache) */
+#if defined(VK_FUCHSIA_buffer_collection)
+	table->vkCreateBufferCollectionFUCHSIA = (PFN_vkCreateBufferCollectionFUCHSIA)load(context, "vkCreateBufferCollectionFUCHSIA");
+	table->vkDestroyBufferCollectionFUCHSIA = (PFN_vkDestroyBufferCollectionFUCHSIA)load(context, "vkDestroyBufferCollectionFUCHSIA");
+	table->vkGetBufferCollectionPropertiesFUCHSIA = (PFN_vkGetBufferCollectionPropertiesFUCHSIA)load(context, "vkGetBufferCollectionPropertiesFUCHSIA");
+	table->vkSetBufferCollectionBufferConstraintsFUCHSIA = (PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)load(context, "vkSetBufferCollectionBufferConstraintsFUCHSIA");
+	table->vkSetBufferCollectionImageConstraintsFUCHSIA = (PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)load(context, "vkSetBufferCollectionImageConstraintsFUCHSIA");
+#endif /* defined(VK_FUCHSIA_buffer_collection) */
+#if defined(VK_FUCHSIA_external_memory)
+	table->vkGetMemoryZirconHandleFUCHSIA = (PFN_vkGetMemoryZirconHandleFUCHSIA)load(context, "vkGetMemoryZirconHandleFUCHSIA");
+	table->vkGetMemoryZirconHandlePropertiesFUCHSIA = (PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)load(context, "vkGetMemoryZirconHandlePropertiesFUCHSIA");
+#endif /* defined(VK_FUCHSIA_external_memory) */
+#if defined(VK_FUCHSIA_external_semaphore)
+	table->vkGetSemaphoreZirconHandleFUCHSIA = (PFN_vkGetSemaphoreZirconHandleFUCHSIA)load(context, "vkGetSemaphoreZirconHandleFUCHSIA");
+	table->vkImportSemaphoreZirconHandleFUCHSIA = (PFN_vkImportSemaphoreZirconHandleFUCHSIA)load(context, "vkImportSemaphoreZirconHandleFUCHSIA");
+#endif /* defined(VK_FUCHSIA_external_semaphore) */
+#if defined(VK_GOOGLE_display_timing)
+	table->vkGetPastPresentationTimingGOOGLE = (PFN_vkGetPastPresentationTimingGOOGLE)load(context, "vkGetPastPresentationTimingGOOGLE");
+	table->vkGetRefreshCycleDurationGOOGLE = (PFN_vkGetRefreshCycleDurationGOOGLE)load(context, "vkGetRefreshCycleDurationGOOGLE");
+#endif /* defined(VK_GOOGLE_display_timing) */
+#if defined(VK_HUAWEI_cluster_culling_shader)
+	table->vkCmdDrawClusterHUAWEI = (PFN_vkCmdDrawClusterHUAWEI)load(context, "vkCmdDrawClusterHUAWEI");
+	table->vkCmdDrawClusterIndirectHUAWEI = (PFN_vkCmdDrawClusterIndirectHUAWEI)load(context, "vkCmdDrawClusterIndirectHUAWEI");
+#endif /* defined(VK_HUAWEI_cluster_culling_shader) */
+#if defined(VK_HUAWEI_invocation_mask)
+	table->vkCmdBindInvocationMaskHUAWEI = (PFN_vkCmdBindInvocationMaskHUAWEI)load(context, "vkCmdBindInvocationMaskHUAWEI");
+#endif /* defined(VK_HUAWEI_invocation_mask) */
+#if defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2
+	table->vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = (PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI)load(context, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI");
+#endif /* defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2 */
+#if defined(VK_HUAWEI_subpass_shading)
+	table->vkCmdSubpassShadingHUAWEI = (PFN_vkCmdSubpassShadingHUAWEI)load(context, "vkCmdSubpassShadingHUAWEI");
+#endif /* defined(VK_HUAWEI_subpass_shading) */
+#if defined(VK_INTEL_performance_query)
+	table->vkAcquirePerformanceConfigurationINTEL = (PFN_vkAcquirePerformanceConfigurationINTEL)load(context, "vkAcquirePerformanceConfigurationINTEL");
+	table->vkCmdSetPerformanceMarkerINTEL = (PFN_vkCmdSetPerformanceMarkerINTEL)load(context, "vkCmdSetPerformanceMarkerINTEL");
+	table->vkCmdSetPerformanceOverrideINTEL = (PFN_vkCmdSetPerformanceOverrideINTEL)load(context, "vkCmdSetPerformanceOverrideINTEL");
+	table->vkCmdSetPerformanceStreamMarkerINTEL = (PFN_vkCmdSetPerformanceStreamMarkerINTEL)load(context, "vkCmdSetPerformanceStreamMarkerINTEL");
+	table->vkGetPerformanceParameterINTEL = (PFN_vkGetPerformanceParameterINTEL)load(context, "vkGetPerformanceParameterINTEL");
+	table->vkInitializePerformanceApiINTEL = (PFN_vkInitializePerformanceApiINTEL)load(context, "vkInitializePerformanceApiINTEL");
+	table->vkQueueSetPerformanceConfigurationINTEL = (PFN_vkQueueSetPerformanceConfigurationINTEL)load(context, "vkQueueSetPerformanceConfigurationINTEL");
+	table->vkReleasePerformanceConfigurationINTEL = (PFN_vkReleasePerformanceConfigurationINTEL)load(context, "vkReleasePerformanceConfigurationINTEL");
+	table->vkUninitializePerformanceApiINTEL = (PFN_vkUninitializePerformanceApiINTEL)load(context, "vkUninitializePerformanceApiINTEL");
+#endif /* defined(VK_INTEL_performance_query) */
+#if defined(VK_KHR_acceleration_structure)
+	table->vkBuildAccelerationStructuresKHR = (PFN_vkBuildAccelerationStructuresKHR)load(context, "vkBuildAccelerationStructuresKHR");
+	table->vkCmdBuildAccelerationStructuresIndirectKHR = (PFN_vkCmdBuildAccelerationStructuresIndirectKHR)load(context, "vkCmdBuildAccelerationStructuresIndirectKHR");
+	table->vkCmdBuildAccelerationStructuresKHR = (PFN_vkCmdBuildAccelerationStructuresKHR)load(context, "vkCmdBuildAccelerationStructuresKHR");
+	table->vkCmdCopyAccelerationStructureKHR = (PFN_vkCmdCopyAccelerationStructureKHR)load(context, "vkCmdCopyAccelerationStructureKHR");
+	table->vkCmdCopyAccelerationStructureToMemoryKHR = (PFN_vkCmdCopyAccelerationStructureToMemoryKHR)load(context, "vkCmdCopyAccelerationStructureToMemoryKHR");
+	table->vkCmdCopyMemoryToAccelerationStructureKHR = (PFN_vkCmdCopyMemoryToAccelerationStructureKHR)load(context, "vkCmdCopyMemoryToAccelerationStructureKHR");
+	table->vkCmdWriteAccelerationStructuresPropertiesKHR = (PFN_vkCmdWriteAccelerationStructuresPropertiesKHR)load(context, "vkCmdWriteAccelerationStructuresPropertiesKHR");
+	table->vkCopyAccelerationStructureKHR = (PFN_vkCopyAccelerationStructureKHR)load(context, "vkCopyAccelerationStructureKHR");
+	table->vkCopyAccelerationStructureToMemoryKHR = (PFN_vkCopyAccelerationStructureToMemoryKHR)load(context, "vkCopyAccelerationStructureToMemoryKHR");
+	table->vkCopyMemoryToAccelerationStructureKHR = (PFN_vkCopyMemoryToAccelerationStructureKHR)load(context, "vkCopyMemoryToAccelerationStructureKHR");
+	table->vkCreateAccelerationStructureKHR = (PFN_vkCreateAccelerationStructureKHR)load(context, "vkCreateAccelerationStructureKHR");
+	table->vkDestroyAccelerationStructureKHR = (PFN_vkDestroyAccelerationStructureKHR)load(context, "vkDestroyAccelerationStructureKHR");
+	table->vkGetAccelerationStructureBuildSizesKHR = (PFN_vkGetAccelerationStructureBuildSizesKHR)load(context, "vkGetAccelerationStructureBuildSizesKHR");
+	table->vkGetAccelerationStructureDeviceAddressKHR = (PFN_vkGetAccelerationStructureDeviceAddressKHR)load(context, "vkGetAccelerationStructureDeviceAddressKHR");
+	table->vkGetDeviceAccelerationStructureCompatibilityKHR = (PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)load(context, "vkGetDeviceAccelerationStructureCompatibilityKHR");
+	table->vkWriteAccelerationStructuresPropertiesKHR = (PFN_vkWriteAccelerationStructuresPropertiesKHR)load(context, "vkWriteAccelerationStructuresPropertiesKHR");
+#endif /* defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_bind_memory2)
+	table->vkBindBufferMemory2KHR = (PFN_vkBindBufferMemory2KHR)load(context, "vkBindBufferMemory2KHR");
+	table->vkBindImageMemory2KHR = (PFN_vkBindImageMemory2KHR)load(context, "vkBindImageMemory2KHR");
+#endif /* defined(VK_KHR_bind_memory2) */
+#if defined(VK_KHR_buffer_device_address)
+	table->vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)load(context, "vkGetBufferDeviceAddressKHR");
+	table->vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)load(context, "vkGetBufferOpaqueCaptureAddressKHR");
+	table->vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)load(context, "vkGetDeviceMemoryOpaqueCaptureAddressKHR");
+#endif /* defined(VK_KHR_buffer_device_address) */
+#if defined(VK_KHR_calibrated_timestamps)
+	table->vkGetCalibratedTimestampsKHR = (PFN_vkGetCalibratedTimestampsKHR)load(context, "vkGetCalibratedTimestampsKHR");
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_copy_commands2)
+	table->vkCmdBlitImage2KHR = (PFN_vkCmdBlitImage2KHR)load(context, "vkCmdBlitImage2KHR");
+	table->vkCmdCopyBuffer2KHR = (PFN_vkCmdCopyBuffer2KHR)load(context, "vkCmdCopyBuffer2KHR");
+	table->vkCmdCopyBufferToImage2KHR = (PFN_vkCmdCopyBufferToImage2KHR)load(context, "vkCmdCopyBufferToImage2KHR");
+	table->vkCmdCopyImage2KHR = (PFN_vkCmdCopyImage2KHR)load(context, "vkCmdCopyImage2KHR");
+	table->vkCmdCopyImageToBuffer2KHR = (PFN_vkCmdCopyImageToBuffer2KHR)load(context, "vkCmdCopyImageToBuffer2KHR");
+	table->vkCmdResolveImage2KHR = (PFN_vkCmdResolveImage2KHR)load(context, "vkCmdResolveImage2KHR");
+#endif /* defined(VK_KHR_copy_commands2) */
+#if defined(VK_KHR_copy_memory_indirect)
+	table->vkCmdCopyMemoryIndirectKHR = (PFN_vkCmdCopyMemoryIndirectKHR)load(context, "vkCmdCopyMemoryIndirectKHR");
+	table->vkCmdCopyMemoryToImageIndirectKHR = (PFN_vkCmdCopyMemoryToImageIndirectKHR)load(context, "vkCmdCopyMemoryToImageIndirectKHR");
+#endif /* defined(VK_KHR_copy_memory_indirect) */
+#if defined(VK_KHR_create_renderpass2)
+	table->vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)load(context, "vkCmdBeginRenderPass2KHR");
+	table->vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)load(context, "vkCmdEndRenderPass2KHR");
+	table->vkCmdNextSubpass2KHR = (PFN_vkCmdNextSubpass2KHR)load(context, "vkCmdNextSubpass2KHR");
+	table->vkCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)load(context, "vkCreateRenderPass2KHR");
+#endif /* defined(VK_KHR_create_renderpass2) */
+#if defined(VK_KHR_deferred_host_operations)
+	table->vkCreateDeferredOperationKHR = (PFN_vkCreateDeferredOperationKHR)load(context, "vkCreateDeferredOperationKHR");
+	table->vkDeferredOperationJoinKHR = (PFN_vkDeferredOperationJoinKHR)load(context, "vkDeferredOperationJoinKHR");
+	table->vkDestroyDeferredOperationKHR = (PFN_vkDestroyDeferredOperationKHR)load(context, "vkDestroyDeferredOperationKHR");
+	table->vkGetDeferredOperationMaxConcurrencyKHR = (PFN_vkGetDeferredOperationMaxConcurrencyKHR)load(context, "vkGetDeferredOperationMaxConcurrencyKHR");
+	table->vkGetDeferredOperationResultKHR = (PFN_vkGetDeferredOperationResultKHR)load(context, "vkGetDeferredOperationResultKHR");
+#endif /* defined(VK_KHR_deferred_host_operations) */
+#if defined(VK_KHR_descriptor_update_template)
+	table->vkCreateDescriptorUpdateTemplateKHR = (PFN_vkCreateDescriptorUpdateTemplateKHR)load(context, "vkCreateDescriptorUpdateTemplateKHR");
+	table->vkDestroyDescriptorUpdateTemplateKHR = (PFN_vkDestroyDescriptorUpdateTemplateKHR)load(context, "vkDestroyDescriptorUpdateTemplateKHR");
+	table->vkUpdateDescriptorSetWithTemplateKHR = (PFN_vkUpdateDescriptorSetWithTemplateKHR)load(context, "vkUpdateDescriptorSetWithTemplateKHR");
+#endif /* defined(VK_KHR_descriptor_update_template) */
+#if defined(VK_KHR_device_address_commands)
+	table->vkCmdBindIndexBuffer3KHR = (PFN_vkCmdBindIndexBuffer3KHR)load(context, "vkCmdBindIndexBuffer3KHR");
+	table->vkCmdBindVertexBuffers3KHR = (PFN_vkCmdBindVertexBuffers3KHR)load(context, "vkCmdBindVertexBuffers3KHR");
+	table->vkCmdCopyImageToMemoryKHR = (PFN_vkCmdCopyImageToMemoryKHR)load(context, "vkCmdCopyImageToMemoryKHR");
+	table->vkCmdCopyMemoryKHR = (PFN_vkCmdCopyMemoryKHR)load(context, "vkCmdCopyMemoryKHR");
+	table->vkCmdCopyMemoryToImageKHR = (PFN_vkCmdCopyMemoryToImageKHR)load(context, "vkCmdCopyMemoryToImageKHR");
+	table->vkCmdCopyQueryPoolResultsToMemoryKHR = (PFN_vkCmdCopyQueryPoolResultsToMemoryKHR)load(context, "vkCmdCopyQueryPoolResultsToMemoryKHR");
+	table->vkCmdDispatchIndirect2KHR = (PFN_vkCmdDispatchIndirect2KHR)load(context, "vkCmdDispatchIndirect2KHR");
+	table->vkCmdDrawIndexedIndirect2KHR = (PFN_vkCmdDrawIndexedIndirect2KHR)load(context, "vkCmdDrawIndexedIndirect2KHR");
+	table->vkCmdDrawIndirect2KHR = (PFN_vkCmdDrawIndirect2KHR)load(context, "vkCmdDrawIndirect2KHR");
+	table->vkCmdFillMemoryKHR = (PFN_vkCmdFillMemoryKHR)load(context, "vkCmdFillMemoryKHR");
+	table->vkCmdUpdateMemoryKHR = (PFN_vkCmdUpdateMemoryKHR)load(context, "vkCmdUpdateMemoryKHR");
+#endif /* defined(VK_KHR_device_address_commands) */
+#if defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2))
+	table->vkCmdDrawIndexedIndirectCount2KHR = (PFN_vkCmdDrawIndexedIndirectCount2KHR)load(context, "vkCmdDrawIndexedIndirectCount2KHR");
+	table->vkCmdDrawIndirectCount2KHR = (PFN_vkCmdDrawIndirectCount2KHR)load(context, "vkCmdDrawIndirectCount2KHR");
+#endif /* defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering)
+	table->vkCmdBeginConditionalRendering2EXT = (PFN_vkCmdBeginConditionalRendering2EXT)load(context, "vkCmdBeginConditionalRendering2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback)
+	table->vkCmdBeginTransformFeedback2EXT = (PFN_vkCmdBeginTransformFeedback2EXT)load(context, "vkCmdBeginTransformFeedback2EXT");
+	table->vkCmdBindTransformFeedbackBuffers2EXT = (PFN_vkCmdBindTransformFeedbackBuffers2EXT)load(context, "vkCmdBindTransformFeedbackBuffers2EXT");
+	table->vkCmdDrawIndirectByteCount2EXT = (PFN_vkCmdDrawIndirectByteCount2EXT)load(context, "vkCmdDrawIndirectByteCount2EXT");
+	table->vkCmdEndTransformFeedback2EXT = (PFN_vkCmdEndTransformFeedback2EXT)load(context, "vkCmdEndTransformFeedback2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader)
+	table->vkCmdDrawMeshTasksIndirect2EXT = (PFN_vkCmdDrawMeshTasksIndirect2EXT)load(context, "vkCmdDrawMeshTasksIndirect2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader) */
+#if defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader))
+	table->vkCmdDrawMeshTasksIndirectCount2EXT = (PFN_vkCmdDrawMeshTasksIndirectCount2EXT)load(context, "vkCmdDrawMeshTasksIndirectCount2EXT");
+#endif /* defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker)
+	table->vkCmdWriteMarkerToMemoryAMD = (PFN_vkCmdWriteMarkerToMemoryAMD)load(context, "vkCmdWriteMarkerToMemoryAMD");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure)
+	table->vkCreateAccelerationStructure2KHR = (PFN_vkCreateAccelerationStructure2KHR)load(context, "vkCreateAccelerationStructure2KHR");
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_device_fault)
+	table->vkGetDeviceFaultDebugInfoKHR = (PFN_vkGetDeviceFaultDebugInfoKHR)load(context, "vkGetDeviceFaultDebugInfoKHR");
+	table->vkGetDeviceFaultReportsKHR = (PFN_vkGetDeviceFaultReportsKHR)load(context, "vkGetDeviceFaultReportsKHR");
+#endif /* defined(VK_KHR_device_fault) */
+#if defined(VK_KHR_device_group)
+	table->vkCmdDispatchBaseKHR = (PFN_vkCmdDispatchBaseKHR)load(context, "vkCmdDispatchBaseKHR");
+	table->vkCmdSetDeviceMaskKHR = (PFN_vkCmdSetDeviceMaskKHR)load(context, "vkCmdSetDeviceMaskKHR");
+	table->vkGetDeviceGroupPeerMemoryFeaturesKHR = (PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR)load(context, "vkGetDeviceGroupPeerMemoryFeaturesKHR");
+#endif /* defined(VK_KHR_device_group) */
+#if defined(VK_KHR_display_swapchain)
+	table->vkCreateSharedSwapchainsKHR = (PFN_vkCreateSharedSwapchainsKHR)load(context, "vkCreateSharedSwapchainsKHR");
+#endif /* defined(VK_KHR_display_swapchain) */
+#if defined(VK_KHR_draw_indirect_count)
+	table->vkCmdDrawIndexedIndirectCountKHR = (PFN_vkCmdDrawIndexedIndirectCountKHR)load(context, "vkCmdDrawIndexedIndirectCountKHR");
+	table->vkCmdDrawIndirectCountKHR = (PFN_vkCmdDrawIndirectCountKHR)load(context, "vkCmdDrawIndirectCountKHR");
+#endif /* defined(VK_KHR_draw_indirect_count) */
+#if defined(VK_KHR_dynamic_rendering)
+	table->vkCmdBeginRenderingKHR = (PFN_vkCmdBeginRenderingKHR)load(context, "vkCmdBeginRenderingKHR");
+	table->vkCmdEndRenderingKHR = (PFN_vkCmdEndRenderingKHR)load(context, "vkCmdEndRenderingKHR");
+#endif /* defined(VK_KHR_dynamic_rendering) */
+#if defined(VK_KHR_dynamic_rendering_local_read)
+	table->vkCmdSetRenderingAttachmentLocationsKHR = (PFN_vkCmdSetRenderingAttachmentLocationsKHR)load(context, "vkCmdSetRenderingAttachmentLocationsKHR");
+	table->vkCmdSetRenderingInputAttachmentIndicesKHR = (PFN_vkCmdSetRenderingInputAttachmentIndicesKHR)load(context, "vkCmdSetRenderingInputAttachmentIndicesKHR");
+#endif /* defined(VK_KHR_dynamic_rendering_local_read) */
+#if defined(VK_KHR_external_fence_fd)
+	table->vkGetFenceFdKHR = (PFN_vkGetFenceFdKHR)load(context, "vkGetFenceFdKHR");
+	table->vkImportFenceFdKHR = (PFN_vkImportFenceFdKHR)load(context, "vkImportFenceFdKHR");
+#endif /* defined(VK_KHR_external_fence_fd) */
+#if defined(VK_KHR_external_fence_win32)
+	table->vkGetFenceWin32HandleKHR = (PFN_vkGetFenceWin32HandleKHR)load(context, "vkGetFenceWin32HandleKHR");
+	table->vkImportFenceWin32HandleKHR = (PFN_vkImportFenceWin32HandleKHR)load(context, "vkImportFenceWin32HandleKHR");
+#endif /* defined(VK_KHR_external_fence_win32) */
+#if defined(VK_KHR_external_memory_fd)
+	table->vkGetMemoryFdKHR = (PFN_vkGetMemoryFdKHR)load(context, "vkGetMemoryFdKHR");
+	table->vkGetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)load(context, "vkGetMemoryFdPropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_fd) */
+#if defined(VK_KHR_external_memory_win32)
+	table->vkGetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)load(context, "vkGetMemoryWin32HandleKHR");
+	table->vkGetMemoryWin32HandlePropertiesKHR = (PFN_vkGetMemoryWin32HandlePropertiesKHR)load(context, "vkGetMemoryWin32HandlePropertiesKHR");
+#endif /* defined(VK_KHR_external_memory_win32) */
+#if defined(VK_KHR_external_semaphore_fd)
+	table->vkGetSemaphoreFdKHR = (PFN_vkGetSemaphoreFdKHR)load(context, "vkGetSemaphoreFdKHR");
+	table->vkImportSemaphoreFdKHR = (PFN_vkImportSemaphoreFdKHR)load(context, "vkImportSemaphoreFdKHR");
+#endif /* defined(VK_KHR_external_semaphore_fd) */
+#if defined(VK_KHR_external_semaphore_win32)
+	table->vkGetSemaphoreWin32HandleKHR = (PFN_vkGetSemaphoreWin32HandleKHR)load(context, "vkGetSemaphoreWin32HandleKHR");
+	table->vkImportSemaphoreWin32HandleKHR = (PFN_vkImportSemaphoreWin32HandleKHR)load(context, "vkImportSemaphoreWin32HandleKHR");
+#endif /* defined(VK_KHR_external_semaphore_win32) */
+#if defined(VK_KHR_fragment_shading_rate)
+	table->vkCmdSetFragmentShadingRateKHR = (PFN_vkCmdSetFragmentShadingRateKHR)load(context, "vkCmdSetFragmentShadingRateKHR");
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_memory_requirements2)
+	table->vkGetBufferMemoryRequirements2KHR = (PFN_vkGetBufferMemoryRequirements2KHR)load(context, "vkGetBufferMemoryRequirements2KHR");
+	table->vkGetImageMemoryRequirements2KHR = (PFN_vkGetImageMemoryRequirements2KHR)load(context, "vkGetImageMemoryRequirements2KHR");
+	table->vkGetImageSparseMemoryRequirements2KHR = (PFN_vkGetImageSparseMemoryRequirements2KHR)load(context, "vkGetImageSparseMemoryRequirements2KHR");
+#endif /* defined(VK_KHR_get_memory_requirements2) */
+#if defined(VK_KHR_line_rasterization)
+	table->vkCmdSetLineStippleKHR = (PFN_vkCmdSetLineStippleKHR)load(context, "vkCmdSetLineStippleKHR");
+#endif /* defined(VK_KHR_line_rasterization) */
+#if defined(VK_KHR_maintenance1)
+	table->vkTrimCommandPoolKHR = (PFN_vkTrimCommandPoolKHR)load(context, "vkTrimCommandPoolKHR");
+#endif /* defined(VK_KHR_maintenance1) */
+#if defined(VK_KHR_maintenance10)
+	table->vkCmdEndRendering2KHR = (PFN_vkCmdEndRendering2KHR)load(context, "vkCmdEndRendering2KHR");
+#endif /* defined(VK_KHR_maintenance10) */
+#if defined(VK_KHR_maintenance3)
+	table->vkGetDescriptorSetLayoutSupportKHR = (PFN_vkGetDescriptorSetLayoutSupportKHR)load(context, "vkGetDescriptorSetLayoutSupportKHR");
+#endif /* defined(VK_KHR_maintenance3) */
+#if defined(VK_KHR_maintenance4)
+	table->vkGetDeviceBufferMemoryRequirementsKHR = (PFN_vkGetDeviceBufferMemoryRequirementsKHR)load(context, "vkGetDeviceBufferMemoryRequirementsKHR");
+	table->vkGetDeviceImageMemoryRequirementsKHR = (PFN_vkGetDeviceImageMemoryRequirementsKHR)load(context, "vkGetDeviceImageMemoryRequirementsKHR");
+	table->vkGetDeviceImageSparseMemoryRequirementsKHR = (PFN_vkGetDeviceImageSparseMemoryRequirementsKHR)load(context, "vkGetDeviceImageSparseMemoryRequirementsKHR");
+#endif /* defined(VK_KHR_maintenance4) */
+#if defined(VK_KHR_maintenance5)
+	table->vkCmdBindIndexBuffer2KHR = (PFN_vkCmdBindIndexBuffer2KHR)load(context, "vkCmdBindIndexBuffer2KHR");
+	table->vkGetDeviceImageSubresourceLayoutKHR = (PFN_vkGetDeviceImageSubresourceLayoutKHR)load(context, "vkGetDeviceImageSubresourceLayoutKHR");
+	table->vkGetImageSubresourceLayout2KHR = (PFN_vkGetImageSubresourceLayout2KHR)load(context, "vkGetImageSubresourceLayout2KHR");
+	table->vkGetRenderingAreaGranularityKHR = (PFN_vkGetRenderingAreaGranularityKHR)load(context, "vkGetRenderingAreaGranularityKHR");
+#endif /* defined(VK_KHR_maintenance5) */
+#if defined(VK_KHR_maintenance6)
+	table->vkCmdBindDescriptorSets2KHR = (PFN_vkCmdBindDescriptorSets2KHR)load(context, "vkCmdBindDescriptorSets2KHR");
+	table->vkCmdPushConstants2KHR = (PFN_vkCmdPushConstants2KHR)load(context, "vkCmdPushConstants2KHR");
+#endif /* defined(VK_KHR_maintenance6) */
+#if defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor)
+	table->vkCmdPushDescriptorSet2KHR = (PFN_vkCmdPushDescriptorSet2KHR)load(context, "vkCmdPushDescriptorSet2KHR");
+	table->vkCmdPushDescriptorSetWithTemplate2KHR = (PFN_vkCmdPushDescriptorSetWithTemplate2KHR)load(context, "vkCmdPushDescriptorSetWithTemplate2KHR");
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer)
+	table->vkCmdBindDescriptorBufferEmbeddedSamplers2EXT = (PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT)load(context, "vkCmdBindDescriptorBufferEmbeddedSamplers2EXT");
+	table->vkCmdSetDescriptorBufferOffsets2EXT = (PFN_vkCmdSetDescriptorBufferOffsets2EXT)load(context, "vkCmdSetDescriptorBufferOffsets2EXT");
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_KHR_map_memory2)
+	table->vkMapMemory2KHR = (PFN_vkMapMemory2KHR)load(context, "vkMapMemory2KHR");
+	table->vkUnmapMemory2KHR = (PFN_vkUnmapMemory2KHR)load(context, "vkUnmapMemory2KHR");
+#endif /* defined(VK_KHR_map_memory2) */
+#if defined(VK_KHR_performance_query)
+	table->vkAcquireProfilingLockKHR = (PFN_vkAcquireProfilingLockKHR)load(context, "vkAcquireProfilingLockKHR");
+	table->vkReleaseProfilingLockKHR = (PFN_vkReleaseProfilingLockKHR)load(context, "vkReleaseProfilingLockKHR");
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_pipeline_binary)
+	table->vkCreatePipelineBinariesKHR = (PFN_vkCreatePipelineBinariesKHR)load(context, "vkCreatePipelineBinariesKHR");
+	table->vkDestroyPipelineBinaryKHR = (PFN_vkDestroyPipelineBinaryKHR)load(context, "vkDestroyPipelineBinaryKHR");
+	table->vkGetPipelineBinaryDataKHR = (PFN_vkGetPipelineBinaryDataKHR)load(context, "vkGetPipelineBinaryDataKHR");
+	table->vkGetPipelineKeyKHR = (PFN_vkGetPipelineKeyKHR)load(context, "vkGetPipelineKeyKHR");
+	table->vkReleaseCapturedPipelineDataKHR = (PFN_vkReleaseCapturedPipelineDataKHR)load(context, "vkReleaseCapturedPipelineDataKHR");
+#endif /* defined(VK_KHR_pipeline_binary) */
+#if defined(VK_KHR_pipeline_executable_properties)
+	table->vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)load(context, "vkGetPipelineExecutableInternalRepresentationsKHR");
+	table->vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)load(context, "vkGetPipelineExecutablePropertiesKHR");
+	table->vkGetPipelineExecutableStatisticsKHR = (PFN_vkGetPipelineExecutableStatisticsKHR)load(context, "vkGetPipelineExecutableStatisticsKHR");
+#endif /* defined(VK_KHR_pipeline_executable_properties) */
+#if defined(VK_KHR_present_wait)
+	table->vkWaitForPresentKHR = (PFN_vkWaitForPresentKHR)load(context, "vkWaitForPresentKHR");
+#endif /* defined(VK_KHR_present_wait) */
+#if defined(VK_KHR_present_wait2)
+	table->vkWaitForPresent2KHR = (PFN_vkWaitForPresent2KHR)load(context, "vkWaitForPresent2KHR");
+#endif /* defined(VK_KHR_present_wait2) */
+#if defined(VK_KHR_push_descriptor)
+	table->vkCmdPushDescriptorSetKHR = (PFN_vkCmdPushDescriptorSetKHR)load(context, "vkCmdPushDescriptorSetKHR");
+#endif /* defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline)
+	table->vkCmdTraceRaysIndirect2KHR = (PFN_vkCmdTraceRaysIndirect2KHR)load(context, "vkCmdTraceRaysIndirect2KHR");
+#endif /* defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_ray_tracing_pipeline)
+	table->vkCmdSetRayTracingPipelineStackSizeKHR = (PFN_vkCmdSetRayTracingPipelineStackSizeKHR)load(context, "vkCmdSetRayTracingPipelineStackSizeKHR");
+	table->vkCmdTraceRaysIndirectKHR = (PFN_vkCmdTraceRaysIndirectKHR)load(context, "vkCmdTraceRaysIndirectKHR");
+	table->vkCmdTraceRaysKHR = (PFN_vkCmdTraceRaysKHR)load(context, "vkCmdTraceRaysKHR");
+	table->vkCreateRayTracingPipelinesKHR = (PFN_vkCreateRayTracingPipelinesKHR)load(context, "vkCreateRayTracingPipelinesKHR");
+	table->vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = (PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)load(context, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR");
+	table->vkGetRayTracingShaderGroupHandlesKHR = (PFN_vkGetRayTracingShaderGroupHandlesKHR)load(context, "vkGetRayTracingShaderGroupHandlesKHR");
+	table->vkGetRayTracingShaderGroupStackSizeKHR = (PFN_vkGetRayTracingShaderGroupStackSizeKHR)load(context, "vkGetRayTracingShaderGroupStackSizeKHR");
+#endif /* defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_sampler_ycbcr_conversion)
+	table->vkCreateSamplerYcbcrConversionKHR = (PFN_vkCreateSamplerYcbcrConversionKHR)load(context, "vkCreateSamplerYcbcrConversionKHR");
+	table->vkDestroySamplerYcbcrConversionKHR = (PFN_vkDestroySamplerYcbcrConversionKHR)load(context, "vkDestroySamplerYcbcrConversionKHR");
+#endif /* defined(VK_KHR_sampler_ycbcr_conversion) */
+#if defined(VK_KHR_shared_presentable_image)
+	table->vkGetSwapchainStatusKHR = (PFN_vkGetSwapchainStatusKHR)load(context, "vkGetSwapchainStatusKHR");
+#endif /* defined(VK_KHR_shared_presentable_image) */
+#if defined(VK_KHR_swapchain)
+	table->vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)load(context, "vkAcquireNextImageKHR");
+	table->vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)load(context, "vkCreateSwapchainKHR");
+	table->vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)load(context, "vkDestroySwapchainKHR");
+	table->vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)load(context, "vkGetSwapchainImagesKHR");
+	table->vkQueuePresentKHR = (PFN_vkQueuePresentKHR)load(context, "vkQueuePresentKHR");
+#endif /* defined(VK_KHR_swapchain) */
+#if defined(VK_KHR_swapchain_maintenance1)
+	table->vkReleaseSwapchainImagesKHR = (PFN_vkReleaseSwapchainImagesKHR)load(context, "vkReleaseSwapchainImagesKHR");
+#endif /* defined(VK_KHR_swapchain_maintenance1) */
+#if defined(VK_KHR_synchronization2)
+	table->vkCmdPipelineBarrier2KHR = (PFN_vkCmdPipelineBarrier2KHR)load(context, "vkCmdPipelineBarrier2KHR");
+	table->vkCmdResetEvent2KHR = (PFN_vkCmdResetEvent2KHR)load(context, "vkCmdResetEvent2KHR");
+	table->vkCmdSetEvent2KHR = (PFN_vkCmdSetEvent2KHR)load(context, "vkCmdSetEvent2KHR");
+	table->vkCmdWaitEvents2KHR = (PFN_vkCmdWaitEvents2KHR)load(context, "vkCmdWaitEvents2KHR");
+	table->vkCmdWriteTimestamp2KHR = (PFN_vkCmdWriteTimestamp2KHR)load(context, "vkCmdWriteTimestamp2KHR");
+	table->vkQueueSubmit2KHR = (PFN_vkQueueSubmit2KHR)load(context, "vkQueueSubmit2KHR");
+#endif /* defined(VK_KHR_synchronization2) */
+#if defined(VK_KHR_timeline_semaphore)
+	table->vkGetSemaphoreCounterValueKHR = (PFN_vkGetSemaphoreCounterValueKHR)load(context, "vkGetSemaphoreCounterValueKHR");
+	table->vkSignalSemaphoreKHR = (PFN_vkSignalSemaphoreKHR)load(context, "vkSignalSemaphoreKHR");
+	table->vkWaitSemaphoresKHR = (PFN_vkWaitSemaphoresKHR)load(context, "vkWaitSemaphoresKHR");
+#endif /* defined(VK_KHR_timeline_semaphore) */
+#if defined(VK_KHR_video_decode_queue)
+	table->vkCmdDecodeVideoKHR = (PFN_vkCmdDecodeVideoKHR)load(context, "vkCmdDecodeVideoKHR");
+#endif /* defined(VK_KHR_video_decode_queue) */
+#if defined(VK_KHR_video_encode_queue)
+	table->vkCmdEncodeVideoKHR = (PFN_vkCmdEncodeVideoKHR)load(context, "vkCmdEncodeVideoKHR");
+	table->vkGetEncodedVideoSessionParametersKHR = (PFN_vkGetEncodedVideoSessionParametersKHR)load(context, "vkGetEncodedVideoSessionParametersKHR");
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	table->vkBindVideoSessionMemoryKHR = (PFN_vkBindVideoSessionMemoryKHR)load(context, "vkBindVideoSessionMemoryKHR");
+	table->vkCmdBeginVideoCodingKHR = (PFN_vkCmdBeginVideoCodingKHR)load(context, "vkCmdBeginVideoCodingKHR");
+	table->vkCmdControlVideoCodingKHR = (PFN_vkCmdControlVideoCodingKHR)load(context, "vkCmdControlVideoCodingKHR");
+	table->vkCmdEndVideoCodingKHR = (PFN_vkCmdEndVideoCodingKHR)load(context, "vkCmdEndVideoCodingKHR");
+	table->vkCreateVideoSessionKHR = (PFN_vkCreateVideoSessionKHR)load(context, "vkCreateVideoSessionKHR");
+	table->vkCreateVideoSessionParametersKHR = (PFN_vkCreateVideoSessionParametersKHR)load(context, "vkCreateVideoSessionParametersKHR");
+	table->vkDestroyVideoSessionKHR = (PFN_vkDestroyVideoSessionKHR)load(context, "vkDestroyVideoSessionKHR");
+	table->vkDestroyVideoSessionParametersKHR = (PFN_vkDestroyVideoSessionParametersKHR)load(context, "vkDestroyVideoSessionParametersKHR");
+	table->vkGetVideoSessionMemoryRequirementsKHR = (PFN_vkGetVideoSessionMemoryRequirementsKHR)load(context, "vkGetVideoSessionMemoryRequirementsKHR");
+	table->vkUpdateVideoSessionParametersKHR = (PFN_vkUpdateVideoSessionParametersKHR)load(context, "vkUpdateVideoSessionParametersKHR");
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_NVX_binary_import)
+	table->vkCmdCuLaunchKernelNVX = (PFN_vkCmdCuLaunchKernelNVX)load(context, "vkCmdCuLaunchKernelNVX");
+	table->vkCreateCuFunctionNVX = (PFN_vkCreateCuFunctionNVX)load(context, "vkCreateCuFunctionNVX");
+	table->vkCreateCuModuleNVX = (PFN_vkCreateCuModuleNVX)load(context, "vkCreateCuModuleNVX");
+	table->vkDestroyCuFunctionNVX = (PFN_vkDestroyCuFunctionNVX)load(context, "vkDestroyCuFunctionNVX");
+	table->vkDestroyCuModuleNVX = (PFN_vkDestroyCuModuleNVX)load(context, "vkDestroyCuModuleNVX");
+#endif /* defined(VK_NVX_binary_import) */
+#if defined(VK_NVX_image_view_handle)
+	table->vkGetImageViewHandleNVX = (PFN_vkGetImageViewHandleNVX)load(context, "vkGetImageViewHandleNVX");
+#endif /* defined(VK_NVX_image_view_handle) */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3
+	table->vkGetImageViewHandle64NVX = (PFN_vkGetImageViewHandle64NVX)load(context, "vkGetImageViewHandle64NVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2
+	table->vkGetImageViewAddressNVX = (PFN_vkGetImageViewAddressNVX)load(context, "vkGetImageViewAddressNVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4
+	table->vkGetDeviceCombinedImageSamplerIndexNVX = (PFN_vkGetDeviceCombinedImageSamplerIndexNVX)load(context, "vkGetDeviceCombinedImageSamplerIndexNVX");
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4 */
+#if defined(VK_NV_clip_space_w_scaling)
+	table->vkCmdSetViewportWScalingNV = (PFN_vkCmdSetViewportWScalingNV)load(context, "vkCmdSetViewportWScalingNV");
+#endif /* defined(VK_NV_clip_space_w_scaling) */
+#if defined(VK_NV_cluster_acceleration_structure)
+	table->vkCmdBuildClusterAccelerationStructureIndirectNV = (PFN_vkCmdBuildClusterAccelerationStructureIndirectNV)load(context, "vkCmdBuildClusterAccelerationStructureIndirectNV");
+	table->vkGetClusterAccelerationStructureBuildSizesNV = (PFN_vkGetClusterAccelerationStructureBuildSizesNV)load(context, "vkGetClusterAccelerationStructureBuildSizesNV");
+#endif /* defined(VK_NV_cluster_acceleration_structure) */
+#if defined(VK_NV_compute_occupancy_priority)
+	table->vkCmdSetComputeOccupancyPriorityNV = (PFN_vkCmdSetComputeOccupancyPriorityNV)load(context, "vkCmdSetComputeOccupancyPriorityNV");
+#endif /* defined(VK_NV_compute_occupancy_priority) */
+#if defined(VK_NV_cooperative_vector)
+	table->vkCmdConvertCooperativeVectorMatrixNV = (PFN_vkCmdConvertCooperativeVectorMatrixNV)load(context, "vkCmdConvertCooperativeVectorMatrixNV");
+	table->vkConvertCooperativeVectorMatrixNV = (PFN_vkConvertCooperativeVectorMatrixNV)load(context, "vkConvertCooperativeVectorMatrixNV");
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_copy_memory_indirect)
+	table->vkCmdCopyMemoryIndirectNV = (PFN_vkCmdCopyMemoryIndirectNV)load(context, "vkCmdCopyMemoryIndirectNV");
+	table->vkCmdCopyMemoryToImageIndirectNV = (PFN_vkCmdCopyMemoryToImageIndirectNV)load(context, "vkCmdCopyMemoryToImageIndirectNV");
+#endif /* defined(VK_NV_copy_memory_indirect) */
+#if defined(VK_NV_cuda_kernel_launch)
+	table->vkCmdCudaLaunchKernelNV = (PFN_vkCmdCudaLaunchKernelNV)load(context, "vkCmdCudaLaunchKernelNV");
+	table->vkCreateCudaFunctionNV = (PFN_vkCreateCudaFunctionNV)load(context, "vkCreateCudaFunctionNV");
+	table->vkCreateCudaModuleNV = (PFN_vkCreateCudaModuleNV)load(context, "vkCreateCudaModuleNV");
+	table->vkDestroyCudaFunctionNV = (PFN_vkDestroyCudaFunctionNV)load(context, "vkDestroyCudaFunctionNV");
+	table->vkDestroyCudaModuleNV = (PFN_vkDestroyCudaModuleNV)load(context, "vkDestroyCudaModuleNV");
+	table->vkGetCudaModuleCacheNV = (PFN_vkGetCudaModuleCacheNV)load(context, "vkGetCudaModuleCacheNV");
+#endif /* defined(VK_NV_cuda_kernel_launch) */
+#if defined(VK_NV_device_diagnostic_checkpoints)
+	table->vkCmdSetCheckpointNV = (PFN_vkCmdSetCheckpointNV)load(context, "vkCmdSetCheckpointNV");
+	table->vkGetQueueCheckpointDataNV = (PFN_vkGetQueueCheckpointDataNV)load(context, "vkGetQueueCheckpointDataNV");
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) */
+#if defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	table->vkGetQueueCheckpointData2NV = (PFN_vkGetQueueCheckpointData2NV)load(context, "vkGetQueueCheckpointData2NV");
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_NV_device_generated_commands)
+	table->vkCmdBindPipelineShaderGroupNV = (PFN_vkCmdBindPipelineShaderGroupNV)load(context, "vkCmdBindPipelineShaderGroupNV");
+	table->vkCmdExecuteGeneratedCommandsNV = (PFN_vkCmdExecuteGeneratedCommandsNV)load(context, "vkCmdExecuteGeneratedCommandsNV");
+	table->vkCmdPreprocessGeneratedCommandsNV = (PFN_vkCmdPreprocessGeneratedCommandsNV)load(context, "vkCmdPreprocessGeneratedCommandsNV");
+	table->vkCreateIndirectCommandsLayoutNV = (PFN_vkCreateIndirectCommandsLayoutNV)load(context, "vkCreateIndirectCommandsLayoutNV");
+	table->vkDestroyIndirectCommandsLayoutNV = (PFN_vkDestroyIndirectCommandsLayoutNV)load(context, "vkDestroyIndirectCommandsLayoutNV");
+	table->vkGetGeneratedCommandsMemoryRequirementsNV = (PFN_vkGetGeneratedCommandsMemoryRequirementsNV)load(context, "vkGetGeneratedCommandsMemoryRequirementsNV");
+#endif /* defined(VK_NV_device_generated_commands) */
+#if defined(VK_NV_device_generated_commands_compute)
+	table->vkCmdUpdatePipelineIndirectBufferNV = (PFN_vkCmdUpdatePipelineIndirectBufferNV)load(context, "vkCmdUpdatePipelineIndirectBufferNV");
+	table->vkGetPipelineIndirectDeviceAddressNV = (PFN_vkGetPipelineIndirectDeviceAddressNV)load(context, "vkGetPipelineIndirectDeviceAddressNV");
+	table->vkGetPipelineIndirectMemoryRequirementsNV = (PFN_vkGetPipelineIndirectMemoryRequirementsNV)load(context, "vkGetPipelineIndirectMemoryRequirementsNV");
+#endif /* defined(VK_NV_device_generated_commands_compute) */
+#if defined(VK_NV_external_compute_queue)
+	table->vkCreateExternalComputeQueueNV = (PFN_vkCreateExternalComputeQueueNV)load(context, "vkCreateExternalComputeQueueNV");
+	table->vkDestroyExternalComputeQueueNV = (PFN_vkDestroyExternalComputeQueueNV)load(context, "vkDestroyExternalComputeQueueNV");
+	table->vkGetExternalComputeQueueDataNV = (PFN_vkGetExternalComputeQueueDataNV)load(context, "vkGetExternalComputeQueueDataNV");
+#endif /* defined(VK_NV_external_compute_queue) */
+#if defined(VK_NV_external_memory_rdma)
+	table->vkGetMemoryRemoteAddressNV = (PFN_vkGetMemoryRemoteAddressNV)load(context, "vkGetMemoryRemoteAddressNV");
+#endif /* defined(VK_NV_external_memory_rdma) */
+#if defined(VK_NV_external_memory_win32)
+	table->vkGetMemoryWin32HandleNV = (PFN_vkGetMemoryWin32HandleNV)load(context, "vkGetMemoryWin32HandleNV");
+#endif /* defined(VK_NV_external_memory_win32) */
+#if defined(VK_NV_fragment_shading_rate_enums)
+	table->vkCmdSetFragmentShadingRateEnumNV = (PFN_vkCmdSetFragmentShadingRateEnumNV)load(context, "vkCmdSetFragmentShadingRateEnumNV");
+#endif /* defined(VK_NV_fragment_shading_rate_enums) */
+#if defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2
+	table->vkGetLatencyTimingsLegacyNV = (PFN_vkGetLatencyTimingsLegacyNV)load(context, "vkGetLatencyTimingsLegacyNV");
+	table->vkGetSleepStatusLegacyNV = (PFN_vkGetSleepStatusLegacyNV)load(context, "vkGetSleepStatusLegacyNV");
+	table->vkLatencySleepLegacyNV = (PFN_vkLatencySleepLegacyNV)load(context, "vkLatencySleepLegacyNV");
+	table->vkQueueNotifyOutOfBandLegacyNV = (PFN_vkQueueNotifyOutOfBandLegacyNV)load(context, "vkQueueNotifyOutOfBandLegacyNV");
+	table->vkSetLatencyMarkerLegacyNV = (PFN_vkSetLatencyMarkerLegacyNV)load(context, "vkSetLatencyMarkerLegacyNV");
+	table->vkSetLatencySleepModeLegacyNV = (PFN_vkSetLatencySleepModeLegacyNV)load(context, "vkSetLatencySleepModeLegacyNV");
+	table->vkShutdownLatencyDeviceLegacyNV = (PFN_vkShutdownLatencyDeviceLegacyNV)load(context, "vkShutdownLatencyDeviceLegacyNV");
+#endif /* defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2 */
+#if defined(VK_NV_low_latency2)
+	table->vkGetLatencyTimingsNV = (PFN_vkGetLatencyTimingsNV)load(context, "vkGetLatencyTimingsNV");
+	table->vkLatencySleepNV = (PFN_vkLatencySleepNV)load(context, "vkLatencySleepNV");
+	table->vkQueueNotifyOutOfBandNV = (PFN_vkQueueNotifyOutOfBandNV)load(context, "vkQueueNotifyOutOfBandNV");
+	table->vkSetLatencyMarkerNV = (PFN_vkSetLatencyMarkerNV)load(context, "vkSetLatencyMarkerNV");
+	table->vkSetLatencySleepModeNV = (PFN_vkSetLatencySleepModeNV)load(context, "vkSetLatencySleepModeNV");
+#endif /* defined(VK_NV_low_latency2) */
+#if defined(VK_NV_memory_decompression)
+	table->vkCmdDecompressMemoryIndirectCountNV = (PFN_vkCmdDecompressMemoryIndirectCountNV)load(context, "vkCmdDecompressMemoryIndirectCountNV");
+	table->vkCmdDecompressMemoryNV = (PFN_vkCmdDecompressMemoryNV)load(context, "vkCmdDecompressMemoryNV");
+#endif /* defined(VK_NV_memory_decompression) */
+#if defined(VK_NV_mesh_shader)
+	table->vkCmdDrawMeshTasksIndirectNV = (PFN_vkCmdDrawMeshTasksIndirectNV)load(context, "vkCmdDrawMeshTasksIndirectNV");
+	table->vkCmdDrawMeshTasksNV = (PFN_vkCmdDrawMeshTasksNV)load(context, "vkCmdDrawMeshTasksNV");
+#endif /* defined(VK_NV_mesh_shader) */
+#if defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	table->vkCmdDrawMeshTasksIndirectCountNV = (PFN_vkCmdDrawMeshTasksIndirectCountNV)load(context, "vkCmdDrawMeshTasksIndirectCountNV");
+#endif /* defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_NV_optical_flow)
+	table->vkBindOpticalFlowSessionImageNV = (PFN_vkBindOpticalFlowSessionImageNV)load(context, "vkBindOpticalFlowSessionImageNV");
+	table->vkCmdOpticalFlowExecuteNV = (PFN_vkCmdOpticalFlowExecuteNV)load(context, "vkCmdOpticalFlowExecuteNV");
+	table->vkCreateOpticalFlowSessionNV = (PFN_vkCreateOpticalFlowSessionNV)load(context, "vkCreateOpticalFlowSessionNV");
+	table->vkDestroyOpticalFlowSessionNV = (PFN_vkDestroyOpticalFlowSessionNV)load(context, "vkDestroyOpticalFlowSessionNV");
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_NV_partitioned_acceleration_structure)
+	table->vkCmdBuildPartitionedAccelerationStructuresNV = (PFN_vkCmdBuildPartitionedAccelerationStructuresNV)load(context, "vkCmdBuildPartitionedAccelerationStructuresNV");
+	table->vkGetPartitionedAccelerationStructuresBuildSizesNV = (PFN_vkGetPartitionedAccelerationStructuresBuildSizesNV)load(context, "vkGetPartitionedAccelerationStructuresBuildSizesNV");
+#endif /* defined(VK_NV_partitioned_acceleration_structure) */
+#if defined(VK_NV_ray_tracing)
+	table->vkBindAccelerationStructureMemoryNV = (PFN_vkBindAccelerationStructureMemoryNV)load(context, "vkBindAccelerationStructureMemoryNV");
+	table->vkCmdBuildAccelerationStructureNV = (PFN_vkCmdBuildAccelerationStructureNV)load(context, "vkCmdBuildAccelerationStructureNV");
+	table->vkCmdCopyAccelerationStructureNV = (PFN_vkCmdCopyAccelerationStructureNV)load(context, "vkCmdCopyAccelerationStructureNV");
+	table->vkCmdTraceRaysNV = (PFN_vkCmdTraceRaysNV)load(context, "vkCmdTraceRaysNV");
+	table->vkCmdWriteAccelerationStructuresPropertiesNV = (PFN_vkCmdWriteAccelerationStructuresPropertiesNV)load(context, "vkCmdWriteAccelerationStructuresPropertiesNV");
+	table->vkCompileDeferredNV = (PFN_vkCompileDeferredNV)load(context, "vkCompileDeferredNV");
+	table->vkCreateAccelerationStructureNV = (PFN_vkCreateAccelerationStructureNV)load(context, "vkCreateAccelerationStructureNV");
+	table->vkCreateRayTracingPipelinesNV = (PFN_vkCreateRayTracingPipelinesNV)load(context, "vkCreateRayTracingPipelinesNV");
+	table->vkDestroyAccelerationStructureNV = (PFN_vkDestroyAccelerationStructureNV)load(context, "vkDestroyAccelerationStructureNV");
+	table->vkGetAccelerationStructureHandleNV = (PFN_vkGetAccelerationStructureHandleNV)load(context, "vkGetAccelerationStructureHandleNV");
+	table->vkGetAccelerationStructureMemoryRequirementsNV = (PFN_vkGetAccelerationStructureMemoryRequirementsNV)load(context, "vkGetAccelerationStructureMemoryRequirementsNV");
+	table->vkGetRayTracingShaderGroupHandlesNV = (PFN_vkGetRayTracingShaderGroupHandlesNV)load(context, "vkGetRayTracingShaderGroupHandlesNV");
+#endif /* defined(VK_NV_ray_tracing) */
+#if defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2
+	table->vkCmdSetExclusiveScissorEnableNV = (PFN_vkCmdSetExclusiveScissorEnableNV)load(context, "vkCmdSetExclusiveScissorEnableNV");
+#endif /* defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2 */
+#if defined(VK_NV_scissor_exclusive)
+	table->vkCmdSetExclusiveScissorNV = (PFN_vkCmdSetExclusiveScissorNV)load(context, "vkCmdSetExclusiveScissorNV");
+#endif /* defined(VK_NV_scissor_exclusive) */
+#if defined(VK_NV_shading_rate_image)
+	table->vkCmdBindShadingRateImageNV = (PFN_vkCmdBindShadingRateImageNV)load(context, "vkCmdBindShadingRateImageNV");
+	table->vkCmdSetCoarseSampleOrderNV = (PFN_vkCmdSetCoarseSampleOrderNV)load(context, "vkCmdSetCoarseSampleOrderNV");
+	table->vkCmdSetViewportShadingRatePaletteNV = (PFN_vkCmdSetViewportShadingRatePaletteNV)load(context, "vkCmdSetViewportShadingRatePaletteNV");
+#endif /* defined(VK_NV_shading_rate_image) */
+#if defined(VK_OHOS_external_memory)
+	table->vkGetMemoryNativeBufferOHOS = (PFN_vkGetMemoryNativeBufferOHOS)load(context, "vkGetMemoryNativeBufferOHOS");
+	table->vkGetNativeBufferPropertiesOHOS = (PFN_vkGetNativeBufferPropertiesOHOS)load(context, "vkGetNativeBufferPropertiesOHOS");
+#endif /* defined(VK_OHOS_external_memory) */
+#if defined(VK_QCOM_queue_perf_hint)
+	table->vkQueueSetPerfHintQCOM = (PFN_vkQueueSetPerfHintQCOM)load(context, "vkQueueSetPerfHintQCOM");
+#endif /* defined(VK_QCOM_queue_perf_hint) */
+#if defined(VK_QCOM_tile_memory_heap)
+	table->vkCmdBindTileMemoryQCOM = (PFN_vkCmdBindTileMemoryQCOM)load(context, "vkCmdBindTileMemoryQCOM");
+#endif /* defined(VK_QCOM_tile_memory_heap) */
+#if defined(VK_QCOM_tile_properties)
+	table->vkGetDynamicRenderingTilePropertiesQCOM = (PFN_vkGetDynamicRenderingTilePropertiesQCOM)load(context, "vkGetDynamicRenderingTilePropertiesQCOM");
+	table->vkGetFramebufferTilePropertiesQCOM = (PFN_vkGetFramebufferTilePropertiesQCOM)load(context, "vkGetFramebufferTilePropertiesQCOM");
+#endif /* defined(VK_QCOM_tile_properties) */
+#if defined(VK_QCOM_tile_shading)
+	table->vkCmdBeginPerTileExecutionQCOM = (PFN_vkCmdBeginPerTileExecutionQCOM)load(context, "vkCmdBeginPerTileExecutionQCOM");
+	table->vkCmdDispatchTileQCOM = (PFN_vkCmdDispatchTileQCOM)load(context, "vkCmdDispatchTileQCOM");
+	table->vkCmdEndPerTileExecutionQCOM = (PFN_vkCmdEndPerTileExecutionQCOM)load(context, "vkCmdEndPerTileExecutionQCOM");
+#endif /* defined(VK_QCOM_tile_shading) */
+#if defined(VK_QNX_external_memory_screen_buffer)
+	table->vkGetScreenBufferPropertiesQNX = (PFN_vkGetScreenBufferPropertiesQNX)load(context, "vkGetScreenBufferPropertiesQNX");
+#endif /* defined(VK_QNX_external_memory_screen_buffer) */
+#if defined(VK_VALVE_descriptor_set_host_mapping)
+	table->vkGetDescriptorSetHostMappingVALVE = (PFN_vkGetDescriptorSetHostMappingVALVE)load(context, "vkGetDescriptorSetHostMappingVALVE");
+	table->vkGetDescriptorSetLayoutHostMappingInfoVALVE = (PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE)load(context, "vkGetDescriptorSetLayoutHostMappingInfoVALVE");
+#endif /* defined(VK_VALVE_descriptor_set_host_mapping) */
+#if (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control))
+	table->vkCmdSetDepthClampRangeEXT = (PFN_vkCmdSetDepthClampRangeEXT)load(context, "vkCmdSetDepthClampRangeEXT");
+#endif /* (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control)) */
+#if (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object))
+	table->vkCmdBindVertexBuffers2EXT = (PFN_vkCmdBindVertexBuffers2EXT)load(context, "vkCmdBindVertexBuffers2EXT");
+	table->vkCmdSetCullModeEXT = (PFN_vkCmdSetCullModeEXT)load(context, "vkCmdSetCullModeEXT");
+	table->vkCmdSetDepthBoundsTestEnableEXT = (PFN_vkCmdSetDepthBoundsTestEnableEXT)load(context, "vkCmdSetDepthBoundsTestEnableEXT");
+	table->vkCmdSetDepthCompareOpEXT = (PFN_vkCmdSetDepthCompareOpEXT)load(context, "vkCmdSetDepthCompareOpEXT");
+	table->vkCmdSetDepthTestEnableEXT = (PFN_vkCmdSetDepthTestEnableEXT)load(context, "vkCmdSetDepthTestEnableEXT");
+	table->vkCmdSetDepthWriteEnableEXT = (PFN_vkCmdSetDepthWriteEnableEXT)load(context, "vkCmdSetDepthWriteEnableEXT");
+	table->vkCmdSetFrontFaceEXT = (PFN_vkCmdSetFrontFaceEXT)load(context, "vkCmdSetFrontFaceEXT");
+	table->vkCmdSetPrimitiveTopologyEXT = (PFN_vkCmdSetPrimitiveTopologyEXT)load(context, "vkCmdSetPrimitiveTopologyEXT");
+	table->vkCmdSetScissorWithCountEXT = (PFN_vkCmdSetScissorWithCountEXT)load(context, "vkCmdSetScissorWithCountEXT");
+	table->vkCmdSetStencilOpEXT = (PFN_vkCmdSetStencilOpEXT)load(context, "vkCmdSetStencilOpEXT");
+	table->vkCmdSetStencilTestEnableEXT = (PFN_vkCmdSetStencilTestEnableEXT)load(context, "vkCmdSetStencilTestEnableEXT");
+	table->vkCmdSetViewportWithCountEXT = (PFN_vkCmdSetViewportWithCountEXT)load(context, "vkCmdSetViewportWithCountEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object))
+	table->vkCmdSetDepthBiasEnableEXT = (PFN_vkCmdSetDepthBiasEnableEXT)load(context, "vkCmdSetDepthBiasEnableEXT");
+	table->vkCmdSetLogicOpEXT = (PFN_vkCmdSetLogicOpEXT)load(context, "vkCmdSetLogicOpEXT");
+	table->vkCmdSetPatchControlPointsEXT = (PFN_vkCmdSetPatchControlPointsEXT)load(context, "vkCmdSetPatchControlPointsEXT");
+	table->vkCmdSetPrimitiveRestartEnableEXT = (PFN_vkCmdSetPrimitiveRestartEnableEXT)load(context, "vkCmdSetPrimitiveRestartEnableEXT");
+	table->vkCmdSetRasterizerDiscardEnableEXT = (PFN_vkCmdSetRasterizerDiscardEnableEXT)load(context, "vkCmdSetRasterizerDiscardEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object))
+	table->vkCmdSetAlphaToCoverageEnableEXT = (PFN_vkCmdSetAlphaToCoverageEnableEXT)load(context, "vkCmdSetAlphaToCoverageEnableEXT");
+	table->vkCmdSetAlphaToOneEnableEXT = (PFN_vkCmdSetAlphaToOneEnableEXT)load(context, "vkCmdSetAlphaToOneEnableEXT");
+	table->vkCmdSetColorBlendEnableEXT = (PFN_vkCmdSetColorBlendEnableEXT)load(context, "vkCmdSetColorBlendEnableEXT");
+	table->vkCmdSetColorBlendEquationEXT = (PFN_vkCmdSetColorBlendEquationEXT)load(context, "vkCmdSetColorBlendEquationEXT");
+	table->vkCmdSetColorWriteMaskEXT = (PFN_vkCmdSetColorWriteMaskEXT)load(context, "vkCmdSetColorWriteMaskEXT");
+	table->vkCmdSetDepthClampEnableEXT = (PFN_vkCmdSetDepthClampEnableEXT)load(context, "vkCmdSetDepthClampEnableEXT");
+	table->vkCmdSetLogicOpEnableEXT = (PFN_vkCmdSetLogicOpEnableEXT)load(context, "vkCmdSetLogicOpEnableEXT");
+	table->vkCmdSetPolygonModeEXT = (PFN_vkCmdSetPolygonModeEXT)load(context, "vkCmdSetPolygonModeEXT");
+	table->vkCmdSetRasterizationSamplesEXT = (PFN_vkCmdSetRasterizationSamplesEXT)load(context, "vkCmdSetRasterizationSamplesEXT");
+	table->vkCmdSetSampleMaskEXT = (PFN_vkCmdSetSampleMaskEXT)load(context, "vkCmdSetSampleMaskEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object))
+	table->vkCmdSetTessellationDomainOriginEXT = (PFN_vkCmdSetTessellationDomainOriginEXT)load(context, "vkCmdSetTessellationDomainOriginEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback))
+	table->vkCmdSetRasterizationStreamEXT = (PFN_vkCmdSetRasterizationStreamEXT)load(context, "vkCmdSetRasterizationStreamEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization))
+	table->vkCmdSetConservativeRasterizationModeEXT = (PFN_vkCmdSetConservativeRasterizationModeEXT)load(context, "vkCmdSetConservativeRasterizationModeEXT");
+	table->vkCmdSetExtraPrimitiveOverestimationSizeEXT = (PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT)load(context, "vkCmdSetExtraPrimitiveOverestimationSizeEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable))
+	table->vkCmdSetDepthClipEnableEXT = (PFN_vkCmdSetDepthClipEnableEXT)load(context, "vkCmdSetDepthClipEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations))
+	table->vkCmdSetSampleLocationsEnableEXT = (PFN_vkCmdSetSampleLocationsEnableEXT)load(context, "vkCmdSetSampleLocationsEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced))
+	table->vkCmdSetColorBlendAdvancedEXT = (PFN_vkCmdSetColorBlendAdvancedEXT)load(context, "vkCmdSetColorBlendAdvancedEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex))
+	table->vkCmdSetProvokingVertexModeEXT = (PFN_vkCmdSetProvokingVertexModeEXT)load(context, "vkCmdSetProvokingVertexModeEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization)))
+	table->vkCmdSetLineRasterizationModeEXT = (PFN_vkCmdSetLineRasterizationModeEXT)load(context, "vkCmdSetLineRasterizationModeEXT");
+	table->vkCmdSetLineStippleEnableEXT = (PFN_vkCmdSetLineStippleEnableEXT)load(context, "vkCmdSetLineStippleEnableEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control))
+	table->vkCmdSetDepthClipNegativeOneToOneEXT = (PFN_vkCmdSetDepthClipNegativeOneToOneEXT)load(context, "vkCmdSetDepthClipNegativeOneToOneEXT");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling))
+	table->vkCmdSetViewportWScalingEnableNV = (PFN_vkCmdSetViewportWScalingEnableNV)load(context, "vkCmdSetViewportWScalingEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle))
+	table->vkCmdSetViewportSwizzleNV = (PFN_vkCmdSetViewportSwizzleNV)load(context, "vkCmdSetViewportSwizzleNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color))
+	table->vkCmdSetCoverageToColorEnableNV = (PFN_vkCmdSetCoverageToColorEnableNV)load(context, "vkCmdSetCoverageToColorEnableNV");
+	table->vkCmdSetCoverageToColorLocationNV = (PFN_vkCmdSetCoverageToColorLocationNV)load(context, "vkCmdSetCoverageToColorLocationNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples))
+	table->vkCmdSetCoverageModulationModeNV = (PFN_vkCmdSetCoverageModulationModeNV)load(context, "vkCmdSetCoverageModulationModeNV");
+	table->vkCmdSetCoverageModulationTableEnableNV = (PFN_vkCmdSetCoverageModulationTableEnableNV)load(context, "vkCmdSetCoverageModulationTableEnableNV");
+	table->vkCmdSetCoverageModulationTableNV = (PFN_vkCmdSetCoverageModulationTableNV)load(context, "vkCmdSetCoverageModulationTableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image))
+	table->vkCmdSetShadingRateImageEnableNV = (PFN_vkCmdSetShadingRateImageEnableNV)load(context, "vkCmdSetShadingRateImageEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test))
+	table->vkCmdSetRepresentativeFragmentTestEnableNV = (PFN_vkCmdSetRepresentativeFragmentTestEnableNV)load(context, "vkCmdSetRepresentativeFragmentTestEnableNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode))
+	table->vkCmdSetCoverageReductionModeNV = (PFN_vkCmdSetCoverageReductionModeNV)load(context, "vkCmdSetCoverageReductionModeNV");
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode)) */
+#if (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control))
+	table->vkGetImageSubresourceLayout2EXT = (PFN_vkGetImageSubresourceLayout2EXT)load(context, "vkGetImageSubresourceLayout2EXT");
+#endif /* (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control)) */
+#if (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state))
+	table->vkCmdSetVertexInputEXT = (PFN_vkCmdSetVertexInputEXT)load(context, "vkCmdSetVertexInputEXT");
+#endif /* (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state)) */
+#if (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template)))
+	table->vkCmdPushDescriptorSetWithTemplateKHR = (PFN_vkCmdPushDescriptorSetWithTemplateKHR)load(context, "vkCmdPushDescriptorSetWithTemplateKHR");
+#endif /* (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template))) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	table->vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR)load(context, "vkGetDeviceGroupPresentCapabilitiesKHR");
+	table->vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR)load(context, "vkGetDeviceGroupSurfacePresentModesKHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	table->vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR)load(context, "vkAcquireNextImage2KHR");
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_LOAD_DEVICE_TABLE */
+}
+
+#ifdef __GNUC__
+#ifdef VOLK_DEFAULT_VISIBILITY
+#	pragma GCC visibility push(default)
+#else
+#	pragma GCC visibility push(hidden)
+#endif
+#endif
+
+/* VOLK_GENERATE_PROTOTYPES_C */
+#if defined(VK_VERSION_1_0)
+PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
+PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
+PFN_vkAllocateMemory vkAllocateMemory;
+PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
+PFN_vkBindBufferMemory vkBindBufferMemory;
+PFN_vkBindImageMemory vkBindImageMemory;
+PFN_vkCmdBeginQuery vkCmdBeginQuery;
+PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
+PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
+PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
+PFN_vkCmdBindPipeline vkCmdBindPipeline;
+PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
+PFN_vkCmdBlitImage vkCmdBlitImage;
+PFN_vkCmdClearAttachments vkCmdClearAttachments;
+PFN_vkCmdClearColorImage vkCmdClearColorImage;
+PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
+PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
+PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
+PFN_vkCmdCopyImage vkCmdCopyImage;
+PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
+PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
+PFN_vkCmdDispatch vkCmdDispatch;
+PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
+PFN_vkCmdDraw vkCmdDraw;
+PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
+PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
+PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
+PFN_vkCmdEndQuery vkCmdEndQuery;
+PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
+PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
+PFN_vkCmdFillBuffer vkCmdFillBuffer;
+PFN_vkCmdNextSubpass vkCmdNextSubpass;
+PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
+PFN_vkCmdPushConstants vkCmdPushConstants;
+PFN_vkCmdResetEvent vkCmdResetEvent;
+PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
+PFN_vkCmdResolveImage vkCmdResolveImage;
+PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
+PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
+PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
+PFN_vkCmdSetEvent vkCmdSetEvent;
+PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
+PFN_vkCmdSetScissor vkCmdSetScissor;
+PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
+PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
+PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
+PFN_vkCmdSetViewport vkCmdSetViewport;
+PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
+PFN_vkCmdWaitEvents vkCmdWaitEvents;
+PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
+PFN_vkCreateBuffer vkCreateBuffer;
+PFN_vkCreateBufferView vkCreateBufferView;
+PFN_vkCreateCommandPool vkCreateCommandPool;
+PFN_vkCreateComputePipelines vkCreateComputePipelines;
+PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
+PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
+PFN_vkCreateDevice vkCreateDevice;
+PFN_vkCreateEvent vkCreateEvent;
+PFN_vkCreateFence vkCreateFence;
+PFN_vkCreateFramebuffer vkCreateFramebuffer;
+PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
+PFN_vkCreateImage vkCreateImage;
+PFN_vkCreateImageView vkCreateImageView;
+PFN_vkCreateInstance vkCreateInstance;
+PFN_vkCreatePipelineCache vkCreatePipelineCache;
+PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
+PFN_vkCreateQueryPool vkCreateQueryPool;
+PFN_vkCreateRenderPass vkCreateRenderPass;
+PFN_vkCreateSampler vkCreateSampler;
+PFN_vkCreateSemaphore vkCreateSemaphore;
+PFN_vkCreateShaderModule vkCreateShaderModule;
+PFN_vkDestroyBuffer vkDestroyBuffer;
+PFN_vkDestroyBufferView vkDestroyBufferView;
+PFN_vkDestroyCommandPool vkDestroyCommandPool;
+PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
+PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
+PFN_vkDestroyDevice vkDestroyDevice;
+PFN_vkDestroyEvent vkDestroyEvent;
+PFN_vkDestroyFence vkDestroyFence;
+PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
+PFN_vkDestroyImage vkDestroyImage;
+PFN_vkDestroyImageView vkDestroyImageView;
+PFN_vkDestroyInstance vkDestroyInstance;
+PFN_vkDestroyPipeline vkDestroyPipeline;
+PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
+PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
+PFN_vkDestroyQueryPool vkDestroyQueryPool;
+PFN_vkDestroyRenderPass vkDestroyRenderPass;
+PFN_vkDestroySampler vkDestroySampler;
+PFN_vkDestroySemaphore vkDestroySemaphore;
+PFN_vkDestroyShaderModule vkDestroyShaderModule;
+PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
+PFN_vkEndCommandBuffer vkEndCommandBuffer;
+PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
+PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
+PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
+PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
+PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
+PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
+PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
+PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
+PFN_vkFreeMemory vkFreeMemory;
+PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
+PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
+PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
+PFN_vkGetDeviceQueue vkGetDeviceQueue;
+PFN_vkGetEventStatus vkGetEventStatus;
+PFN_vkGetFenceStatus vkGetFenceStatus;
+PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
+PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
+PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
+PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
+PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
+PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
+PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
+PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
+PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
+PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
+PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
+PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
+PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
+PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
+PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
+PFN_vkMapMemory vkMapMemory;
+PFN_vkMergePipelineCaches vkMergePipelineCaches;
+PFN_vkQueueBindSparse vkQueueBindSparse;
+PFN_vkQueueSubmit vkQueueSubmit;
+PFN_vkQueueWaitIdle vkQueueWaitIdle;
+PFN_vkResetCommandBuffer vkResetCommandBuffer;
+PFN_vkResetCommandPool vkResetCommandPool;
+PFN_vkResetDescriptorPool vkResetDescriptorPool;
+PFN_vkResetEvent vkResetEvent;
+PFN_vkResetFences vkResetFences;
+PFN_vkSetEvent vkSetEvent;
+PFN_vkUnmapMemory vkUnmapMemory;
+PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
+PFN_vkWaitForFences vkWaitForFences;
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+PFN_vkBindBufferMemory2 vkBindBufferMemory2;
+PFN_vkBindImageMemory2 vkBindImageMemory2;
+PFN_vkCmdDispatchBase vkCmdDispatchBase;
+PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask;
+PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate;
+PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion;
+PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate;
+PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion;
+PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion;
+PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups;
+PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2;
+PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport;
+PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures;
+PFN_vkGetDeviceQueue2 vkGetDeviceQueue2;
+PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2;
+PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2;
+PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties;
+PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties;
+PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties;
+PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2;
+PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2;
+PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2;
+PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2;
+PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2;
+PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2;
+PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2;
+PFN_vkTrimCommandPool vkTrimCommandPool;
+PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_2)
+PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
+PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
+PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
+PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
+PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
+PFN_vkCreateRenderPass2 vkCreateRenderPass2;
+PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
+PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
+PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
+PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
+PFN_vkResetQueryPool vkResetQueryPool;
+PFN_vkSignalSemaphore vkSignalSemaphore;
+PFN_vkWaitSemaphores vkWaitSemaphores;
+#endif /* defined(VK_VERSION_1_2) */
+#if defined(VK_VERSION_1_3)
+PFN_vkCmdBeginRendering vkCmdBeginRendering;
+PFN_vkCmdBindVertexBuffers2 vkCmdBindVertexBuffers2;
+PFN_vkCmdBlitImage2 vkCmdBlitImage2;
+PFN_vkCmdCopyBuffer2 vkCmdCopyBuffer2;
+PFN_vkCmdCopyBufferToImage2 vkCmdCopyBufferToImage2;
+PFN_vkCmdCopyImage2 vkCmdCopyImage2;
+PFN_vkCmdCopyImageToBuffer2 vkCmdCopyImageToBuffer2;
+PFN_vkCmdEndRendering vkCmdEndRendering;
+PFN_vkCmdPipelineBarrier2 vkCmdPipelineBarrier2;
+PFN_vkCmdResetEvent2 vkCmdResetEvent2;
+PFN_vkCmdResolveImage2 vkCmdResolveImage2;
+PFN_vkCmdSetCullMode vkCmdSetCullMode;
+PFN_vkCmdSetDepthBiasEnable vkCmdSetDepthBiasEnable;
+PFN_vkCmdSetDepthBoundsTestEnable vkCmdSetDepthBoundsTestEnable;
+PFN_vkCmdSetDepthCompareOp vkCmdSetDepthCompareOp;
+PFN_vkCmdSetDepthTestEnable vkCmdSetDepthTestEnable;
+PFN_vkCmdSetDepthWriteEnable vkCmdSetDepthWriteEnable;
+PFN_vkCmdSetEvent2 vkCmdSetEvent2;
+PFN_vkCmdSetFrontFace vkCmdSetFrontFace;
+PFN_vkCmdSetPrimitiveRestartEnable vkCmdSetPrimitiveRestartEnable;
+PFN_vkCmdSetPrimitiveTopology vkCmdSetPrimitiveTopology;
+PFN_vkCmdSetRasterizerDiscardEnable vkCmdSetRasterizerDiscardEnable;
+PFN_vkCmdSetScissorWithCount vkCmdSetScissorWithCount;
+PFN_vkCmdSetStencilOp vkCmdSetStencilOp;
+PFN_vkCmdSetStencilTestEnable vkCmdSetStencilTestEnable;
+PFN_vkCmdSetViewportWithCount vkCmdSetViewportWithCount;
+PFN_vkCmdWaitEvents2 vkCmdWaitEvents2;
+PFN_vkCmdWriteTimestamp2 vkCmdWriteTimestamp2;
+PFN_vkCreatePrivateDataSlot vkCreatePrivateDataSlot;
+PFN_vkDestroyPrivateDataSlot vkDestroyPrivateDataSlot;
+PFN_vkGetDeviceBufferMemoryRequirements vkGetDeviceBufferMemoryRequirements;
+PFN_vkGetDeviceImageMemoryRequirements vkGetDeviceImageMemoryRequirements;
+PFN_vkGetDeviceImageSparseMemoryRequirements vkGetDeviceImageSparseMemoryRequirements;
+PFN_vkGetPhysicalDeviceToolProperties vkGetPhysicalDeviceToolProperties;
+PFN_vkGetPrivateData vkGetPrivateData;
+PFN_vkQueueSubmit2 vkQueueSubmit2;
+PFN_vkSetPrivateData vkSetPrivateData;
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_VERSION_1_4)
+PFN_vkCmdBindDescriptorSets2 vkCmdBindDescriptorSets2;
+PFN_vkCmdBindIndexBuffer2 vkCmdBindIndexBuffer2;
+PFN_vkCmdPushConstants2 vkCmdPushConstants2;
+PFN_vkCmdPushDescriptorSet vkCmdPushDescriptorSet;
+PFN_vkCmdPushDescriptorSet2 vkCmdPushDescriptorSet2;
+PFN_vkCmdPushDescriptorSetWithTemplate vkCmdPushDescriptorSetWithTemplate;
+PFN_vkCmdPushDescriptorSetWithTemplate2 vkCmdPushDescriptorSetWithTemplate2;
+PFN_vkCmdSetLineStipple vkCmdSetLineStipple;
+PFN_vkCmdSetRenderingAttachmentLocations vkCmdSetRenderingAttachmentLocations;
+PFN_vkCmdSetRenderingInputAttachmentIndices vkCmdSetRenderingInputAttachmentIndices;
+PFN_vkCopyImageToImage vkCopyImageToImage;
+PFN_vkCopyImageToMemory vkCopyImageToMemory;
+PFN_vkCopyMemoryToImage vkCopyMemoryToImage;
+PFN_vkGetDeviceImageSubresourceLayout vkGetDeviceImageSubresourceLayout;
+PFN_vkGetImageSubresourceLayout2 vkGetImageSubresourceLayout2;
+PFN_vkGetRenderingAreaGranularity vkGetRenderingAreaGranularity;
+PFN_vkMapMemory2 vkMapMemory2;
+PFN_vkTransitionImageLayout vkTransitionImageLayout;
+PFN_vkUnmapMemory2 vkUnmapMemory2;
+#endif /* defined(VK_VERSION_1_4) */
+#if defined(VK_AMDX_shader_enqueue)
+PFN_vkCmdDispatchGraphAMDX vkCmdDispatchGraphAMDX;
+PFN_vkCmdDispatchGraphIndirectAMDX vkCmdDispatchGraphIndirectAMDX;
+PFN_vkCmdDispatchGraphIndirectCountAMDX vkCmdDispatchGraphIndirectCountAMDX;
+PFN_vkCmdInitializeGraphScratchMemoryAMDX vkCmdInitializeGraphScratchMemoryAMDX;
+PFN_vkCreateExecutionGraphPipelinesAMDX vkCreateExecutionGraphPipelinesAMDX;
+PFN_vkGetExecutionGraphPipelineNodeIndexAMDX vkGetExecutionGraphPipelineNodeIndexAMDX;
+PFN_vkGetExecutionGraphPipelineScratchSizeAMDX vkGetExecutionGraphPipelineScratchSizeAMDX;
+#endif /* defined(VK_AMDX_shader_enqueue) */
+#if defined(VK_AMD_anti_lag)
+PFN_vkAntiLagUpdateAMD vkAntiLagUpdateAMD;
+#endif /* defined(VK_AMD_anti_lag) */
+#if defined(VK_AMD_buffer_marker)
+PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
+#endif /* defined(VK_AMD_buffer_marker) */
+#if defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+PFN_vkCmdWriteBufferMarker2AMD vkCmdWriteBufferMarker2AMD;
+#endif /* defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_AMD_display_native_hdr)
+PFN_vkSetLocalDimmingAMD vkSetLocalDimmingAMD;
+#endif /* defined(VK_AMD_display_native_hdr) */
+#if defined(VK_AMD_draw_indirect_count)
+PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD;
+PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD;
+#endif /* defined(VK_AMD_draw_indirect_count) */
+#if defined(VK_AMD_gpa_interface)
+PFN_vkCmdBeginGpaSampleAMD vkCmdBeginGpaSampleAMD;
+PFN_vkCmdBeginGpaSessionAMD vkCmdBeginGpaSessionAMD;
+PFN_vkCmdCopyGpaSessionResultsAMD vkCmdCopyGpaSessionResultsAMD;
+PFN_vkCmdEndGpaSampleAMD vkCmdEndGpaSampleAMD;
+PFN_vkCmdEndGpaSessionAMD vkCmdEndGpaSessionAMD;
+PFN_vkCreateGpaSessionAMD vkCreateGpaSessionAMD;
+PFN_vkDestroyGpaSessionAMD vkDestroyGpaSessionAMD;
+PFN_vkGetGpaDeviceClockInfoAMD vkGetGpaDeviceClockInfoAMD;
+PFN_vkGetGpaSessionResultsAMD vkGetGpaSessionResultsAMD;
+PFN_vkGetGpaSessionStatusAMD vkGetGpaSessionStatusAMD;
+PFN_vkResetGpaSessionAMD vkResetGpaSessionAMD;
+PFN_vkSetGpaDeviceClockModeAMD vkSetGpaDeviceClockModeAMD;
+#endif /* defined(VK_AMD_gpa_interface) */
+#if defined(VK_AMD_shader_info)
+PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD;
+#endif /* defined(VK_AMD_shader_info) */
+#if defined(VK_ANDROID_external_memory_android_hardware_buffer)
+PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
+PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
+#endif /* defined(VK_ANDROID_external_memory_android_hardware_buffer) */
+#if defined(VK_ARM_data_graph)
+PFN_vkBindDataGraphPipelineSessionMemoryARM vkBindDataGraphPipelineSessionMemoryARM;
+PFN_vkCmdDispatchDataGraphARM vkCmdDispatchDataGraphARM;
+PFN_vkCreateDataGraphPipelineSessionARM vkCreateDataGraphPipelineSessionARM;
+PFN_vkCreateDataGraphPipelinesARM vkCreateDataGraphPipelinesARM;
+PFN_vkDestroyDataGraphPipelineSessionARM vkDestroyDataGraphPipelineSessionARM;
+PFN_vkGetDataGraphPipelineAvailablePropertiesARM vkGetDataGraphPipelineAvailablePropertiesARM;
+PFN_vkGetDataGraphPipelinePropertiesARM vkGetDataGraphPipelinePropertiesARM;
+PFN_vkGetDataGraphPipelineSessionBindPointRequirementsARM vkGetDataGraphPipelineSessionBindPointRequirementsARM;
+PFN_vkGetDataGraphPipelineSessionMemoryRequirementsARM vkGetDataGraphPipelineSessionMemoryRequirementsARM;
+PFN_vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM;
+PFN_vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM;
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_data_graph_optical_flow)
+PFN_vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM;
+#endif /* defined(VK_ARM_data_graph_optical_flow) */
+#if defined(VK_ARM_performance_counters_by_region)
+PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM;
+#endif /* defined(VK_ARM_performance_counters_by_region) */
+#if defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2
+PFN_vkCmdSetDispatchParametersARM vkCmdSetDispatchParametersARM;
+#endif /* defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2 */
+#if defined(VK_ARM_shader_instrumentation)
+PFN_vkClearShaderInstrumentationMetricsARM vkClearShaderInstrumentationMetricsARM;
+PFN_vkCmdBeginShaderInstrumentationARM vkCmdBeginShaderInstrumentationARM;
+PFN_vkCmdEndShaderInstrumentationARM vkCmdEndShaderInstrumentationARM;
+PFN_vkCreateShaderInstrumentationARM vkCreateShaderInstrumentationARM;
+PFN_vkDestroyShaderInstrumentationARM vkDestroyShaderInstrumentationARM;
+PFN_vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM;
+PFN_vkGetShaderInstrumentationValuesARM vkGetShaderInstrumentationValuesARM;
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+PFN_vkBindTensorMemoryARM vkBindTensorMemoryARM;
+PFN_vkCmdCopyTensorARM vkCmdCopyTensorARM;
+PFN_vkCreateTensorARM vkCreateTensorARM;
+PFN_vkCreateTensorViewARM vkCreateTensorViewARM;
+PFN_vkDestroyTensorARM vkDestroyTensorARM;
+PFN_vkDestroyTensorViewARM vkDestroyTensorViewARM;
+PFN_vkGetDeviceTensorMemoryRequirementsARM vkGetDeviceTensorMemoryRequirementsARM;
+PFN_vkGetPhysicalDeviceExternalTensorPropertiesARM vkGetPhysicalDeviceExternalTensorPropertiesARM;
+PFN_vkGetTensorMemoryRequirementsARM vkGetTensorMemoryRequirementsARM;
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer)
+PFN_vkGetTensorOpaqueCaptureDescriptorDataARM vkGetTensorOpaqueCaptureDescriptorDataARM;
+PFN_vkGetTensorViewOpaqueCaptureDescriptorDataARM vkGetTensorViewOpaqueCaptureDescriptorDataARM;
+#endif /* defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_acquire_drm_display)
+PFN_vkAcquireDrmDisplayEXT vkAcquireDrmDisplayEXT;
+PFN_vkGetDrmDisplayEXT vkGetDrmDisplayEXT;
+#endif /* defined(VK_EXT_acquire_drm_display) */
+#if defined(VK_EXT_acquire_xlib_display)
+PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT;
+PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT;
+#endif /* defined(VK_EXT_acquire_xlib_display) */
+#if defined(VK_EXT_attachment_feedback_loop_dynamic_state)
+PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT vkCmdSetAttachmentFeedbackLoopEnableEXT;
+#endif /* defined(VK_EXT_attachment_feedback_loop_dynamic_state) */
+#if defined(VK_EXT_buffer_device_address)
+PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT;
+#endif /* defined(VK_EXT_buffer_device_address) */
+#if defined(VK_EXT_calibrated_timestamps)
+PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT;
+PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT;
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_color_write_enable)
+PFN_vkCmdSetColorWriteEnableEXT vkCmdSetColorWriteEnableEXT;
+#endif /* defined(VK_EXT_color_write_enable) */
+#if defined(VK_EXT_conditional_rendering)
+PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT;
+PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT;
+#endif /* defined(VK_EXT_conditional_rendering) */
+#if defined(VK_EXT_cooperative_matrix_maintenance1)
+PFN_vkGetPhysicalDeviceCooperativeMatrixProperties2EXT vkGetPhysicalDeviceCooperativeMatrixProperties2EXT;
+#endif /* defined(VK_EXT_cooperative_matrix_maintenance1) */
+#if defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3))
+PFN_vkCmdBeginCustomResolveEXT vkCmdBeginCustomResolveEXT;
+#endif /* defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3)) */
+#if defined(VK_EXT_debug_marker)
+PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT;
+PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT;
+PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT;
+PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT;
+PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT;
+#endif /* defined(VK_EXT_debug_marker) */
+#if defined(VK_EXT_debug_report)
+PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
+PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
+PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
+#endif /* defined(VK_EXT_debug_report) */
+#if defined(VK_EXT_debug_utils)
+PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT;
+PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT;
+PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT;
+PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
+PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
+PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT;
+PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT;
+PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT;
+PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT;
+PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT;
+PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT;
+#endif /* defined(VK_EXT_debug_utils) */
+#if defined(VK_EXT_depth_bias_control)
+PFN_vkCmdSetDepthBias2EXT vkCmdSetDepthBias2EXT;
+#endif /* defined(VK_EXT_depth_bias_control) */
+#if defined(VK_EXT_descriptor_buffer)
+PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT vkCmdBindDescriptorBufferEmbeddedSamplersEXT;
+PFN_vkCmdBindDescriptorBuffersEXT vkCmdBindDescriptorBuffersEXT;
+PFN_vkCmdSetDescriptorBufferOffsetsEXT vkCmdSetDescriptorBufferOffsetsEXT;
+PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT vkGetBufferOpaqueCaptureDescriptorDataEXT;
+PFN_vkGetDescriptorEXT vkGetDescriptorEXT;
+PFN_vkGetDescriptorSetLayoutBindingOffsetEXT vkGetDescriptorSetLayoutBindingOffsetEXT;
+PFN_vkGetDescriptorSetLayoutSizeEXT vkGetDescriptorSetLayoutSizeEXT;
+PFN_vkGetImageOpaqueCaptureDescriptorDataEXT vkGetImageOpaqueCaptureDescriptorDataEXT;
+PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT vkGetImageViewOpaqueCaptureDescriptorDataEXT;
+PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT vkGetSamplerOpaqueCaptureDescriptorDataEXT;
+#endif /* defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing))
+PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT;
+#endif /* defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing)) */
+#if defined(VK_EXT_descriptor_heap)
+PFN_vkCmdBindResourceHeapEXT vkCmdBindResourceHeapEXT;
+PFN_vkCmdBindSamplerHeapEXT vkCmdBindSamplerHeapEXT;
+PFN_vkCmdPushDataEXT vkCmdPushDataEXT;
+PFN_vkGetImageOpaqueCaptureDataEXT vkGetImageOpaqueCaptureDataEXT;
+PFN_vkGetPhysicalDeviceDescriptorSizeEXT vkGetPhysicalDeviceDescriptorSizeEXT;
+PFN_vkWriteResourceDescriptorsEXT vkWriteResourceDescriptorsEXT;
+PFN_vkWriteSamplerDescriptorsEXT vkWriteSamplerDescriptorsEXT;
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color)
+PFN_vkRegisterCustomBorderColorEXT vkRegisterCustomBorderColorEXT;
+PFN_vkUnregisterCustomBorderColorEXT vkUnregisterCustomBorderColorEXT;
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors)
+PFN_vkGetTensorOpaqueCaptureDataARM vkGetTensorOpaqueCaptureDataARM;
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors) */
+#if defined(VK_EXT_device_fault)
+PFN_vkGetDeviceFaultInfoEXT vkGetDeviceFaultInfoEXT;
+#endif /* defined(VK_EXT_device_fault) */
+#if defined(VK_EXT_device_generated_commands)
+PFN_vkCmdExecuteGeneratedCommandsEXT vkCmdExecuteGeneratedCommandsEXT;
+PFN_vkCmdPreprocessGeneratedCommandsEXT vkCmdPreprocessGeneratedCommandsEXT;
+PFN_vkCreateIndirectCommandsLayoutEXT vkCreateIndirectCommandsLayoutEXT;
+PFN_vkCreateIndirectExecutionSetEXT vkCreateIndirectExecutionSetEXT;
+PFN_vkDestroyIndirectCommandsLayoutEXT vkDestroyIndirectCommandsLayoutEXT;
+PFN_vkDestroyIndirectExecutionSetEXT vkDestroyIndirectExecutionSetEXT;
+PFN_vkGetGeneratedCommandsMemoryRequirementsEXT vkGetGeneratedCommandsMemoryRequirementsEXT;
+PFN_vkUpdateIndirectExecutionSetPipelineEXT vkUpdateIndirectExecutionSetPipelineEXT;
+PFN_vkUpdateIndirectExecutionSetShaderEXT vkUpdateIndirectExecutionSetShaderEXT;
+#endif /* defined(VK_EXT_device_generated_commands) */
+#if defined(VK_EXT_direct_mode_display)
+PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT;
+#endif /* defined(VK_EXT_direct_mode_display) */
+#if defined(VK_EXT_directfb_surface)
+PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT;
+PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT;
+#endif /* defined(VK_EXT_directfb_surface) */
+#if defined(VK_EXT_discard_rectangles)
+PFN_vkCmdSetDiscardRectangleEXT vkCmdSetDiscardRectangleEXT;
+#endif /* defined(VK_EXT_discard_rectangles) */
+#if defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2
+PFN_vkCmdSetDiscardRectangleEnableEXT vkCmdSetDiscardRectangleEnableEXT;
+PFN_vkCmdSetDiscardRectangleModeEXT vkCmdSetDiscardRectangleModeEXT;
+#endif /* defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2 */
+#if defined(VK_EXT_display_control)
+PFN_vkDisplayPowerControlEXT vkDisplayPowerControlEXT;
+PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT;
+PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT;
+PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT;
+#endif /* defined(VK_EXT_display_control) */
+#if defined(VK_EXT_display_surface_counter)
+PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT;
+#endif /* defined(VK_EXT_display_surface_counter) */
+#if defined(VK_EXT_external_memory_host)
+PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
+#endif /* defined(VK_EXT_external_memory_host) */
+#if defined(VK_EXT_external_memory_metal)
+PFN_vkGetMemoryMetalHandleEXT vkGetMemoryMetalHandleEXT;
+PFN_vkGetMemoryMetalHandlePropertiesEXT vkGetMemoryMetalHandlePropertiesEXT;
+#endif /* defined(VK_EXT_external_memory_metal) */
+#if defined(VK_EXT_fragment_density_map_offset)
+PFN_vkCmdEndRendering2EXT vkCmdEndRendering2EXT;
+#endif /* defined(VK_EXT_fragment_density_map_offset) */
+#if defined(VK_EXT_full_screen_exclusive)
+PFN_vkAcquireFullScreenExclusiveModeEXT vkAcquireFullScreenExclusiveModeEXT;
+PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT vkGetPhysicalDeviceSurfacePresentModes2EXT;
+PFN_vkReleaseFullScreenExclusiveModeEXT vkReleaseFullScreenExclusiveModeEXT;
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1))
+PFN_vkGetDeviceGroupSurfacePresentModes2EXT vkGetDeviceGroupSurfacePresentModes2EXT;
+#endif /* defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1)) */
+#if defined(VK_EXT_hdr_metadata)
+PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT;
+#endif /* defined(VK_EXT_hdr_metadata) */
+#if defined(VK_EXT_headless_surface)
+PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT;
+#endif /* defined(VK_EXT_headless_surface) */
+#if defined(VK_EXT_host_image_copy)
+PFN_vkCopyImageToImageEXT vkCopyImageToImageEXT;
+PFN_vkCopyImageToMemoryEXT vkCopyImageToMemoryEXT;
+PFN_vkCopyMemoryToImageEXT vkCopyMemoryToImageEXT;
+PFN_vkTransitionImageLayoutEXT vkTransitionImageLayoutEXT;
+#endif /* defined(VK_EXT_host_image_copy) */
+#if defined(VK_EXT_host_query_reset)
+PFN_vkResetQueryPoolEXT vkResetQueryPoolEXT;
+#endif /* defined(VK_EXT_host_query_reset) */
+#if defined(VK_EXT_image_drm_format_modifier)
+PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT;
+#endif /* defined(VK_EXT_image_drm_format_modifier) */
+#if defined(VK_EXT_line_rasterization)
+PFN_vkCmdSetLineStippleEXT vkCmdSetLineStippleEXT;
+#endif /* defined(VK_EXT_line_rasterization) */
+#if defined(VK_EXT_memory_decompression)
+PFN_vkCmdDecompressMemoryEXT vkCmdDecompressMemoryEXT;
+PFN_vkCmdDecompressMemoryIndirectCountEXT vkCmdDecompressMemoryIndirectCountEXT;
+#endif /* defined(VK_EXT_memory_decompression) */
+#if defined(VK_EXT_mesh_shader)
+PFN_vkCmdDrawMeshTasksEXT vkCmdDrawMeshTasksEXT;
+PFN_vkCmdDrawMeshTasksIndirectEXT vkCmdDrawMeshTasksIndirectEXT;
+#endif /* defined(VK_EXT_mesh_shader) */
+#if defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+PFN_vkCmdDrawMeshTasksIndirectCountEXT vkCmdDrawMeshTasksIndirectCountEXT;
+#endif /* defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_EXT_metal_objects)
+PFN_vkExportMetalObjectsEXT vkExportMetalObjectsEXT;
+#endif /* defined(VK_EXT_metal_objects) */
+#if defined(VK_EXT_metal_surface)
+PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
+#endif /* defined(VK_EXT_metal_surface) */
+#if defined(VK_EXT_multi_draw)
+PFN_vkCmdDrawMultiEXT vkCmdDrawMultiEXT;
+PFN_vkCmdDrawMultiIndexedEXT vkCmdDrawMultiIndexedEXT;
+#endif /* defined(VK_EXT_multi_draw) */
+#if defined(VK_EXT_opacity_micromap)
+PFN_vkBuildMicromapsEXT vkBuildMicromapsEXT;
+PFN_vkCmdBuildMicromapsEXT vkCmdBuildMicromapsEXT;
+PFN_vkCmdCopyMemoryToMicromapEXT vkCmdCopyMemoryToMicromapEXT;
+PFN_vkCmdCopyMicromapEXT vkCmdCopyMicromapEXT;
+PFN_vkCmdCopyMicromapToMemoryEXT vkCmdCopyMicromapToMemoryEXT;
+PFN_vkCmdWriteMicromapsPropertiesEXT vkCmdWriteMicromapsPropertiesEXT;
+PFN_vkCopyMemoryToMicromapEXT vkCopyMemoryToMicromapEXT;
+PFN_vkCopyMicromapEXT vkCopyMicromapEXT;
+PFN_vkCopyMicromapToMemoryEXT vkCopyMicromapToMemoryEXT;
+PFN_vkCreateMicromapEXT vkCreateMicromapEXT;
+PFN_vkDestroyMicromapEXT vkDestroyMicromapEXT;
+PFN_vkGetDeviceMicromapCompatibilityEXT vkGetDeviceMicromapCompatibilityEXT;
+PFN_vkGetMicromapBuildSizesEXT vkGetMicromapBuildSizesEXT;
+PFN_vkWriteMicromapsPropertiesEXT vkWriteMicromapsPropertiesEXT;
+#endif /* defined(VK_EXT_opacity_micromap) */
+#if defined(VK_EXT_pageable_device_local_memory)
+PFN_vkSetDeviceMemoryPriorityEXT vkSetDeviceMemoryPriorityEXT;
+#endif /* defined(VK_EXT_pageable_device_local_memory) */
+#if defined(VK_EXT_pipeline_properties)
+PFN_vkGetPipelinePropertiesEXT vkGetPipelinePropertiesEXT;
+#endif /* defined(VK_EXT_pipeline_properties) */
+#if defined(VK_EXT_present_timing)
+PFN_vkGetPastPresentationTimingEXT vkGetPastPresentationTimingEXT;
+PFN_vkGetSwapchainTimeDomainPropertiesEXT vkGetSwapchainTimeDomainPropertiesEXT;
+PFN_vkGetSwapchainTimingPropertiesEXT vkGetSwapchainTimingPropertiesEXT;
+PFN_vkSetSwapchainPresentTimingQueueSizeEXT vkSetSwapchainPresentTimingQueueSizeEXT;
+#endif /* defined(VK_EXT_present_timing) */
+#if defined(VK_EXT_primitive_restart_index)
+PFN_vkCmdSetPrimitiveRestartIndexEXT vkCmdSetPrimitiveRestartIndexEXT;
+#endif /* defined(VK_EXT_primitive_restart_index) */
+#if defined(VK_EXT_private_data)
+PFN_vkCreatePrivateDataSlotEXT vkCreatePrivateDataSlotEXT;
+PFN_vkDestroyPrivateDataSlotEXT vkDestroyPrivateDataSlotEXT;
+PFN_vkGetPrivateDataEXT vkGetPrivateDataEXT;
+PFN_vkSetPrivateDataEXT vkSetPrivateDataEXT;
+#endif /* defined(VK_EXT_private_data) */
+#if defined(VK_EXT_sample_locations)
+PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT;
+PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT;
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_shader_module_identifier)
+PFN_vkGetShaderModuleCreateInfoIdentifierEXT vkGetShaderModuleCreateInfoIdentifierEXT;
+PFN_vkGetShaderModuleIdentifierEXT vkGetShaderModuleIdentifierEXT;
+#endif /* defined(VK_EXT_shader_module_identifier) */
+#if defined(VK_EXT_shader_object)
+PFN_vkCmdBindShadersEXT vkCmdBindShadersEXT;
+PFN_vkCreateShadersEXT vkCreateShadersEXT;
+PFN_vkDestroyShaderEXT vkDestroyShaderEXT;
+PFN_vkGetShaderBinaryDataEXT vkGetShaderBinaryDataEXT;
+#endif /* defined(VK_EXT_shader_object) */
+#if defined(VK_EXT_swapchain_maintenance1)
+PFN_vkReleaseSwapchainImagesEXT vkReleaseSwapchainImagesEXT;
+#endif /* defined(VK_EXT_swapchain_maintenance1) */
+#if defined(VK_EXT_tooling_info)
+PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT;
+#endif /* defined(VK_EXT_tooling_info) */
+#if defined(VK_EXT_transform_feedback)
+PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT;
+PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT;
+PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT;
+PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT;
+PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT;
+PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT;
+#endif /* defined(VK_EXT_transform_feedback) */
+#if defined(VK_EXT_validation_cache)
+PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT;
+PFN_vkDestroyValidationCacheEXT vkDestroyValidationCacheEXT;
+PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT;
+PFN_vkMergeValidationCachesEXT vkMergeValidationCachesEXT;
+#endif /* defined(VK_EXT_validation_cache) */
+#if defined(VK_FUCHSIA_buffer_collection)
+PFN_vkCreateBufferCollectionFUCHSIA vkCreateBufferCollectionFUCHSIA;
+PFN_vkDestroyBufferCollectionFUCHSIA vkDestroyBufferCollectionFUCHSIA;
+PFN_vkGetBufferCollectionPropertiesFUCHSIA vkGetBufferCollectionPropertiesFUCHSIA;
+PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA vkSetBufferCollectionBufferConstraintsFUCHSIA;
+PFN_vkSetBufferCollectionImageConstraintsFUCHSIA vkSetBufferCollectionImageConstraintsFUCHSIA;
+#endif /* defined(VK_FUCHSIA_buffer_collection) */
+#if defined(VK_FUCHSIA_external_memory)
+PFN_vkGetMemoryZirconHandleFUCHSIA vkGetMemoryZirconHandleFUCHSIA;
+PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA vkGetMemoryZirconHandlePropertiesFUCHSIA;
+#endif /* defined(VK_FUCHSIA_external_memory) */
+#if defined(VK_FUCHSIA_external_semaphore)
+PFN_vkGetSemaphoreZirconHandleFUCHSIA vkGetSemaphoreZirconHandleFUCHSIA;
+PFN_vkImportSemaphoreZirconHandleFUCHSIA vkImportSemaphoreZirconHandleFUCHSIA;
+#endif /* defined(VK_FUCHSIA_external_semaphore) */
+#if defined(VK_FUCHSIA_imagepipe_surface)
+PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA;
+#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
+#if defined(VK_GGP_stream_descriptor_surface)
+PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP;
+#endif /* defined(VK_GGP_stream_descriptor_surface) */
+#if defined(VK_GOOGLE_display_timing)
+PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE;
+PFN_vkGetRefreshCycleDurationGOOGLE vkGetRefreshCycleDurationGOOGLE;
+#endif /* defined(VK_GOOGLE_display_timing) */
+#if defined(VK_HUAWEI_cluster_culling_shader)
+PFN_vkCmdDrawClusterHUAWEI vkCmdDrawClusterHUAWEI;
+PFN_vkCmdDrawClusterIndirectHUAWEI vkCmdDrawClusterIndirectHUAWEI;
+#endif /* defined(VK_HUAWEI_cluster_culling_shader) */
+#if defined(VK_HUAWEI_invocation_mask)
+PFN_vkCmdBindInvocationMaskHUAWEI vkCmdBindInvocationMaskHUAWEI;
+#endif /* defined(VK_HUAWEI_invocation_mask) */
+#if defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2
+PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI;
+#endif /* defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2 */
+#if defined(VK_HUAWEI_subpass_shading)
+PFN_vkCmdSubpassShadingHUAWEI vkCmdSubpassShadingHUAWEI;
+#endif /* defined(VK_HUAWEI_subpass_shading) */
+#if defined(VK_INTEL_performance_query)
+PFN_vkAcquirePerformanceConfigurationINTEL vkAcquirePerformanceConfigurationINTEL;
+PFN_vkCmdSetPerformanceMarkerINTEL vkCmdSetPerformanceMarkerINTEL;
+PFN_vkCmdSetPerformanceOverrideINTEL vkCmdSetPerformanceOverrideINTEL;
+PFN_vkCmdSetPerformanceStreamMarkerINTEL vkCmdSetPerformanceStreamMarkerINTEL;
+PFN_vkGetPerformanceParameterINTEL vkGetPerformanceParameterINTEL;
+PFN_vkInitializePerformanceApiINTEL vkInitializePerformanceApiINTEL;
+PFN_vkQueueSetPerformanceConfigurationINTEL vkQueueSetPerformanceConfigurationINTEL;
+PFN_vkReleasePerformanceConfigurationINTEL vkReleasePerformanceConfigurationINTEL;
+PFN_vkUninitializePerformanceApiINTEL vkUninitializePerformanceApiINTEL;
+#endif /* defined(VK_INTEL_performance_query) */
+#if defined(VK_KHR_acceleration_structure)
+PFN_vkBuildAccelerationStructuresKHR vkBuildAccelerationStructuresKHR;
+PFN_vkCmdBuildAccelerationStructuresIndirectKHR vkCmdBuildAccelerationStructuresIndirectKHR;
+PFN_vkCmdBuildAccelerationStructuresKHR vkCmdBuildAccelerationStructuresKHR;
+PFN_vkCmdCopyAccelerationStructureKHR vkCmdCopyAccelerationStructureKHR;
+PFN_vkCmdCopyAccelerationStructureToMemoryKHR vkCmdCopyAccelerationStructureToMemoryKHR;
+PFN_vkCmdCopyMemoryToAccelerationStructureKHR vkCmdCopyMemoryToAccelerationStructureKHR;
+PFN_vkCmdWriteAccelerationStructuresPropertiesKHR vkCmdWriteAccelerationStructuresPropertiesKHR;
+PFN_vkCopyAccelerationStructureKHR vkCopyAccelerationStructureKHR;
+PFN_vkCopyAccelerationStructureToMemoryKHR vkCopyAccelerationStructureToMemoryKHR;
+PFN_vkCopyMemoryToAccelerationStructureKHR vkCopyMemoryToAccelerationStructureKHR;
+PFN_vkCreateAccelerationStructureKHR vkCreateAccelerationStructureKHR;
+PFN_vkDestroyAccelerationStructureKHR vkDestroyAccelerationStructureKHR;
+PFN_vkGetAccelerationStructureBuildSizesKHR vkGetAccelerationStructureBuildSizesKHR;
+PFN_vkGetAccelerationStructureDeviceAddressKHR vkGetAccelerationStructureDeviceAddressKHR;
+PFN_vkGetDeviceAccelerationStructureCompatibilityKHR vkGetDeviceAccelerationStructureCompatibilityKHR;
+PFN_vkWriteAccelerationStructuresPropertiesKHR vkWriteAccelerationStructuresPropertiesKHR;
+#endif /* defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_android_surface)
+PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
+#endif /* defined(VK_KHR_android_surface) */
+#if defined(VK_KHR_bind_memory2)
+PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
+PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
+#endif /* defined(VK_KHR_bind_memory2) */
+#if defined(VK_KHR_buffer_device_address)
+PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
+PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
+PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
+#endif /* defined(VK_KHR_buffer_device_address) */
+#if defined(VK_KHR_calibrated_timestamps)
+PFN_vkGetCalibratedTimestampsKHR vkGetCalibratedTimestampsKHR;
+PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR vkGetPhysicalDeviceCalibrateableTimeDomainsKHR;
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_cooperative_matrix)
+PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR;
+#endif /* defined(VK_KHR_cooperative_matrix) */
+#if defined(VK_KHR_copy_commands2)
+PFN_vkCmdBlitImage2KHR vkCmdBlitImage2KHR;
+PFN_vkCmdCopyBuffer2KHR vkCmdCopyBuffer2KHR;
+PFN_vkCmdCopyBufferToImage2KHR vkCmdCopyBufferToImage2KHR;
+PFN_vkCmdCopyImage2KHR vkCmdCopyImage2KHR;
+PFN_vkCmdCopyImageToBuffer2KHR vkCmdCopyImageToBuffer2KHR;
+PFN_vkCmdResolveImage2KHR vkCmdResolveImage2KHR;
+#endif /* defined(VK_KHR_copy_commands2) */
+#if defined(VK_KHR_copy_memory_indirect)
+PFN_vkCmdCopyMemoryIndirectKHR vkCmdCopyMemoryIndirectKHR;
+PFN_vkCmdCopyMemoryToImageIndirectKHR vkCmdCopyMemoryToImageIndirectKHR;
+#endif /* defined(VK_KHR_copy_memory_indirect) */
+#if defined(VK_KHR_create_renderpass2)
+PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
+PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
+PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR;
+PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR;
+#endif /* defined(VK_KHR_create_renderpass2) */
+#if defined(VK_KHR_deferred_host_operations)
+PFN_vkCreateDeferredOperationKHR vkCreateDeferredOperationKHR;
+PFN_vkDeferredOperationJoinKHR vkDeferredOperationJoinKHR;
+PFN_vkDestroyDeferredOperationKHR vkDestroyDeferredOperationKHR;
+PFN_vkGetDeferredOperationMaxConcurrencyKHR vkGetDeferredOperationMaxConcurrencyKHR;
+PFN_vkGetDeferredOperationResultKHR vkGetDeferredOperationResultKHR;
+#endif /* defined(VK_KHR_deferred_host_operations) */
+#if defined(VK_KHR_descriptor_update_template)
+PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR;
+PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR;
+PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR;
+#endif /* defined(VK_KHR_descriptor_update_template) */
+#if defined(VK_KHR_device_address_commands)
+PFN_vkCmdBindIndexBuffer3KHR vkCmdBindIndexBuffer3KHR;
+PFN_vkCmdBindVertexBuffers3KHR vkCmdBindVertexBuffers3KHR;
+PFN_vkCmdCopyImageToMemoryKHR vkCmdCopyImageToMemoryKHR;
+PFN_vkCmdCopyMemoryKHR vkCmdCopyMemoryKHR;
+PFN_vkCmdCopyMemoryToImageKHR vkCmdCopyMemoryToImageKHR;
+PFN_vkCmdCopyQueryPoolResultsToMemoryKHR vkCmdCopyQueryPoolResultsToMemoryKHR;
+PFN_vkCmdDispatchIndirect2KHR vkCmdDispatchIndirect2KHR;
+PFN_vkCmdDrawIndexedIndirect2KHR vkCmdDrawIndexedIndirect2KHR;
+PFN_vkCmdDrawIndirect2KHR vkCmdDrawIndirect2KHR;
+PFN_vkCmdFillMemoryKHR vkCmdFillMemoryKHR;
+PFN_vkCmdUpdateMemoryKHR vkCmdUpdateMemoryKHR;
+#endif /* defined(VK_KHR_device_address_commands) */
+#if defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2))
+PFN_vkCmdDrawIndexedIndirectCount2KHR vkCmdDrawIndexedIndirectCount2KHR;
+PFN_vkCmdDrawIndirectCount2KHR vkCmdDrawIndirectCount2KHR;
+#endif /* defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering)
+PFN_vkCmdBeginConditionalRendering2EXT vkCmdBeginConditionalRendering2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback)
+PFN_vkCmdBeginTransformFeedback2EXT vkCmdBeginTransformFeedback2EXT;
+PFN_vkCmdBindTransformFeedbackBuffers2EXT vkCmdBindTransformFeedbackBuffers2EXT;
+PFN_vkCmdDrawIndirectByteCount2EXT vkCmdDrawIndirectByteCount2EXT;
+PFN_vkCmdEndTransformFeedback2EXT vkCmdEndTransformFeedback2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader)
+PFN_vkCmdDrawMeshTasksIndirect2EXT vkCmdDrawMeshTasksIndirect2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader) */
+#if defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader))
+PFN_vkCmdDrawMeshTasksIndirectCount2EXT vkCmdDrawMeshTasksIndirectCount2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker)
+PFN_vkCmdWriteMarkerToMemoryAMD vkCmdWriteMarkerToMemoryAMD;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure)
+PFN_vkCreateAccelerationStructure2KHR vkCreateAccelerationStructure2KHR;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_device_fault)
+PFN_vkGetDeviceFaultDebugInfoKHR vkGetDeviceFaultDebugInfoKHR;
+PFN_vkGetDeviceFaultReportsKHR vkGetDeviceFaultReportsKHR;
+#endif /* defined(VK_KHR_device_fault) */
+#if defined(VK_KHR_device_group)
+PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR;
+PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR;
+PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR;
+#endif /* defined(VK_KHR_device_group) */
+#if defined(VK_KHR_device_group_creation)
+PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR;
+#endif /* defined(VK_KHR_device_group_creation) */
+#if defined(VK_KHR_display)
+PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
+PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
+PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
+PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
+PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
+PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
+PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
+#endif /* defined(VK_KHR_display) */
+#if defined(VK_KHR_display_swapchain)
+PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
+#endif /* defined(VK_KHR_display_swapchain) */
+#if defined(VK_KHR_draw_indirect_count)
+PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR;
+PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR;
+#endif /* defined(VK_KHR_draw_indirect_count) */
+#if defined(VK_KHR_dynamic_rendering)
+PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
+PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
+#endif /* defined(VK_KHR_dynamic_rendering) */
+#if defined(VK_KHR_dynamic_rendering_local_read)
+PFN_vkCmdSetRenderingAttachmentLocationsKHR vkCmdSetRenderingAttachmentLocationsKHR;
+PFN_vkCmdSetRenderingInputAttachmentIndicesKHR vkCmdSetRenderingInputAttachmentIndicesKHR;
+#endif /* defined(VK_KHR_dynamic_rendering_local_read) */
+#if defined(VK_KHR_external_fence_capabilities)
+PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR;
+#endif /* defined(VK_KHR_external_fence_capabilities) */
+#if defined(VK_KHR_external_fence_fd)
+PFN_vkGetFenceFdKHR vkGetFenceFdKHR;
+PFN_vkImportFenceFdKHR vkImportFenceFdKHR;
+#endif /* defined(VK_KHR_external_fence_fd) */
+#if defined(VK_KHR_external_fence_win32)
+PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR;
+PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR;
+#endif /* defined(VK_KHR_external_fence_win32) */
+#if defined(VK_KHR_external_memory_capabilities)
+PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_capabilities) */
+#if defined(VK_KHR_external_memory_fd)
+PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR;
+PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_fd) */
+#if defined(VK_KHR_external_memory_win32)
+PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR;
+PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_win32) */
+#if defined(VK_KHR_external_semaphore_capabilities)
+PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR;
+#endif /* defined(VK_KHR_external_semaphore_capabilities) */
+#if defined(VK_KHR_external_semaphore_fd)
+PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
+PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
+#endif /* defined(VK_KHR_external_semaphore_fd) */
+#if defined(VK_KHR_external_semaphore_win32)
+PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR;
+PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR;
+#endif /* defined(VK_KHR_external_semaphore_win32) */
+#if defined(VK_KHR_fragment_shading_rate)
+PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR;
+PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR vkGetPhysicalDeviceFragmentShadingRatesKHR;
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_display_properties2)
+PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR;
+PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR;
+PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR;
+PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR;
+#endif /* defined(VK_KHR_get_display_properties2) */
+#if defined(VK_KHR_get_memory_requirements2)
+PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
+PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
+PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR;
+#endif /* defined(VK_KHR_get_memory_requirements2) */
+#if defined(VK_KHR_get_physical_device_properties2)
+PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
+PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR;
+PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR;
+PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
+PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
+PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR;
+PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR;
+#endif /* defined(VK_KHR_get_physical_device_properties2) */
+#if defined(VK_KHR_get_surface_capabilities2)
+PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR;
+PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR;
+#endif /* defined(VK_KHR_get_surface_capabilities2) */
+#if defined(VK_KHR_line_rasterization)
+PFN_vkCmdSetLineStippleKHR vkCmdSetLineStippleKHR;
+#endif /* defined(VK_KHR_line_rasterization) */
+#if defined(VK_KHR_maintenance1)
+PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
+#endif /* defined(VK_KHR_maintenance1) */
+#if defined(VK_KHR_maintenance10)
+PFN_vkCmdEndRendering2KHR vkCmdEndRendering2KHR;
+#endif /* defined(VK_KHR_maintenance10) */
+#if defined(VK_KHR_maintenance3)
+PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
+#endif /* defined(VK_KHR_maintenance3) */
+#if defined(VK_KHR_maintenance4)
+PFN_vkGetDeviceBufferMemoryRequirementsKHR vkGetDeviceBufferMemoryRequirementsKHR;
+PFN_vkGetDeviceImageMemoryRequirementsKHR vkGetDeviceImageMemoryRequirementsKHR;
+PFN_vkGetDeviceImageSparseMemoryRequirementsKHR vkGetDeviceImageSparseMemoryRequirementsKHR;
+#endif /* defined(VK_KHR_maintenance4) */
+#if defined(VK_KHR_maintenance5)
+PFN_vkCmdBindIndexBuffer2KHR vkCmdBindIndexBuffer2KHR;
+PFN_vkGetDeviceImageSubresourceLayoutKHR vkGetDeviceImageSubresourceLayoutKHR;
+PFN_vkGetImageSubresourceLayout2KHR vkGetImageSubresourceLayout2KHR;
+PFN_vkGetRenderingAreaGranularityKHR vkGetRenderingAreaGranularityKHR;
+#endif /* defined(VK_KHR_maintenance5) */
+#if defined(VK_KHR_maintenance6)
+PFN_vkCmdBindDescriptorSets2KHR vkCmdBindDescriptorSets2KHR;
+PFN_vkCmdPushConstants2KHR vkCmdPushConstants2KHR;
+#endif /* defined(VK_KHR_maintenance6) */
+#if defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor)
+PFN_vkCmdPushDescriptorSet2KHR vkCmdPushDescriptorSet2KHR;
+PFN_vkCmdPushDescriptorSetWithTemplate2KHR vkCmdPushDescriptorSetWithTemplate2KHR;
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer)
+PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT vkCmdBindDescriptorBufferEmbeddedSamplers2EXT;
+PFN_vkCmdSetDescriptorBufferOffsets2EXT vkCmdSetDescriptorBufferOffsets2EXT;
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_KHR_map_memory2)
+PFN_vkMapMemory2KHR vkMapMemory2KHR;
+PFN_vkUnmapMemory2KHR vkUnmapMemory2KHR;
+#endif /* defined(VK_KHR_map_memory2) */
+#if defined(VK_KHR_performance_query)
+PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
+PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
+PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
+PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_pipeline_binary)
+PFN_vkCreatePipelineBinariesKHR vkCreatePipelineBinariesKHR;
+PFN_vkDestroyPipelineBinaryKHR vkDestroyPipelineBinaryKHR;
+PFN_vkGetPipelineBinaryDataKHR vkGetPipelineBinaryDataKHR;
+PFN_vkGetPipelineKeyKHR vkGetPipelineKeyKHR;
+PFN_vkReleaseCapturedPipelineDataKHR vkReleaseCapturedPipelineDataKHR;
+#endif /* defined(VK_KHR_pipeline_binary) */
+#if defined(VK_KHR_pipeline_executable_properties)
+PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
+PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
+PFN_vkGetPipelineExecutableStatisticsKHR vkGetPipelineExecutableStatisticsKHR;
+#endif /* defined(VK_KHR_pipeline_executable_properties) */
+#if defined(VK_KHR_present_wait)
+PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
+#endif /* defined(VK_KHR_present_wait) */
+#if defined(VK_KHR_present_wait2)
+PFN_vkWaitForPresent2KHR vkWaitForPresent2KHR;
+#endif /* defined(VK_KHR_present_wait2) */
+#if defined(VK_KHR_push_descriptor)
+PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR;
+#endif /* defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline)
+PFN_vkCmdTraceRaysIndirect2KHR vkCmdTraceRaysIndirect2KHR;
+#endif /* defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_ray_tracing_pipeline)
+PFN_vkCmdSetRayTracingPipelineStackSizeKHR vkCmdSetRayTracingPipelineStackSizeKHR;
+PFN_vkCmdTraceRaysIndirectKHR vkCmdTraceRaysIndirectKHR;
+PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR;
+PFN_vkCreateRayTracingPipelinesKHR vkCreateRayTracingPipelinesKHR;
+PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR vkGetRayTracingCaptureReplayShaderGroupHandlesKHR;
+PFN_vkGetRayTracingShaderGroupHandlesKHR vkGetRayTracingShaderGroupHandlesKHR;
+PFN_vkGetRayTracingShaderGroupStackSizeKHR vkGetRayTracingShaderGroupStackSizeKHR;
+#endif /* defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_sampler_ycbcr_conversion)
+PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
+PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
+#endif /* defined(VK_KHR_sampler_ycbcr_conversion) */
+#if defined(VK_KHR_shared_presentable_image)
+PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR;
+#endif /* defined(VK_KHR_shared_presentable_image) */
+#if defined(VK_KHR_surface)
+PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
+PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
+PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
+PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
+PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
+#endif /* defined(VK_KHR_surface) */
+#if defined(VK_KHR_swapchain)
+PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
+PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
+PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
+PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
+PFN_vkQueuePresentKHR vkQueuePresentKHR;
+#endif /* defined(VK_KHR_swapchain) */
+#if defined(VK_KHR_swapchain_maintenance1)
+PFN_vkReleaseSwapchainImagesKHR vkReleaseSwapchainImagesKHR;
+#endif /* defined(VK_KHR_swapchain_maintenance1) */
+#if defined(VK_KHR_synchronization2)
+PFN_vkCmdPipelineBarrier2KHR vkCmdPipelineBarrier2KHR;
+PFN_vkCmdResetEvent2KHR vkCmdResetEvent2KHR;
+PFN_vkCmdSetEvent2KHR vkCmdSetEvent2KHR;
+PFN_vkCmdWaitEvents2KHR vkCmdWaitEvents2KHR;
+PFN_vkCmdWriteTimestamp2KHR vkCmdWriteTimestamp2KHR;
+PFN_vkQueueSubmit2KHR vkQueueSubmit2KHR;
+#endif /* defined(VK_KHR_synchronization2) */
+#if defined(VK_KHR_timeline_semaphore)
+PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
+PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
+PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
+#endif /* defined(VK_KHR_timeline_semaphore) */
+#if defined(VK_KHR_video_decode_queue)
+PFN_vkCmdDecodeVideoKHR vkCmdDecodeVideoKHR;
+#endif /* defined(VK_KHR_video_decode_queue) */
+#if defined(VK_KHR_video_encode_queue)
+PFN_vkCmdEncodeVideoKHR vkCmdEncodeVideoKHR;
+PFN_vkGetEncodedVideoSessionParametersKHR vkGetEncodedVideoSessionParametersKHR;
+PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR;
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+PFN_vkBindVideoSessionMemoryKHR vkBindVideoSessionMemoryKHR;
+PFN_vkCmdBeginVideoCodingKHR vkCmdBeginVideoCodingKHR;
+PFN_vkCmdControlVideoCodingKHR vkCmdControlVideoCodingKHR;
+PFN_vkCmdEndVideoCodingKHR vkCmdEndVideoCodingKHR;
+PFN_vkCreateVideoSessionKHR vkCreateVideoSessionKHR;
+PFN_vkCreateVideoSessionParametersKHR vkCreateVideoSessionParametersKHR;
+PFN_vkDestroyVideoSessionKHR vkDestroyVideoSessionKHR;
+PFN_vkDestroyVideoSessionParametersKHR vkDestroyVideoSessionParametersKHR;
+PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR;
+PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR vkGetPhysicalDeviceVideoFormatPropertiesKHR;
+PFN_vkGetVideoSessionMemoryRequirementsKHR vkGetVideoSessionMemoryRequirementsKHR;
+PFN_vkUpdateVideoSessionParametersKHR vkUpdateVideoSessionParametersKHR;
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_KHR_wayland_surface)
+PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
+PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
+#endif /* defined(VK_KHR_wayland_surface) */
+#if defined(VK_KHR_win32_surface)
+PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
+PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
+#endif /* defined(VK_KHR_win32_surface) */
+#if defined(VK_KHR_xcb_surface)
+PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
+PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
+#endif /* defined(VK_KHR_xcb_surface) */
+#if defined(VK_KHR_xlib_surface)
+PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
+PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
+#endif /* defined(VK_KHR_xlib_surface) */
+#if defined(VK_MVK_ios_surface)
+PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK;
+#endif /* defined(VK_MVK_ios_surface) */
+#if defined(VK_MVK_macos_surface)
+PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
+#endif /* defined(VK_MVK_macos_surface) */
+#if defined(VK_NN_vi_surface)
+PFN_vkCreateViSurfaceNN vkCreateViSurfaceNN;
+#endif /* defined(VK_NN_vi_surface) */
+#if defined(VK_NVX_binary_import)
+PFN_vkCmdCuLaunchKernelNVX vkCmdCuLaunchKernelNVX;
+PFN_vkCreateCuFunctionNVX vkCreateCuFunctionNVX;
+PFN_vkCreateCuModuleNVX vkCreateCuModuleNVX;
+PFN_vkDestroyCuFunctionNVX vkDestroyCuFunctionNVX;
+PFN_vkDestroyCuModuleNVX vkDestroyCuModuleNVX;
+#endif /* defined(VK_NVX_binary_import) */
+#if defined(VK_NVX_image_view_handle)
+PFN_vkGetImageViewHandleNVX vkGetImageViewHandleNVX;
+#endif /* defined(VK_NVX_image_view_handle) */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3
+PFN_vkGetImageViewHandle64NVX vkGetImageViewHandle64NVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2
+PFN_vkGetImageViewAddressNVX vkGetImageViewAddressNVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4
+PFN_vkGetDeviceCombinedImageSamplerIndexNVX vkGetDeviceCombinedImageSamplerIndexNVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4 */
+#if defined(VK_NV_acquire_winrt_display)
+PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV;
+PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV;
+#endif /* defined(VK_NV_acquire_winrt_display) */
+#if defined(VK_NV_clip_space_w_scaling)
+PFN_vkCmdSetViewportWScalingNV vkCmdSetViewportWScalingNV;
+#endif /* defined(VK_NV_clip_space_w_scaling) */
+#if defined(VK_NV_cluster_acceleration_structure)
+PFN_vkCmdBuildClusterAccelerationStructureIndirectNV vkCmdBuildClusterAccelerationStructureIndirectNV;
+PFN_vkGetClusterAccelerationStructureBuildSizesNV vkGetClusterAccelerationStructureBuildSizesNV;
+#endif /* defined(VK_NV_cluster_acceleration_structure) */
+#if defined(VK_NV_compute_occupancy_priority)
+PFN_vkCmdSetComputeOccupancyPriorityNV vkCmdSetComputeOccupancyPriorityNV;
+#endif /* defined(VK_NV_compute_occupancy_priority) */
+#if defined(VK_NV_cooperative_matrix)
+PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV;
+#endif /* defined(VK_NV_cooperative_matrix) */
+#if defined(VK_NV_cooperative_matrix2)
+PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV;
+#endif /* defined(VK_NV_cooperative_matrix2) */
+#if defined(VK_NV_cooperative_vector)
+PFN_vkCmdConvertCooperativeVectorMatrixNV vkCmdConvertCooperativeVectorMatrixNV;
+PFN_vkConvertCooperativeVectorMatrixNV vkConvertCooperativeVectorMatrixNV;
+PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV vkGetPhysicalDeviceCooperativeVectorPropertiesNV;
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_copy_memory_indirect)
+PFN_vkCmdCopyMemoryIndirectNV vkCmdCopyMemoryIndirectNV;
+PFN_vkCmdCopyMemoryToImageIndirectNV vkCmdCopyMemoryToImageIndirectNV;
+#endif /* defined(VK_NV_copy_memory_indirect) */
+#if defined(VK_NV_coverage_reduction_mode)
+PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV;
+#endif /* defined(VK_NV_coverage_reduction_mode) */
+#if defined(VK_NV_cuda_kernel_launch)
+PFN_vkCmdCudaLaunchKernelNV vkCmdCudaLaunchKernelNV;
+PFN_vkCreateCudaFunctionNV vkCreateCudaFunctionNV;
+PFN_vkCreateCudaModuleNV vkCreateCudaModuleNV;
+PFN_vkDestroyCudaFunctionNV vkDestroyCudaFunctionNV;
+PFN_vkDestroyCudaModuleNV vkDestroyCudaModuleNV;
+PFN_vkGetCudaModuleCacheNV vkGetCudaModuleCacheNV;
+#endif /* defined(VK_NV_cuda_kernel_launch) */
+#if defined(VK_NV_device_diagnostic_checkpoints)
+PFN_vkCmdSetCheckpointNV vkCmdSetCheckpointNV;
+PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV;
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) */
+#if defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+PFN_vkGetQueueCheckpointData2NV vkGetQueueCheckpointData2NV;
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_NV_device_generated_commands)
+PFN_vkCmdBindPipelineShaderGroupNV vkCmdBindPipelineShaderGroupNV;
+PFN_vkCmdExecuteGeneratedCommandsNV vkCmdExecuteGeneratedCommandsNV;
+PFN_vkCmdPreprocessGeneratedCommandsNV vkCmdPreprocessGeneratedCommandsNV;
+PFN_vkCreateIndirectCommandsLayoutNV vkCreateIndirectCommandsLayoutNV;
+PFN_vkDestroyIndirectCommandsLayoutNV vkDestroyIndirectCommandsLayoutNV;
+PFN_vkGetGeneratedCommandsMemoryRequirementsNV vkGetGeneratedCommandsMemoryRequirementsNV;
+#endif /* defined(VK_NV_device_generated_commands) */
+#if defined(VK_NV_device_generated_commands_compute)
+PFN_vkCmdUpdatePipelineIndirectBufferNV vkCmdUpdatePipelineIndirectBufferNV;
+PFN_vkGetPipelineIndirectDeviceAddressNV vkGetPipelineIndirectDeviceAddressNV;
+PFN_vkGetPipelineIndirectMemoryRequirementsNV vkGetPipelineIndirectMemoryRequirementsNV;
+#endif /* defined(VK_NV_device_generated_commands_compute) */
+#if defined(VK_NV_external_compute_queue)
+PFN_vkCreateExternalComputeQueueNV vkCreateExternalComputeQueueNV;
+PFN_vkDestroyExternalComputeQueueNV vkDestroyExternalComputeQueueNV;
+PFN_vkGetExternalComputeQueueDataNV vkGetExternalComputeQueueDataNV;
+#endif /* defined(VK_NV_external_compute_queue) */
+#if defined(VK_NV_external_memory_capabilities)
+PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
+#endif /* defined(VK_NV_external_memory_capabilities) */
+#if defined(VK_NV_external_memory_rdma)
+PFN_vkGetMemoryRemoteAddressNV vkGetMemoryRemoteAddressNV;
+#endif /* defined(VK_NV_external_memory_rdma) */
+#if defined(VK_NV_external_memory_win32)
+PFN_vkGetMemoryWin32HandleNV vkGetMemoryWin32HandleNV;
+#endif /* defined(VK_NV_external_memory_win32) */
+#if defined(VK_NV_fragment_shading_rate_enums)
+PFN_vkCmdSetFragmentShadingRateEnumNV vkCmdSetFragmentShadingRateEnumNV;
+#endif /* defined(VK_NV_fragment_shading_rate_enums) */
+#if defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2
+PFN_vkGetLatencyTimingsLegacyNV vkGetLatencyTimingsLegacyNV;
+PFN_vkGetSleepStatusLegacyNV vkGetSleepStatusLegacyNV;
+PFN_vkLatencySleepLegacyNV vkLatencySleepLegacyNV;
+PFN_vkQueueNotifyOutOfBandLegacyNV vkQueueNotifyOutOfBandLegacyNV;
+PFN_vkSetLatencyMarkerLegacyNV vkSetLatencyMarkerLegacyNV;
+PFN_vkSetLatencySleepModeLegacyNV vkSetLatencySleepModeLegacyNV;
+PFN_vkShutdownLatencyDeviceLegacyNV vkShutdownLatencyDeviceLegacyNV;
+#endif /* defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2 */
+#if defined(VK_NV_low_latency2)
+PFN_vkGetLatencyTimingsNV vkGetLatencyTimingsNV;
+PFN_vkLatencySleepNV vkLatencySleepNV;
+PFN_vkQueueNotifyOutOfBandNV vkQueueNotifyOutOfBandNV;
+PFN_vkSetLatencyMarkerNV vkSetLatencyMarkerNV;
+PFN_vkSetLatencySleepModeNV vkSetLatencySleepModeNV;
+#endif /* defined(VK_NV_low_latency2) */
+#if defined(VK_NV_memory_decompression)
+PFN_vkCmdDecompressMemoryIndirectCountNV vkCmdDecompressMemoryIndirectCountNV;
+PFN_vkCmdDecompressMemoryNV vkCmdDecompressMemoryNV;
+#endif /* defined(VK_NV_memory_decompression) */
+#if defined(VK_NV_mesh_shader)
+PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV;
+PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV;
+#endif /* defined(VK_NV_mesh_shader) */
+#if defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV;
+#endif /* defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_NV_optical_flow)
+PFN_vkBindOpticalFlowSessionImageNV vkBindOpticalFlowSessionImageNV;
+PFN_vkCmdOpticalFlowExecuteNV vkCmdOpticalFlowExecuteNV;
+PFN_vkCreateOpticalFlowSessionNV vkCreateOpticalFlowSessionNV;
+PFN_vkDestroyOpticalFlowSessionNV vkDestroyOpticalFlowSessionNV;
+PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV vkGetPhysicalDeviceOpticalFlowImageFormatsNV;
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_NV_partitioned_acceleration_structure)
+PFN_vkCmdBuildPartitionedAccelerationStructuresNV vkCmdBuildPartitionedAccelerationStructuresNV;
+PFN_vkGetPartitionedAccelerationStructuresBuildSizesNV vkGetPartitionedAccelerationStructuresBuildSizesNV;
+#endif /* defined(VK_NV_partitioned_acceleration_structure) */
+#if defined(VK_NV_ray_tracing)
+PFN_vkBindAccelerationStructureMemoryNV vkBindAccelerationStructureMemoryNV;
+PFN_vkCmdBuildAccelerationStructureNV vkCmdBuildAccelerationStructureNV;
+PFN_vkCmdCopyAccelerationStructureNV vkCmdCopyAccelerationStructureNV;
+PFN_vkCmdTraceRaysNV vkCmdTraceRaysNV;
+PFN_vkCmdWriteAccelerationStructuresPropertiesNV vkCmdWriteAccelerationStructuresPropertiesNV;
+PFN_vkCompileDeferredNV vkCompileDeferredNV;
+PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV;
+PFN_vkCreateRayTracingPipelinesNV vkCreateRayTracingPipelinesNV;
+PFN_vkDestroyAccelerationStructureNV vkDestroyAccelerationStructureNV;
+PFN_vkGetAccelerationStructureHandleNV vkGetAccelerationStructureHandleNV;
+PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV;
+PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV;
+#endif /* defined(VK_NV_ray_tracing) */
+#if defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2
+PFN_vkCmdSetExclusiveScissorEnableNV vkCmdSetExclusiveScissorEnableNV;
+#endif /* defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2 */
+#if defined(VK_NV_scissor_exclusive)
+PFN_vkCmdSetExclusiveScissorNV vkCmdSetExclusiveScissorNV;
+#endif /* defined(VK_NV_scissor_exclusive) */
+#if defined(VK_NV_shading_rate_image)
+PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV;
+PFN_vkCmdSetCoarseSampleOrderNV vkCmdSetCoarseSampleOrderNV;
+PFN_vkCmdSetViewportShadingRatePaletteNV vkCmdSetViewportShadingRatePaletteNV;
+#endif /* defined(VK_NV_shading_rate_image) */
+#if defined(VK_OHOS_external_memory)
+PFN_vkGetMemoryNativeBufferOHOS vkGetMemoryNativeBufferOHOS;
+PFN_vkGetNativeBufferPropertiesOHOS vkGetNativeBufferPropertiesOHOS;
+#endif /* defined(VK_OHOS_external_memory) */
+#if defined(VK_OHOS_surface)
+PFN_vkCreateSurfaceOHOS vkCreateSurfaceOHOS;
+#endif /* defined(VK_OHOS_surface) */
+#if defined(VK_QCOM_queue_perf_hint)
+PFN_vkQueueSetPerfHintQCOM vkQueueSetPerfHintQCOM;
+#endif /* defined(VK_QCOM_queue_perf_hint) */
+#if defined(VK_QCOM_tile_memory_heap)
+PFN_vkCmdBindTileMemoryQCOM vkCmdBindTileMemoryQCOM;
+#endif /* defined(VK_QCOM_tile_memory_heap) */
+#if defined(VK_QCOM_tile_properties)
+PFN_vkGetDynamicRenderingTilePropertiesQCOM vkGetDynamicRenderingTilePropertiesQCOM;
+PFN_vkGetFramebufferTilePropertiesQCOM vkGetFramebufferTilePropertiesQCOM;
+#endif /* defined(VK_QCOM_tile_properties) */
+#if defined(VK_QCOM_tile_shading)
+PFN_vkCmdBeginPerTileExecutionQCOM vkCmdBeginPerTileExecutionQCOM;
+PFN_vkCmdDispatchTileQCOM vkCmdDispatchTileQCOM;
+PFN_vkCmdEndPerTileExecutionQCOM vkCmdEndPerTileExecutionQCOM;
+#endif /* defined(VK_QCOM_tile_shading) */
+#if defined(VK_QNX_external_memory_screen_buffer)
+PFN_vkGetScreenBufferPropertiesQNX vkGetScreenBufferPropertiesQNX;
+#endif /* defined(VK_QNX_external_memory_screen_buffer) */
+#if defined(VK_QNX_screen_surface)
+PFN_vkCreateScreenSurfaceQNX vkCreateScreenSurfaceQNX;
+PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX vkGetPhysicalDeviceScreenPresentationSupportQNX;
+#endif /* defined(VK_QNX_screen_surface) */
+#if defined(VK_SEC_ubm_surface)
+PFN_vkCreateUbmSurfaceSEC vkCreateUbmSurfaceSEC;
+PFN_vkGetPhysicalDeviceUbmPresentationSupportSEC vkGetPhysicalDeviceUbmPresentationSupportSEC;
+#endif /* defined(VK_SEC_ubm_surface) */
+#if defined(VK_VALVE_descriptor_set_host_mapping)
+PFN_vkGetDescriptorSetHostMappingVALVE vkGetDescriptorSetHostMappingVALVE;
+PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE vkGetDescriptorSetLayoutHostMappingInfoVALVE;
+#endif /* defined(VK_VALVE_descriptor_set_host_mapping) */
+#if (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow))
+PFN_vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM;
+#endif /* (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow)) */
+#if (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control))
+PFN_vkCmdSetDepthClampRangeEXT vkCmdSetDepthClampRangeEXT;
+#endif /* (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control)) */
+#if (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object))
+PFN_vkCmdBindVertexBuffers2EXT vkCmdBindVertexBuffers2EXT;
+PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT;
+PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT;
+PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT;
+PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT;
+PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT;
+PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT;
+PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT;
+PFN_vkCmdSetScissorWithCountEXT vkCmdSetScissorWithCountEXT;
+PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT;
+PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT;
+PFN_vkCmdSetViewportWithCountEXT vkCmdSetViewportWithCountEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object))
+PFN_vkCmdSetDepthBiasEnableEXT vkCmdSetDepthBiasEnableEXT;
+PFN_vkCmdSetLogicOpEXT vkCmdSetLogicOpEXT;
+PFN_vkCmdSetPatchControlPointsEXT vkCmdSetPatchControlPointsEXT;
+PFN_vkCmdSetPrimitiveRestartEnableEXT vkCmdSetPrimitiveRestartEnableEXT;
+PFN_vkCmdSetRasterizerDiscardEnableEXT vkCmdSetRasterizerDiscardEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object))
+PFN_vkCmdSetAlphaToCoverageEnableEXT vkCmdSetAlphaToCoverageEnableEXT;
+PFN_vkCmdSetAlphaToOneEnableEXT vkCmdSetAlphaToOneEnableEXT;
+PFN_vkCmdSetColorBlendEnableEXT vkCmdSetColorBlendEnableEXT;
+PFN_vkCmdSetColorBlendEquationEXT vkCmdSetColorBlendEquationEXT;
+PFN_vkCmdSetColorWriteMaskEXT vkCmdSetColorWriteMaskEXT;
+PFN_vkCmdSetDepthClampEnableEXT vkCmdSetDepthClampEnableEXT;
+PFN_vkCmdSetLogicOpEnableEXT vkCmdSetLogicOpEnableEXT;
+PFN_vkCmdSetPolygonModeEXT vkCmdSetPolygonModeEXT;
+PFN_vkCmdSetRasterizationSamplesEXT vkCmdSetRasterizationSamplesEXT;
+PFN_vkCmdSetSampleMaskEXT vkCmdSetSampleMaskEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object))
+PFN_vkCmdSetTessellationDomainOriginEXT vkCmdSetTessellationDomainOriginEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback))
+PFN_vkCmdSetRasterizationStreamEXT vkCmdSetRasterizationStreamEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization))
+PFN_vkCmdSetConservativeRasterizationModeEXT vkCmdSetConservativeRasterizationModeEXT;
+PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT vkCmdSetExtraPrimitiveOverestimationSizeEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable))
+PFN_vkCmdSetDepthClipEnableEXT vkCmdSetDepthClipEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations))
+PFN_vkCmdSetSampleLocationsEnableEXT vkCmdSetSampleLocationsEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced))
+PFN_vkCmdSetColorBlendAdvancedEXT vkCmdSetColorBlendAdvancedEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex))
+PFN_vkCmdSetProvokingVertexModeEXT vkCmdSetProvokingVertexModeEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization)))
+PFN_vkCmdSetLineRasterizationModeEXT vkCmdSetLineRasterizationModeEXT;
+PFN_vkCmdSetLineStippleEnableEXT vkCmdSetLineStippleEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control))
+PFN_vkCmdSetDepthClipNegativeOneToOneEXT vkCmdSetDepthClipNegativeOneToOneEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling))
+PFN_vkCmdSetViewportWScalingEnableNV vkCmdSetViewportWScalingEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle))
+PFN_vkCmdSetViewportSwizzleNV vkCmdSetViewportSwizzleNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color))
+PFN_vkCmdSetCoverageToColorEnableNV vkCmdSetCoverageToColorEnableNV;
+PFN_vkCmdSetCoverageToColorLocationNV vkCmdSetCoverageToColorLocationNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples))
+PFN_vkCmdSetCoverageModulationModeNV vkCmdSetCoverageModulationModeNV;
+PFN_vkCmdSetCoverageModulationTableEnableNV vkCmdSetCoverageModulationTableEnableNV;
+PFN_vkCmdSetCoverageModulationTableNV vkCmdSetCoverageModulationTableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image))
+PFN_vkCmdSetShadingRateImageEnableNV vkCmdSetShadingRateImageEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test))
+PFN_vkCmdSetRepresentativeFragmentTestEnableNV vkCmdSetRepresentativeFragmentTestEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode))
+PFN_vkCmdSetCoverageReductionModeNV vkCmdSetCoverageReductionModeNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode)) */
+#if (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control))
+PFN_vkGetImageSubresourceLayout2EXT vkGetImageSubresourceLayout2EXT;
+#endif /* (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control)) */
+#if (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state))
+PFN_vkCmdSetVertexInputEXT vkCmdSetVertexInputEXT;
+#endif /* (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state)) */
+#if (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template)))
+PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR;
+#endif /* (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template))) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR;
+PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR;
+PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR;
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+/* VOLK_GENERATE_PROTOTYPES_C */
+
+#ifdef __GNUC__
+#	pragma GCC visibility pop
+#endif
+
+#ifdef __cplusplus
+} // extern "C" / namespace volk
+#endif
+/* clang-format on */
ADD · third-party/volk.h +3493 -0
--- a/third-party/volk.h
+++ b/third-party/volk.h
@@ -0,0 +1,3493 @@
+/**
+ * volk
+ *
+ * Copyright (C) 2018-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
+ * Report bugs and download new versions at https://github.com/zeux/volk
+ *
+ * This library is distributed under the MIT License. See notice at the end of this file.
+ */
+/* clang-format off */
+#ifndef VOLK_H_
+#define VOLK_H_
+
+#if defined(VOLK_NAMESPACE) && !defined(__cplusplus)
+#error VOLK_NAMESPACE is only supported in C++
+#endif
+
+#if defined(VULKAN_H_) && !defined(VK_NO_PROTOTYPES)
+#	error To use volk, you need to define VK_NO_PROTOTYPES before including vulkan.h
+#endif
+
+/* VOLK_GENERATE_VERSION_DEFINE */
+#define VOLK_HEADER_VERSION 359
+/* VOLK_GENERATE_VERSION_DEFINE */
+
+#ifndef VK_NO_PROTOTYPES
+#	define VK_NO_PROTOTYPES
+#endif
+
+#ifndef VULKAN_H_
+#	ifdef VOLK_VULKAN_H_PATH
+#		include VOLK_VULKAN_H_PATH
+#	else /* Platform headers included below */
+#		include <vulkan/vk_platform.h>
+#		include <vulkan/vulkan_core.h>
+#	endif
+#endif
+
+#ifdef __cplusplus
+#ifdef VOLK_NAMESPACE
+namespace volk {
+#else
+extern "C" {
+#endif
+#endif
+
+struct VolkInstanceTable;
+struct VolkDeviceTable;
+
+/**
+ * Initialize library by loading Vulkan loader; call this function before creating the Vulkan instance.
+ *
+ * Returns VK_SUCCESS on success and VK_ERROR_INITIALIZATION_FAILED otherwise.
+ */
+VkResult volkInitialize(void);
+
+/**
+ * Initialize library by providing a custom handler to load global symbols.
+ *
+ * This function can be used instead of volkInitialize.
+ * The handler function pointer will be asked to load global Vulkan symbols which require no instance
+ * (such as vkCreateInstance, vkEnumerateInstance* and vkEnumerateInstanceVersion if available).
+ */
+void volkInitializeCustom(PFN_vkGetInstanceProcAddr handler);
+
+/**
+ * Finalize library by unloading Vulkan loader and resetting global symbols to NULL.
+ *
+ * This function does not need to be called on process exit (as loader will be unloaded automatically) or if volkInitialize failed.
+ * In general this function is optional to call but may be useful in rare cases eg if volk needs to be reinitialized multiple times.
+ */
+void volkFinalize(void);
+
+/**
+ * Get Vulkan instance version supported by the Vulkan loader, or 0 if Vulkan isn't supported
+ *
+ * Returns 0 if volkInitialize wasn't called or failed.
+ */
+uint32_t volkGetInstanceVersion(void);
+
+/**
+ * Load global function pointers using application-created VkInstance; call this function after creating the Vulkan instance.
+ */
+void volkLoadInstance(VkInstance instance);
+
+/**
+ * Load global function pointers using application-created VkInstance; call this function after creating the Vulkan instance.
+ * Skips loading device-based function pointers, requires usage of volkLoadDevice afterwards.
+ */
+void volkLoadInstanceOnly(VkInstance instance);
+
+/**
+ * Load global function pointers using application-created VkDevice; call this function after creating the Vulkan device.
+ *
+ * Note: this is not suitable for applications that want to use multiple VkDevice objects concurrently.
+ */
+void volkLoadDevice(VkDevice device);
+
+/**
+ * Return last VkInstance for which global function pointers have been loaded via volkLoadInstance(),
+ * or VK_NULL_HANDLE if volkLoadInstance() has not been called.
+ */
+VkInstance volkGetLoadedInstance(void);
+
+/**
+ * Return last VkDevice for which global function pointers have been loaded via volkLoadDevice(),
+ * or VK_NULL_HANDLE if volkLoadDevice() has not been called.
+ */
+VkDevice volkGetLoadedDevice(void);
+
+/**
+ * Load function pointers using application-created VkInstance into a table.
+ * Application should use function pointers from that table instead of using global function pointers.
+ */
+void volkLoadInstanceTable(struct VolkInstanceTable* table, VkInstance instance);
+
+/**
+ * Load function pointers using application-created VkDevice into a table.
+ * Application should use function pointers from that table instead of using global function pointers.
+ */
+void volkLoadDeviceTable(struct VolkDeviceTable* table, VkDevice device);
+
+#ifdef __cplusplus
+} // extern "C" / namespace volk
+#endif
+
+/* Instead of directly including vulkan.h, we include platform-specific parts of the SDK manually
+ * This is necessary to avoid including platform headers in some cases (which vulkan.h does unconditionally)
+ * and replace them with forward declarations, which makes build times faster and avoids macro conflicts.
+ *
+ * Note that we only replace platform-specific headers when the headers are known to be problematic: very large
+ * or slow to compile (Windows), or introducing unprefixed macros which can cause conflicts (Windows, Xlib).
+ */
+#if !defined(VULKAN_H_) && !defined(VOLK_VULKAN_H_PATH)
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+#include <vulkan/vulkan_android.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_FUCHSIA
+#include <zircon/types.h>
+#include <vulkan/vulkan_fuchsia.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_IOS_MVK
+#include <vulkan/vulkan_ios.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_MACOS_MVK
+#include <vulkan/vulkan_macos.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_METAL_EXT
+#include <vulkan/vulkan_metal.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_VI_NN
+#include <vulkan/vulkan_vi.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+#include <vulkan/vulkan_wayland.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+typedef unsigned long DWORD;
+typedef const wchar_t* LPCWSTR;
+typedef void* HANDLE;
+typedef struct HINSTANCE__* HINSTANCE;
+typedef struct HWND__* HWND;
+typedef struct HMONITOR__* HMONITOR;
+typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
+#include <vulkan/vulkan_win32.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+#include <xcb/xcb.h>
+#include <vulkan/vulkan_xcb.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+typedef struct _XDisplay Display;
+typedef unsigned long Window;
+typedef unsigned long VisualID;
+#include <vulkan/vulkan_xlib.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
+#include <directfb.h>
+#include <vulkan/vulkan_directfb.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+typedef struct _XDisplay Display;
+typedef unsigned long RROutput;
+#include <vulkan/vulkan_xlib_xrandr.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_GGP
+#include <ggp_c/vulkan_types.h>
+#include <vulkan/vulkan_ggp.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_SCREEN_QNX
+#include <screen/screen.h>
+#include <vulkan/vulkan_screen.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_SCI
+#include <nvscisync.h>
+#include <nvscibuf.h>
+#include <vulkan/vulkan_sci.h>
+#endif
+
+#ifdef VK_ENABLE_BETA_EXTENSIONS
+#include <vulkan/vulkan_beta.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_OHOS
+#include <vulkan/vulkan_ohos.h>
+#endif
+
+#endif
+
+#ifdef __cplusplus
+#ifdef VOLK_NAMESPACE
+namespace volk {
+#else
+extern "C" {
+#endif
+#endif
+
+/**
+ * Instance-specific function pointer table
+ */
+struct VolkInstanceTable
+{
+	/* VOLK_GENERATE_INSTANCE_TABLE */
+#if defined(VK_VERSION_1_0)
+	PFN_vkCreateDevice vkCreateDevice;
+	PFN_vkDestroyInstance vkDestroyInstance;
+	PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
+	PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
+	PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
+	PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
+	PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
+	PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
+	PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
+	PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
+	PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
+	PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
+	PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
+#else
+	PFN_vkVoidFunction padding_f34b07f4[13];
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups;
+	PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties;
+	PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties;
+	PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties;
+	PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2;
+	PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2;
+	PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2;
+	PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2;
+	PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2;
+	PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2;
+	PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2;
+#else
+	PFN_vkVoidFunction padding_73de037b[11];
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_3)
+	PFN_vkGetPhysicalDeviceToolProperties vkGetPhysicalDeviceToolProperties;
+#else
+	PFN_vkVoidFunction padding_60958868[1];
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_ARM_data_graph)
+	PFN_vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM;
+	PFN_vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM;
+#else
+	PFN_vkVoidFunction padding_15920a35[2];
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_data_graph_optical_flow)
+	PFN_vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM;
+#else
+	PFN_vkVoidFunction padding_4da6b74b[1];
+#endif /* defined(VK_ARM_data_graph_optical_flow) */
+#if defined(VK_ARM_performance_counters_by_region)
+	PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM;
+#else
+	PFN_vkVoidFunction padding_4fd09193[1];
+#endif /* defined(VK_ARM_performance_counters_by_region) */
+#if defined(VK_ARM_shader_instrumentation)
+	PFN_vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM;
+#else
+	PFN_vkVoidFunction padding_faae0311[1];
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	PFN_vkGetPhysicalDeviceExternalTensorPropertiesARM vkGetPhysicalDeviceExternalTensorPropertiesARM;
+#else
+	PFN_vkVoidFunction padding_4622403f[1];
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_EXT_acquire_drm_display)
+	PFN_vkAcquireDrmDisplayEXT vkAcquireDrmDisplayEXT;
+	PFN_vkGetDrmDisplayEXT vkGetDrmDisplayEXT;
+#else
+	PFN_vkVoidFunction padding_8e427d62[2];
+#endif /* defined(VK_EXT_acquire_drm_display) */
+#if defined(VK_EXT_acquire_xlib_display)
+	PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT;
+	PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT;
+#else
+	PFN_vkVoidFunction padding_6e6f0a05[2];
+#endif /* defined(VK_EXT_acquire_xlib_display) */
+#if defined(VK_EXT_calibrated_timestamps)
+	PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT;
+#else
+	PFN_vkVoidFunction padding_61710136[1];
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_cooperative_matrix_maintenance1)
+	PFN_vkGetPhysicalDeviceCooperativeMatrixProperties2EXT vkGetPhysicalDeviceCooperativeMatrixProperties2EXT;
+#else
+	PFN_vkVoidFunction padding_c8d35e9d[1];
+#endif /* defined(VK_EXT_cooperative_matrix_maintenance1) */
+#if defined(VK_EXT_debug_report)
+	PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
+	PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
+	PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
+#else
+	PFN_vkVoidFunction padding_250c28de[3];
+#endif /* defined(VK_EXT_debug_report) */
+#if defined(VK_EXT_debug_utils)
+	PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT;
+	PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT;
+	PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT;
+	PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
+	PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
+	PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT;
+	PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT;
+	PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT;
+	PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT;
+	PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT;
+	PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT;
+#else
+	PFN_vkVoidFunction padding_3e2e81f7[11];
+#endif /* defined(VK_EXT_debug_utils) */
+#if defined(VK_EXT_descriptor_heap)
+	PFN_vkGetPhysicalDeviceDescriptorSizeEXT vkGetPhysicalDeviceDescriptorSizeEXT;
+#else
+	PFN_vkVoidFunction padding_ce9bfed[1];
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_direct_mode_display)
+	PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT;
+#else
+	PFN_vkVoidFunction padding_899830c3[1];
+#endif /* defined(VK_EXT_direct_mode_display) */
+#if defined(VK_EXT_directfb_surface)
+	PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT;
+	PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT;
+#else
+	PFN_vkVoidFunction padding_f7e0f7b1[2];
+#endif /* defined(VK_EXT_directfb_surface) */
+#if defined(VK_EXT_display_surface_counter)
+	PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT;
+#else
+	PFN_vkVoidFunction padding_8bff43f7[1];
+#endif /* defined(VK_EXT_display_surface_counter) */
+#if defined(VK_EXT_full_screen_exclusive)
+	PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT vkGetPhysicalDeviceSurfacePresentModes2EXT;
+#else
+	PFN_vkVoidFunction padding_ff6b086[1];
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_headless_surface)
+	PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT;
+#else
+	PFN_vkVoidFunction padding_f8cab9e0[1];
+#endif /* defined(VK_EXT_headless_surface) */
+#if defined(VK_EXT_metal_surface)
+	PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
+#else
+	PFN_vkVoidFunction padding_1c6d079a[1];
+#endif /* defined(VK_EXT_metal_surface) */
+#if defined(VK_EXT_sample_locations)
+	PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_fd7ffce7[1];
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_tooling_info)
+	PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_99aa5ee9[1];
+#endif /* defined(VK_EXT_tooling_info) */
+#if defined(VK_FUCHSIA_imagepipe_surface)
+	PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA;
+#else
+	PFN_vkVoidFunction padding_6db35e8f[1];
+#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
+#if defined(VK_GGP_stream_descriptor_surface)
+	PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP;
+#else
+	PFN_vkVoidFunction padding_cc96d0ec[1];
+#endif /* defined(VK_GGP_stream_descriptor_surface) */
+#if defined(VK_KHR_android_surface)
+	PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
+#else
+	PFN_vkVoidFunction padding_ab4fe82c[1];
+#endif /* defined(VK_KHR_android_surface) */
+#if defined(VK_KHR_calibrated_timestamps)
+	PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR vkGetPhysicalDeviceCalibrateableTimeDomainsKHR;
+#else
+	PFN_vkVoidFunction padding_663b2fa0[1];
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_cooperative_matrix)
+	PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_59e376cc[1];
+#endif /* defined(VK_KHR_cooperative_matrix) */
+#if defined(VK_KHR_device_group_creation)
+	PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR;
+#else
+	PFN_vkVoidFunction padding_6db81211[1];
+#endif /* defined(VK_KHR_device_group_creation) */
+#if defined(VK_KHR_display)
+	PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
+	PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
+	PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
+	PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
+	PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
+	PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
+	PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_cce37eaf[7];
+#endif /* defined(VK_KHR_display) */
+#if defined(VK_KHR_external_fence_capabilities)
+	PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_b2076412[1];
+#endif /* defined(VK_KHR_external_fence_capabilities) */
+#if defined(VK_KHR_external_memory_capabilities)
+	PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_f167e378[1];
+#endif /* defined(VK_KHR_external_memory_capabilities) */
+#if defined(VK_KHR_external_semaphore_capabilities)
+	PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_acdaf099[1];
+#endif /* defined(VK_KHR_external_semaphore_capabilities) */
+#if defined(VK_KHR_fragment_shading_rate)
+	PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR vkGetPhysicalDeviceFragmentShadingRatesKHR;
+#else
+	PFN_vkVoidFunction padding_d59cae82[1];
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_display_properties2)
+	PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR;
+	PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR;
+	PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR;
+	PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR;
+#else
+	PFN_vkVoidFunction padding_46c0938b[4];
+#endif /* defined(VK_KHR_get_display_properties2) */
+#if defined(VK_KHR_get_physical_device_properties2)
+	PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
+	PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR;
+	PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR;
+	PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
+	PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
+	PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR;
+	PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR;
+#else
+	PFN_vkVoidFunction padding_5fac460e[7];
+#endif /* defined(VK_KHR_get_physical_device_properties2) */
+#if defined(VK_KHR_get_surface_capabilities2)
+	PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR;
+	PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR;
+#else
+	PFN_vkVoidFunction padding_3baff606[2];
+#endif /* defined(VK_KHR_get_surface_capabilities2) */
+#if defined(VK_KHR_performance_query)
+	PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
+	PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
+#else
+	PFN_vkVoidFunction padding_1b45ef8f[2];
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_surface)
+	PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
+	PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
+	PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
+	PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
+	PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
+#else
+	PFN_vkVoidFunction padding_8f1ea665[5];
+#endif /* defined(VK_KHR_surface) */
+#if defined(VK_KHR_video_encode_queue)
+	PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_f0a3114[1];
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR;
+	PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR vkGetPhysicalDeviceVideoFormatPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_12d937aa[2];
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_KHR_wayland_surface)
+	PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
+	PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
+#else
+	PFN_vkVoidFunction padding_92436324[2];
+#endif /* defined(VK_KHR_wayland_surface) */
+#if defined(VK_KHR_win32_surface)
+	PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
+	PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
+#else
+	PFN_vkVoidFunction padding_b8dcaf56[2];
+#endif /* defined(VK_KHR_win32_surface) */
+#if defined(VK_KHR_xcb_surface)
+	PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
+	PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
+#else
+	PFN_vkVoidFunction padding_b6b79326[2];
+#endif /* defined(VK_KHR_xcb_surface) */
+#if defined(VK_KHR_xlib_surface)
+	PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
+	PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
+#else
+	PFN_vkVoidFunction padding_c5e2b5db[2];
+#endif /* defined(VK_KHR_xlib_surface) */
+#if defined(VK_MVK_ios_surface)
+	PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK;
+#else
+	PFN_vkVoidFunction padding_52f99096[1];
+#endif /* defined(VK_MVK_ios_surface) */
+#if defined(VK_MVK_macos_surface)
+	PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
+#else
+	PFN_vkVoidFunction padding_1d7ced9a[1];
+#endif /* defined(VK_MVK_macos_surface) */
+#if defined(VK_NN_vi_surface)
+	PFN_vkCreateViSurfaceNN vkCreateViSurfaceNN;
+#else
+	PFN_vkVoidFunction padding_d9ec3901[1];
+#endif /* defined(VK_NN_vi_surface) */
+#if defined(VK_NV_acquire_winrt_display)
+	PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV;
+	PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV;
+#else
+	PFN_vkVoidFunction padding_41c66e6[2];
+#endif /* defined(VK_NV_acquire_winrt_display) */
+#if defined(VK_NV_cooperative_matrix)
+	PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV;
+#else
+	PFN_vkVoidFunction padding_ee7fcfc8[1];
+#endif /* defined(VK_NV_cooperative_matrix) */
+#if defined(VK_NV_cooperative_matrix2)
+	PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV;
+#else
+	PFN_vkVoidFunction padding_2ec091f4[1];
+#endif /* defined(VK_NV_cooperative_matrix2) */
+#if defined(VK_NV_cooperative_vector)
+	PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV vkGetPhysicalDeviceCooperativeVectorPropertiesNV;
+#else
+	PFN_vkVoidFunction padding_50d51145[1];
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_coverage_reduction_mode)
+	PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV;
+#else
+	PFN_vkVoidFunction padding_9a9f15ac[1];
+#endif /* defined(VK_NV_coverage_reduction_mode) */
+#if defined(VK_NV_external_memory_capabilities)
+	PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
+#else
+	PFN_vkVoidFunction padding_988145[1];
+#endif /* defined(VK_NV_external_memory_capabilities) */
+#if defined(VK_NV_optical_flow)
+	PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV vkGetPhysicalDeviceOpticalFlowImageFormatsNV;
+#else
+	PFN_vkVoidFunction padding_46a4b95[1];
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_OHOS_surface)
+	PFN_vkCreateSurfaceOHOS vkCreateSurfaceOHOS;
+#else
+	PFN_vkVoidFunction padding_b94570ee[1];
+#endif /* defined(VK_OHOS_surface) */
+#if defined(VK_QNX_screen_surface)
+	PFN_vkCreateScreenSurfaceQNX vkCreateScreenSurfaceQNX;
+	PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX vkGetPhysicalDeviceScreenPresentationSupportQNX;
+#else
+	PFN_vkVoidFunction padding_9b43b57c[2];
+#endif /* defined(VK_QNX_screen_surface) */
+#if defined(VK_SEC_ubm_surface)
+	PFN_vkCreateUbmSurfaceSEC vkCreateUbmSurfaceSEC;
+	PFN_vkGetPhysicalDeviceUbmPresentationSupportSEC vkGetPhysicalDeviceUbmPresentationSupportSEC;
+#else
+	PFN_vkVoidFunction padding_bdcf11f9[2];
+#endif /* defined(VK_SEC_ubm_surface) */
+#if (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow))
+	PFN_vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM;
+#else
+	PFN_vkVoidFunction padding_d3dcb1f3[1];
+#endif /* (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR;
+#else
+	PFN_vkVoidFunction padding_a8092b55[1];
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_INSTANCE_TABLE */
+};
+
+/**
+ * Device-specific function pointer table
+ */
+struct VolkDeviceTable
+{
+	/* VOLK_GENERATE_DEVICE_TABLE */
+#if defined(VK_VERSION_1_0)
+	PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
+	PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
+	PFN_vkAllocateMemory vkAllocateMemory;
+	PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
+	PFN_vkBindBufferMemory vkBindBufferMemory;
+	PFN_vkBindImageMemory vkBindImageMemory;
+	PFN_vkCmdBeginQuery vkCmdBeginQuery;
+	PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
+	PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
+	PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
+	PFN_vkCmdBindPipeline vkCmdBindPipeline;
+	PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
+	PFN_vkCmdBlitImage vkCmdBlitImage;
+	PFN_vkCmdClearAttachments vkCmdClearAttachments;
+	PFN_vkCmdClearColorImage vkCmdClearColorImage;
+	PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
+	PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
+	PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
+	PFN_vkCmdCopyImage vkCmdCopyImage;
+	PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
+	PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
+	PFN_vkCmdDispatch vkCmdDispatch;
+	PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
+	PFN_vkCmdDraw vkCmdDraw;
+	PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
+	PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
+	PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
+	PFN_vkCmdEndQuery vkCmdEndQuery;
+	PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
+	PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
+	PFN_vkCmdFillBuffer vkCmdFillBuffer;
+	PFN_vkCmdNextSubpass vkCmdNextSubpass;
+	PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
+	PFN_vkCmdPushConstants vkCmdPushConstants;
+	PFN_vkCmdResetEvent vkCmdResetEvent;
+	PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
+	PFN_vkCmdResolveImage vkCmdResolveImage;
+	PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
+	PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
+	PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
+	PFN_vkCmdSetEvent vkCmdSetEvent;
+	PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
+	PFN_vkCmdSetScissor vkCmdSetScissor;
+	PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
+	PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
+	PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
+	PFN_vkCmdSetViewport vkCmdSetViewport;
+	PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
+	PFN_vkCmdWaitEvents vkCmdWaitEvents;
+	PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
+	PFN_vkCreateBuffer vkCreateBuffer;
+	PFN_vkCreateBufferView vkCreateBufferView;
+	PFN_vkCreateCommandPool vkCreateCommandPool;
+	PFN_vkCreateComputePipelines vkCreateComputePipelines;
+	PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
+	PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
+	PFN_vkCreateEvent vkCreateEvent;
+	PFN_vkCreateFence vkCreateFence;
+	PFN_vkCreateFramebuffer vkCreateFramebuffer;
+	PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
+	PFN_vkCreateImage vkCreateImage;
+	PFN_vkCreateImageView vkCreateImageView;
+	PFN_vkCreatePipelineCache vkCreatePipelineCache;
+	PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
+	PFN_vkCreateQueryPool vkCreateQueryPool;
+	PFN_vkCreateRenderPass vkCreateRenderPass;
+	PFN_vkCreateSampler vkCreateSampler;
+	PFN_vkCreateSemaphore vkCreateSemaphore;
+	PFN_vkCreateShaderModule vkCreateShaderModule;
+	PFN_vkDestroyBuffer vkDestroyBuffer;
+	PFN_vkDestroyBufferView vkDestroyBufferView;
+	PFN_vkDestroyCommandPool vkDestroyCommandPool;
+	PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
+	PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
+	PFN_vkDestroyDevice vkDestroyDevice;
+	PFN_vkDestroyEvent vkDestroyEvent;
+	PFN_vkDestroyFence vkDestroyFence;
+	PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
+	PFN_vkDestroyImage vkDestroyImage;
+	PFN_vkDestroyImageView vkDestroyImageView;
+	PFN_vkDestroyPipeline vkDestroyPipeline;
+	PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
+	PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
+	PFN_vkDestroyQueryPool vkDestroyQueryPool;
+	PFN_vkDestroyRenderPass vkDestroyRenderPass;
+	PFN_vkDestroySampler vkDestroySampler;
+	PFN_vkDestroySemaphore vkDestroySemaphore;
+	PFN_vkDestroyShaderModule vkDestroyShaderModule;
+	PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
+	PFN_vkEndCommandBuffer vkEndCommandBuffer;
+	PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
+	PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
+	PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
+	PFN_vkFreeMemory vkFreeMemory;
+	PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
+	PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
+	PFN_vkGetDeviceQueue vkGetDeviceQueue;
+	PFN_vkGetEventStatus vkGetEventStatus;
+	PFN_vkGetFenceStatus vkGetFenceStatus;
+	PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
+	PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
+	PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
+	PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
+	PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
+	PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
+	PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
+	PFN_vkMapMemory vkMapMemory;
+	PFN_vkMergePipelineCaches vkMergePipelineCaches;
+	PFN_vkQueueBindSparse vkQueueBindSparse;
+	PFN_vkQueueSubmit vkQueueSubmit;
+	PFN_vkQueueWaitIdle vkQueueWaitIdle;
+	PFN_vkResetCommandBuffer vkResetCommandBuffer;
+	PFN_vkResetCommandPool vkResetCommandPool;
+	PFN_vkResetDescriptorPool vkResetDescriptorPool;
+	PFN_vkResetEvent vkResetEvent;
+	PFN_vkResetFences vkResetFences;
+	PFN_vkSetEvent vkSetEvent;
+	PFN_vkUnmapMemory vkUnmapMemory;
+	PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
+	PFN_vkWaitForFences vkWaitForFences;
+#else
+	PFN_vkVoidFunction padding_6ce80d51[120];
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+	PFN_vkBindBufferMemory2 vkBindBufferMemory2;
+	PFN_vkBindImageMemory2 vkBindImageMemory2;
+	PFN_vkCmdDispatchBase vkCmdDispatchBase;
+	PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask;
+	PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate;
+	PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion;
+	PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate;
+	PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion;
+	PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2;
+	PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport;
+	PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures;
+	PFN_vkGetDeviceQueue2 vkGetDeviceQueue2;
+	PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2;
+	PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2;
+	PFN_vkTrimCommandPool vkTrimCommandPool;
+	PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
+#else
+	PFN_vkVoidFunction padding_1ec56847[16];
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_2)
+	PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
+	PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
+	PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
+	PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
+	PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
+	PFN_vkCreateRenderPass2 vkCreateRenderPass2;
+	PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
+	PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
+	PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
+	PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
+	PFN_vkResetQueryPool vkResetQueryPool;
+	PFN_vkSignalSemaphore vkSignalSemaphore;
+	PFN_vkWaitSemaphores vkWaitSemaphores;
+#else
+	PFN_vkVoidFunction padding_a3e00662[13];
+#endif /* defined(VK_VERSION_1_2) */
+#if defined(VK_VERSION_1_3)
+	PFN_vkCmdBeginRendering vkCmdBeginRendering;
+	PFN_vkCmdBindVertexBuffers2 vkCmdBindVertexBuffers2;
+	PFN_vkCmdBlitImage2 vkCmdBlitImage2;
+	PFN_vkCmdCopyBuffer2 vkCmdCopyBuffer2;
+	PFN_vkCmdCopyBufferToImage2 vkCmdCopyBufferToImage2;
+	PFN_vkCmdCopyImage2 vkCmdCopyImage2;
+	PFN_vkCmdCopyImageToBuffer2 vkCmdCopyImageToBuffer2;
+	PFN_vkCmdEndRendering vkCmdEndRendering;
+	PFN_vkCmdPipelineBarrier2 vkCmdPipelineBarrier2;
+	PFN_vkCmdResetEvent2 vkCmdResetEvent2;
+	PFN_vkCmdResolveImage2 vkCmdResolveImage2;
+	PFN_vkCmdSetCullMode vkCmdSetCullMode;
+	PFN_vkCmdSetDepthBiasEnable vkCmdSetDepthBiasEnable;
+	PFN_vkCmdSetDepthBoundsTestEnable vkCmdSetDepthBoundsTestEnable;
+	PFN_vkCmdSetDepthCompareOp vkCmdSetDepthCompareOp;
+	PFN_vkCmdSetDepthTestEnable vkCmdSetDepthTestEnable;
+	PFN_vkCmdSetDepthWriteEnable vkCmdSetDepthWriteEnable;
+	PFN_vkCmdSetEvent2 vkCmdSetEvent2;
+	PFN_vkCmdSetFrontFace vkCmdSetFrontFace;
+	PFN_vkCmdSetPrimitiveRestartEnable vkCmdSetPrimitiveRestartEnable;
+	PFN_vkCmdSetPrimitiveTopology vkCmdSetPrimitiveTopology;
+	PFN_vkCmdSetRasterizerDiscardEnable vkCmdSetRasterizerDiscardEnable;
+	PFN_vkCmdSetScissorWithCount vkCmdSetScissorWithCount;
+	PFN_vkCmdSetStencilOp vkCmdSetStencilOp;
+	PFN_vkCmdSetStencilTestEnable vkCmdSetStencilTestEnable;
+	PFN_vkCmdSetViewportWithCount vkCmdSetViewportWithCount;
+	PFN_vkCmdWaitEvents2 vkCmdWaitEvents2;
+	PFN_vkCmdWriteTimestamp2 vkCmdWriteTimestamp2;
+	PFN_vkCreatePrivateDataSlot vkCreatePrivateDataSlot;
+	PFN_vkDestroyPrivateDataSlot vkDestroyPrivateDataSlot;
+	PFN_vkGetDeviceBufferMemoryRequirements vkGetDeviceBufferMemoryRequirements;
+	PFN_vkGetDeviceImageMemoryRequirements vkGetDeviceImageMemoryRequirements;
+	PFN_vkGetDeviceImageSparseMemoryRequirements vkGetDeviceImageSparseMemoryRequirements;
+	PFN_vkGetPrivateData vkGetPrivateData;
+	PFN_vkQueueSubmit2 vkQueueSubmit2;
+	PFN_vkSetPrivateData vkSetPrivateData;
+#else
+	PFN_vkVoidFunction padding_ee798a88[36];
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_VERSION_1_4)
+	PFN_vkCmdBindDescriptorSets2 vkCmdBindDescriptorSets2;
+	PFN_vkCmdBindIndexBuffer2 vkCmdBindIndexBuffer2;
+	PFN_vkCmdPushConstants2 vkCmdPushConstants2;
+	PFN_vkCmdPushDescriptorSet vkCmdPushDescriptorSet;
+	PFN_vkCmdPushDescriptorSet2 vkCmdPushDescriptorSet2;
+	PFN_vkCmdPushDescriptorSetWithTemplate vkCmdPushDescriptorSetWithTemplate;
+	PFN_vkCmdPushDescriptorSetWithTemplate2 vkCmdPushDescriptorSetWithTemplate2;
+	PFN_vkCmdSetLineStipple vkCmdSetLineStipple;
+	PFN_vkCmdSetRenderingAttachmentLocations vkCmdSetRenderingAttachmentLocations;
+	PFN_vkCmdSetRenderingInputAttachmentIndices vkCmdSetRenderingInputAttachmentIndices;
+	PFN_vkCopyImageToImage vkCopyImageToImage;
+	PFN_vkCopyImageToMemory vkCopyImageToMemory;
+	PFN_vkCopyMemoryToImage vkCopyMemoryToImage;
+	PFN_vkGetDeviceImageSubresourceLayout vkGetDeviceImageSubresourceLayout;
+	PFN_vkGetImageSubresourceLayout2 vkGetImageSubresourceLayout2;
+	PFN_vkGetRenderingAreaGranularity vkGetRenderingAreaGranularity;
+	PFN_vkMapMemory2 vkMapMemory2;
+	PFN_vkTransitionImageLayout vkTransitionImageLayout;
+	PFN_vkUnmapMemory2 vkUnmapMemory2;
+#else
+	PFN_vkVoidFunction padding_82585fa3[19];
+#endif /* defined(VK_VERSION_1_4) */
+#if defined(VK_AMDX_shader_enqueue)
+	PFN_vkCmdDispatchGraphAMDX vkCmdDispatchGraphAMDX;
+	PFN_vkCmdDispatchGraphIndirectAMDX vkCmdDispatchGraphIndirectAMDX;
+	PFN_vkCmdDispatchGraphIndirectCountAMDX vkCmdDispatchGraphIndirectCountAMDX;
+	PFN_vkCmdInitializeGraphScratchMemoryAMDX vkCmdInitializeGraphScratchMemoryAMDX;
+	PFN_vkCreateExecutionGraphPipelinesAMDX vkCreateExecutionGraphPipelinesAMDX;
+	PFN_vkGetExecutionGraphPipelineNodeIndexAMDX vkGetExecutionGraphPipelineNodeIndexAMDX;
+	PFN_vkGetExecutionGraphPipelineScratchSizeAMDX vkGetExecutionGraphPipelineScratchSizeAMDX;
+#else
+	PFN_vkVoidFunction padding_9d3e2bba[7];
+#endif /* defined(VK_AMDX_shader_enqueue) */
+#if defined(VK_AMD_anti_lag)
+	PFN_vkAntiLagUpdateAMD vkAntiLagUpdateAMD;
+#else
+	PFN_vkVoidFunction padding_cf792fb4[1];
+#endif /* defined(VK_AMD_anti_lag) */
+#if defined(VK_AMD_buffer_marker)
+	PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
+#else
+	PFN_vkVoidFunction padding_7836e92f[1];
+#endif /* defined(VK_AMD_buffer_marker) */
+#if defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	PFN_vkCmdWriteBufferMarker2AMD vkCmdWriteBufferMarker2AMD;
+#else
+	PFN_vkVoidFunction padding_bbf9b7bb[1];
+#endif /* defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_AMD_display_native_hdr)
+	PFN_vkSetLocalDimmingAMD vkSetLocalDimmingAMD;
+#else
+	PFN_vkVoidFunction padding_6b81b2fb[1];
+#endif /* defined(VK_AMD_display_native_hdr) */
+#if defined(VK_AMD_draw_indirect_count)
+	PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD;
+	PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD;
+#else
+	PFN_vkVoidFunction padding_fbfa9964[2];
+#endif /* defined(VK_AMD_draw_indirect_count) */
+#if defined(VK_AMD_gpa_interface)
+	PFN_vkCmdBeginGpaSampleAMD vkCmdBeginGpaSampleAMD;
+	PFN_vkCmdBeginGpaSessionAMD vkCmdBeginGpaSessionAMD;
+	PFN_vkCmdCopyGpaSessionResultsAMD vkCmdCopyGpaSessionResultsAMD;
+	PFN_vkCmdEndGpaSampleAMD vkCmdEndGpaSampleAMD;
+	PFN_vkCmdEndGpaSessionAMD vkCmdEndGpaSessionAMD;
+	PFN_vkCreateGpaSessionAMD vkCreateGpaSessionAMD;
+	PFN_vkDestroyGpaSessionAMD vkDestroyGpaSessionAMD;
+	PFN_vkGetGpaDeviceClockInfoAMD vkGetGpaDeviceClockInfoAMD;
+	PFN_vkGetGpaSessionResultsAMD vkGetGpaSessionResultsAMD;
+	PFN_vkGetGpaSessionStatusAMD vkGetGpaSessionStatusAMD;
+	PFN_vkResetGpaSessionAMD vkResetGpaSessionAMD;
+	PFN_vkSetGpaDeviceClockModeAMD vkSetGpaDeviceClockModeAMD;
+#else
+	PFN_vkVoidFunction padding_56ca082d[12];
+#endif /* defined(VK_AMD_gpa_interface) */
+#if defined(VK_AMD_shader_info)
+	PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD;
+#else
+	PFN_vkVoidFunction padding_bfb754b[1];
+#endif /* defined(VK_AMD_shader_info) */
+#if defined(VK_ANDROID_external_memory_android_hardware_buffer)
+	PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
+	PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
+#else
+	PFN_vkVoidFunction padding_c67b1beb[2];
+#endif /* defined(VK_ANDROID_external_memory_android_hardware_buffer) */
+#if defined(VK_ARM_data_graph)
+	PFN_vkBindDataGraphPipelineSessionMemoryARM vkBindDataGraphPipelineSessionMemoryARM;
+	PFN_vkCmdDispatchDataGraphARM vkCmdDispatchDataGraphARM;
+	PFN_vkCreateDataGraphPipelineSessionARM vkCreateDataGraphPipelineSessionARM;
+	PFN_vkCreateDataGraphPipelinesARM vkCreateDataGraphPipelinesARM;
+	PFN_vkDestroyDataGraphPipelineSessionARM vkDestroyDataGraphPipelineSessionARM;
+	PFN_vkGetDataGraphPipelineAvailablePropertiesARM vkGetDataGraphPipelineAvailablePropertiesARM;
+	PFN_vkGetDataGraphPipelinePropertiesARM vkGetDataGraphPipelinePropertiesARM;
+	PFN_vkGetDataGraphPipelineSessionBindPointRequirementsARM vkGetDataGraphPipelineSessionBindPointRequirementsARM;
+	PFN_vkGetDataGraphPipelineSessionMemoryRequirementsARM vkGetDataGraphPipelineSessionMemoryRequirementsARM;
+#else
+	PFN_vkVoidFunction padding_894d85d8[9];
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2
+	PFN_vkCmdSetDispatchParametersARM vkCmdSetDispatchParametersARM;
+#else
+	PFN_vkVoidFunction padding_4702b278[1];
+#endif /* defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2 */
+#if defined(VK_ARM_shader_instrumentation)
+	PFN_vkClearShaderInstrumentationMetricsARM vkClearShaderInstrumentationMetricsARM;
+	PFN_vkCmdBeginShaderInstrumentationARM vkCmdBeginShaderInstrumentationARM;
+	PFN_vkCmdEndShaderInstrumentationARM vkCmdEndShaderInstrumentationARM;
+	PFN_vkCreateShaderInstrumentationARM vkCreateShaderInstrumentationARM;
+	PFN_vkDestroyShaderInstrumentationARM vkDestroyShaderInstrumentationARM;
+	PFN_vkGetShaderInstrumentationValuesARM vkGetShaderInstrumentationValuesARM;
+#else
+	PFN_vkVoidFunction padding_dcecc311[6];
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+	PFN_vkBindTensorMemoryARM vkBindTensorMemoryARM;
+	PFN_vkCmdCopyTensorARM vkCmdCopyTensorARM;
+	PFN_vkCreateTensorARM vkCreateTensorARM;
+	PFN_vkCreateTensorViewARM vkCreateTensorViewARM;
+	PFN_vkDestroyTensorARM vkDestroyTensorARM;
+	PFN_vkDestroyTensorViewARM vkDestroyTensorViewARM;
+	PFN_vkGetDeviceTensorMemoryRequirementsARM vkGetDeviceTensorMemoryRequirementsARM;
+	PFN_vkGetTensorMemoryRequirementsARM vkGetTensorMemoryRequirementsARM;
+#else
+	PFN_vkVoidFunction padding_df67a729[8];
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer)
+	PFN_vkGetTensorOpaqueCaptureDescriptorDataARM vkGetTensorOpaqueCaptureDescriptorDataARM;
+	PFN_vkGetTensorViewOpaqueCaptureDescriptorDataARM vkGetTensorViewOpaqueCaptureDescriptorDataARM;
+#else
+	PFN_vkVoidFunction padding_9483bf7e[2];
+#endif /* defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_attachment_feedback_loop_dynamic_state)
+	PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT vkCmdSetAttachmentFeedbackLoopEnableEXT;
+#else
+	PFN_vkVoidFunction padding_760a41f5[1];
+#endif /* defined(VK_EXT_attachment_feedback_loop_dynamic_state) */
+#if defined(VK_EXT_buffer_device_address)
+	PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT;
+#else
+	PFN_vkVoidFunction padding_3b69d885[1];
+#endif /* defined(VK_EXT_buffer_device_address) */
+#if defined(VK_EXT_calibrated_timestamps)
+	PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT;
+#else
+	PFN_vkVoidFunction padding_d0981c89[1];
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_color_write_enable)
+	PFN_vkCmdSetColorWriteEnableEXT vkCmdSetColorWriteEnableEXT;
+#else
+	PFN_vkVoidFunction padding_d301ecc3[1];
+#endif /* defined(VK_EXT_color_write_enable) */
+#if defined(VK_EXT_conditional_rendering)
+	PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT;
+	PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT;
+#else
+	PFN_vkVoidFunction padding_ab532c18[2];
+#endif /* defined(VK_EXT_conditional_rendering) */
+#if defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3))
+	PFN_vkCmdBeginCustomResolveEXT vkCmdBeginCustomResolveEXT;
+#else
+	PFN_vkVoidFunction padding_962e418a[1];
+#endif /* defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3)) */
+#if defined(VK_EXT_debug_marker)
+	PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT;
+	PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT;
+	PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT;
+	PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT;
+	PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT;
+#else
+	PFN_vkVoidFunction padding_89986968[5];
+#endif /* defined(VK_EXT_debug_marker) */
+#if defined(VK_EXT_depth_bias_control)
+	PFN_vkCmdSetDepthBias2EXT vkCmdSetDepthBias2EXT;
+#else
+	PFN_vkVoidFunction padding_bcddab4d[1];
+#endif /* defined(VK_EXT_depth_bias_control) */
+#if defined(VK_EXT_descriptor_buffer)
+	PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT vkCmdBindDescriptorBufferEmbeddedSamplersEXT;
+	PFN_vkCmdBindDescriptorBuffersEXT vkCmdBindDescriptorBuffersEXT;
+	PFN_vkCmdSetDescriptorBufferOffsetsEXT vkCmdSetDescriptorBufferOffsetsEXT;
+	PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT vkGetBufferOpaqueCaptureDescriptorDataEXT;
+	PFN_vkGetDescriptorEXT vkGetDescriptorEXT;
+	PFN_vkGetDescriptorSetLayoutBindingOffsetEXT vkGetDescriptorSetLayoutBindingOffsetEXT;
+	PFN_vkGetDescriptorSetLayoutSizeEXT vkGetDescriptorSetLayoutSizeEXT;
+	PFN_vkGetImageOpaqueCaptureDescriptorDataEXT vkGetImageOpaqueCaptureDescriptorDataEXT;
+	PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT vkGetImageViewOpaqueCaptureDescriptorDataEXT;
+	PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT vkGetSamplerOpaqueCaptureDescriptorDataEXT;
+#else
+	PFN_vkVoidFunction padding_80aa973c[10];
+#endif /* defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing))
+	PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT;
+#else
+	PFN_vkVoidFunction padding_98d0fb33[1];
+#endif /* defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing)) */
+#if defined(VK_EXT_descriptor_heap)
+	PFN_vkCmdBindResourceHeapEXT vkCmdBindResourceHeapEXT;
+	PFN_vkCmdBindSamplerHeapEXT vkCmdBindSamplerHeapEXT;
+	PFN_vkCmdPushDataEXT vkCmdPushDataEXT;
+	PFN_vkGetImageOpaqueCaptureDataEXT vkGetImageOpaqueCaptureDataEXT;
+	PFN_vkWriteResourceDescriptorsEXT vkWriteResourceDescriptorsEXT;
+	PFN_vkWriteSamplerDescriptorsEXT vkWriteSamplerDescriptorsEXT;
+#else
+	PFN_vkVoidFunction padding_a061cda9[6];
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color)
+	PFN_vkRegisterCustomBorderColorEXT vkRegisterCustomBorderColorEXT;
+	PFN_vkUnregisterCustomBorderColorEXT vkUnregisterCustomBorderColorEXT;
+#else
+	PFN_vkVoidFunction padding_7b7ddcfe[2];
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors)
+	PFN_vkGetTensorOpaqueCaptureDataARM vkGetTensorOpaqueCaptureDataARM;
+#else
+	PFN_vkVoidFunction padding_533712c5[1];
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors) */
+#if defined(VK_EXT_device_fault)
+	PFN_vkGetDeviceFaultInfoEXT vkGetDeviceFaultInfoEXT;
+#else
+	PFN_vkVoidFunction padding_55095419[1];
+#endif /* defined(VK_EXT_device_fault) */
+#if defined(VK_EXT_device_generated_commands)
+	PFN_vkCmdExecuteGeneratedCommandsEXT vkCmdExecuteGeneratedCommandsEXT;
+	PFN_vkCmdPreprocessGeneratedCommandsEXT vkCmdPreprocessGeneratedCommandsEXT;
+	PFN_vkCreateIndirectCommandsLayoutEXT vkCreateIndirectCommandsLayoutEXT;
+	PFN_vkCreateIndirectExecutionSetEXT vkCreateIndirectExecutionSetEXT;
+	PFN_vkDestroyIndirectCommandsLayoutEXT vkDestroyIndirectCommandsLayoutEXT;
+	PFN_vkDestroyIndirectExecutionSetEXT vkDestroyIndirectExecutionSetEXT;
+	PFN_vkGetGeneratedCommandsMemoryRequirementsEXT vkGetGeneratedCommandsMemoryRequirementsEXT;
+	PFN_vkUpdateIndirectExecutionSetPipelineEXT vkUpdateIndirectExecutionSetPipelineEXT;
+	PFN_vkUpdateIndirectExecutionSetShaderEXT vkUpdateIndirectExecutionSetShaderEXT;
+#else
+	PFN_vkVoidFunction padding_7ba7ebaa[9];
+#endif /* defined(VK_EXT_device_generated_commands) */
+#if defined(VK_EXT_discard_rectangles)
+	PFN_vkCmdSetDiscardRectangleEXT vkCmdSetDiscardRectangleEXT;
+#else
+	PFN_vkVoidFunction padding_d6355c2[1];
+#endif /* defined(VK_EXT_discard_rectangles) */
+#if defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2
+	PFN_vkCmdSetDiscardRectangleEnableEXT vkCmdSetDiscardRectangleEnableEXT;
+	PFN_vkCmdSetDiscardRectangleModeEXT vkCmdSetDiscardRectangleModeEXT;
+#else
+	PFN_vkVoidFunction padding_7bb44f77[2];
+#endif /* defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2 */
+#if defined(VK_EXT_display_control)
+	PFN_vkDisplayPowerControlEXT vkDisplayPowerControlEXT;
+	PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT;
+	PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT;
+	PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT;
+#else
+	PFN_vkVoidFunction padding_d30dfaaf[4];
+#endif /* defined(VK_EXT_display_control) */
+#if defined(VK_EXT_external_memory_host)
+	PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_357656e9[1];
+#endif /* defined(VK_EXT_external_memory_host) */
+#if defined(VK_EXT_external_memory_metal)
+	PFN_vkGetMemoryMetalHandleEXT vkGetMemoryMetalHandleEXT;
+	PFN_vkGetMemoryMetalHandlePropertiesEXT vkGetMemoryMetalHandlePropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_37d43fb[2];
+#endif /* defined(VK_EXT_external_memory_metal) */
+#if defined(VK_EXT_fragment_density_map_offset)
+	PFN_vkCmdEndRendering2EXT vkCmdEndRendering2EXT;
+#else
+	PFN_vkVoidFunction padding_9c90cf11[1];
+#endif /* defined(VK_EXT_fragment_density_map_offset) */
+#if defined(VK_EXT_full_screen_exclusive)
+	PFN_vkAcquireFullScreenExclusiveModeEXT vkAcquireFullScreenExclusiveModeEXT;
+	PFN_vkReleaseFullScreenExclusiveModeEXT vkReleaseFullScreenExclusiveModeEXT;
+#else
+	PFN_vkVoidFunction padding_3859df46[2];
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1))
+	PFN_vkGetDeviceGroupSurfacePresentModes2EXT vkGetDeviceGroupSurfacePresentModes2EXT;
+#else
+	PFN_vkVoidFunction padding_e5b48b5b[1];
+#endif /* defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1)) */
+#if defined(VK_EXT_hdr_metadata)
+	PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT;
+#else
+	PFN_vkVoidFunction padding_ca6d733c[1];
+#endif /* defined(VK_EXT_hdr_metadata) */
+#if defined(VK_EXT_host_image_copy)
+	PFN_vkCopyImageToImageEXT vkCopyImageToImageEXT;
+	PFN_vkCopyImageToMemoryEXT vkCopyImageToMemoryEXT;
+	PFN_vkCopyMemoryToImageEXT vkCopyMemoryToImageEXT;
+	PFN_vkTransitionImageLayoutEXT vkTransitionImageLayoutEXT;
+#else
+	PFN_vkVoidFunction padding_dd6d9b61[4];
+#endif /* defined(VK_EXT_host_image_copy) */
+#if defined(VK_EXT_host_query_reset)
+	PFN_vkResetQueryPoolEXT vkResetQueryPoolEXT;
+#else
+	PFN_vkVoidFunction padding_34e58bd3[1];
+#endif /* defined(VK_EXT_host_query_reset) */
+#if defined(VK_EXT_image_drm_format_modifier)
+	PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_eb50dc14[1];
+#endif /* defined(VK_EXT_image_drm_format_modifier) */
+#if defined(VK_EXT_line_rasterization)
+	PFN_vkCmdSetLineStippleEXT vkCmdSetLineStippleEXT;
+#else
+	PFN_vkVoidFunction padding_8a212c37[1];
+#endif /* defined(VK_EXT_line_rasterization) */
+#if defined(VK_EXT_memory_decompression)
+	PFN_vkCmdDecompressMemoryEXT vkCmdDecompressMemoryEXT;
+	PFN_vkCmdDecompressMemoryIndirectCountEXT vkCmdDecompressMemoryIndirectCountEXT;
+#else
+	PFN_vkVoidFunction padding_c3b649ee[2];
+#endif /* defined(VK_EXT_memory_decompression) */
+#if defined(VK_EXT_mesh_shader)
+	PFN_vkCmdDrawMeshTasksEXT vkCmdDrawMeshTasksEXT;
+	PFN_vkCmdDrawMeshTasksIndirectEXT vkCmdDrawMeshTasksIndirectEXT;
+#else
+	PFN_vkVoidFunction padding_f65e838[2];
+#endif /* defined(VK_EXT_mesh_shader) */
+#if defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	PFN_vkCmdDrawMeshTasksIndirectCountEXT vkCmdDrawMeshTasksIndirectCountEXT;
+#else
+	PFN_vkVoidFunction padding_dcbaac2f[1];
+#endif /* defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_EXT_metal_objects)
+	PFN_vkExportMetalObjectsEXT vkExportMetalObjectsEXT;
+#else
+	PFN_vkVoidFunction padding_df21f735[1];
+#endif /* defined(VK_EXT_metal_objects) */
+#if defined(VK_EXT_multi_draw)
+	PFN_vkCmdDrawMultiEXT vkCmdDrawMultiEXT;
+	PFN_vkCmdDrawMultiIndexedEXT vkCmdDrawMultiIndexedEXT;
+#else
+	PFN_vkVoidFunction padding_ce8b93b6[2];
+#endif /* defined(VK_EXT_multi_draw) */
+#if defined(VK_EXT_opacity_micromap)
+	PFN_vkBuildMicromapsEXT vkBuildMicromapsEXT;
+	PFN_vkCmdBuildMicromapsEXT vkCmdBuildMicromapsEXT;
+	PFN_vkCmdCopyMemoryToMicromapEXT vkCmdCopyMemoryToMicromapEXT;
+	PFN_vkCmdCopyMicromapEXT vkCmdCopyMicromapEXT;
+	PFN_vkCmdCopyMicromapToMemoryEXT vkCmdCopyMicromapToMemoryEXT;
+	PFN_vkCmdWriteMicromapsPropertiesEXT vkCmdWriteMicromapsPropertiesEXT;
+	PFN_vkCopyMemoryToMicromapEXT vkCopyMemoryToMicromapEXT;
+	PFN_vkCopyMicromapEXT vkCopyMicromapEXT;
+	PFN_vkCopyMicromapToMemoryEXT vkCopyMicromapToMemoryEXT;
+	PFN_vkCreateMicromapEXT vkCreateMicromapEXT;
+	PFN_vkDestroyMicromapEXT vkDestroyMicromapEXT;
+	PFN_vkGetDeviceMicromapCompatibilityEXT vkGetDeviceMicromapCompatibilityEXT;
+	PFN_vkGetMicromapBuildSizesEXT vkGetMicromapBuildSizesEXT;
+	PFN_vkWriteMicromapsPropertiesEXT vkWriteMicromapsPropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_fa41e53c[14];
+#endif /* defined(VK_EXT_opacity_micromap) */
+#if defined(VK_EXT_pageable_device_local_memory)
+	PFN_vkSetDeviceMemoryPriorityEXT vkSetDeviceMemoryPriorityEXT;
+#else
+	PFN_vkVoidFunction padding_b2d2c2d7[1];
+#endif /* defined(VK_EXT_pageable_device_local_memory) */
+#if defined(VK_EXT_pipeline_properties)
+	PFN_vkGetPipelinePropertiesEXT vkGetPipelinePropertiesEXT;
+#else
+	PFN_vkVoidFunction padding_11313020[1];
+#endif /* defined(VK_EXT_pipeline_properties) */
+#if defined(VK_EXT_present_timing)
+	PFN_vkGetPastPresentationTimingEXT vkGetPastPresentationTimingEXT;
+	PFN_vkGetSwapchainTimeDomainPropertiesEXT vkGetSwapchainTimeDomainPropertiesEXT;
+	PFN_vkGetSwapchainTimingPropertiesEXT vkGetSwapchainTimingPropertiesEXT;
+	PFN_vkSetSwapchainPresentTimingQueueSizeEXT vkSetSwapchainPresentTimingQueueSizeEXT;
+#else
+	PFN_vkVoidFunction padding_8751feb5[4];
+#endif /* defined(VK_EXT_present_timing) */
+#if defined(VK_EXT_primitive_restart_index)
+	PFN_vkCmdSetPrimitiveRestartIndexEXT vkCmdSetPrimitiveRestartIndexEXT;
+#else
+	PFN_vkVoidFunction padding_a1770b32[1];
+#endif /* defined(VK_EXT_primitive_restart_index) */
+#if defined(VK_EXT_private_data)
+	PFN_vkCreatePrivateDataSlotEXT vkCreatePrivateDataSlotEXT;
+	PFN_vkDestroyPrivateDataSlotEXT vkDestroyPrivateDataSlotEXT;
+	PFN_vkGetPrivateDataEXT vkGetPrivateDataEXT;
+	PFN_vkSetPrivateDataEXT vkSetPrivateDataEXT;
+#else
+	PFN_vkVoidFunction padding_108010f[4];
+#endif /* defined(VK_EXT_private_data) */
+#if defined(VK_EXT_sample_locations)
+	PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT;
+#else
+	PFN_vkVoidFunction padding_26f9079f[1];
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_shader_module_identifier)
+	PFN_vkGetShaderModuleCreateInfoIdentifierEXT vkGetShaderModuleCreateInfoIdentifierEXT;
+	PFN_vkGetShaderModuleIdentifierEXT vkGetShaderModuleIdentifierEXT;
+#else
+	PFN_vkVoidFunction padding_e10c8f86[2];
+#endif /* defined(VK_EXT_shader_module_identifier) */
+#if defined(VK_EXT_shader_object)
+	PFN_vkCmdBindShadersEXT vkCmdBindShadersEXT;
+	PFN_vkCreateShadersEXT vkCreateShadersEXT;
+	PFN_vkDestroyShaderEXT vkDestroyShaderEXT;
+	PFN_vkGetShaderBinaryDataEXT vkGetShaderBinaryDataEXT;
+#else
+	PFN_vkVoidFunction padding_374f3e18[4];
+#endif /* defined(VK_EXT_shader_object) */
+#if defined(VK_EXT_swapchain_maintenance1)
+	PFN_vkReleaseSwapchainImagesEXT vkReleaseSwapchainImagesEXT;
+#else
+	PFN_vkVoidFunction padding_ea55bf74[1];
+#endif /* defined(VK_EXT_swapchain_maintenance1) */
+#if defined(VK_EXT_transform_feedback)
+	PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT;
+	PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT;
+	PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT;
+	PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT;
+	PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT;
+	PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT;
+#else
+	PFN_vkVoidFunction padding_36980658[6];
+#endif /* defined(VK_EXT_transform_feedback) */
+#if defined(VK_EXT_validation_cache)
+	PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT;
+	PFN_vkDestroyValidationCacheEXT vkDestroyValidationCacheEXT;
+	PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT;
+	PFN_vkMergeValidationCachesEXT vkMergeValidationCachesEXT;
+#else
+	PFN_vkVoidFunction padding_b4f2df29[4];
+#endif /* defined(VK_EXT_validation_cache) */
+#if defined(VK_FUCHSIA_buffer_collection)
+	PFN_vkCreateBufferCollectionFUCHSIA vkCreateBufferCollectionFUCHSIA;
+	PFN_vkDestroyBufferCollectionFUCHSIA vkDestroyBufferCollectionFUCHSIA;
+	PFN_vkGetBufferCollectionPropertiesFUCHSIA vkGetBufferCollectionPropertiesFUCHSIA;
+	PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA vkSetBufferCollectionBufferConstraintsFUCHSIA;
+	PFN_vkSetBufferCollectionImageConstraintsFUCHSIA vkSetBufferCollectionImageConstraintsFUCHSIA;
+#else
+	PFN_vkVoidFunction padding_8eaa27bc[5];
+#endif /* defined(VK_FUCHSIA_buffer_collection) */
+#if defined(VK_FUCHSIA_external_memory)
+	PFN_vkGetMemoryZirconHandleFUCHSIA vkGetMemoryZirconHandleFUCHSIA;
+	PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA vkGetMemoryZirconHandlePropertiesFUCHSIA;
+#else
+	PFN_vkVoidFunction padding_e3cb8a67[2];
+#endif /* defined(VK_FUCHSIA_external_memory) */
+#if defined(VK_FUCHSIA_external_semaphore)
+	PFN_vkGetSemaphoreZirconHandleFUCHSIA vkGetSemaphoreZirconHandleFUCHSIA;
+	PFN_vkImportSemaphoreZirconHandleFUCHSIA vkImportSemaphoreZirconHandleFUCHSIA;
+#else
+	PFN_vkVoidFunction padding_3df6f656[2];
+#endif /* defined(VK_FUCHSIA_external_semaphore) */
+#if defined(VK_GOOGLE_display_timing)
+	PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE;
+	PFN_vkGetRefreshCycleDurationGOOGLE vkGetRefreshCycleDurationGOOGLE;
+#else
+	PFN_vkVoidFunction padding_2a6f50cd[2];
+#endif /* defined(VK_GOOGLE_display_timing) */
+#if defined(VK_HUAWEI_cluster_culling_shader)
+	PFN_vkCmdDrawClusterHUAWEI vkCmdDrawClusterHUAWEI;
+	PFN_vkCmdDrawClusterIndirectHUAWEI vkCmdDrawClusterIndirectHUAWEI;
+#else
+	PFN_vkVoidFunction padding_75b97be6[2];
+#endif /* defined(VK_HUAWEI_cluster_culling_shader) */
+#if defined(VK_HUAWEI_invocation_mask)
+	PFN_vkCmdBindInvocationMaskHUAWEI vkCmdBindInvocationMaskHUAWEI;
+#else
+	PFN_vkVoidFunction padding_c3a4569f[1];
+#endif /* defined(VK_HUAWEI_invocation_mask) */
+#if defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2
+	PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI;
+#else
+	PFN_vkVoidFunction padding_2e923f32[1];
+#endif /* defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2 */
+#if defined(VK_HUAWEI_subpass_shading)
+	PFN_vkCmdSubpassShadingHUAWEI vkCmdSubpassShadingHUAWEI;
+#else
+	PFN_vkVoidFunction padding_f766fdf5[1];
+#endif /* defined(VK_HUAWEI_subpass_shading) */
+#if defined(VK_INTEL_performance_query)
+	PFN_vkAcquirePerformanceConfigurationINTEL vkAcquirePerformanceConfigurationINTEL;
+	PFN_vkCmdSetPerformanceMarkerINTEL vkCmdSetPerformanceMarkerINTEL;
+	PFN_vkCmdSetPerformanceOverrideINTEL vkCmdSetPerformanceOverrideINTEL;
+	PFN_vkCmdSetPerformanceStreamMarkerINTEL vkCmdSetPerformanceStreamMarkerINTEL;
+	PFN_vkGetPerformanceParameterINTEL vkGetPerformanceParameterINTEL;
+	PFN_vkInitializePerformanceApiINTEL vkInitializePerformanceApiINTEL;
+	PFN_vkQueueSetPerformanceConfigurationINTEL vkQueueSetPerformanceConfigurationINTEL;
+	PFN_vkReleasePerformanceConfigurationINTEL vkReleasePerformanceConfigurationINTEL;
+	PFN_vkUninitializePerformanceApiINTEL vkUninitializePerformanceApiINTEL;
+#else
+	PFN_vkVoidFunction padding_495a0a0b[9];
+#endif /* defined(VK_INTEL_performance_query) */
+#if defined(VK_KHR_acceleration_structure)
+	PFN_vkBuildAccelerationStructuresKHR vkBuildAccelerationStructuresKHR;
+	PFN_vkCmdBuildAccelerationStructuresIndirectKHR vkCmdBuildAccelerationStructuresIndirectKHR;
+	PFN_vkCmdBuildAccelerationStructuresKHR vkCmdBuildAccelerationStructuresKHR;
+	PFN_vkCmdCopyAccelerationStructureKHR vkCmdCopyAccelerationStructureKHR;
+	PFN_vkCmdCopyAccelerationStructureToMemoryKHR vkCmdCopyAccelerationStructureToMemoryKHR;
+	PFN_vkCmdCopyMemoryToAccelerationStructureKHR vkCmdCopyMemoryToAccelerationStructureKHR;
+	PFN_vkCmdWriteAccelerationStructuresPropertiesKHR vkCmdWriteAccelerationStructuresPropertiesKHR;
+	PFN_vkCopyAccelerationStructureKHR vkCopyAccelerationStructureKHR;
+	PFN_vkCopyAccelerationStructureToMemoryKHR vkCopyAccelerationStructureToMemoryKHR;
+	PFN_vkCopyMemoryToAccelerationStructureKHR vkCopyMemoryToAccelerationStructureKHR;
+	PFN_vkCreateAccelerationStructureKHR vkCreateAccelerationStructureKHR;
+	PFN_vkDestroyAccelerationStructureKHR vkDestroyAccelerationStructureKHR;
+	PFN_vkGetAccelerationStructureBuildSizesKHR vkGetAccelerationStructureBuildSizesKHR;
+	PFN_vkGetAccelerationStructureDeviceAddressKHR vkGetAccelerationStructureDeviceAddressKHR;
+	PFN_vkGetDeviceAccelerationStructureCompatibilityKHR vkGetDeviceAccelerationStructureCompatibilityKHR;
+	PFN_vkWriteAccelerationStructuresPropertiesKHR vkWriteAccelerationStructuresPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_5a999b78[16];
+#endif /* defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_bind_memory2)
+	PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
+	PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
+#else
+	PFN_vkVoidFunction padding_ed8481f5[2];
+#endif /* defined(VK_KHR_bind_memory2) */
+#if defined(VK_KHR_buffer_device_address)
+	PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
+	PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
+	PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
+#else
+	PFN_vkVoidFunction padding_178fdf81[3];
+#endif /* defined(VK_KHR_buffer_device_address) */
+#if defined(VK_KHR_calibrated_timestamps)
+	PFN_vkGetCalibratedTimestampsKHR vkGetCalibratedTimestampsKHR;
+#else
+	PFN_vkVoidFunction padding_8fd6f40d[1];
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_copy_commands2)
+	PFN_vkCmdBlitImage2KHR vkCmdBlitImage2KHR;
+	PFN_vkCmdCopyBuffer2KHR vkCmdCopyBuffer2KHR;
+	PFN_vkCmdCopyBufferToImage2KHR vkCmdCopyBufferToImage2KHR;
+	PFN_vkCmdCopyImage2KHR vkCmdCopyImage2KHR;
+	PFN_vkCmdCopyImageToBuffer2KHR vkCmdCopyImageToBuffer2KHR;
+	PFN_vkCmdResolveImage2KHR vkCmdResolveImage2KHR;
+#else
+	PFN_vkVoidFunction padding_4c841ff2[6];
+#endif /* defined(VK_KHR_copy_commands2) */
+#if defined(VK_KHR_copy_memory_indirect)
+	PFN_vkCmdCopyMemoryIndirectKHR vkCmdCopyMemoryIndirectKHR;
+	PFN_vkCmdCopyMemoryToImageIndirectKHR vkCmdCopyMemoryToImageIndirectKHR;
+#else
+	PFN_vkVoidFunction padding_95995957[2];
+#endif /* defined(VK_KHR_copy_memory_indirect) */
+#if defined(VK_KHR_create_renderpass2)
+	PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
+	PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
+	PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR;
+	PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR;
+#else
+	PFN_vkVoidFunction padding_2a0a8727[4];
+#endif /* defined(VK_KHR_create_renderpass2) */
+#if defined(VK_KHR_deferred_host_operations)
+	PFN_vkCreateDeferredOperationKHR vkCreateDeferredOperationKHR;
+	PFN_vkDeferredOperationJoinKHR vkDeferredOperationJoinKHR;
+	PFN_vkDestroyDeferredOperationKHR vkDestroyDeferredOperationKHR;
+	PFN_vkGetDeferredOperationMaxConcurrencyKHR vkGetDeferredOperationMaxConcurrencyKHR;
+	PFN_vkGetDeferredOperationResultKHR vkGetDeferredOperationResultKHR;
+#else
+	PFN_vkVoidFunction padding_346287bb[5];
+#endif /* defined(VK_KHR_deferred_host_operations) */
+#if defined(VK_KHR_descriptor_update_template)
+	PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR;
+	PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR;
+	PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR;
+#else
+	PFN_vkVoidFunction padding_3d63aec0[3];
+#endif /* defined(VK_KHR_descriptor_update_template) */
+#if defined(VK_KHR_device_address_commands)
+	PFN_vkCmdBindIndexBuffer3KHR vkCmdBindIndexBuffer3KHR;
+	PFN_vkCmdBindVertexBuffers3KHR vkCmdBindVertexBuffers3KHR;
+	PFN_vkCmdCopyImageToMemoryKHR vkCmdCopyImageToMemoryKHR;
+	PFN_vkCmdCopyMemoryKHR vkCmdCopyMemoryKHR;
+	PFN_vkCmdCopyMemoryToImageKHR vkCmdCopyMemoryToImageKHR;
+	PFN_vkCmdCopyQueryPoolResultsToMemoryKHR vkCmdCopyQueryPoolResultsToMemoryKHR;
+	PFN_vkCmdDispatchIndirect2KHR vkCmdDispatchIndirect2KHR;
+	PFN_vkCmdDrawIndexedIndirect2KHR vkCmdDrawIndexedIndirect2KHR;
+	PFN_vkCmdDrawIndirect2KHR vkCmdDrawIndirect2KHR;
+	PFN_vkCmdFillMemoryKHR vkCmdFillMemoryKHR;
+	PFN_vkCmdUpdateMemoryKHR vkCmdUpdateMemoryKHR;
+#else
+	PFN_vkVoidFunction padding_2b90e4ce[11];
+#endif /* defined(VK_KHR_device_address_commands) */
+#if defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2))
+	PFN_vkCmdDrawIndexedIndirectCount2KHR vkCmdDrawIndexedIndirectCount2KHR;
+	PFN_vkCmdDrawIndirectCount2KHR vkCmdDrawIndirectCount2KHR;
+#else
+	PFN_vkVoidFunction padding_7a492754[2];
+#endif /* defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering)
+	PFN_vkCmdBeginConditionalRendering2EXT vkCmdBeginConditionalRendering2EXT;
+#else
+	PFN_vkVoidFunction padding_f9bf440[1];
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback)
+	PFN_vkCmdBeginTransformFeedback2EXT vkCmdBeginTransformFeedback2EXT;
+	PFN_vkCmdBindTransformFeedbackBuffers2EXT vkCmdBindTransformFeedbackBuffers2EXT;
+	PFN_vkCmdDrawIndirectByteCount2EXT vkCmdDrawIndirectByteCount2EXT;
+	PFN_vkCmdEndTransformFeedback2EXT vkCmdEndTransformFeedback2EXT;
+#else
+	PFN_vkVoidFunction padding_2d72d440[4];
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader)
+	PFN_vkCmdDrawMeshTasksIndirect2EXT vkCmdDrawMeshTasksIndirect2EXT;
+#else
+	PFN_vkVoidFunction padding_4e6fc3d1[1];
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader) */
+#if defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader))
+	PFN_vkCmdDrawMeshTasksIndirectCount2EXT vkCmdDrawMeshTasksIndirectCount2EXT;
+#else
+	PFN_vkVoidFunction padding_5dc290cb[1];
+#endif /* defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker)
+	PFN_vkCmdWriteMarkerToMemoryAMD vkCmdWriteMarkerToMemoryAMD;
+#else
+	PFN_vkVoidFunction padding_140dbb45[1];
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure)
+	PFN_vkCreateAccelerationStructure2KHR vkCreateAccelerationStructure2KHR;
+#else
+	PFN_vkVoidFunction padding_2564889a[1];
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_device_fault)
+	PFN_vkGetDeviceFaultDebugInfoKHR vkGetDeviceFaultDebugInfoKHR;
+	PFN_vkGetDeviceFaultReportsKHR vkGetDeviceFaultReportsKHR;
+#else
+	PFN_vkVoidFunction padding_d83e9289[2];
+#endif /* defined(VK_KHR_device_fault) */
+#if defined(VK_KHR_device_group)
+	PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR;
+	PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR;
+	PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR;
+#else
+	PFN_vkVoidFunction padding_5ebe16bd[3];
+#endif /* defined(VK_KHR_device_group) */
+#if defined(VK_KHR_display_swapchain)
+	PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
+#else
+	PFN_vkVoidFunction padding_12099367[1];
+#endif /* defined(VK_KHR_display_swapchain) */
+#if defined(VK_KHR_draw_indirect_count)
+	PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR;
+	PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR;
+#else
+	PFN_vkVoidFunction padding_7b5bc4c1[2];
+#endif /* defined(VK_KHR_draw_indirect_count) */
+#if defined(VK_KHR_dynamic_rendering)
+	PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
+	PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
+#else
+	PFN_vkVoidFunction padding_b80f75a5[2];
+#endif /* defined(VK_KHR_dynamic_rendering) */
+#if defined(VK_KHR_dynamic_rendering_local_read)
+	PFN_vkCmdSetRenderingAttachmentLocationsKHR vkCmdSetRenderingAttachmentLocationsKHR;
+	PFN_vkCmdSetRenderingInputAttachmentIndicesKHR vkCmdSetRenderingInputAttachmentIndicesKHR;
+#else
+	PFN_vkVoidFunction padding_b1510532[2];
+#endif /* defined(VK_KHR_dynamic_rendering_local_read) */
+#if defined(VK_KHR_external_fence_fd)
+	PFN_vkGetFenceFdKHR vkGetFenceFdKHR;
+	PFN_vkImportFenceFdKHR vkImportFenceFdKHR;
+#else
+	PFN_vkVoidFunction padding_a2c787d5[2];
+#endif /* defined(VK_KHR_external_fence_fd) */
+#if defined(VK_KHR_external_fence_win32)
+	PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR;
+	PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR;
+#else
+	PFN_vkVoidFunction padding_55d8e6a9[2];
+#endif /* defined(VK_KHR_external_fence_win32) */
+#if defined(VK_KHR_external_memory_fd)
+	PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR;
+	PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_982d9e19[2];
+#endif /* defined(VK_KHR_external_memory_fd) */
+#if defined(VK_KHR_external_memory_win32)
+	PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR;
+	PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR;
+#else
+	PFN_vkVoidFunction padding_4af9e25a[2];
+#endif /* defined(VK_KHR_external_memory_win32) */
+#if defined(VK_KHR_external_semaphore_fd)
+	PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
+	PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
+#else
+	PFN_vkVoidFunction padding_2237b7cf[2];
+#endif /* defined(VK_KHR_external_semaphore_fd) */
+#if defined(VK_KHR_external_semaphore_win32)
+	PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR;
+	PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR;
+#else
+	PFN_vkVoidFunction padding_c18dea52[2];
+#endif /* defined(VK_KHR_external_semaphore_win32) */
+#if defined(VK_KHR_fragment_shading_rate)
+	PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR;
+#else
+	PFN_vkVoidFunction padding_f91b0a90[1];
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_memory_requirements2)
+	PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
+	PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
+	PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR;
+#else
+	PFN_vkVoidFunction padding_79d9c5c4[3];
+#endif /* defined(VK_KHR_get_memory_requirements2) */
+#if defined(VK_KHR_line_rasterization)
+	PFN_vkCmdSetLineStippleKHR vkCmdSetLineStippleKHR;
+#else
+	PFN_vkVoidFunction padding_83c2939[1];
+#endif /* defined(VK_KHR_line_rasterization) */
+#if defined(VK_KHR_maintenance1)
+	PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
+#else
+	PFN_vkVoidFunction padding_4b372c56[1];
+#endif /* defined(VK_KHR_maintenance1) */
+#if defined(VK_KHR_maintenance10)
+	PFN_vkCmdEndRendering2KHR vkCmdEndRendering2KHR;
+#else
+	PFN_vkVoidFunction padding_c866e6ce[1];
+#endif /* defined(VK_KHR_maintenance10) */
+#if defined(VK_KHR_maintenance3)
+	PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
+#else
+	PFN_vkVoidFunction padding_5ea7858d[1];
+#endif /* defined(VK_KHR_maintenance3) */
+#if defined(VK_KHR_maintenance4)
+	PFN_vkGetDeviceBufferMemoryRequirementsKHR vkGetDeviceBufferMemoryRequirementsKHR;
+	PFN_vkGetDeviceImageMemoryRequirementsKHR vkGetDeviceImageMemoryRequirementsKHR;
+	PFN_vkGetDeviceImageSparseMemoryRequirementsKHR vkGetDeviceImageSparseMemoryRequirementsKHR;
+#else
+	PFN_vkVoidFunction padding_8e2d4198[3];
+#endif /* defined(VK_KHR_maintenance4) */
+#if defined(VK_KHR_maintenance5)
+	PFN_vkCmdBindIndexBuffer2KHR vkCmdBindIndexBuffer2KHR;
+	PFN_vkGetDeviceImageSubresourceLayoutKHR vkGetDeviceImageSubresourceLayoutKHR;
+	PFN_vkGetImageSubresourceLayout2KHR vkGetImageSubresourceLayout2KHR;
+	PFN_vkGetRenderingAreaGranularityKHR vkGetRenderingAreaGranularityKHR;
+#else
+	PFN_vkVoidFunction padding_37040339[4];
+#endif /* defined(VK_KHR_maintenance5) */
+#if defined(VK_KHR_maintenance6)
+	PFN_vkCmdBindDescriptorSets2KHR vkCmdBindDescriptorSets2KHR;
+	PFN_vkCmdPushConstants2KHR vkCmdPushConstants2KHR;
+#else
+	PFN_vkVoidFunction padding_442955d8[2];
+#endif /* defined(VK_KHR_maintenance6) */
+#if defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor)
+	PFN_vkCmdPushDescriptorSet2KHR vkCmdPushDescriptorSet2KHR;
+	PFN_vkCmdPushDescriptorSetWithTemplate2KHR vkCmdPushDescriptorSetWithTemplate2KHR;
+#else
+	PFN_vkVoidFunction padding_80e8513f[2];
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer)
+	PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT vkCmdBindDescriptorBufferEmbeddedSamplers2EXT;
+	PFN_vkCmdSetDescriptorBufferOffsets2EXT vkCmdSetDescriptorBufferOffsets2EXT;
+#else
+	PFN_vkVoidFunction padding_2816b9cd[2];
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_KHR_map_memory2)
+	PFN_vkMapMemory2KHR vkMapMemory2KHR;
+	PFN_vkUnmapMemory2KHR vkUnmapMemory2KHR;
+#else
+	PFN_vkVoidFunction padding_5a6d8986[2];
+#endif /* defined(VK_KHR_map_memory2) */
+#if defined(VK_KHR_performance_query)
+	PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
+	PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
+#else
+	PFN_vkVoidFunction padding_76f2673b[2];
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_pipeline_binary)
+	PFN_vkCreatePipelineBinariesKHR vkCreatePipelineBinariesKHR;
+	PFN_vkDestroyPipelineBinaryKHR vkDestroyPipelineBinaryKHR;
+	PFN_vkGetPipelineBinaryDataKHR vkGetPipelineBinaryDataKHR;
+	PFN_vkGetPipelineKeyKHR vkGetPipelineKeyKHR;
+	PFN_vkReleaseCapturedPipelineDataKHR vkReleaseCapturedPipelineDataKHR;
+#else
+	PFN_vkVoidFunction padding_65232810[5];
+#endif /* defined(VK_KHR_pipeline_binary) */
+#if defined(VK_KHR_pipeline_executable_properties)
+	PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
+	PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
+	PFN_vkGetPipelineExecutableStatisticsKHR vkGetPipelineExecutableStatisticsKHR;
+#else
+	PFN_vkVoidFunction padding_f7629b1e[3];
+#endif /* defined(VK_KHR_pipeline_executable_properties) */
+#if defined(VK_KHR_present_wait)
+	PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
+#else
+	PFN_vkVoidFunction padding_b16cbe03[1];
+#endif /* defined(VK_KHR_present_wait) */
+#if defined(VK_KHR_present_wait2)
+	PFN_vkWaitForPresent2KHR vkWaitForPresent2KHR;
+#else
+	PFN_vkVoidFunction padding_7401483a[1];
+#endif /* defined(VK_KHR_present_wait2) */
+#if defined(VK_KHR_push_descriptor)
+	PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR;
+#else
+	PFN_vkVoidFunction padding_8f7712ad[1];
+#endif /* defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline)
+	PFN_vkCmdTraceRaysIndirect2KHR vkCmdTraceRaysIndirect2KHR;
+#else
+	PFN_vkVoidFunction padding_dd5f9b4a[1];
+#endif /* defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_ray_tracing_pipeline)
+	PFN_vkCmdSetRayTracingPipelineStackSizeKHR vkCmdSetRayTracingPipelineStackSizeKHR;
+	PFN_vkCmdTraceRaysIndirectKHR vkCmdTraceRaysIndirectKHR;
+	PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR;
+	PFN_vkCreateRayTracingPipelinesKHR vkCreateRayTracingPipelinesKHR;
+	PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR vkGetRayTracingCaptureReplayShaderGroupHandlesKHR;
+	PFN_vkGetRayTracingShaderGroupHandlesKHR vkGetRayTracingShaderGroupHandlesKHR;
+	PFN_vkGetRayTracingShaderGroupStackSizeKHR vkGetRayTracingShaderGroupStackSizeKHR;
+#else
+	PFN_vkVoidFunction padding_af99aedc[7];
+#endif /* defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_sampler_ycbcr_conversion)
+	PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
+	PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
+#else
+	PFN_vkVoidFunction padding_88e61b30[2];
+#endif /* defined(VK_KHR_sampler_ycbcr_conversion) */
+#if defined(VK_KHR_shared_presentable_image)
+	PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR;
+#else
+	PFN_vkVoidFunction padding_1ff3379[1];
+#endif /* defined(VK_KHR_shared_presentable_image) */
+#if defined(VK_KHR_swapchain)
+	PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
+	PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
+	PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
+	PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
+	PFN_vkQueuePresentKHR vkQueuePresentKHR;
+#else
+	PFN_vkVoidFunction padding_a1de893b[5];
+#endif /* defined(VK_KHR_swapchain) */
+#if defined(VK_KHR_swapchain_maintenance1)
+	PFN_vkReleaseSwapchainImagesKHR vkReleaseSwapchainImagesKHR;
+#else
+	PFN_vkVoidFunction padding_e032d5c4[1];
+#endif /* defined(VK_KHR_swapchain_maintenance1) */
+#if defined(VK_KHR_synchronization2)
+	PFN_vkCmdPipelineBarrier2KHR vkCmdPipelineBarrier2KHR;
+	PFN_vkCmdResetEvent2KHR vkCmdResetEvent2KHR;
+	PFN_vkCmdSetEvent2KHR vkCmdSetEvent2KHR;
+	PFN_vkCmdWaitEvents2KHR vkCmdWaitEvents2KHR;
+	PFN_vkCmdWriteTimestamp2KHR vkCmdWriteTimestamp2KHR;
+	PFN_vkQueueSubmit2KHR vkQueueSubmit2KHR;
+#else
+	PFN_vkVoidFunction padding_e85bf128[6];
+#endif /* defined(VK_KHR_synchronization2) */
+#if defined(VK_KHR_timeline_semaphore)
+	PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
+	PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
+	PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
+#else
+	PFN_vkVoidFunction padding_c799d931[3];
+#endif /* defined(VK_KHR_timeline_semaphore) */
+#if defined(VK_KHR_video_decode_queue)
+	PFN_vkCmdDecodeVideoKHR vkCmdDecodeVideoKHR;
+#else
+	PFN_vkVoidFunction padding_7a7cc7ad[1];
+#endif /* defined(VK_KHR_video_decode_queue) */
+#if defined(VK_KHR_video_encode_queue)
+	PFN_vkCmdEncodeVideoKHR vkCmdEncodeVideoKHR;
+	PFN_vkGetEncodedVideoSessionParametersKHR vkGetEncodedVideoSessionParametersKHR;
+#else
+	PFN_vkVoidFunction padding_f2997fb4[2];
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+	PFN_vkBindVideoSessionMemoryKHR vkBindVideoSessionMemoryKHR;
+	PFN_vkCmdBeginVideoCodingKHR vkCmdBeginVideoCodingKHR;
+	PFN_vkCmdControlVideoCodingKHR vkCmdControlVideoCodingKHR;
+	PFN_vkCmdEndVideoCodingKHR vkCmdEndVideoCodingKHR;
+	PFN_vkCreateVideoSessionKHR vkCreateVideoSessionKHR;
+	PFN_vkCreateVideoSessionParametersKHR vkCreateVideoSessionParametersKHR;
+	PFN_vkDestroyVideoSessionKHR vkDestroyVideoSessionKHR;
+	PFN_vkDestroyVideoSessionParametersKHR vkDestroyVideoSessionParametersKHR;
+	PFN_vkGetVideoSessionMemoryRequirementsKHR vkGetVideoSessionMemoryRequirementsKHR;
+	PFN_vkUpdateVideoSessionParametersKHR vkUpdateVideoSessionParametersKHR;
+#else
+	PFN_vkVoidFunction padding_98fb7016[10];
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_NVX_binary_import)
+	PFN_vkCmdCuLaunchKernelNVX vkCmdCuLaunchKernelNVX;
+	PFN_vkCreateCuFunctionNVX vkCreateCuFunctionNVX;
+	PFN_vkCreateCuModuleNVX vkCreateCuModuleNVX;
+	PFN_vkDestroyCuFunctionNVX vkDestroyCuFunctionNVX;
+	PFN_vkDestroyCuModuleNVX vkDestroyCuModuleNVX;
+#else
+	PFN_vkVoidFunction padding_eb54309b[5];
+#endif /* defined(VK_NVX_binary_import) */
+#if defined(VK_NVX_image_view_handle)
+	PFN_vkGetImageViewHandleNVX vkGetImageViewHandleNVX;
+#else
+	PFN_vkVoidFunction padding_887f6736[1];
+#endif /* defined(VK_NVX_image_view_handle) */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3
+	PFN_vkGetImageViewHandle64NVX vkGetImageViewHandle64NVX;
+#else
+	PFN_vkVoidFunction padding_64ad40e2[1];
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2
+	PFN_vkGetImageViewAddressNVX vkGetImageViewAddressNVX;
+#else
+	PFN_vkVoidFunction padding_d290479a[1];
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4
+	PFN_vkGetDeviceCombinedImageSamplerIndexNVX vkGetDeviceCombinedImageSamplerIndexNVX;
+#else
+	PFN_vkVoidFunction padding_a980205b[1];
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4 */
+#if defined(VK_NV_clip_space_w_scaling)
+	PFN_vkCmdSetViewportWScalingNV vkCmdSetViewportWScalingNV;
+#else
+	PFN_vkVoidFunction padding_88d7eb2e[1];
+#endif /* defined(VK_NV_clip_space_w_scaling) */
+#if defined(VK_NV_cluster_acceleration_structure)
+	PFN_vkCmdBuildClusterAccelerationStructureIndirectNV vkCmdBuildClusterAccelerationStructureIndirectNV;
+	PFN_vkGetClusterAccelerationStructureBuildSizesNV vkGetClusterAccelerationStructureBuildSizesNV;
+#else
+	PFN_vkVoidFunction padding_60e35395[2];
+#endif /* defined(VK_NV_cluster_acceleration_structure) */
+#if defined(VK_NV_compute_occupancy_priority)
+	PFN_vkCmdSetComputeOccupancyPriorityNV vkCmdSetComputeOccupancyPriorityNV;
+#else
+	PFN_vkVoidFunction padding_488584ea[1];
+#endif /* defined(VK_NV_compute_occupancy_priority) */
+#if defined(VK_NV_cooperative_vector)
+	PFN_vkCmdConvertCooperativeVectorMatrixNV vkCmdConvertCooperativeVectorMatrixNV;
+	PFN_vkConvertCooperativeVectorMatrixNV vkConvertCooperativeVectorMatrixNV;
+#else
+	PFN_vkVoidFunction padding_f4a887d0[2];
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_copy_memory_indirect)
+	PFN_vkCmdCopyMemoryIndirectNV vkCmdCopyMemoryIndirectNV;
+	PFN_vkCmdCopyMemoryToImageIndirectNV vkCmdCopyMemoryToImageIndirectNV;
+#else
+	PFN_vkVoidFunction padding_9536230e[2];
+#endif /* defined(VK_NV_copy_memory_indirect) */
+#if defined(VK_NV_cuda_kernel_launch)
+	PFN_vkCmdCudaLaunchKernelNV vkCmdCudaLaunchKernelNV;
+	PFN_vkCreateCudaFunctionNV vkCreateCudaFunctionNV;
+	PFN_vkCreateCudaModuleNV vkCreateCudaModuleNV;
+	PFN_vkDestroyCudaFunctionNV vkDestroyCudaFunctionNV;
+	PFN_vkDestroyCudaModuleNV vkDestroyCudaModuleNV;
+	PFN_vkGetCudaModuleCacheNV vkGetCudaModuleCacheNV;
+#else
+	PFN_vkVoidFunction padding_2eabdf3b[6];
+#endif /* defined(VK_NV_cuda_kernel_launch) */
+#if defined(VK_NV_device_diagnostic_checkpoints)
+	PFN_vkCmdSetCheckpointNV vkCmdSetCheckpointNV;
+	PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV;
+#else
+	PFN_vkVoidFunction padding_adaa5a21[2];
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) */
+#if defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+	PFN_vkGetQueueCheckpointData2NV vkGetQueueCheckpointData2NV;
+#else
+	PFN_vkVoidFunction padding_c776633d[1];
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_NV_device_generated_commands)
+	PFN_vkCmdBindPipelineShaderGroupNV vkCmdBindPipelineShaderGroupNV;
+	PFN_vkCmdExecuteGeneratedCommandsNV vkCmdExecuteGeneratedCommandsNV;
+	PFN_vkCmdPreprocessGeneratedCommandsNV vkCmdPreprocessGeneratedCommandsNV;
+	PFN_vkCreateIndirectCommandsLayoutNV vkCreateIndirectCommandsLayoutNV;
+	PFN_vkDestroyIndirectCommandsLayoutNV vkDestroyIndirectCommandsLayoutNV;
+	PFN_vkGetGeneratedCommandsMemoryRequirementsNV vkGetGeneratedCommandsMemoryRequirementsNV;
+#else
+	PFN_vkVoidFunction padding_4c7e4395[6];
+#endif /* defined(VK_NV_device_generated_commands) */
+#if defined(VK_NV_device_generated_commands_compute)
+	PFN_vkCmdUpdatePipelineIndirectBufferNV vkCmdUpdatePipelineIndirectBufferNV;
+	PFN_vkGetPipelineIndirectDeviceAddressNV vkGetPipelineIndirectDeviceAddressNV;
+	PFN_vkGetPipelineIndirectMemoryRequirementsNV vkGetPipelineIndirectMemoryRequirementsNV;
+#else
+	PFN_vkVoidFunction padding_5195094c[3];
+#endif /* defined(VK_NV_device_generated_commands_compute) */
+#if defined(VK_NV_external_compute_queue)
+	PFN_vkCreateExternalComputeQueueNV vkCreateExternalComputeQueueNV;
+	PFN_vkDestroyExternalComputeQueueNV vkDestroyExternalComputeQueueNV;
+	PFN_vkGetExternalComputeQueueDataNV vkGetExternalComputeQueueDataNV;
+#else
+	PFN_vkVoidFunction padding_4f947e0b[3];
+#endif /* defined(VK_NV_external_compute_queue) */
+#if defined(VK_NV_external_memory_rdma)
+	PFN_vkGetMemoryRemoteAddressNV vkGetMemoryRemoteAddressNV;
+#else
+	PFN_vkVoidFunction padding_920e405[1];
+#endif /* defined(VK_NV_external_memory_rdma) */
+#if defined(VK_NV_external_memory_win32)
+	PFN_vkGetMemoryWin32HandleNV vkGetMemoryWin32HandleNV;
+#else
+	PFN_vkVoidFunction padding_c13d6f3a[1];
+#endif /* defined(VK_NV_external_memory_win32) */
+#if defined(VK_NV_fragment_shading_rate_enums)
+	PFN_vkCmdSetFragmentShadingRateEnumNV vkCmdSetFragmentShadingRateEnumNV;
+#else
+	PFN_vkVoidFunction padding_4979ca14[1];
+#endif /* defined(VK_NV_fragment_shading_rate_enums) */
+#if defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2
+	PFN_vkGetLatencyTimingsLegacyNV vkGetLatencyTimingsLegacyNV;
+	PFN_vkGetSleepStatusLegacyNV vkGetSleepStatusLegacyNV;
+	PFN_vkLatencySleepLegacyNV vkLatencySleepLegacyNV;
+	PFN_vkQueueNotifyOutOfBandLegacyNV vkQueueNotifyOutOfBandLegacyNV;
+	PFN_vkSetLatencyMarkerLegacyNV vkSetLatencyMarkerLegacyNV;
+	PFN_vkSetLatencySleepModeLegacyNV vkSetLatencySleepModeLegacyNV;
+	PFN_vkShutdownLatencyDeviceLegacyNV vkShutdownLatencyDeviceLegacyNV;
+#else
+	PFN_vkVoidFunction padding_f08173c[7];
+#endif /* defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2 */
+#if defined(VK_NV_low_latency2)
+	PFN_vkGetLatencyTimingsNV vkGetLatencyTimingsNV;
+	PFN_vkLatencySleepNV vkLatencySleepNV;
+	PFN_vkQueueNotifyOutOfBandNV vkQueueNotifyOutOfBandNV;
+	PFN_vkSetLatencyMarkerNV vkSetLatencyMarkerNV;
+	PFN_vkSetLatencySleepModeNV vkSetLatencySleepModeNV;
+#else
+	PFN_vkVoidFunction padding_fabf8b19[5];
+#endif /* defined(VK_NV_low_latency2) */
+#if defined(VK_NV_memory_decompression)
+	PFN_vkCmdDecompressMemoryIndirectCountNV vkCmdDecompressMemoryIndirectCountNV;
+	PFN_vkCmdDecompressMemoryNV vkCmdDecompressMemoryNV;
+#else
+	PFN_vkVoidFunction padding_706009[2];
+#endif /* defined(VK_NV_memory_decompression) */
+#if defined(VK_NV_mesh_shader)
+	PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV;
+	PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV;
+#else
+	PFN_vkVoidFunction padding_ac232758[2];
+#endif /* defined(VK_NV_mesh_shader) */
+#if defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+	PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV;
+#else
+	PFN_vkVoidFunction padding_53495be7[1];
+#endif /* defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_NV_optical_flow)
+	PFN_vkBindOpticalFlowSessionImageNV vkBindOpticalFlowSessionImageNV;
+	PFN_vkCmdOpticalFlowExecuteNV vkCmdOpticalFlowExecuteNV;
+	PFN_vkCreateOpticalFlowSessionNV vkCreateOpticalFlowSessionNV;
+	PFN_vkDestroyOpticalFlowSessionNV vkDestroyOpticalFlowSessionNV;
+#else
+	PFN_vkVoidFunction padding_f67571eb[4];
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_NV_partitioned_acceleration_structure)
+	PFN_vkCmdBuildPartitionedAccelerationStructuresNV vkCmdBuildPartitionedAccelerationStructuresNV;
+	PFN_vkGetPartitionedAccelerationStructuresBuildSizesNV vkGetPartitionedAccelerationStructuresBuildSizesNV;
+#else
+	PFN_vkVoidFunction padding_d27c8c6d[2];
+#endif /* defined(VK_NV_partitioned_acceleration_structure) */
+#if defined(VK_NV_ray_tracing)
+	PFN_vkBindAccelerationStructureMemoryNV vkBindAccelerationStructureMemoryNV;
+	PFN_vkCmdBuildAccelerationStructureNV vkCmdBuildAccelerationStructureNV;
+	PFN_vkCmdCopyAccelerationStructureNV vkCmdCopyAccelerationStructureNV;
+	PFN_vkCmdTraceRaysNV vkCmdTraceRaysNV;
+	PFN_vkCmdWriteAccelerationStructuresPropertiesNV vkCmdWriteAccelerationStructuresPropertiesNV;
+	PFN_vkCompileDeferredNV vkCompileDeferredNV;
+	PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV;
+	PFN_vkCreateRayTracingPipelinesNV vkCreateRayTracingPipelinesNV;
+	PFN_vkDestroyAccelerationStructureNV vkDestroyAccelerationStructureNV;
+	PFN_vkGetAccelerationStructureHandleNV vkGetAccelerationStructureHandleNV;
+	PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV;
+	PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV;
+#else
+	PFN_vkVoidFunction padding_feefbeac[12];
+#endif /* defined(VK_NV_ray_tracing) */
+#if defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2
+	PFN_vkCmdSetExclusiveScissorEnableNV vkCmdSetExclusiveScissorEnableNV;
+#else
+	PFN_vkVoidFunction padding_e3c24f80[1];
+#endif /* defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2 */
+#if defined(VK_NV_scissor_exclusive)
+	PFN_vkCmdSetExclusiveScissorNV vkCmdSetExclusiveScissorNV;
+#else
+	PFN_vkVoidFunction padding_8e88d86c[1];
+#endif /* defined(VK_NV_scissor_exclusive) */
+#if defined(VK_NV_shading_rate_image)
+	PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV;
+	PFN_vkCmdSetCoarseSampleOrderNV vkCmdSetCoarseSampleOrderNV;
+	PFN_vkCmdSetViewportShadingRatePaletteNV vkCmdSetViewportShadingRatePaletteNV;
+#else
+	PFN_vkVoidFunction padding_92a0767f[3];
+#endif /* defined(VK_NV_shading_rate_image) */
+#if defined(VK_OHOS_external_memory)
+	PFN_vkGetMemoryNativeBufferOHOS vkGetMemoryNativeBufferOHOS;
+	PFN_vkGetNativeBufferPropertiesOHOS vkGetNativeBufferPropertiesOHOS;
+#else
+	PFN_vkVoidFunction padding_9c703846[2];
+#endif /* defined(VK_OHOS_external_memory) */
+#if defined(VK_QCOM_queue_perf_hint)
+	PFN_vkQueueSetPerfHintQCOM vkQueueSetPerfHintQCOM;
+#else
+	PFN_vkVoidFunction padding_98b80534[1];
+#endif /* defined(VK_QCOM_queue_perf_hint) */
+#if defined(VK_QCOM_tile_memory_heap)
+	PFN_vkCmdBindTileMemoryQCOM vkCmdBindTileMemoryQCOM;
+#else
+	PFN_vkVoidFunction padding_e2d55d04[1];
+#endif /* defined(VK_QCOM_tile_memory_heap) */
+#if defined(VK_QCOM_tile_properties)
+	PFN_vkGetDynamicRenderingTilePropertiesQCOM vkGetDynamicRenderingTilePropertiesQCOM;
+	PFN_vkGetFramebufferTilePropertiesQCOM vkGetFramebufferTilePropertiesQCOM;
+#else
+	PFN_vkVoidFunction padding_be12e32[2];
+#endif /* defined(VK_QCOM_tile_properties) */
+#if defined(VK_QCOM_tile_shading)
+	PFN_vkCmdBeginPerTileExecutionQCOM vkCmdBeginPerTileExecutionQCOM;
+	PFN_vkCmdDispatchTileQCOM vkCmdDispatchTileQCOM;
+	PFN_vkCmdEndPerTileExecutionQCOM vkCmdEndPerTileExecutionQCOM;
+#else
+	PFN_vkVoidFunction padding_fcd9e1df[3];
+#endif /* defined(VK_QCOM_tile_shading) */
+#if defined(VK_QNX_external_memory_screen_buffer)
+	PFN_vkGetScreenBufferPropertiesQNX vkGetScreenBufferPropertiesQNX;
+#else
+	PFN_vkVoidFunction padding_1c27735d[1];
+#endif /* defined(VK_QNX_external_memory_screen_buffer) */
+#if defined(VK_VALVE_descriptor_set_host_mapping)
+	PFN_vkGetDescriptorSetHostMappingVALVE vkGetDescriptorSetHostMappingVALVE;
+	PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE vkGetDescriptorSetLayoutHostMappingInfoVALVE;
+#else
+	PFN_vkVoidFunction padding_fd71e4c6[2];
+#endif /* defined(VK_VALVE_descriptor_set_host_mapping) */
+#if (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control))
+	PFN_vkCmdSetDepthClampRangeEXT vkCmdSetDepthClampRangeEXT;
+#else
+	PFN_vkVoidFunction padding_faa18a61[1];
+#endif /* (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control)) */
+#if (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object))
+	PFN_vkCmdBindVertexBuffers2EXT vkCmdBindVertexBuffers2EXT;
+	PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT;
+	PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT;
+	PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT;
+	PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT;
+	PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT;
+	PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT;
+	PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT;
+	PFN_vkCmdSetScissorWithCountEXT vkCmdSetScissorWithCountEXT;
+	PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT;
+	PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT;
+	PFN_vkCmdSetViewportWithCountEXT vkCmdSetViewportWithCountEXT;
+#else
+	PFN_vkVoidFunction padding_3e8c720f[12];
+#endif /* (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object))
+	PFN_vkCmdSetDepthBiasEnableEXT vkCmdSetDepthBiasEnableEXT;
+	PFN_vkCmdSetLogicOpEXT vkCmdSetLogicOpEXT;
+	PFN_vkCmdSetPatchControlPointsEXT vkCmdSetPatchControlPointsEXT;
+	PFN_vkCmdSetPrimitiveRestartEnableEXT vkCmdSetPrimitiveRestartEnableEXT;
+	PFN_vkCmdSetRasterizerDiscardEnableEXT vkCmdSetRasterizerDiscardEnableEXT;
+#else
+	PFN_vkVoidFunction padding_b93e02a6[5];
+#endif /* (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object))
+	PFN_vkCmdSetAlphaToCoverageEnableEXT vkCmdSetAlphaToCoverageEnableEXT;
+	PFN_vkCmdSetAlphaToOneEnableEXT vkCmdSetAlphaToOneEnableEXT;
+	PFN_vkCmdSetColorBlendEnableEXT vkCmdSetColorBlendEnableEXT;
+	PFN_vkCmdSetColorBlendEquationEXT vkCmdSetColorBlendEquationEXT;
+	PFN_vkCmdSetColorWriteMaskEXT vkCmdSetColorWriteMaskEXT;
+	PFN_vkCmdSetDepthClampEnableEXT vkCmdSetDepthClampEnableEXT;
+	PFN_vkCmdSetLogicOpEnableEXT vkCmdSetLogicOpEnableEXT;
+	PFN_vkCmdSetPolygonModeEXT vkCmdSetPolygonModeEXT;
+	PFN_vkCmdSetRasterizationSamplesEXT vkCmdSetRasterizationSamplesEXT;
+	PFN_vkCmdSetSampleMaskEXT vkCmdSetSampleMaskEXT;
+#else
+	PFN_vkVoidFunction padding_ab566e7e[10];
+#endif /* (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object))
+	PFN_vkCmdSetTessellationDomainOriginEXT vkCmdSetTessellationDomainOriginEXT;
+#else
+	PFN_vkVoidFunction padding_6730ed0c[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback))
+	PFN_vkCmdSetRasterizationStreamEXT vkCmdSetRasterizationStreamEXT;
+#else
+	PFN_vkVoidFunction padding_d3ebb335[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization))
+	PFN_vkCmdSetConservativeRasterizationModeEXT vkCmdSetConservativeRasterizationModeEXT;
+	PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT vkCmdSetExtraPrimitiveOverestimationSizeEXT;
+#else
+	PFN_vkVoidFunction padding_a21758f4[2];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable))
+	PFN_vkCmdSetDepthClipEnableEXT vkCmdSetDepthClipEnableEXT;
+#else
+	PFN_vkVoidFunction padding_a498a838[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations))
+	PFN_vkCmdSetSampleLocationsEnableEXT vkCmdSetSampleLocationsEnableEXT;
+#else
+	PFN_vkVoidFunction padding_67db38de[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced))
+	PFN_vkCmdSetColorBlendAdvancedEXT vkCmdSetColorBlendAdvancedEXT;
+#else
+	PFN_vkVoidFunction padding_fbea7481[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex))
+	PFN_vkCmdSetProvokingVertexModeEXT vkCmdSetProvokingVertexModeEXT;
+#else
+	PFN_vkVoidFunction padding_3a8ec90e[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization)))
+	PFN_vkCmdSetLineRasterizationModeEXT vkCmdSetLineRasterizationModeEXT;
+	PFN_vkCmdSetLineStippleEnableEXT vkCmdSetLineStippleEnableEXT;
+#else
+	PFN_vkVoidFunction padding_29cdb756[2];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control))
+	PFN_vkCmdSetDepthClipNegativeOneToOneEXT vkCmdSetDepthClipNegativeOneToOneEXT;
+#else
+	PFN_vkVoidFunction padding_815a7240[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling))
+	PFN_vkCmdSetViewportWScalingEnableNV vkCmdSetViewportWScalingEnableNV;
+#else
+	PFN_vkVoidFunction padding_d1f00511[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle))
+	PFN_vkCmdSetViewportSwizzleNV vkCmdSetViewportSwizzleNV;
+#else
+	PFN_vkVoidFunction padding_7a73d553[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color))
+	PFN_vkCmdSetCoverageToColorEnableNV vkCmdSetCoverageToColorEnableNV;
+	PFN_vkCmdSetCoverageToColorLocationNV vkCmdSetCoverageToColorLocationNV;
+#else
+	PFN_vkVoidFunction padding_6045fb8c[2];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples))
+	PFN_vkCmdSetCoverageModulationModeNV vkCmdSetCoverageModulationModeNV;
+	PFN_vkCmdSetCoverageModulationTableEnableNV vkCmdSetCoverageModulationTableEnableNV;
+	PFN_vkCmdSetCoverageModulationTableNV vkCmdSetCoverageModulationTableNV;
+#else
+	PFN_vkVoidFunction padding_bdc35c80[3];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image))
+	PFN_vkCmdSetShadingRateImageEnableNV vkCmdSetShadingRateImageEnableNV;
+#else
+	PFN_vkVoidFunction padding_9a5cd6e8[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test))
+	PFN_vkCmdSetRepresentativeFragmentTestEnableNV vkCmdSetRepresentativeFragmentTestEnableNV;
+#else
+	PFN_vkVoidFunction padding_3ee17e96[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode))
+	PFN_vkCmdSetCoverageReductionModeNV vkCmdSetCoverageReductionModeNV;
+#else
+	PFN_vkVoidFunction padding_263d525a[1];
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode)) */
+#if (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control))
+	PFN_vkGetImageSubresourceLayout2EXT vkGetImageSubresourceLayout2EXT;
+#else
+	PFN_vkVoidFunction padding_ecddace1[1];
+#endif /* (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control)) */
+#if (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state))
+	PFN_vkCmdSetVertexInputEXT vkCmdSetVertexInputEXT;
+#else
+	PFN_vkVoidFunction padding_d83e1de1[1];
+#endif /* (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state)) */
+#if (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template)))
+	PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR;
+#else
+	PFN_vkVoidFunction padding_60f8358a[1];
+#endif /* (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template))) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR;
+	PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR;
+#else
+	PFN_vkVoidFunction padding_460290c6[2];
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+	PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
+#else
+	PFN_vkVoidFunction padding_cffc198[1];
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+	/* VOLK_GENERATE_DEVICE_TABLE */
+};
+
+/* VOLK_GENERATE_PROTOTYPES_H */
+#if defined(VK_VERSION_1_0)
+extern PFN_vkCreateDevice vkCreateDevice;
+extern PFN_vkCreateInstance vkCreateInstance;
+extern PFN_vkDestroyInstance vkDestroyInstance;
+extern PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
+extern PFN_vkEnumerateDeviceLayerProperties vkEnumerateDeviceLayerProperties;
+extern PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
+extern PFN_vkEnumerateInstanceLayerProperties vkEnumerateInstanceLayerProperties;
+extern PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices;
+extern PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
+extern PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
+extern PFN_vkGetPhysicalDeviceFeatures vkGetPhysicalDeviceFeatures;
+extern PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
+extern PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
+extern PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
+extern PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties;
+extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vkGetPhysicalDeviceQueueFamilyProperties;
+extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties vkGetPhysicalDeviceSparseImageFormatProperties;
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+extern PFN_vkEnumerateInstanceVersion vkEnumerateInstanceVersion;
+extern PFN_vkEnumeratePhysicalDeviceGroups vkEnumeratePhysicalDeviceGroups;
+extern PFN_vkGetPhysicalDeviceExternalBufferProperties vkGetPhysicalDeviceExternalBufferProperties;
+extern PFN_vkGetPhysicalDeviceExternalFenceProperties vkGetPhysicalDeviceExternalFenceProperties;
+extern PFN_vkGetPhysicalDeviceExternalSemaphoreProperties vkGetPhysicalDeviceExternalSemaphoreProperties;
+extern PFN_vkGetPhysicalDeviceFeatures2 vkGetPhysicalDeviceFeatures2;
+extern PFN_vkGetPhysicalDeviceFormatProperties2 vkGetPhysicalDeviceFormatProperties2;
+extern PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2;
+extern PFN_vkGetPhysicalDeviceMemoryProperties2 vkGetPhysicalDeviceMemoryProperties2;
+extern PFN_vkGetPhysicalDeviceProperties2 vkGetPhysicalDeviceProperties2;
+extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2 vkGetPhysicalDeviceQueueFamilyProperties2;
+extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 vkGetPhysicalDeviceSparseImageFormatProperties2;
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_3)
+extern PFN_vkGetPhysicalDeviceToolProperties vkGetPhysicalDeviceToolProperties;
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_ARM_data_graph)
+extern PFN_vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM;
+extern PFN_vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphPropertiesARM;
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_data_graph_optical_flow)
+extern PFN_vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM vkGetPhysicalDeviceQueueFamilyDataGraphOpticalFlowImageFormatsARM;
+#endif /* defined(VK_ARM_data_graph_optical_flow) */
+#if defined(VK_ARM_performance_counters_by_region)
+extern PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM vkEnumeratePhysicalDeviceQueueFamilyPerformanceCountersByRegionARM;
+#endif /* defined(VK_ARM_performance_counters_by_region) */
+#if defined(VK_ARM_shader_instrumentation)
+extern PFN_vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM vkEnumeratePhysicalDeviceShaderInstrumentationMetricsARM;
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+extern PFN_vkGetPhysicalDeviceExternalTensorPropertiesARM vkGetPhysicalDeviceExternalTensorPropertiesARM;
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_EXT_acquire_drm_display)
+extern PFN_vkAcquireDrmDisplayEXT vkAcquireDrmDisplayEXT;
+extern PFN_vkGetDrmDisplayEXT vkGetDrmDisplayEXT;
+#endif /* defined(VK_EXT_acquire_drm_display) */
+#if defined(VK_EXT_acquire_xlib_display)
+extern PFN_vkAcquireXlibDisplayEXT vkAcquireXlibDisplayEXT;
+extern PFN_vkGetRandROutputDisplayEXT vkGetRandROutputDisplayEXT;
+#endif /* defined(VK_EXT_acquire_xlib_display) */
+#if defined(VK_EXT_calibrated_timestamps)
+extern PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT vkGetPhysicalDeviceCalibrateableTimeDomainsEXT;
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_cooperative_matrix_maintenance1)
+extern PFN_vkGetPhysicalDeviceCooperativeMatrixProperties2EXT vkGetPhysicalDeviceCooperativeMatrixProperties2EXT;
+#endif /* defined(VK_EXT_cooperative_matrix_maintenance1) */
+#if defined(VK_EXT_debug_report)
+extern PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallbackEXT;
+extern PFN_vkDebugReportMessageEXT vkDebugReportMessageEXT;
+extern PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallbackEXT;
+#endif /* defined(VK_EXT_debug_report) */
+#if defined(VK_EXT_debug_utils)
+extern PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT;
+extern PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT;
+extern PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT;
+extern PFN_vkCreateDebugUtilsMessengerEXT vkCreateDebugUtilsMessengerEXT;
+extern PFN_vkDestroyDebugUtilsMessengerEXT vkDestroyDebugUtilsMessengerEXT;
+extern PFN_vkQueueBeginDebugUtilsLabelEXT vkQueueBeginDebugUtilsLabelEXT;
+extern PFN_vkQueueEndDebugUtilsLabelEXT vkQueueEndDebugUtilsLabelEXT;
+extern PFN_vkQueueInsertDebugUtilsLabelEXT vkQueueInsertDebugUtilsLabelEXT;
+extern PFN_vkSetDebugUtilsObjectNameEXT vkSetDebugUtilsObjectNameEXT;
+extern PFN_vkSetDebugUtilsObjectTagEXT vkSetDebugUtilsObjectTagEXT;
+extern PFN_vkSubmitDebugUtilsMessageEXT vkSubmitDebugUtilsMessageEXT;
+#endif /* defined(VK_EXT_debug_utils) */
+#if defined(VK_EXT_descriptor_heap)
+extern PFN_vkGetPhysicalDeviceDescriptorSizeEXT vkGetPhysicalDeviceDescriptorSizeEXT;
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_direct_mode_display)
+extern PFN_vkReleaseDisplayEXT vkReleaseDisplayEXT;
+#endif /* defined(VK_EXT_direct_mode_display) */
+#if defined(VK_EXT_directfb_surface)
+extern PFN_vkCreateDirectFBSurfaceEXT vkCreateDirectFBSurfaceEXT;
+extern PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT vkGetPhysicalDeviceDirectFBPresentationSupportEXT;
+#endif /* defined(VK_EXT_directfb_surface) */
+#if defined(VK_EXT_display_surface_counter)
+extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT vkGetPhysicalDeviceSurfaceCapabilities2EXT;
+#endif /* defined(VK_EXT_display_surface_counter) */
+#if defined(VK_EXT_full_screen_exclusive)
+extern PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT vkGetPhysicalDeviceSurfacePresentModes2EXT;
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_headless_surface)
+extern PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT;
+#endif /* defined(VK_EXT_headless_surface) */
+#if defined(VK_EXT_metal_surface)
+extern PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
+#endif /* defined(VK_EXT_metal_surface) */
+#if defined(VK_EXT_sample_locations)
+extern PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT vkGetPhysicalDeviceMultisamplePropertiesEXT;
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_tooling_info)
+extern PFN_vkGetPhysicalDeviceToolPropertiesEXT vkGetPhysicalDeviceToolPropertiesEXT;
+#endif /* defined(VK_EXT_tooling_info) */
+#if defined(VK_FUCHSIA_imagepipe_surface)
+extern PFN_vkCreateImagePipeSurfaceFUCHSIA vkCreateImagePipeSurfaceFUCHSIA;
+#endif /* defined(VK_FUCHSIA_imagepipe_surface) */
+#if defined(VK_GGP_stream_descriptor_surface)
+extern PFN_vkCreateStreamDescriptorSurfaceGGP vkCreateStreamDescriptorSurfaceGGP;
+#endif /* defined(VK_GGP_stream_descriptor_surface) */
+#if defined(VK_KHR_android_surface)
+extern PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
+#endif /* defined(VK_KHR_android_surface) */
+#if defined(VK_KHR_calibrated_timestamps)
+extern PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR vkGetPhysicalDeviceCalibrateableTimeDomainsKHR;
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_cooperative_matrix)
+extern PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR;
+#endif /* defined(VK_KHR_cooperative_matrix) */
+#if defined(VK_KHR_device_group_creation)
+extern PFN_vkEnumeratePhysicalDeviceGroupsKHR vkEnumeratePhysicalDeviceGroupsKHR;
+#endif /* defined(VK_KHR_device_group_creation) */
+#if defined(VK_KHR_display)
+extern PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR;
+extern PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR;
+extern PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR;
+extern PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR;
+extern PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR;
+extern PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR;
+extern PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR;
+#endif /* defined(VK_KHR_display) */
+#if defined(VK_KHR_external_fence_capabilities)
+extern PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR vkGetPhysicalDeviceExternalFencePropertiesKHR;
+#endif /* defined(VK_KHR_external_fence_capabilities) */
+#if defined(VK_KHR_external_memory_capabilities)
+extern PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR vkGetPhysicalDeviceExternalBufferPropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_capabilities) */
+#if defined(VK_KHR_external_semaphore_capabilities)
+extern PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR vkGetPhysicalDeviceExternalSemaphorePropertiesKHR;
+#endif /* defined(VK_KHR_external_semaphore_capabilities) */
+#if defined(VK_KHR_fragment_shading_rate)
+extern PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR vkGetPhysicalDeviceFragmentShadingRatesKHR;
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_display_properties2)
+extern PFN_vkGetDisplayModeProperties2KHR vkGetDisplayModeProperties2KHR;
+extern PFN_vkGetDisplayPlaneCapabilities2KHR vkGetDisplayPlaneCapabilities2KHR;
+extern PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR vkGetPhysicalDeviceDisplayPlaneProperties2KHR;
+extern PFN_vkGetPhysicalDeviceDisplayProperties2KHR vkGetPhysicalDeviceDisplayProperties2KHR;
+#endif /* defined(VK_KHR_get_display_properties2) */
+#if defined(VK_KHR_get_physical_device_properties2)
+extern PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR;
+extern PFN_vkGetPhysicalDeviceFormatProperties2KHR vkGetPhysicalDeviceFormatProperties2KHR;
+extern PFN_vkGetPhysicalDeviceImageFormatProperties2KHR vkGetPhysicalDeviceImageFormatProperties2KHR;
+extern PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR;
+extern PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR;
+extern PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR vkGetPhysicalDeviceQueueFamilyProperties2KHR;
+extern PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR vkGetPhysicalDeviceSparseImageFormatProperties2KHR;
+#endif /* defined(VK_KHR_get_physical_device_properties2) */
+#if defined(VK_KHR_get_surface_capabilities2)
+extern PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR vkGetPhysicalDeviceSurfaceCapabilities2KHR;
+extern PFN_vkGetPhysicalDeviceSurfaceFormats2KHR vkGetPhysicalDeviceSurfaceFormats2KHR;
+#endif /* defined(VK_KHR_get_surface_capabilities2) */
+#if defined(VK_KHR_performance_query)
+extern PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR;
+extern PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR;
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_surface)
+extern PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
+extern PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
+extern PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR;
+extern PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR;
+extern PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR;
+#endif /* defined(VK_KHR_surface) */
+#if defined(VK_KHR_video_encode_queue)
+extern PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR;
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+extern PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR vkGetPhysicalDeviceVideoCapabilitiesKHR;
+extern PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR vkGetPhysicalDeviceVideoFormatPropertiesKHR;
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_KHR_wayland_surface)
+extern PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
+extern PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR;
+#endif /* defined(VK_KHR_wayland_surface) */
+#if defined(VK_KHR_win32_surface)
+extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
+extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR;
+#endif /* defined(VK_KHR_win32_surface) */
+#if defined(VK_KHR_xcb_surface)
+extern PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
+extern PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR;
+#endif /* defined(VK_KHR_xcb_surface) */
+#if defined(VK_KHR_xlib_surface)
+extern PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
+extern PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR;
+#endif /* defined(VK_KHR_xlib_surface) */
+#if defined(VK_MVK_ios_surface)
+extern PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK;
+#endif /* defined(VK_MVK_ios_surface) */
+#if defined(VK_MVK_macos_surface)
+extern PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
+#endif /* defined(VK_MVK_macos_surface) */
+#if defined(VK_NN_vi_surface)
+extern PFN_vkCreateViSurfaceNN vkCreateViSurfaceNN;
+#endif /* defined(VK_NN_vi_surface) */
+#if defined(VK_NV_acquire_winrt_display)
+extern PFN_vkAcquireWinrtDisplayNV vkAcquireWinrtDisplayNV;
+extern PFN_vkGetWinrtDisplayNV vkGetWinrtDisplayNV;
+#endif /* defined(VK_NV_acquire_winrt_display) */
+#if defined(VK_NV_cooperative_matrix)
+extern PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV vkGetPhysicalDeviceCooperativeMatrixPropertiesNV;
+#endif /* defined(VK_NV_cooperative_matrix) */
+#if defined(VK_NV_cooperative_matrix2)
+extern PFN_vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV vkGetPhysicalDeviceCooperativeMatrixFlexibleDimensionsPropertiesNV;
+#endif /* defined(VK_NV_cooperative_matrix2) */
+#if defined(VK_NV_cooperative_vector)
+extern PFN_vkGetPhysicalDeviceCooperativeVectorPropertiesNV vkGetPhysicalDeviceCooperativeVectorPropertiesNV;
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_coverage_reduction_mode)
+extern PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV;
+#endif /* defined(VK_NV_coverage_reduction_mode) */
+#if defined(VK_NV_external_memory_capabilities)
+extern PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
+#endif /* defined(VK_NV_external_memory_capabilities) */
+#if defined(VK_NV_optical_flow)
+extern PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV vkGetPhysicalDeviceOpticalFlowImageFormatsNV;
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_OHOS_surface)
+extern PFN_vkCreateSurfaceOHOS vkCreateSurfaceOHOS;
+#endif /* defined(VK_OHOS_surface) */
+#if defined(VK_QNX_screen_surface)
+extern PFN_vkCreateScreenSurfaceQNX vkCreateScreenSurfaceQNX;
+extern PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX vkGetPhysicalDeviceScreenPresentationSupportQNX;
+#endif /* defined(VK_QNX_screen_surface) */
+#if defined(VK_SEC_ubm_surface)
+extern PFN_vkCreateUbmSurfaceSEC vkCreateUbmSurfaceSEC;
+extern PFN_vkGetPhysicalDeviceUbmPresentationSupportSEC vkGetPhysicalDeviceUbmPresentationSupportSEC;
+#endif /* defined(VK_SEC_ubm_surface) */
+#if (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow))
+extern PFN_vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM vkGetPhysicalDeviceQueueFamilyDataGraphEngineOperationPropertiesARM;
+#endif /* (defined(VK_ARM_data_graph_instruction_set_tosa)) || (defined(VK_ARM_data_graph_optical_flow)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+extern PFN_vkGetPhysicalDevicePresentRectanglesKHR vkGetPhysicalDevicePresentRectanglesKHR;
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+/* VOLK_GENERATE_PROTOTYPES_H */
+
+#ifndef VOLK_NO_DEVICE_PROTOTYPES
+/* VOLK_GENERATE_PROTOTYPES_H_DEVICE */
+#if defined(VK_VERSION_1_0)
+extern PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
+extern PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets;
+extern PFN_vkAllocateMemory vkAllocateMemory;
+extern PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
+extern PFN_vkBindBufferMemory vkBindBufferMemory;
+extern PFN_vkBindImageMemory vkBindImageMemory;
+extern PFN_vkCmdBeginQuery vkCmdBeginQuery;
+extern PFN_vkCmdBeginRenderPass vkCmdBeginRenderPass;
+extern PFN_vkCmdBindDescriptorSets vkCmdBindDescriptorSets;
+extern PFN_vkCmdBindIndexBuffer vkCmdBindIndexBuffer;
+extern PFN_vkCmdBindPipeline vkCmdBindPipeline;
+extern PFN_vkCmdBindVertexBuffers vkCmdBindVertexBuffers;
+extern PFN_vkCmdBlitImage vkCmdBlitImage;
+extern PFN_vkCmdClearAttachments vkCmdClearAttachments;
+extern PFN_vkCmdClearColorImage vkCmdClearColorImage;
+extern PFN_vkCmdClearDepthStencilImage vkCmdClearDepthStencilImage;
+extern PFN_vkCmdCopyBuffer vkCmdCopyBuffer;
+extern PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
+extern PFN_vkCmdCopyImage vkCmdCopyImage;
+extern PFN_vkCmdCopyImageToBuffer vkCmdCopyImageToBuffer;
+extern PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
+extern PFN_vkCmdDispatch vkCmdDispatch;
+extern PFN_vkCmdDispatchIndirect vkCmdDispatchIndirect;
+extern PFN_vkCmdDraw vkCmdDraw;
+extern PFN_vkCmdDrawIndexed vkCmdDrawIndexed;
+extern PFN_vkCmdDrawIndexedIndirect vkCmdDrawIndexedIndirect;
+extern PFN_vkCmdDrawIndirect vkCmdDrawIndirect;
+extern PFN_vkCmdEndQuery vkCmdEndQuery;
+extern PFN_vkCmdEndRenderPass vkCmdEndRenderPass;
+extern PFN_vkCmdExecuteCommands vkCmdExecuteCommands;
+extern PFN_vkCmdFillBuffer vkCmdFillBuffer;
+extern PFN_vkCmdNextSubpass vkCmdNextSubpass;
+extern PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
+extern PFN_vkCmdPushConstants vkCmdPushConstants;
+extern PFN_vkCmdResetEvent vkCmdResetEvent;
+extern PFN_vkCmdResetQueryPool vkCmdResetQueryPool;
+extern PFN_vkCmdResolveImage vkCmdResolveImage;
+extern PFN_vkCmdSetBlendConstants vkCmdSetBlendConstants;
+extern PFN_vkCmdSetDepthBias vkCmdSetDepthBias;
+extern PFN_vkCmdSetDepthBounds vkCmdSetDepthBounds;
+extern PFN_vkCmdSetEvent vkCmdSetEvent;
+extern PFN_vkCmdSetLineWidth vkCmdSetLineWidth;
+extern PFN_vkCmdSetScissor vkCmdSetScissor;
+extern PFN_vkCmdSetStencilCompareMask vkCmdSetStencilCompareMask;
+extern PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
+extern PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
+extern PFN_vkCmdSetViewport vkCmdSetViewport;
+extern PFN_vkCmdUpdateBuffer vkCmdUpdateBuffer;
+extern PFN_vkCmdWaitEvents vkCmdWaitEvents;
+extern PFN_vkCmdWriteTimestamp vkCmdWriteTimestamp;
+extern PFN_vkCreateBuffer vkCreateBuffer;
+extern PFN_vkCreateBufferView vkCreateBufferView;
+extern PFN_vkCreateCommandPool vkCreateCommandPool;
+extern PFN_vkCreateComputePipelines vkCreateComputePipelines;
+extern PFN_vkCreateDescriptorPool vkCreateDescriptorPool;
+extern PFN_vkCreateDescriptorSetLayout vkCreateDescriptorSetLayout;
+extern PFN_vkCreateEvent vkCreateEvent;
+extern PFN_vkCreateFence vkCreateFence;
+extern PFN_vkCreateFramebuffer vkCreateFramebuffer;
+extern PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines;
+extern PFN_vkCreateImage vkCreateImage;
+extern PFN_vkCreateImageView vkCreateImageView;
+extern PFN_vkCreatePipelineCache vkCreatePipelineCache;
+extern PFN_vkCreatePipelineLayout vkCreatePipelineLayout;
+extern PFN_vkCreateQueryPool vkCreateQueryPool;
+extern PFN_vkCreateRenderPass vkCreateRenderPass;
+extern PFN_vkCreateSampler vkCreateSampler;
+extern PFN_vkCreateSemaphore vkCreateSemaphore;
+extern PFN_vkCreateShaderModule vkCreateShaderModule;
+extern PFN_vkDestroyBuffer vkDestroyBuffer;
+extern PFN_vkDestroyBufferView vkDestroyBufferView;
+extern PFN_vkDestroyCommandPool vkDestroyCommandPool;
+extern PFN_vkDestroyDescriptorPool vkDestroyDescriptorPool;
+extern PFN_vkDestroyDescriptorSetLayout vkDestroyDescriptorSetLayout;
+extern PFN_vkDestroyDevice vkDestroyDevice;
+extern PFN_vkDestroyEvent vkDestroyEvent;
+extern PFN_vkDestroyFence vkDestroyFence;
+extern PFN_vkDestroyFramebuffer vkDestroyFramebuffer;
+extern PFN_vkDestroyImage vkDestroyImage;
+extern PFN_vkDestroyImageView vkDestroyImageView;
+extern PFN_vkDestroyPipeline vkDestroyPipeline;
+extern PFN_vkDestroyPipelineCache vkDestroyPipelineCache;
+extern PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout;
+extern PFN_vkDestroyQueryPool vkDestroyQueryPool;
+extern PFN_vkDestroyRenderPass vkDestroyRenderPass;
+extern PFN_vkDestroySampler vkDestroySampler;
+extern PFN_vkDestroySemaphore vkDestroySemaphore;
+extern PFN_vkDestroyShaderModule vkDestroyShaderModule;
+extern PFN_vkDeviceWaitIdle vkDeviceWaitIdle;
+extern PFN_vkEndCommandBuffer vkEndCommandBuffer;
+extern PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges;
+extern PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
+extern PFN_vkFreeDescriptorSets vkFreeDescriptorSets;
+extern PFN_vkFreeMemory vkFreeMemory;
+extern PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
+extern PFN_vkGetDeviceMemoryCommitment vkGetDeviceMemoryCommitment;
+extern PFN_vkGetDeviceQueue vkGetDeviceQueue;
+extern PFN_vkGetEventStatus vkGetEventStatus;
+extern PFN_vkGetFenceStatus vkGetFenceStatus;
+extern PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
+extern PFN_vkGetImageSparseMemoryRequirements vkGetImageSparseMemoryRequirements;
+extern PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
+extern PFN_vkGetPipelineCacheData vkGetPipelineCacheData;
+extern PFN_vkGetQueryPoolResults vkGetQueryPoolResults;
+extern PFN_vkGetRenderAreaGranularity vkGetRenderAreaGranularity;
+extern PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges;
+extern PFN_vkMapMemory vkMapMemory;
+extern PFN_vkMergePipelineCaches vkMergePipelineCaches;
+extern PFN_vkQueueBindSparse vkQueueBindSparse;
+extern PFN_vkQueueSubmit vkQueueSubmit;
+extern PFN_vkQueueWaitIdle vkQueueWaitIdle;
+extern PFN_vkResetCommandBuffer vkResetCommandBuffer;
+extern PFN_vkResetCommandPool vkResetCommandPool;
+extern PFN_vkResetDescriptorPool vkResetDescriptorPool;
+extern PFN_vkResetEvent vkResetEvent;
+extern PFN_vkResetFences vkResetFences;
+extern PFN_vkSetEvent vkSetEvent;
+extern PFN_vkUnmapMemory vkUnmapMemory;
+extern PFN_vkUpdateDescriptorSets vkUpdateDescriptorSets;
+extern PFN_vkWaitForFences vkWaitForFences;
+#endif /* defined(VK_VERSION_1_0) */
+#if defined(VK_VERSION_1_1)
+extern PFN_vkBindBufferMemory2 vkBindBufferMemory2;
+extern PFN_vkBindImageMemory2 vkBindImageMemory2;
+extern PFN_vkCmdDispatchBase vkCmdDispatchBase;
+extern PFN_vkCmdSetDeviceMask vkCmdSetDeviceMask;
+extern PFN_vkCreateDescriptorUpdateTemplate vkCreateDescriptorUpdateTemplate;
+extern PFN_vkCreateSamplerYcbcrConversion vkCreateSamplerYcbcrConversion;
+extern PFN_vkDestroyDescriptorUpdateTemplate vkDestroyDescriptorUpdateTemplate;
+extern PFN_vkDestroySamplerYcbcrConversion vkDestroySamplerYcbcrConversion;
+extern PFN_vkGetBufferMemoryRequirements2 vkGetBufferMemoryRequirements2;
+extern PFN_vkGetDescriptorSetLayoutSupport vkGetDescriptorSetLayoutSupport;
+extern PFN_vkGetDeviceGroupPeerMemoryFeatures vkGetDeviceGroupPeerMemoryFeatures;
+extern PFN_vkGetDeviceQueue2 vkGetDeviceQueue2;
+extern PFN_vkGetImageMemoryRequirements2 vkGetImageMemoryRequirements2;
+extern PFN_vkGetImageSparseMemoryRequirements2 vkGetImageSparseMemoryRequirements2;
+extern PFN_vkTrimCommandPool vkTrimCommandPool;
+extern PFN_vkUpdateDescriptorSetWithTemplate vkUpdateDescriptorSetWithTemplate;
+#endif /* defined(VK_VERSION_1_1) */
+#if defined(VK_VERSION_1_2)
+extern PFN_vkCmdBeginRenderPass2 vkCmdBeginRenderPass2;
+extern PFN_vkCmdDrawIndexedIndirectCount vkCmdDrawIndexedIndirectCount;
+extern PFN_vkCmdDrawIndirectCount vkCmdDrawIndirectCount;
+extern PFN_vkCmdEndRenderPass2 vkCmdEndRenderPass2;
+extern PFN_vkCmdNextSubpass2 vkCmdNextSubpass2;
+extern PFN_vkCreateRenderPass2 vkCreateRenderPass2;
+extern PFN_vkGetBufferDeviceAddress vkGetBufferDeviceAddress;
+extern PFN_vkGetBufferOpaqueCaptureAddress vkGetBufferOpaqueCaptureAddress;
+extern PFN_vkGetDeviceMemoryOpaqueCaptureAddress vkGetDeviceMemoryOpaqueCaptureAddress;
+extern PFN_vkGetSemaphoreCounterValue vkGetSemaphoreCounterValue;
+extern PFN_vkResetQueryPool vkResetQueryPool;
+extern PFN_vkSignalSemaphore vkSignalSemaphore;
+extern PFN_vkWaitSemaphores vkWaitSemaphores;
+#endif /* defined(VK_VERSION_1_2) */
+#if defined(VK_VERSION_1_3)
+extern PFN_vkCmdBeginRendering vkCmdBeginRendering;
+extern PFN_vkCmdBindVertexBuffers2 vkCmdBindVertexBuffers2;
+extern PFN_vkCmdBlitImage2 vkCmdBlitImage2;
+extern PFN_vkCmdCopyBuffer2 vkCmdCopyBuffer2;
+extern PFN_vkCmdCopyBufferToImage2 vkCmdCopyBufferToImage2;
+extern PFN_vkCmdCopyImage2 vkCmdCopyImage2;
+extern PFN_vkCmdCopyImageToBuffer2 vkCmdCopyImageToBuffer2;
+extern PFN_vkCmdEndRendering vkCmdEndRendering;
+extern PFN_vkCmdPipelineBarrier2 vkCmdPipelineBarrier2;
+extern PFN_vkCmdResetEvent2 vkCmdResetEvent2;
+extern PFN_vkCmdResolveImage2 vkCmdResolveImage2;
+extern PFN_vkCmdSetCullMode vkCmdSetCullMode;
+extern PFN_vkCmdSetDepthBiasEnable vkCmdSetDepthBiasEnable;
+extern PFN_vkCmdSetDepthBoundsTestEnable vkCmdSetDepthBoundsTestEnable;
+extern PFN_vkCmdSetDepthCompareOp vkCmdSetDepthCompareOp;
+extern PFN_vkCmdSetDepthTestEnable vkCmdSetDepthTestEnable;
+extern PFN_vkCmdSetDepthWriteEnable vkCmdSetDepthWriteEnable;
+extern PFN_vkCmdSetEvent2 vkCmdSetEvent2;
+extern PFN_vkCmdSetFrontFace vkCmdSetFrontFace;
+extern PFN_vkCmdSetPrimitiveRestartEnable vkCmdSetPrimitiveRestartEnable;
+extern PFN_vkCmdSetPrimitiveTopology vkCmdSetPrimitiveTopology;
+extern PFN_vkCmdSetRasterizerDiscardEnable vkCmdSetRasterizerDiscardEnable;
+extern PFN_vkCmdSetScissorWithCount vkCmdSetScissorWithCount;
+extern PFN_vkCmdSetStencilOp vkCmdSetStencilOp;
+extern PFN_vkCmdSetStencilTestEnable vkCmdSetStencilTestEnable;
+extern PFN_vkCmdSetViewportWithCount vkCmdSetViewportWithCount;
+extern PFN_vkCmdWaitEvents2 vkCmdWaitEvents2;
+extern PFN_vkCmdWriteTimestamp2 vkCmdWriteTimestamp2;
+extern PFN_vkCreatePrivateDataSlot vkCreatePrivateDataSlot;
+extern PFN_vkDestroyPrivateDataSlot vkDestroyPrivateDataSlot;
+extern PFN_vkGetDeviceBufferMemoryRequirements vkGetDeviceBufferMemoryRequirements;
+extern PFN_vkGetDeviceImageMemoryRequirements vkGetDeviceImageMemoryRequirements;
+extern PFN_vkGetDeviceImageSparseMemoryRequirements vkGetDeviceImageSparseMemoryRequirements;
+extern PFN_vkGetPrivateData vkGetPrivateData;
+extern PFN_vkQueueSubmit2 vkQueueSubmit2;
+extern PFN_vkSetPrivateData vkSetPrivateData;
+#endif /* defined(VK_VERSION_1_3) */
+#if defined(VK_VERSION_1_4)
+extern PFN_vkCmdBindDescriptorSets2 vkCmdBindDescriptorSets2;
+extern PFN_vkCmdBindIndexBuffer2 vkCmdBindIndexBuffer2;
+extern PFN_vkCmdPushConstants2 vkCmdPushConstants2;
+extern PFN_vkCmdPushDescriptorSet vkCmdPushDescriptorSet;
+extern PFN_vkCmdPushDescriptorSet2 vkCmdPushDescriptorSet2;
+extern PFN_vkCmdPushDescriptorSetWithTemplate vkCmdPushDescriptorSetWithTemplate;
+extern PFN_vkCmdPushDescriptorSetWithTemplate2 vkCmdPushDescriptorSetWithTemplate2;
+extern PFN_vkCmdSetLineStipple vkCmdSetLineStipple;
+extern PFN_vkCmdSetRenderingAttachmentLocations vkCmdSetRenderingAttachmentLocations;
+extern PFN_vkCmdSetRenderingInputAttachmentIndices vkCmdSetRenderingInputAttachmentIndices;
+extern PFN_vkCopyImageToImage vkCopyImageToImage;
+extern PFN_vkCopyImageToMemory vkCopyImageToMemory;
+extern PFN_vkCopyMemoryToImage vkCopyMemoryToImage;
+extern PFN_vkGetDeviceImageSubresourceLayout vkGetDeviceImageSubresourceLayout;
+extern PFN_vkGetImageSubresourceLayout2 vkGetImageSubresourceLayout2;
+extern PFN_vkGetRenderingAreaGranularity vkGetRenderingAreaGranularity;
+extern PFN_vkMapMemory2 vkMapMemory2;
+extern PFN_vkTransitionImageLayout vkTransitionImageLayout;
+extern PFN_vkUnmapMemory2 vkUnmapMemory2;
+#endif /* defined(VK_VERSION_1_4) */
+#if defined(VK_AMDX_shader_enqueue)
+extern PFN_vkCmdDispatchGraphAMDX vkCmdDispatchGraphAMDX;
+extern PFN_vkCmdDispatchGraphIndirectAMDX vkCmdDispatchGraphIndirectAMDX;
+extern PFN_vkCmdDispatchGraphIndirectCountAMDX vkCmdDispatchGraphIndirectCountAMDX;
+extern PFN_vkCmdInitializeGraphScratchMemoryAMDX vkCmdInitializeGraphScratchMemoryAMDX;
+extern PFN_vkCreateExecutionGraphPipelinesAMDX vkCreateExecutionGraphPipelinesAMDX;
+extern PFN_vkGetExecutionGraphPipelineNodeIndexAMDX vkGetExecutionGraphPipelineNodeIndexAMDX;
+extern PFN_vkGetExecutionGraphPipelineScratchSizeAMDX vkGetExecutionGraphPipelineScratchSizeAMDX;
+#endif /* defined(VK_AMDX_shader_enqueue) */
+#if defined(VK_AMD_anti_lag)
+extern PFN_vkAntiLagUpdateAMD vkAntiLagUpdateAMD;
+#endif /* defined(VK_AMD_anti_lag) */
+#if defined(VK_AMD_buffer_marker)
+extern PFN_vkCmdWriteBufferMarkerAMD vkCmdWriteBufferMarkerAMD;
+#endif /* defined(VK_AMD_buffer_marker) */
+#if defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+extern PFN_vkCmdWriteBufferMarker2AMD vkCmdWriteBufferMarker2AMD;
+#endif /* defined(VK_AMD_buffer_marker) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_AMD_display_native_hdr)
+extern PFN_vkSetLocalDimmingAMD vkSetLocalDimmingAMD;
+#endif /* defined(VK_AMD_display_native_hdr) */
+#if defined(VK_AMD_draw_indirect_count)
+extern PFN_vkCmdDrawIndexedIndirectCountAMD vkCmdDrawIndexedIndirectCountAMD;
+extern PFN_vkCmdDrawIndirectCountAMD vkCmdDrawIndirectCountAMD;
+#endif /* defined(VK_AMD_draw_indirect_count) */
+#if defined(VK_AMD_gpa_interface)
+extern PFN_vkCmdBeginGpaSampleAMD vkCmdBeginGpaSampleAMD;
+extern PFN_vkCmdBeginGpaSessionAMD vkCmdBeginGpaSessionAMD;
+extern PFN_vkCmdCopyGpaSessionResultsAMD vkCmdCopyGpaSessionResultsAMD;
+extern PFN_vkCmdEndGpaSampleAMD vkCmdEndGpaSampleAMD;
+extern PFN_vkCmdEndGpaSessionAMD vkCmdEndGpaSessionAMD;
+extern PFN_vkCreateGpaSessionAMD vkCreateGpaSessionAMD;
+extern PFN_vkDestroyGpaSessionAMD vkDestroyGpaSessionAMD;
+extern PFN_vkGetGpaDeviceClockInfoAMD vkGetGpaDeviceClockInfoAMD;
+extern PFN_vkGetGpaSessionResultsAMD vkGetGpaSessionResultsAMD;
+extern PFN_vkGetGpaSessionStatusAMD vkGetGpaSessionStatusAMD;
+extern PFN_vkResetGpaSessionAMD vkResetGpaSessionAMD;
+extern PFN_vkSetGpaDeviceClockModeAMD vkSetGpaDeviceClockModeAMD;
+#endif /* defined(VK_AMD_gpa_interface) */
+#if defined(VK_AMD_shader_info)
+extern PFN_vkGetShaderInfoAMD vkGetShaderInfoAMD;
+#endif /* defined(VK_AMD_shader_info) */
+#if defined(VK_ANDROID_external_memory_android_hardware_buffer)
+extern PFN_vkGetAndroidHardwareBufferPropertiesANDROID vkGetAndroidHardwareBufferPropertiesANDROID;
+extern PFN_vkGetMemoryAndroidHardwareBufferANDROID vkGetMemoryAndroidHardwareBufferANDROID;
+#endif /* defined(VK_ANDROID_external_memory_android_hardware_buffer) */
+#if defined(VK_ARM_data_graph)
+extern PFN_vkBindDataGraphPipelineSessionMemoryARM vkBindDataGraphPipelineSessionMemoryARM;
+extern PFN_vkCmdDispatchDataGraphARM vkCmdDispatchDataGraphARM;
+extern PFN_vkCreateDataGraphPipelineSessionARM vkCreateDataGraphPipelineSessionARM;
+extern PFN_vkCreateDataGraphPipelinesARM vkCreateDataGraphPipelinesARM;
+extern PFN_vkDestroyDataGraphPipelineSessionARM vkDestroyDataGraphPipelineSessionARM;
+extern PFN_vkGetDataGraphPipelineAvailablePropertiesARM vkGetDataGraphPipelineAvailablePropertiesARM;
+extern PFN_vkGetDataGraphPipelinePropertiesARM vkGetDataGraphPipelinePropertiesARM;
+extern PFN_vkGetDataGraphPipelineSessionBindPointRequirementsARM vkGetDataGraphPipelineSessionBindPointRequirementsARM;
+extern PFN_vkGetDataGraphPipelineSessionMemoryRequirementsARM vkGetDataGraphPipelineSessionMemoryRequirementsARM;
+#endif /* defined(VK_ARM_data_graph) */
+#if defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2
+extern PFN_vkCmdSetDispatchParametersARM vkCmdSetDispatchParametersARM;
+#endif /* defined(VK_ARM_scheduling_controls) && VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION >= 2 */
+#if defined(VK_ARM_shader_instrumentation)
+extern PFN_vkClearShaderInstrumentationMetricsARM vkClearShaderInstrumentationMetricsARM;
+extern PFN_vkCmdBeginShaderInstrumentationARM vkCmdBeginShaderInstrumentationARM;
+extern PFN_vkCmdEndShaderInstrumentationARM vkCmdEndShaderInstrumentationARM;
+extern PFN_vkCreateShaderInstrumentationARM vkCreateShaderInstrumentationARM;
+extern PFN_vkDestroyShaderInstrumentationARM vkDestroyShaderInstrumentationARM;
+extern PFN_vkGetShaderInstrumentationValuesARM vkGetShaderInstrumentationValuesARM;
+#endif /* defined(VK_ARM_shader_instrumentation) */
+#if defined(VK_ARM_tensors)
+extern PFN_vkBindTensorMemoryARM vkBindTensorMemoryARM;
+extern PFN_vkCmdCopyTensorARM vkCmdCopyTensorARM;
+extern PFN_vkCreateTensorARM vkCreateTensorARM;
+extern PFN_vkCreateTensorViewARM vkCreateTensorViewARM;
+extern PFN_vkDestroyTensorARM vkDestroyTensorARM;
+extern PFN_vkDestroyTensorViewARM vkDestroyTensorViewARM;
+extern PFN_vkGetDeviceTensorMemoryRequirementsARM vkGetDeviceTensorMemoryRequirementsARM;
+extern PFN_vkGetTensorMemoryRequirementsARM vkGetTensorMemoryRequirementsARM;
+#endif /* defined(VK_ARM_tensors) */
+#if defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer)
+extern PFN_vkGetTensorOpaqueCaptureDescriptorDataARM vkGetTensorOpaqueCaptureDescriptorDataARM;
+extern PFN_vkGetTensorViewOpaqueCaptureDescriptorDataARM vkGetTensorViewOpaqueCaptureDescriptorDataARM;
+#endif /* defined(VK_ARM_tensors) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_attachment_feedback_loop_dynamic_state)
+extern PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT vkCmdSetAttachmentFeedbackLoopEnableEXT;
+#endif /* defined(VK_EXT_attachment_feedback_loop_dynamic_state) */
+#if defined(VK_EXT_buffer_device_address)
+extern PFN_vkGetBufferDeviceAddressEXT vkGetBufferDeviceAddressEXT;
+#endif /* defined(VK_EXT_buffer_device_address) */
+#if defined(VK_EXT_calibrated_timestamps)
+extern PFN_vkGetCalibratedTimestampsEXT vkGetCalibratedTimestampsEXT;
+#endif /* defined(VK_EXT_calibrated_timestamps) */
+#if defined(VK_EXT_color_write_enable)
+extern PFN_vkCmdSetColorWriteEnableEXT vkCmdSetColorWriteEnableEXT;
+#endif /* defined(VK_EXT_color_write_enable) */
+#if defined(VK_EXT_conditional_rendering)
+extern PFN_vkCmdBeginConditionalRenderingEXT vkCmdBeginConditionalRenderingEXT;
+extern PFN_vkCmdEndConditionalRenderingEXT vkCmdEndConditionalRenderingEXT;
+#endif /* defined(VK_EXT_conditional_rendering) */
+#if defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3))
+extern PFN_vkCmdBeginCustomResolveEXT vkCmdBeginCustomResolveEXT;
+#endif /* defined(VK_EXT_custom_resolve) && (defined(VK_KHR_dynamic_rendering) || defined(VK_VERSION_1_3)) */
+#if defined(VK_EXT_debug_marker)
+extern PFN_vkCmdDebugMarkerBeginEXT vkCmdDebugMarkerBeginEXT;
+extern PFN_vkCmdDebugMarkerEndEXT vkCmdDebugMarkerEndEXT;
+extern PFN_vkCmdDebugMarkerInsertEXT vkCmdDebugMarkerInsertEXT;
+extern PFN_vkDebugMarkerSetObjectNameEXT vkDebugMarkerSetObjectNameEXT;
+extern PFN_vkDebugMarkerSetObjectTagEXT vkDebugMarkerSetObjectTagEXT;
+#endif /* defined(VK_EXT_debug_marker) */
+#if defined(VK_EXT_depth_bias_control)
+extern PFN_vkCmdSetDepthBias2EXT vkCmdSetDepthBias2EXT;
+#endif /* defined(VK_EXT_depth_bias_control) */
+#if defined(VK_EXT_descriptor_buffer)
+extern PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT vkCmdBindDescriptorBufferEmbeddedSamplersEXT;
+extern PFN_vkCmdBindDescriptorBuffersEXT vkCmdBindDescriptorBuffersEXT;
+extern PFN_vkCmdSetDescriptorBufferOffsetsEXT vkCmdSetDescriptorBufferOffsetsEXT;
+extern PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT vkGetBufferOpaqueCaptureDescriptorDataEXT;
+extern PFN_vkGetDescriptorEXT vkGetDescriptorEXT;
+extern PFN_vkGetDescriptorSetLayoutBindingOffsetEXT vkGetDescriptorSetLayoutBindingOffsetEXT;
+extern PFN_vkGetDescriptorSetLayoutSizeEXT vkGetDescriptorSetLayoutSizeEXT;
+extern PFN_vkGetImageOpaqueCaptureDescriptorDataEXT vkGetImageOpaqueCaptureDescriptorDataEXT;
+extern PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT vkGetImageViewOpaqueCaptureDescriptorDataEXT;
+extern PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT vkGetSamplerOpaqueCaptureDescriptorDataEXT;
+#endif /* defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing))
+extern PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT;
+#endif /* defined(VK_EXT_descriptor_buffer) && (defined(VK_KHR_acceleration_structure) || defined(VK_NV_ray_tracing)) */
+#if defined(VK_EXT_descriptor_heap)
+extern PFN_vkCmdBindResourceHeapEXT vkCmdBindResourceHeapEXT;
+extern PFN_vkCmdBindSamplerHeapEXT vkCmdBindSamplerHeapEXT;
+extern PFN_vkCmdPushDataEXT vkCmdPushDataEXT;
+extern PFN_vkGetImageOpaqueCaptureDataEXT vkGetImageOpaqueCaptureDataEXT;
+extern PFN_vkWriteResourceDescriptorsEXT vkWriteResourceDescriptorsEXT;
+extern PFN_vkWriteSamplerDescriptorsEXT vkWriteSamplerDescriptorsEXT;
+#endif /* defined(VK_EXT_descriptor_heap) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color)
+extern PFN_vkRegisterCustomBorderColorEXT vkRegisterCustomBorderColorEXT;
+extern PFN_vkUnregisterCustomBorderColorEXT vkUnregisterCustomBorderColorEXT;
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_EXT_custom_border_color) */
+#if defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors)
+extern PFN_vkGetTensorOpaqueCaptureDataARM vkGetTensorOpaqueCaptureDataARM;
+#endif /* defined(VK_EXT_descriptor_heap) && defined(VK_ARM_tensors) */
+#if defined(VK_EXT_device_fault)
+extern PFN_vkGetDeviceFaultInfoEXT vkGetDeviceFaultInfoEXT;
+#endif /* defined(VK_EXT_device_fault) */
+#if defined(VK_EXT_device_generated_commands)
+extern PFN_vkCmdExecuteGeneratedCommandsEXT vkCmdExecuteGeneratedCommandsEXT;
+extern PFN_vkCmdPreprocessGeneratedCommandsEXT vkCmdPreprocessGeneratedCommandsEXT;
+extern PFN_vkCreateIndirectCommandsLayoutEXT vkCreateIndirectCommandsLayoutEXT;
+extern PFN_vkCreateIndirectExecutionSetEXT vkCreateIndirectExecutionSetEXT;
+extern PFN_vkDestroyIndirectCommandsLayoutEXT vkDestroyIndirectCommandsLayoutEXT;
+extern PFN_vkDestroyIndirectExecutionSetEXT vkDestroyIndirectExecutionSetEXT;
+extern PFN_vkGetGeneratedCommandsMemoryRequirementsEXT vkGetGeneratedCommandsMemoryRequirementsEXT;
+extern PFN_vkUpdateIndirectExecutionSetPipelineEXT vkUpdateIndirectExecutionSetPipelineEXT;
+extern PFN_vkUpdateIndirectExecutionSetShaderEXT vkUpdateIndirectExecutionSetShaderEXT;
+#endif /* defined(VK_EXT_device_generated_commands) */
+#if defined(VK_EXT_discard_rectangles)
+extern PFN_vkCmdSetDiscardRectangleEXT vkCmdSetDiscardRectangleEXT;
+#endif /* defined(VK_EXT_discard_rectangles) */
+#if defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2
+extern PFN_vkCmdSetDiscardRectangleEnableEXT vkCmdSetDiscardRectangleEnableEXT;
+extern PFN_vkCmdSetDiscardRectangleModeEXT vkCmdSetDiscardRectangleModeEXT;
+#endif /* defined(VK_EXT_discard_rectangles) && VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION >= 2 */
+#if defined(VK_EXT_display_control)
+extern PFN_vkDisplayPowerControlEXT vkDisplayPowerControlEXT;
+extern PFN_vkGetSwapchainCounterEXT vkGetSwapchainCounterEXT;
+extern PFN_vkRegisterDeviceEventEXT vkRegisterDeviceEventEXT;
+extern PFN_vkRegisterDisplayEventEXT vkRegisterDisplayEventEXT;
+#endif /* defined(VK_EXT_display_control) */
+#if defined(VK_EXT_external_memory_host)
+extern PFN_vkGetMemoryHostPointerPropertiesEXT vkGetMemoryHostPointerPropertiesEXT;
+#endif /* defined(VK_EXT_external_memory_host) */
+#if defined(VK_EXT_external_memory_metal)
+extern PFN_vkGetMemoryMetalHandleEXT vkGetMemoryMetalHandleEXT;
+extern PFN_vkGetMemoryMetalHandlePropertiesEXT vkGetMemoryMetalHandlePropertiesEXT;
+#endif /* defined(VK_EXT_external_memory_metal) */
+#if defined(VK_EXT_fragment_density_map_offset)
+extern PFN_vkCmdEndRendering2EXT vkCmdEndRendering2EXT;
+#endif /* defined(VK_EXT_fragment_density_map_offset) */
+#if defined(VK_EXT_full_screen_exclusive)
+extern PFN_vkAcquireFullScreenExclusiveModeEXT vkAcquireFullScreenExclusiveModeEXT;
+extern PFN_vkReleaseFullScreenExclusiveModeEXT vkReleaseFullScreenExclusiveModeEXT;
+#endif /* defined(VK_EXT_full_screen_exclusive) */
+#if defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1))
+extern PFN_vkGetDeviceGroupSurfacePresentModes2EXT vkGetDeviceGroupSurfacePresentModes2EXT;
+#endif /* defined(VK_EXT_full_screen_exclusive) && (defined(VK_KHR_device_group) || defined(VK_VERSION_1_1)) */
+#if defined(VK_EXT_hdr_metadata)
+extern PFN_vkSetHdrMetadataEXT vkSetHdrMetadataEXT;
+#endif /* defined(VK_EXT_hdr_metadata) */
+#if defined(VK_EXT_host_image_copy)
+extern PFN_vkCopyImageToImageEXT vkCopyImageToImageEXT;
+extern PFN_vkCopyImageToMemoryEXT vkCopyImageToMemoryEXT;
+extern PFN_vkCopyMemoryToImageEXT vkCopyMemoryToImageEXT;
+extern PFN_vkTransitionImageLayoutEXT vkTransitionImageLayoutEXT;
+#endif /* defined(VK_EXT_host_image_copy) */
+#if defined(VK_EXT_host_query_reset)
+extern PFN_vkResetQueryPoolEXT vkResetQueryPoolEXT;
+#endif /* defined(VK_EXT_host_query_reset) */
+#if defined(VK_EXT_image_drm_format_modifier)
+extern PFN_vkGetImageDrmFormatModifierPropertiesEXT vkGetImageDrmFormatModifierPropertiesEXT;
+#endif /* defined(VK_EXT_image_drm_format_modifier) */
+#if defined(VK_EXT_line_rasterization)
+extern PFN_vkCmdSetLineStippleEXT vkCmdSetLineStippleEXT;
+#endif /* defined(VK_EXT_line_rasterization) */
+#if defined(VK_EXT_memory_decompression)
+extern PFN_vkCmdDecompressMemoryEXT vkCmdDecompressMemoryEXT;
+extern PFN_vkCmdDecompressMemoryIndirectCountEXT vkCmdDecompressMemoryIndirectCountEXT;
+#endif /* defined(VK_EXT_memory_decompression) */
+#if defined(VK_EXT_mesh_shader)
+extern PFN_vkCmdDrawMeshTasksEXT vkCmdDrawMeshTasksEXT;
+extern PFN_vkCmdDrawMeshTasksIndirectEXT vkCmdDrawMeshTasksIndirectEXT;
+#endif /* defined(VK_EXT_mesh_shader) */
+#if defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+extern PFN_vkCmdDrawMeshTasksIndirectCountEXT vkCmdDrawMeshTasksIndirectCountEXT;
+#endif /* defined(VK_EXT_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_EXT_metal_objects)
+extern PFN_vkExportMetalObjectsEXT vkExportMetalObjectsEXT;
+#endif /* defined(VK_EXT_metal_objects) */
+#if defined(VK_EXT_multi_draw)
+extern PFN_vkCmdDrawMultiEXT vkCmdDrawMultiEXT;
+extern PFN_vkCmdDrawMultiIndexedEXT vkCmdDrawMultiIndexedEXT;
+#endif /* defined(VK_EXT_multi_draw) */
+#if defined(VK_EXT_opacity_micromap)
+extern PFN_vkBuildMicromapsEXT vkBuildMicromapsEXT;
+extern PFN_vkCmdBuildMicromapsEXT vkCmdBuildMicromapsEXT;
+extern PFN_vkCmdCopyMemoryToMicromapEXT vkCmdCopyMemoryToMicromapEXT;
+extern PFN_vkCmdCopyMicromapEXT vkCmdCopyMicromapEXT;
+extern PFN_vkCmdCopyMicromapToMemoryEXT vkCmdCopyMicromapToMemoryEXT;
+extern PFN_vkCmdWriteMicromapsPropertiesEXT vkCmdWriteMicromapsPropertiesEXT;
+extern PFN_vkCopyMemoryToMicromapEXT vkCopyMemoryToMicromapEXT;
+extern PFN_vkCopyMicromapEXT vkCopyMicromapEXT;
+extern PFN_vkCopyMicromapToMemoryEXT vkCopyMicromapToMemoryEXT;
+extern PFN_vkCreateMicromapEXT vkCreateMicromapEXT;
+extern PFN_vkDestroyMicromapEXT vkDestroyMicromapEXT;
+extern PFN_vkGetDeviceMicromapCompatibilityEXT vkGetDeviceMicromapCompatibilityEXT;
+extern PFN_vkGetMicromapBuildSizesEXT vkGetMicromapBuildSizesEXT;
+extern PFN_vkWriteMicromapsPropertiesEXT vkWriteMicromapsPropertiesEXT;
+#endif /* defined(VK_EXT_opacity_micromap) */
+#if defined(VK_EXT_pageable_device_local_memory)
+extern PFN_vkSetDeviceMemoryPriorityEXT vkSetDeviceMemoryPriorityEXT;
+#endif /* defined(VK_EXT_pageable_device_local_memory) */
+#if defined(VK_EXT_pipeline_properties)
+extern PFN_vkGetPipelinePropertiesEXT vkGetPipelinePropertiesEXT;
+#endif /* defined(VK_EXT_pipeline_properties) */
+#if defined(VK_EXT_present_timing)
+extern PFN_vkGetPastPresentationTimingEXT vkGetPastPresentationTimingEXT;
+extern PFN_vkGetSwapchainTimeDomainPropertiesEXT vkGetSwapchainTimeDomainPropertiesEXT;
+extern PFN_vkGetSwapchainTimingPropertiesEXT vkGetSwapchainTimingPropertiesEXT;
+extern PFN_vkSetSwapchainPresentTimingQueueSizeEXT vkSetSwapchainPresentTimingQueueSizeEXT;
+#endif /* defined(VK_EXT_present_timing) */
+#if defined(VK_EXT_primitive_restart_index)
+extern PFN_vkCmdSetPrimitiveRestartIndexEXT vkCmdSetPrimitiveRestartIndexEXT;
+#endif /* defined(VK_EXT_primitive_restart_index) */
+#if defined(VK_EXT_private_data)
+extern PFN_vkCreatePrivateDataSlotEXT vkCreatePrivateDataSlotEXT;
+extern PFN_vkDestroyPrivateDataSlotEXT vkDestroyPrivateDataSlotEXT;
+extern PFN_vkGetPrivateDataEXT vkGetPrivateDataEXT;
+extern PFN_vkSetPrivateDataEXT vkSetPrivateDataEXT;
+#endif /* defined(VK_EXT_private_data) */
+#if defined(VK_EXT_sample_locations)
+extern PFN_vkCmdSetSampleLocationsEXT vkCmdSetSampleLocationsEXT;
+#endif /* defined(VK_EXT_sample_locations) */
+#if defined(VK_EXT_shader_module_identifier)
+extern PFN_vkGetShaderModuleCreateInfoIdentifierEXT vkGetShaderModuleCreateInfoIdentifierEXT;
+extern PFN_vkGetShaderModuleIdentifierEXT vkGetShaderModuleIdentifierEXT;
+#endif /* defined(VK_EXT_shader_module_identifier) */
+#if defined(VK_EXT_shader_object)
+extern PFN_vkCmdBindShadersEXT vkCmdBindShadersEXT;
+extern PFN_vkCreateShadersEXT vkCreateShadersEXT;
+extern PFN_vkDestroyShaderEXT vkDestroyShaderEXT;
+extern PFN_vkGetShaderBinaryDataEXT vkGetShaderBinaryDataEXT;
+#endif /* defined(VK_EXT_shader_object) */
+#if defined(VK_EXT_swapchain_maintenance1)
+extern PFN_vkReleaseSwapchainImagesEXT vkReleaseSwapchainImagesEXT;
+#endif /* defined(VK_EXT_swapchain_maintenance1) */
+#if defined(VK_EXT_transform_feedback)
+extern PFN_vkCmdBeginQueryIndexedEXT vkCmdBeginQueryIndexedEXT;
+extern PFN_vkCmdBeginTransformFeedbackEXT vkCmdBeginTransformFeedbackEXT;
+extern PFN_vkCmdBindTransformFeedbackBuffersEXT vkCmdBindTransformFeedbackBuffersEXT;
+extern PFN_vkCmdDrawIndirectByteCountEXT vkCmdDrawIndirectByteCountEXT;
+extern PFN_vkCmdEndQueryIndexedEXT vkCmdEndQueryIndexedEXT;
+extern PFN_vkCmdEndTransformFeedbackEXT vkCmdEndTransformFeedbackEXT;
+#endif /* defined(VK_EXT_transform_feedback) */
+#if defined(VK_EXT_validation_cache)
+extern PFN_vkCreateValidationCacheEXT vkCreateValidationCacheEXT;
+extern PFN_vkDestroyValidationCacheEXT vkDestroyValidationCacheEXT;
+extern PFN_vkGetValidationCacheDataEXT vkGetValidationCacheDataEXT;
+extern PFN_vkMergeValidationCachesEXT vkMergeValidationCachesEXT;
+#endif /* defined(VK_EXT_validation_cache) */
+#if defined(VK_FUCHSIA_buffer_collection)
+extern PFN_vkCreateBufferCollectionFUCHSIA vkCreateBufferCollectionFUCHSIA;
+extern PFN_vkDestroyBufferCollectionFUCHSIA vkDestroyBufferCollectionFUCHSIA;
+extern PFN_vkGetBufferCollectionPropertiesFUCHSIA vkGetBufferCollectionPropertiesFUCHSIA;
+extern PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA vkSetBufferCollectionBufferConstraintsFUCHSIA;
+extern PFN_vkSetBufferCollectionImageConstraintsFUCHSIA vkSetBufferCollectionImageConstraintsFUCHSIA;
+#endif /* defined(VK_FUCHSIA_buffer_collection) */
+#if defined(VK_FUCHSIA_external_memory)
+extern PFN_vkGetMemoryZirconHandleFUCHSIA vkGetMemoryZirconHandleFUCHSIA;
+extern PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA vkGetMemoryZirconHandlePropertiesFUCHSIA;
+#endif /* defined(VK_FUCHSIA_external_memory) */
+#if defined(VK_FUCHSIA_external_semaphore)
+extern PFN_vkGetSemaphoreZirconHandleFUCHSIA vkGetSemaphoreZirconHandleFUCHSIA;
+extern PFN_vkImportSemaphoreZirconHandleFUCHSIA vkImportSemaphoreZirconHandleFUCHSIA;
+#endif /* defined(VK_FUCHSIA_external_semaphore) */
+#if defined(VK_GOOGLE_display_timing)
+extern PFN_vkGetPastPresentationTimingGOOGLE vkGetPastPresentationTimingGOOGLE;
+extern PFN_vkGetRefreshCycleDurationGOOGLE vkGetRefreshCycleDurationGOOGLE;
+#endif /* defined(VK_GOOGLE_display_timing) */
+#if defined(VK_HUAWEI_cluster_culling_shader)
+extern PFN_vkCmdDrawClusterHUAWEI vkCmdDrawClusterHUAWEI;
+extern PFN_vkCmdDrawClusterIndirectHUAWEI vkCmdDrawClusterIndirectHUAWEI;
+#endif /* defined(VK_HUAWEI_cluster_culling_shader) */
+#if defined(VK_HUAWEI_invocation_mask)
+extern PFN_vkCmdBindInvocationMaskHUAWEI vkCmdBindInvocationMaskHUAWEI;
+#endif /* defined(VK_HUAWEI_invocation_mask) */
+#if defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2
+extern PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI;
+#endif /* defined(VK_HUAWEI_subpass_shading) && VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION >= 2 */
+#if defined(VK_HUAWEI_subpass_shading)
+extern PFN_vkCmdSubpassShadingHUAWEI vkCmdSubpassShadingHUAWEI;
+#endif /* defined(VK_HUAWEI_subpass_shading) */
+#if defined(VK_INTEL_performance_query)
+extern PFN_vkAcquirePerformanceConfigurationINTEL vkAcquirePerformanceConfigurationINTEL;
+extern PFN_vkCmdSetPerformanceMarkerINTEL vkCmdSetPerformanceMarkerINTEL;
+extern PFN_vkCmdSetPerformanceOverrideINTEL vkCmdSetPerformanceOverrideINTEL;
+extern PFN_vkCmdSetPerformanceStreamMarkerINTEL vkCmdSetPerformanceStreamMarkerINTEL;
+extern PFN_vkGetPerformanceParameterINTEL vkGetPerformanceParameterINTEL;
+extern PFN_vkInitializePerformanceApiINTEL vkInitializePerformanceApiINTEL;
+extern PFN_vkQueueSetPerformanceConfigurationINTEL vkQueueSetPerformanceConfigurationINTEL;
+extern PFN_vkReleasePerformanceConfigurationINTEL vkReleasePerformanceConfigurationINTEL;
+extern PFN_vkUninitializePerformanceApiINTEL vkUninitializePerformanceApiINTEL;
+#endif /* defined(VK_INTEL_performance_query) */
+#if defined(VK_KHR_acceleration_structure)
+extern PFN_vkBuildAccelerationStructuresKHR vkBuildAccelerationStructuresKHR;
+extern PFN_vkCmdBuildAccelerationStructuresIndirectKHR vkCmdBuildAccelerationStructuresIndirectKHR;
+extern PFN_vkCmdBuildAccelerationStructuresKHR vkCmdBuildAccelerationStructuresKHR;
+extern PFN_vkCmdCopyAccelerationStructureKHR vkCmdCopyAccelerationStructureKHR;
+extern PFN_vkCmdCopyAccelerationStructureToMemoryKHR vkCmdCopyAccelerationStructureToMemoryKHR;
+extern PFN_vkCmdCopyMemoryToAccelerationStructureKHR vkCmdCopyMemoryToAccelerationStructureKHR;
+extern PFN_vkCmdWriteAccelerationStructuresPropertiesKHR vkCmdWriteAccelerationStructuresPropertiesKHR;
+extern PFN_vkCopyAccelerationStructureKHR vkCopyAccelerationStructureKHR;
+extern PFN_vkCopyAccelerationStructureToMemoryKHR vkCopyAccelerationStructureToMemoryKHR;
+extern PFN_vkCopyMemoryToAccelerationStructureKHR vkCopyMemoryToAccelerationStructureKHR;
+extern PFN_vkCreateAccelerationStructureKHR vkCreateAccelerationStructureKHR;
+extern PFN_vkDestroyAccelerationStructureKHR vkDestroyAccelerationStructureKHR;
+extern PFN_vkGetAccelerationStructureBuildSizesKHR vkGetAccelerationStructureBuildSizesKHR;
+extern PFN_vkGetAccelerationStructureDeviceAddressKHR vkGetAccelerationStructureDeviceAddressKHR;
+extern PFN_vkGetDeviceAccelerationStructureCompatibilityKHR vkGetDeviceAccelerationStructureCompatibilityKHR;
+extern PFN_vkWriteAccelerationStructuresPropertiesKHR vkWriteAccelerationStructuresPropertiesKHR;
+#endif /* defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_bind_memory2)
+extern PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR;
+extern PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR;
+#endif /* defined(VK_KHR_bind_memory2) */
+#if defined(VK_KHR_buffer_device_address)
+extern PFN_vkGetBufferDeviceAddressKHR vkGetBufferDeviceAddressKHR;
+extern PFN_vkGetBufferOpaqueCaptureAddressKHR vkGetBufferOpaqueCaptureAddressKHR;
+extern PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR vkGetDeviceMemoryOpaqueCaptureAddressKHR;
+#endif /* defined(VK_KHR_buffer_device_address) */
+#if defined(VK_KHR_calibrated_timestamps)
+extern PFN_vkGetCalibratedTimestampsKHR vkGetCalibratedTimestampsKHR;
+#endif /* defined(VK_KHR_calibrated_timestamps) */
+#if defined(VK_KHR_copy_commands2)
+extern PFN_vkCmdBlitImage2KHR vkCmdBlitImage2KHR;
+extern PFN_vkCmdCopyBuffer2KHR vkCmdCopyBuffer2KHR;
+extern PFN_vkCmdCopyBufferToImage2KHR vkCmdCopyBufferToImage2KHR;
+extern PFN_vkCmdCopyImage2KHR vkCmdCopyImage2KHR;
+extern PFN_vkCmdCopyImageToBuffer2KHR vkCmdCopyImageToBuffer2KHR;
+extern PFN_vkCmdResolveImage2KHR vkCmdResolveImage2KHR;
+#endif /* defined(VK_KHR_copy_commands2) */
+#if defined(VK_KHR_copy_memory_indirect)
+extern PFN_vkCmdCopyMemoryIndirectKHR vkCmdCopyMemoryIndirectKHR;
+extern PFN_vkCmdCopyMemoryToImageIndirectKHR vkCmdCopyMemoryToImageIndirectKHR;
+#endif /* defined(VK_KHR_copy_memory_indirect) */
+#if defined(VK_KHR_create_renderpass2)
+extern PFN_vkCmdBeginRenderPass2KHR vkCmdBeginRenderPass2KHR;
+extern PFN_vkCmdEndRenderPass2KHR vkCmdEndRenderPass2KHR;
+extern PFN_vkCmdNextSubpass2KHR vkCmdNextSubpass2KHR;
+extern PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR;
+#endif /* defined(VK_KHR_create_renderpass2) */
+#if defined(VK_KHR_deferred_host_operations)
+extern PFN_vkCreateDeferredOperationKHR vkCreateDeferredOperationKHR;
+extern PFN_vkDeferredOperationJoinKHR vkDeferredOperationJoinKHR;
+extern PFN_vkDestroyDeferredOperationKHR vkDestroyDeferredOperationKHR;
+extern PFN_vkGetDeferredOperationMaxConcurrencyKHR vkGetDeferredOperationMaxConcurrencyKHR;
+extern PFN_vkGetDeferredOperationResultKHR vkGetDeferredOperationResultKHR;
+#endif /* defined(VK_KHR_deferred_host_operations) */
+#if defined(VK_KHR_descriptor_update_template)
+extern PFN_vkCreateDescriptorUpdateTemplateKHR vkCreateDescriptorUpdateTemplateKHR;
+extern PFN_vkDestroyDescriptorUpdateTemplateKHR vkDestroyDescriptorUpdateTemplateKHR;
+extern PFN_vkUpdateDescriptorSetWithTemplateKHR vkUpdateDescriptorSetWithTemplateKHR;
+#endif /* defined(VK_KHR_descriptor_update_template) */
+#if defined(VK_KHR_device_address_commands)
+extern PFN_vkCmdBindIndexBuffer3KHR vkCmdBindIndexBuffer3KHR;
+extern PFN_vkCmdBindVertexBuffers3KHR vkCmdBindVertexBuffers3KHR;
+extern PFN_vkCmdCopyImageToMemoryKHR vkCmdCopyImageToMemoryKHR;
+extern PFN_vkCmdCopyMemoryKHR vkCmdCopyMemoryKHR;
+extern PFN_vkCmdCopyMemoryToImageKHR vkCmdCopyMemoryToImageKHR;
+extern PFN_vkCmdCopyQueryPoolResultsToMemoryKHR vkCmdCopyQueryPoolResultsToMemoryKHR;
+extern PFN_vkCmdDispatchIndirect2KHR vkCmdDispatchIndirect2KHR;
+extern PFN_vkCmdDrawIndexedIndirect2KHR vkCmdDrawIndexedIndirect2KHR;
+extern PFN_vkCmdDrawIndirect2KHR vkCmdDrawIndirect2KHR;
+extern PFN_vkCmdFillMemoryKHR vkCmdFillMemoryKHR;
+extern PFN_vkCmdUpdateMemoryKHR vkCmdUpdateMemoryKHR;
+#endif /* defined(VK_KHR_device_address_commands) */
+#if defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2))
+extern PFN_vkCmdDrawIndexedIndirectCount2KHR vkCmdDrawIndexedIndirectCount2KHR;
+extern PFN_vkCmdDrawIndirectCount2KHR vkCmdDrawIndirectCount2KHR;
+#endif /* defined(VK_KHR_device_address_commands) && (defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering)
+extern PFN_vkCmdBeginConditionalRendering2EXT vkCmdBeginConditionalRendering2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_conditional_rendering) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback)
+extern PFN_vkCmdBeginTransformFeedback2EXT vkCmdBeginTransformFeedback2EXT;
+extern PFN_vkCmdBindTransformFeedbackBuffers2EXT vkCmdBindTransformFeedbackBuffers2EXT;
+extern PFN_vkCmdDrawIndirectByteCount2EXT vkCmdDrawIndirectByteCount2EXT;
+extern PFN_vkCmdEndTransformFeedback2EXT vkCmdEndTransformFeedback2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_transform_feedback) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader)
+extern PFN_vkCmdDrawMeshTasksIndirect2EXT vkCmdDrawMeshTasksIndirect2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_EXT_mesh_shader) */
+#if defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader))
+extern PFN_vkCmdDrawMeshTasksIndirectCount2EXT vkCmdDrawMeshTasksIndirectCount2EXT;
+#endif /* defined(VK_KHR_device_address_commands) && ((defined(VK_KHR_draw_indirect_count) || defined(VK_VERSION_1_2)) && defined(VK_EXT_mesh_shader)) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker)
+extern PFN_vkCmdWriteMarkerToMemoryAMD vkCmdWriteMarkerToMemoryAMD;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_AMD_buffer_marker) */
+#if defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure)
+extern PFN_vkCreateAccelerationStructure2KHR vkCreateAccelerationStructure2KHR;
+#endif /* defined(VK_KHR_device_address_commands) && defined(VK_KHR_acceleration_structure) */
+#if defined(VK_KHR_device_fault)
+extern PFN_vkGetDeviceFaultDebugInfoKHR vkGetDeviceFaultDebugInfoKHR;
+extern PFN_vkGetDeviceFaultReportsKHR vkGetDeviceFaultReportsKHR;
+#endif /* defined(VK_KHR_device_fault) */
+#if defined(VK_KHR_device_group)
+extern PFN_vkCmdDispatchBaseKHR vkCmdDispatchBaseKHR;
+extern PFN_vkCmdSetDeviceMaskKHR vkCmdSetDeviceMaskKHR;
+extern PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR vkGetDeviceGroupPeerMemoryFeaturesKHR;
+#endif /* defined(VK_KHR_device_group) */
+#if defined(VK_KHR_display_swapchain)
+extern PFN_vkCreateSharedSwapchainsKHR vkCreateSharedSwapchainsKHR;
+#endif /* defined(VK_KHR_display_swapchain) */
+#if defined(VK_KHR_draw_indirect_count)
+extern PFN_vkCmdDrawIndexedIndirectCountKHR vkCmdDrawIndexedIndirectCountKHR;
+extern PFN_vkCmdDrawIndirectCountKHR vkCmdDrawIndirectCountKHR;
+#endif /* defined(VK_KHR_draw_indirect_count) */
+#if defined(VK_KHR_dynamic_rendering)
+extern PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
+extern PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
+#endif /* defined(VK_KHR_dynamic_rendering) */
+#if defined(VK_KHR_dynamic_rendering_local_read)
+extern PFN_vkCmdSetRenderingAttachmentLocationsKHR vkCmdSetRenderingAttachmentLocationsKHR;
+extern PFN_vkCmdSetRenderingInputAttachmentIndicesKHR vkCmdSetRenderingInputAttachmentIndicesKHR;
+#endif /* defined(VK_KHR_dynamic_rendering_local_read) */
+#if defined(VK_KHR_external_fence_fd)
+extern PFN_vkGetFenceFdKHR vkGetFenceFdKHR;
+extern PFN_vkImportFenceFdKHR vkImportFenceFdKHR;
+#endif /* defined(VK_KHR_external_fence_fd) */
+#if defined(VK_KHR_external_fence_win32)
+extern PFN_vkGetFenceWin32HandleKHR vkGetFenceWin32HandleKHR;
+extern PFN_vkImportFenceWin32HandleKHR vkImportFenceWin32HandleKHR;
+#endif /* defined(VK_KHR_external_fence_win32) */
+#if defined(VK_KHR_external_memory_fd)
+extern PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR;
+extern PFN_vkGetMemoryFdPropertiesKHR vkGetMemoryFdPropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_fd) */
+#if defined(VK_KHR_external_memory_win32)
+extern PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR;
+extern PFN_vkGetMemoryWin32HandlePropertiesKHR vkGetMemoryWin32HandlePropertiesKHR;
+#endif /* defined(VK_KHR_external_memory_win32) */
+#if defined(VK_KHR_external_semaphore_fd)
+extern PFN_vkGetSemaphoreFdKHR vkGetSemaphoreFdKHR;
+extern PFN_vkImportSemaphoreFdKHR vkImportSemaphoreFdKHR;
+#endif /* defined(VK_KHR_external_semaphore_fd) */
+#if defined(VK_KHR_external_semaphore_win32)
+extern PFN_vkGetSemaphoreWin32HandleKHR vkGetSemaphoreWin32HandleKHR;
+extern PFN_vkImportSemaphoreWin32HandleKHR vkImportSemaphoreWin32HandleKHR;
+#endif /* defined(VK_KHR_external_semaphore_win32) */
+#if defined(VK_KHR_fragment_shading_rate)
+extern PFN_vkCmdSetFragmentShadingRateKHR vkCmdSetFragmentShadingRateKHR;
+#endif /* defined(VK_KHR_fragment_shading_rate) */
+#if defined(VK_KHR_get_memory_requirements2)
+extern PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR;
+extern PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
+extern PFN_vkGetImageSparseMemoryRequirements2KHR vkGetImageSparseMemoryRequirements2KHR;
+#endif /* defined(VK_KHR_get_memory_requirements2) */
+#if defined(VK_KHR_line_rasterization)
+extern PFN_vkCmdSetLineStippleKHR vkCmdSetLineStippleKHR;
+#endif /* defined(VK_KHR_line_rasterization) */
+#if defined(VK_KHR_maintenance1)
+extern PFN_vkTrimCommandPoolKHR vkTrimCommandPoolKHR;
+#endif /* defined(VK_KHR_maintenance1) */
+#if defined(VK_KHR_maintenance10)
+extern PFN_vkCmdEndRendering2KHR vkCmdEndRendering2KHR;
+#endif /* defined(VK_KHR_maintenance10) */
+#if defined(VK_KHR_maintenance3)
+extern PFN_vkGetDescriptorSetLayoutSupportKHR vkGetDescriptorSetLayoutSupportKHR;
+#endif /* defined(VK_KHR_maintenance3) */
+#if defined(VK_KHR_maintenance4)
+extern PFN_vkGetDeviceBufferMemoryRequirementsKHR vkGetDeviceBufferMemoryRequirementsKHR;
+extern PFN_vkGetDeviceImageMemoryRequirementsKHR vkGetDeviceImageMemoryRequirementsKHR;
+extern PFN_vkGetDeviceImageSparseMemoryRequirementsKHR vkGetDeviceImageSparseMemoryRequirementsKHR;
+#endif /* defined(VK_KHR_maintenance4) */
+#if defined(VK_KHR_maintenance5)
+extern PFN_vkCmdBindIndexBuffer2KHR vkCmdBindIndexBuffer2KHR;
+extern PFN_vkGetDeviceImageSubresourceLayoutKHR vkGetDeviceImageSubresourceLayoutKHR;
+extern PFN_vkGetImageSubresourceLayout2KHR vkGetImageSubresourceLayout2KHR;
+extern PFN_vkGetRenderingAreaGranularityKHR vkGetRenderingAreaGranularityKHR;
+#endif /* defined(VK_KHR_maintenance5) */
+#if defined(VK_KHR_maintenance6)
+extern PFN_vkCmdBindDescriptorSets2KHR vkCmdBindDescriptorSets2KHR;
+extern PFN_vkCmdPushConstants2KHR vkCmdPushConstants2KHR;
+#endif /* defined(VK_KHR_maintenance6) */
+#if defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor)
+extern PFN_vkCmdPushDescriptorSet2KHR vkCmdPushDescriptorSet2KHR;
+extern PFN_vkCmdPushDescriptorSetWithTemplate2KHR vkCmdPushDescriptorSetWithTemplate2KHR;
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer)
+extern PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT vkCmdBindDescriptorBufferEmbeddedSamplers2EXT;
+extern PFN_vkCmdSetDescriptorBufferOffsets2EXT vkCmdSetDescriptorBufferOffsets2EXT;
+#endif /* defined(VK_KHR_maintenance6) && defined(VK_EXT_descriptor_buffer) */
+#if defined(VK_KHR_map_memory2)
+extern PFN_vkMapMemory2KHR vkMapMemory2KHR;
+extern PFN_vkUnmapMemory2KHR vkUnmapMemory2KHR;
+#endif /* defined(VK_KHR_map_memory2) */
+#if defined(VK_KHR_performance_query)
+extern PFN_vkAcquireProfilingLockKHR vkAcquireProfilingLockKHR;
+extern PFN_vkReleaseProfilingLockKHR vkReleaseProfilingLockKHR;
+#endif /* defined(VK_KHR_performance_query) */
+#if defined(VK_KHR_pipeline_binary)
+extern PFN_vkCreatePipelineBinariesKHR vkCreatePipelineBinariesKHR;
+extern PFN_vkDestroyPipelineBinaryKHR vkDestroyPipelineBinaryKHR;
+extern PFN_vkGetPipelineBinaryDataKHR vkGetPipelineBinaryDataKHR;
+extern PFN_vkGetPipelineKeyKHR vkGetPipelineKeyKHR;
+extern PFN_vkReleaseCapturedPipelineDataKHR vkReleaseCapturedPipelineDataKHR;
+#endif /* defined(VK_KHR_pipeline_binary) */
+#if defined(VK_KHR_pipeline_executable_properties)
+extern PFN_vkGetPipelineExecutableInternalRepresentationsKHR vkGetPipelineExecutableInternalRepresentationsKHR;
+extern PFN_vkGetPipelineExecutablePropertiesKHR vkGetPipelineExecutablePropertiesKHR;
+extern PFN_vkGetPipelineExecutableStatisticsKHR vkGetPipelineExecutableStatisticsKHR;
+#endif /* defined(VK_KHR_pipeline_executable_properties) */
+#if defined(VK_KHR_present_wait)
+extern PFN_vkWaitForPresentKHR vkWaitForPresentKHR;
+#endif /* defined(VK_KHR_present_wait) */
+#if defined(VK_KHR_present_wait2)
+extern PFN_vkWaitForPresent2KHR vkWaitForPresent2KHR;
+#endif /* defined(VK_KHR_present_wait2) */
+#if defined(VK_KHR_push_descriptor)
+extern PFN_vkCmdPushDescriptorSetKHR vkCmdPushDescriptorSetKHR;
+#endif /* defined(VK_KHR_push_descriptor) */
+#if defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline)
+extern PFN_vkCmdTraceRaysIndirect2KHR vkCmdTraceRaysIndirect2KHR;
+#endif /* defined(VK_KHR_ray_tracing_maintenance1) && defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_ray_tracing_pipeline)
+extern PFN_vkCmdSetRayTracingPipelineStackSizeKHR vkCmdSetRayTracingPipelineStackSizeKHR;
+extern PFN_vkCmdTraceRaysIndirectKHR vkCmdTraceRaysIndirectKHR;
+extern PFN_vkCmdTraceRaysKHR vkCmdTraceRaysKHR;
+extern PFN_vkCreateRayTracingPipelinesKHR vkCreateRayTracingPipelinesKHR;
+extern PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR vkGetRayTracingCaptureReplayShaderGroupHandlesKHR;
+extern PFN_vkGetRayTracingShaderGroupHandlesKHR vkGetRayTracingShaderGroupHandlesKHR;
+extern PFN_vkGetRayTracingShaderGroupStackSizeKHR vkGetRayTracingShaderGroupStackSizeKHR;
+#endif /* defined(VK_KHR_ray_tracing_pipeline) */
+#if defined(VK_KHR_sampler_ycbcr_conversion)
+extern PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
+extern PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
+#endif /* defined(VK_KHR_sampler_ycbcr_conversion) */
+#if defined(VK_KHR_shared_presentable_image)
+extern PFN_vkGetSwapchainStatusKHR vkGetSwapchainStatusKHR;
+#endif /* defined(VK_KHR_shared_presentable_image) */
+#if defined(VK_KHR_swapchain)
+extern PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR;
+extern PFN_vkCreateSwapchainKHR vkCreateSwapchainKHR;
+extern PFN_vkDestroySwapchainKHR vkDestroySwapchainKHR;
+extern PFN_vkGetSwapchainImagesKHR vkGetSwapchainImagesKHR;
+extern PFN_vkQueuePresentKHR vkQueuePresentKHR;
+#endif /* defined(VK_KHR_swapchain) */
+#if defined(VK_KHR_swapchain_maintenance1)
+extern PFN_vkReleaseSwapchainImagesKHR vkReleaseSwapchainImagesKHR;
+#endif /* defined(VK_KHR_swapchain_maintenance1) */
+#if defined(VK_KHR_synchronization2)
+extern PFN_vkCmdPipelineBarrier2KHR vkCmdPipelineBarrier2KHR;
+extern PFN_vkCmdResetEvent2KHR vkCmdResetEvent2KHR;
+extern PFN_vkCmdSetEvent2KHR vkCmdSetEvent2KHR;
+extern PFN_vkCmdWaitEvents2KHR vkCmdWaitEvents2KHR;
+extern PFN_vkCmdWriteTimestamp2KHR vkCmdWriteTimestamp2KHR;
+extern PFN_vkQueueSubmit2KHR vkQueueSubmit2KHR;
+#endif /* defined(VK_KHR_synchronization2) */
+#if defined(VK_KHR_timeline_semaphore)
+extern PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR;
+extern PFN_vkSignalSemaphoreKHR vkSignalSemaphoreKHR;
+extern PFN_vkWaitSemaphoresKHR vkWaitSemaphoresKHR;
+#endif /* defined(VK_KHR_timeline_semaphore) */
+#if defined(VK_KHR_video_decode_queue)
+extern PFN_vkCmdDecodeVideoKHR vkCmdDecodeVideoKHR;
+#endif /* defined(VK_KHR_video_decode_queue) */
+#if defined(VK_KHR_video_encode_queue)
+extern PFN_vkCmdEncodeVideoKHR vkCmdEncodeVideoKHR;
+extern PFN_vkGetEncodedVideoSessionParametersKHR vkGetEncodedVideoSessionParametersKHR;
+#endif /* defined(VK_KHR_video_encode_queue) */
+#if defined(VK_KHR_video_queue)
+extern PFN_vkBindVideoSessionMemoryKHR vkBindVideoSessionMemoryKHR;
+extern PFN_vkCmdBeginVideoCodingKHR vkCmdBeginVideoCodingKHR;
+extern PFN_vkCmdControlVideoCodingKHR vkCmdControlVideoCodingKHR;
+extern PFN_vkCmdEndVideoCodingKHR vkCmdEndVideoCodingKHR;
+extern PFN_vkCreateVideoSessionKHR vkCreateVideoSessionKHR;
+extern PFN_vkCreateVideoSessionParametersKHR vkCreateVideoSessionParametersKHR;
+extern PFN_vkDestroyVideoSessionKHR vkDestroyVideoSessionKHR;
+extern PFN_vkDestroyVideoSessionParametersKHR vkDestroyVideoSessionParametersKHR;
+extern PFN_vkGetVideoSessionMemoryRequirementsKHR vkGetVideoSessionMemoryRequirementsKHR;
+extern PFN_vkUpdateVideoSessionParametersKHR vkUpdateVideoSessionParametersKHR;
+#endif /* defined(VK_KHR_video_queue) */
+#if defined(VK_NVX_binary_import)
+extern PFN_vkCmdCuLaunchKernelNVX vkCmdCuLaunchKernelNVX;
+extern PFN_vkCreateCuFunctionNVX vkCreateCuFunctionNVX;
+extern PFN_vkCreateCuModuleNVX vkCreateCuModuleNVX;
+extern PFN_vkDestroyCuFunctionNVX vkDestroyCuFunctionNVX;
+extern PFN_vkDestroyCuModuleNVX vkDestroyCuModuleNVX;
+#endif /* defined(VK_NVX_binary_import) */
+#if defined(VK_NVX_image_view_handle)
+extern PFN_vkGetImageViewHandleNVX vkGetImageViewHandleNVX;
+#endif /* defined(VK_NVX_image_view_handle) */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3
+extern PFN_vkGetImageViewHandle64NVX vkGetImageViewHandle64NVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 3 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2
+extern PFN_vkGetImageViewAddressNVX vkGetImageViewAddressNVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 2 */
+#if defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4
+extern PFN_vkGetDeviceCombinedImageSamplerIndexNVX vkGetDeviceCombinedImageSamplerIndexNVX;
+#endif /* defined(VK_NVX_image_view_handle) && VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION >= 4 */
+#if defined(VK_NV_clip_space_w_scaling)
+extern PFN_vkCmdSetViewportWScalingNV vkCmdSetViewportWScalingNV;
+#endif /* defined(VK_NV_clip_space_w_scaling) */
+#if defined(VK_NV_cluster_acceleration_structure)
+extern PFN_vkCmdBuildClusterAccelerationStructureIndirectNV vkCmdBuildClusterAccelerationStructureIndirectNV;
+extern PFN_vkGetClusterAccelerationStructureBuildSizesNV vkGetClusterAccelerationStructureBuildSizesNV;
+#endif /* defined(VK_NV_cluster_acceleration_structure) */
+#if defined(VK_NV_compute_occupancy_priority)
+extern PFN_vkCmdSetComputeOccupancyPriorityNV vkCmdSetComputeOccupancyPriorityNV;
+#endif /* defined(VK_NV_compute_occupancy_priority) */
+#if defined(VK_NV_cooperative_vector)
+extern PFN_vkCmdConvertCooperativeVectorMatrixNV vkCmdConvertCooperativeVectorMatrixNV;
+extern PFN_vkConvertCooperativeVectorMatrixNV vkConvertCooperativeVectorMatrixNV;
+#endif /* defined(VK_NV_cooperative_vector) */
+#if defined(VK_NV_copy_memory_indirect)
+extern PFN_vkCmdCopyMemoryIndirectNV vkCmdCopyMemoryIndirectNV;
+extern PFN_vkCmdCopyMemoryToImageIndirectNV vkCmdCopyMemoryToImageIndirectNV;
+#endif /* defined(VK_NV_copy_memory_indirect) */
+#if defined(VK_NV_cuda_kernel_launch)
+extern PFN_vkCmdCudaLaunchKernelNV vkCmdCudaLaunchKernelNV;
+extern PFN_vkCreateCudaFunctionNV vkCreateCudaFunctionNV;
+extern PFN_vkCreateCudaModuleNV vkCreateCudaModuleNV;
+extern PFN_vkDestroyCudaFunctionNV vkDestroyCudaFunctionNV;
+extern PFN_vkDestroyCudaModuleNV vkDestroyCudaModuleNV;
+extern PFN_vkGetCudaModuleCacheNV vkGetCudaModuleCacheNV;
+#endif /* defined(VK_NV_cuda_kernel_launch) */
+#if defined(VK_NV_device_diagnostic_checkpoints)
+extern PFN_vkCmdSetCheckpointNV vkCmdSetCheckpointNV;
+extern PFN_vkGetQueueCheckpointDataNV vkGetQueueCheckpointDataNV;
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) */
+#if defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2))
+extern PFN_vkGetQueueCheckpointData2NV vkGetQueueCheckpointData2NV;
+#endif /* defined(VK_NV_device_diagnostic_checkpoints) && (defined(VK_VERSION_1_3) || defined(VK_KHR_synchronization2)) */
+#if defined(VK_NV_device_generated_commands)
+extern PFN_vkCmdBindPipelineShaderGroupNV vkCmdBindPipelineShaderGroupNV;
+extern PFN_vkCmdExecuteGeneratedCommandsNV vkCmdExecuteGeneratedCommandsNV;
+extern PFN_vkCmdPreprocessGeneratedCommandsNV vkCmdPreprocessGeneratedCommandsNV;
+extern PFN_vkCreateIndirectCommandsLayoutNV vkCreateIndirectCommandsLayoutNV;
+extern PFN_vkDestroyIndirectCommandsLayoutNV vkDestroyIndirectCommandsLayoutNV;
+extern PFN_vkGetGeneratedCommandsMemoryRequirementsNV vkGetGeneratedCommandsMemoryRequirementsNV;
+#endif /* defined(VK_NV_device_generated_commands) */
+#if defined(VK_NV_device_generated_commands_compute)
+extern PFN_vkCmdUpdatePipelineIndirectBufferNV vkCmdUpdatePipelineIndirectBufferNV;
+extern PFN_vkGetPipelineIndirectDeviceAddressNV vkGetPipelineIndirectDeviceAddressNV;
+extern PFN_vkGetPipelineIndirectMemoryRequirementsNV vkGetPipelineIndirectMemoryRequirementsNV;
+#endif /* defined(VK_NV_device_generated_commands_compute) */
+#if defined(VK_NV_external_compute_queue)
+extern PFN_vkCreateExternalComputeQueueNV vkCreateExternalComputeQueueNV;
+extern PFN_vkDestroyExternalComputeQueueNV vkDestroyExternalComputeQueueNV;
+extern PFN_vkGetExternalComputeQueueDataNV vkGetExternalComputeQueueDataNV;
+#endif /* defined(VK_NV_external_compute_queue) */
+#if defined(VK_NV_external_memory_rdma)
+extern PFN_vkGetMemoryRemoteAddressNV vkGetMemoryRemoteAddressNV;
+#endif /* defined(VK_NV_external_memory_rdma) */
+#if defined(VK_NV_external_memory_win32)
+extern PFN_vkGetMemoryWin32HandleNV vkGetMemoryWin32HandleNV;
+#endif /* defined(VK_NV_external_memory_win32) */
+#if defined(VK_NV_fragment_shading_rate_enums)
+extern PFN_vkCmdSetFragmentShadingRateEnumNV vkCmdSetFragmentShadingRateEnumNV;
+#endif /* defined(VK_NV_fragment_shading_rate_enums) */
+#if defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2
+extern PFN_vkGetLatencyTimingsLegacyNV vkGetLatencyTimingsLegacyNV;
+extern PFN_vkGetSleepStatusLegacyNV vkGetSleepStatusLegacyNV;
+extern PFN_vkLatencySleepLegacyNV vkLatencySleepLegacyNV;
+extern PFN_vkQueueNotifyOutOfBandLegacyNV vkQueueNotifyOutOfBandLegacyNV;
+extern PFN_vkSetLatencyMarkerLegacyNV vkSetLatencyMarkerLegacyNV;
+extern PFN_vkSetLatencySleepModeLegacyNV vkSetLatencySleepModeLegacyNV;
+extern PFN_vkShutdownLatencyDeviceLegacyNV vkShutdownLatencyDeviceLegacyNV;
+#endif /* defined(VK_NV_low_latency) && VK_NV_LOW_LATENCY_SPEC_VERSION >= 2 */
+#if defined(VK_NV_low_latency2)
+extern PFN_vkGetLatencyTimingsNV vkGetLatencyTimingsNV;
+extern PFN_vkLatencySleepNV vkLatencySleepNV;
+extern PFN_vkQueueNotifyOutOfBandNV vkQueueNotifyOutOfBandNV;
+extern PFN_vkSetLatencyMarkerNV vkSetLatencyMarkerNV;
+extern PFN_vkSetLatencySleepModeNV vkSetLatencySleepModeNV;
+#endif /* defined(VK_NV_low_latency2) */
+#if defined(VK_NV_memory_decompression)
+extern PFN_vkCmdDecompressMemoryIndirectCountNV vkCmdDecompressMemoryIndirectCountNV;
+extern PFN_vkCmdDecompressMemoryNV vkCmdDecompressMemoryNV;
+#endif /* defined(VK_NV_memory_decompression) */
+#if defined(VK_NV_mesh_shader)
+extern PFN_vkCmdDrawMeshTasksIndirectNV vkCmdDrawMeshTasksIndirectNV;
+extern PFN_vkCmdDrawMeshTasksNV vkCmdDrawMeshTasksNV;
+#endif /* defined(VK_NV_mesh_shader) */
+#if defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count))
+extern PFN_vkCmdDrawMeshTasksIndirectCountNV vkCmdDrawMeshTasksIndirectCountNV;
+#endif /* defined(VK_NV_mesh_shader) && (defined(VK_VERSION_1_2) || defined(VK_KHR_draw_indirect_count) || defined(VK_AMD_draw_indirect_count)) */
+#if defined(VK_NV_optical_flow)
+extern PFN_vkBindOpticalFlowSessionImageNV vkBindOpticalFlowSessionImageNV;
+extern PFN_vkCmdOpticalFlowExecuteNV vkCmdOpticalFlowExecuteNV;
+extern PFN_vkCreateOpticalFlowSessionNV vkCreateOpticalFlowSessionNV;
+extern PFN_vkDestroyOpticalFlowSessionNV vkDestroyOpticalFlowSessionNV;
+#endif /* defined(VK_NV_optical_flow) */
+#if defined(VK_NV_partitioned_acceleration_structure)
+extern PFN_vkCmdBuildPartitionedAccelerationStructuresNV vkCmdBuildPartitionedAccelerationStructuresNV;
+extern PFN_vkGetPartitionedAccelerationStructuresBuildSizesNV vkGetPartitionedAccelerationStructuresBuildSizesNV;
+#endif /* defined(VK_NV_partitioned_acceleration_structure) */
+#if defined(VK_NV_ray_tracing)
+extern PFN_vkBindAccelerationStructureMemoryNV vkBindAccelerationStructureMemoryNV;
+extern PFN_vkCmdBuildAccelerationStructureNV vkCmdBuildAccelerationStructureNV;
+extern PFN_vkCmdCopyAccelerationStructureNV vkCmdCopyAccelerationStructureNV;
+extern PFN_vkCmdTraceRaysNV vkCmdTraceRaysNV;
+extern PFN_vkCmdWriteAccelerationStructuresPropertiesNV vkCmdWriteAccelerationStructuresPropertiesNV;
+extern PFN_vkCompileDeferredNV vkCompileDeferredNV;
+extern PFN_vkCreateAccelerationStructureNV vkCreateAccelerationStructureNV;
+extern PFN_vkCreateRayTracingPipelinesNV vkCreateRayTracingPipelinesNV;
+extern PFN_vkDestroyAccelerationStructureNV vkDestroyAccelerationStructureNV;
+extern PFN_vkGetAccelerationStructureHandleNV vkGetAccelerationStructureHandleNV;
+extern PFN_vkGetAccelerationStructureMemoryRequirementsNV vkGetAccelerationStructureMemoryRequirementsNV;
+extern PFN_vkGetRayTracingShaderGroupHandlesNV vkGetRayTracingShaderGroupHandlesNV;
+#endif /* defined(VK_NV_ray_tracing) */
+#if defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2
+extern PFN_vkCmdSetExclusiveScissorEnableNV vkCmdSetExclusiveScissorEnableNV;
+#endif /* defined(VK_NV_scissor_exclusive) && VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION >= 2 */
+#if defined(VK_NV_scissor_exclusive)
+extern PFN_vkCmdSetExclusiveScissorNV vkCmdSetExclusiveScissorNV;
+#endif /* defined(VK_NV_scissor_exclusive) */
+#if defined(VK_NV_shading_rate_image)
+extern PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV;
+extern PFN_vkCmdSetCoarseSampleOrderNV vkCmdSetCoarseSampleOrderNV;
+extern PFN_vkCmdSetViewportShadingRatePaletteNV vkCmdSetViewportShadingRatePaletteNV;
+#endif /* defined(VK_NV_shading_rate_image) */
+#if defined(VK_OHOS_external_memory)
+extern PFN_vkGetMemoryNativeBufferOHOS vkGetMemoryNativeBufferOHOS;
+extern PFN_vkGetNativeBufferPropertiesOHOS vkGetNativeBufferPropertiesOHOS;
+#endif /* defined(VK_OHOS_external_memory) */
+#if defined(VK_QCOM_queue_perf_hint)
+extern PFN_vkQueueSetPerfHintQCOM vkQueueSetPerfHintQCOM;
+#endif /* defined(VK_QCOM_queue_perf_hint) */
+#if defined(VK_QCOM_tile_memory_heap)
+extern PFN_vkCmdBindTileMemoryQCOM vkCmdBindTileMemoryQCOM;
+#endif /* defined(VK_QCOM_tile_memory_heap) */
+#if defined(VK_QCOM_tile_properties)
+extern PFN_vkGetDynamicRenderingTilePropertiesQCOM vkGetDynamicRenderingTilePropertiesQCOM;
+extern PFN_vkGetFramebufferTilePropertiesQCOM vkGetFramebufferTilePropertiesQCOM;
+#endif /* defined(VK_QCOM_tile_properties) */
+#if defined(VK_QCOM_tile_shading)
+extern PFN_vkCmdBeginPerTileExecutionQCOM vkCmdBeginPerTileExecutionQCOM;
+extern PFN_vkCmdDispatchTileQCOM vkCmdDispatchTileQCOM;
+extern PFN_vkCmdEndPerTileExecutionQCOM vkCmdEndPerTileExecutionQCOM;
+#endif /* defined(VK_QCOM_tile_shading) */
+#if defined(VK_QNX_external_memory_screen_buffer)
+extern PFN_vkGetScreenBufferPropertiesQNX vkGetScreenBufferPropertiesQNX;
+#endif /* defined(VK_QNX_external_memory_screen_buffer) */
+#if defined(VK_VALVE_descriptor_set_host_mapping)
+extern PFN_vkGetDescriptorSetHostMappingVALVE vkGetDescriptorSetHostMappingVALVE;
+extern PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE vkGetDescriptorSetLayoutHostMappingInfoVALVE;
+#endif /* defined(VK_VALVE_descriptor_set_host_mapping) */
+#if (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control))
+extern PFN_vkCmdSetDepthClampRangeEXT vkCmdSetDepthClampRangeEXT;
+#endif /* (defined(VK_EXT_depth_clamp_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clamp_control)) */
+#if (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object))
+extern PFN_vkCmdBindVertexBuffers2EXT vkCmdBindVertexBuffers2EXT;
+extern PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT;
+extern PFN_vkCmdSetDepthBoundsTestEnableEXT vkCmdSetDepthBoundsTestEnableEXT;
+extern PFN_vkCmdSetDepthCompareOpEXT vkCmdSetDepthCompareOpEXT;
+extern PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT;
+extern PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT;
+extern PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT;
+extern PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT;
+extern PFN_vkCmdSetScissorWithCountEXT vkCmdSetScissorWithCountEXT;
+extern PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT;
+extern PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT;
+extern PFN_vkCmdSetViewportWithCountEXT vkCmdSetViewportWithCountEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object))
+extern PFN_vkCmdSetDepthBiasEnableEXT vkCmdSetDepthBiasEnableEXT;
+extern PFN_vkCmdSetLogicOpEXT vkCmdSetLogicOpEXT;
+extern PFN_vkCmdSetPatchControlPointsEXT vkCmdSetPatchControlPointsEXT;
+extern PFN_vkCmdSetPrimitiveRestartEnableEXT vkCmdSetPrimitiveRestartEnableEXT;
+extern PFN_vkCmdSetRasterizerDiscardEnableEXT vkCmdSetRasterizerDiscardEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state2)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object))
+extern PFN_vkCmdSetAlphaToCoverageEnableEXT vkCmdSetAlphaToCoverageEnableEXT;
+extern PFN_vkCmdSetAlphaToOneEnableEXT vkCmdSetAlphaToOneEnableEXT;
+extern PFN_vkCmdSetColorBlendEnableEXT vkCmdSetColorBlendEnableEXT;
+extern PFN_vkCmdSetColorBlendEquationEXT vkCmdSetColorBlendEquationEXT;
+extern PFN_vkCmdSetColorWriteMaskEXT vkCmdSetColorWriteMaskEXT;
+extern PFN_vkCmdSetDepthClampEnableEXT vkCmdSetDepthClampEnableEXT;
+extern PFN_vkCmdSetLogicOpEnableEXT vkCmdSetLogicOpEnableEXT;
+extern PFN_vkCmdSetPolygonModeEXT vkCmdSetPolygonModeEXT;
+extern PFN_vkCmdSetRasterizationSamplesEXT vkCmdSetRasterizationSamplesEXT;
+extern PFN_vkCmdSetSampleMaskEXT vkCmdSetSampleMaskEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3)) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object))
+extern PFN_vkCmdSetTessellationDomainOriginEXT vkCmdSetTessellationDomainOriginEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_KHR_maintenance2) || defined(VK_VERSION_1_1))) || (defined(VK_EXT_shader_object)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback))
+extern PFN_vkCmdSetRasterizationStreamEXT vkCmdSetRasterizationStreamEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_transform_feedback)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_transform_feedback)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization))
+extern PFN_vkCmdSetConservativeRasterizationModeEXT vkCmdSetConservativeRasterizationModeEXT;
+extern PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT vkCmdSetExtraPrimitiveOverestimationSizeEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_conservative_rasterization)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_conservative_rasterization)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable))
+extern PFN_vkCmdSetDepthClipEnableEXT vkCmdSetDepthClipEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_enable)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_enable)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations))
+extern PFN_vkCmdSetSampleLocationsEnableEXT vkCmdSetSampleLocationsEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_sample_locations)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_sample_locations)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced))
+extern PFN_vkCmdSetColorBlendAdvancedEXT vkCmdSetColorBlendAdvancedEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_blend_operation_advanced)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_blend_operation_advanced)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex))
+extern PFN_vkCmdSetProvokingVertexModeEXT vkCmdSetProvokingVertexModeEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_provoking_vertex)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_provoking_vertex)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization)))
+extern PFN_vkCmdSetLineRasterizationModeEXT vkCmdSetLineRasterizationModeEXT;
+extern PFN_vkCmdSetLineStippleEnableEXT vkCmdSetLineStippleEnableEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) || (defined(VK_EXT_shader_object) && (defined(VK_VERSION_1_4) || defined(VK_KHR_line_rasterization) || defined(VK_EXT_line_rasterization))) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control))
+extern PFN_vkCmdSetDepthClipNegativeOneToOneEXT vkCmdSetDepthClipNegativeOneToOneEXT;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_EXT_depth_clip_control)) || (defined(VK_EXT_shader_object) && defined(VK_EXT_depth_clip_control)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling))
+extern PFN_vkCmdSetViewportWScalingEnableNV vkCmdSetViewportWScalingEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_clip_space_w_scaling)) || (defined(VK_EXT_shader_object) && defined(VK_NV_clip_space_w_scaling)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle))
+extern PFN_vkCmdSetViewportSwizzleNV vkCmdSetViewportSwizzleNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_viewport_swizzle)) || (defined(VK_EXT_shader_object) && defined(VK_NV_viewport_swizzle)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color))
+extern PFN_vkCmdSetCoverageToColorEnableNV vkCmdSetCoverageToColorEnableNV;
+extern PFN_vkCmdSetCoverageToColorLocationNV vkCmdSetCoverageToColorLocationNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_fragment_coverage_to_color)) || (defined(VK_EXT_shader_object) && defined(VK_NV_fragment_coverage_to_color)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples))
+extern PFN_vkCmdSetCoverageModulationModeNV vkCmdSetCoverageModulationModeNV;
+extern PFN_vkCmdSetCoverageModulationTableEnableNV vkCmdSetCoverageModulationTableEnableNV;
+extern PFN_vkCmdSetCoverageModulationTableNV vkCmdSetCoverageModulationTableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_framebuffer_mixed_samples)) || (defined(VK_EXT_shader_object) && defined(VK_NV_framebuffer_mixed_samples)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image))
+extern PFN_vkCmdSetShadingRateImageEnableNV vkCmdSetShadingRateImageEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_shading_rate_image)) || (defined(VK_EXT_shader_object) && defined(VK_NV_shading_rate_image)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test))
+extern PFN_vkCmdSetRepresentativeFragmentTestEnableNV vkCmdSetRepresentativeFragmentTestEnableNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_representative_fragment_test)) || (defined(VK_EXT_shader_object) && defined(VK_NV_representative_fragment_test)) */
+#if (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode))
+extern PFN_vkCmdSetCoverageReductionModeNV vkCmdSetCoverageReductionModeNV;
+#endif /* (defined(VK_EXT_extended_dynamic_state3) && defined(VK_NV_coverage_reduction_mode)) || (defined(VK_EXT_shader_object) && defined(VK_NV_coverage_reduction_mode)) */
+#if (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control))
+extern PFN_vkGetImageSubresourceLayout2EXT vkGetImageSubresourceLayout2EXT;
+#endif /* (defined(VK_EXT_host_image_copy)) || (defined(VK_EXT_image_compression_control)) */
+#if (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state))
+extern PFN_vkCmdSetVertexInputEXT vkCmdSetVertexInputEXT;
+#endif /* (defined(VK_EXT_shader_object)) || (defined(VK_EXT_vertex_input_dynamic_state)) */
+#if (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template)))
+extern PFN_vkCmdPushDescriptorSetWithTemplateKHR vkCmdPushDescriptorSetWithTemplateKHR;
+#endif /* (defined(VK_KHR_descriptor_update_template) && defined(VK_KHR_push_descriptor)) || (defined(VK_KHR_push_descriptor) && (defined(VK_VERSION_1_1) || defined(VK_KHR_descriptor_update_template))) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+extern PFN_vkGetDeviceGroupPresentCapabilitiesKHR vkGetDeviceGroupPresentCapabilitiesKHR;
+extern PFN_vkGetDeviceGroupSurfacePresentModesKHR vkGetDeviceGroupSurfacePresentModesKHR;
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
+extern PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
+#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
+/* VOLK_GENERATE_PROTOTYPES_H_DEVICE */
+#endif
+
+#ifdef __cplusplus
+} // extern "C" / namespace volk
+#endif
+
+#ifdef VOLK_NAMESPACE
+using namespace volk;
+#endif
+
+#endif // VOLK_H
+
+#ifdef VOLK_IMPLEMENTATION
+#undef VOLK_IMPLEMENTATION
+/* Prevent tools like dependency checkers from detecting a cyclic dependency */
+#define VOLK_SOURCE "volk.c"
+#include VOLK_SOURCE
+#endif
+
+/**
+ * Copyright (c) 2018-2026 Arseny Kapoulkine
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+/* clang-format on */