diff --git a/.clang-format b/.clang-format
deleted file mode 100755
index 84552f33..00000000
--- a/.clang-format
+++ /dev/null
@@ -1,170 +0,0 @@
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-# The style used for all options not specifically set in the configuration.
-BasedOnStyle: LLVM
-
-# The extra indent or outdent of access modifiers, e.g. public:.
-AccessModifierOffset: -4
-
-# If true, aligns escaped newlines as far left as possible. Otherwise puts them into the right-most column.
-AlignEscapedNewlinesLeft: true
-
-# If true, aligns trailing comments.
-AlignTrailingComments: false
-
-# Allow putting all parameters of a function declaration onto the next line even if BinPackParameters is false.
-AllowAllParametersOfDeclarationOnNextLine: false
-
-# Allows contracting simple braced statements to a single line.
-AllowShortBlocksOnASingleLine: false
-
-# If true, short case labels will be contracted to a single line.
-AllowShortCaseLabelsOnASingleLine: false
-
-# Dependent on the value, int f() { return 0; } can be put on a single line. Possible values: None, Inline, All.
-AllowShortFunctionsOnASingleLine: None
-
-# If true, if (a) return; can be put on a single line.
-AllowShortIfStatementsOnASingleLine: false
-
-# If true, while (true) continue; can be put on a single line.
-AllowShortLoopsOnASingleLine: false
-
-# If true, always break after function definition return types.
-AlwaysBreakAfterDefinitionReturnType: false
-
-# If true, always break before multiline string literals.
-AlwaysBreakBeforeMultilineStrings: false
-
-# If true, always break after the template<...> of a template declaration.
-AlwaysBreakTemplateDeclarations: true
-
-# If false, a function call's arguments will either be all on the same line or will have one line each.
-BinPackArguments: true
-
-# If false, a function declaration's or function definition's parameters will either all be on the same line
-# or will have one line each.
-BinPackParameters: true
-
-# The way to wrap binary operators. Possible values: None, NonAssignment, All.
-BreakBeforeBinaryOperators: None
-
-# The brace breaking style to use. Possible values: Attach, Linux, Stroustrup, Allman, GNU.
-BreakBeforeBraces: Allman
-
-# If true, ternary operators will be placed after line breaks.
-BreakBeforeTernaryOperators: false
-
-# Always break constructor initializers before commas and align the commas with the colon.
-BreakConstructorInitializersBeforeComma: true
-
-# The column limit. A column limit of 0 means that there is no column limit.
-ColumnLimit: 120
-
-# A regular expression that describes comments with special meaning, which should not be split into lines or otherwise changed.
-CommentPragmas: '^ *'
-
-# If the constructor initializers don't fit on a line, put each initializer on its own line.
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-
-# The number of characters to use for indentation of constructor initializer lists.
-ConstructorInitializerIndentWidth: 4
-
-# Indent width for line continuations.
-ContinuationIndentWidth: 4
-
-# If true, format braced lists as best suited for C++11 braced lists.
-Cpp11BracedListStyle: false
-
-# Disables formatting at all.
-DisableFormat: false
-
-# A vector of macros that should be interpreted as foreach loops instead of as function calls.
-#ForEachMacros: ''
-
-# Indent case labels one level from the switch statement.
-# When false, use the same indentation level as for the switch statement.
-# Switch statement body is always indented one level more than case labels.
-IndentCaseLabels: false
-
-# The number of columns to use for indentation.
-IndentWidth: 4
-
-# Indent if a function definition or declaration is wrapped after the type.
-IndentWrappedFunctionNames: false
-
-# If true, empty lines at the start of blocks are kept.
-KeepEmptyLinesAtTheStartOfBlocks: true
-
-# Language, this format style is targeted at. Possible values: None, Cpp, Java, JavaScript, Proto.
-Language: Cpp
-
-# The maximum number of consecutive empty lines to keep.
-MaxEmptyLinesToKeep: 1
-
-# The indentation used for namespaces. Possible values: None, Inner, All.
-NamespaceIndentation: None
-
-# The penalty for breaking a function call after "call(".
-PenaltyBreakBeforeFirstCallParameter: 19
-
-# The penalty for each line break introduced inside a comment.
-PenaltyBreakComment: 300
-
-# The penalty for breaking before the first <<.
-PenaltyBreakFirstLessLess: 120
-
-# The penalty for each line break introduced inside a string literal.
-PenaltyBreakString: 1000
-
-# The penalty for each character outside of the column limit.
-PenaltyExcessCharacter: 1000000
-
-# Penalty for putting the return type of a function onto its own line.
-PenaltyReturnTypeOnItsOwnLine: 1000000000
-
-# Pointer and reference alignment style. Possible values: Left, Right, Middle.
-PointerAlignment: Right
-
-# If true, a space may be inserted after C style casts.
-SpaceAfterCStyleCast: false
-
-# If false, spaces will be removed before assignment operators.
-SpaceBeforeAssignmentOperators: true
-
-# Defines in which cases to put a space before opening parentheses. Possible values: Never, ControlStatements, Always.
-SpaceBeforeParens: ControlStatements
-
-# If true, spaces may be inserted into '()'.
-SpaceInEmptyParentheses: false
-
-# The number of spaces before trailing line comments (// - comments).
-SpacesBeforeTrailingComments: 1
-
-# If true, spaces will be inserted after '<' and before '>' in template argument lists.
-SpacesInAngles: false
-
-# If true, spaces may be inserted into C style casts.
-SpacesInCStyleCastParentheses: false
-
-# If true, spaces are inserted inside container literals (e.g. ObjC and Javascript array and dict literals).
-SpacesInContainerLiterals: false
-
-# If true, spaces will be inserted after '(' and before ')'.
-SpacesInParentheses: false
-
-# If true, spaces will be inserted after '[' and befor']'.
-SpacesInSquareBrackets: false
-
-# Format compatible with this standard, e.g. use A > instead of A> for LS_Cpp03. Possible values: Cpp03, Cpp11, Auto.
-Standard: Cpp11
-
-# The number of columns used for tab stops.
-TabWidth: 4
-
-# The way to use tab characters in the resulting file. Possible values: Never, ForIndentation, Always.
-UseTab: ForIndentation
-
-# Do not reflow comments
-ReflowComments: false
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index c2e81cb5..00000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2020-2021 The Khronos Group, Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-name: CI
-
-on:
- push:
- branches: [ main ]
- pull_request:
- types: [ opened, synchronize, reopened ]
-
-jobs:
- build:
- name: "Build ${{ matrix.platform }}"
- strategy:
- matrix:
- platform: [windows-latest, ubuntu-20.04, ubuntu-22.04, macos-latest]
- env:
- PARALLEL: -j 2
-
- runs-on: "${{ matrix.platform }}"
- steps:
- - uses: actions/checkout@v3
-
- - uses: actions/setup-python@v4
- with:
- python-version: '3.x'
-
- - name: Cache glslang / SPIRV-Tools
- id: cache-externals
- uses: actions/cache@v3
- with:
- path: external/*-build/output
- key: ${{ matrix.platform }} externals ${{ hashFiles('checkout_glslang_spirv_tools.sh', 'build_glslang_spirv_tools.sh') }}
-
- - name: Pull glslang / SPIRV-Tools
- if: steps.cache-externals.outputs.cache-hit != 'true'
- shell: bash
- working-directory: ${{github.workspace}}
- run: ./checkout_glslang_spirv_tools.sh
-
- - name: Build glslang / SPIRV-Tools
- if: steps.cache-externals.outputs.cache-hit != 'true'
- shell: bash
- working-directory: ${{github.workspace}}
- run: ./build_glslang_spirv_tools.sh Release 4
-
- - name: Configure SPIRV-Cross
- shell: bash
- run: |
- mkdir build
- cd build
- cmake .. -DSPIRV_CROSS_WERROR=ON -DSPIRV_CROSS_MISC_WARNINGS=ON -DSPIRV_CROSS_SHARED=ON -DCMAKE_INSTALL_PREFIX=output -DCMAKE_BUILD_TYPE=Release -DSPIRV_CROSS_ENABLE_TESTS=ON
-
- - name: Build SPIRV-Cross
- shell: bash
- working-directory: ${{github.workspace}}/build
- run: |
- cmake --build . --config Release --parallel 4
- cmake --build . --config Release --target install
-
- - uses: actions/upload-artifact@v3
- with:
- name: ${{ matrix.platform }}-binaries
- path: build/output
- - name: Test SPIRV-Cross
- shell: bash
- working-directory: ${{github.workspace}}/build
- run: ctest --verbose -C Release
- reuse:
- name: "REUSE license check"
- runs-on: ubuntu-latest
- container: khronosgroup/docker-images:asciidoctor-spec
-
- steps:
- - uses: actions/checkout@v3
-
- # REUSE license checker
- - name: license-check
- run: |
- reuse lint
-
-
diff --git a/.reuse/dep5 b/.reuse/dep5
deleted file mode 100644
index cbdbbaed..00000000
--- a/.reuse/dep5
+++ /dev/null
@@ -1,11 +0,0 @@
-Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: SPIRV-Cross
-Source: https://github.com/KhronosGroup/SPIRV-Cross
-
-Files: shaders*/* reference/* tests-other/*
-Copyright: 2016-2021 The Khronos Group, Inc.
-License: Apache-2.0
-
-Files: spirv.h spirv.hpp GLSL.std.450.h
-Copyright: 2016-2021 The Khronos Group, Inc.
-License: LicenseRef-KhronosFreeUse
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 53b7d09d..00000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,635 +0,0 @@
-# Copyright 2016-2021 Google Inc.
-# SPDX-License-Identifier: Apache-2.0 OR MIT
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#
-# At your option, you may choose to accept this material under either:
-# 1. The Apache License, Version 2.0, found at , or
-# 2. The MIT License, found at .
-#
-
-cmake_minimum_required(VERSION 3.6)
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_EXTENSIONS OFF)
-
-# Avoid a warning if parent project sets VERSION in project().
-if (${CMAKE_VERSION} VERSION_GREATER "3.0.1")
- cmake_policy(SET CMP0048 NEW)
-endif()
-
-project(SPIRV-Cross LANGUAGES CXX C)
-enable_testing()
-
-include(GNUInstallDirs)
-
-option(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS "Instead of throwing exceptions assert" OFF)
-option(SPIRV_CROSS_SHARED "Build the C API as a single shared library." OFF)
-option(SPIRV_CROSS_STATIC "Build the C and C++ API as static libraries." ON)
-option(SPIRV_CROSS_CLI "Build the CLI binary. Requires SPIRV_CROSS_STATIC." ON)
-option(SPIRV_CROSS_ENABLE_TESTS "Enable SPIRV-Cross tests." ON)
-
-option(SPIRV_CROSS_ENABLE_GLSL "Enable GLSL support." ON)
-option(SPIRV_CROSS_ENABLE_HLSL "Enable HLSL target support." ON)
-option(SPIRV_CROSS_ENABLE_MSL "Enable MSL target support." ON)
-option(SPIRV_CROSS_ENABLE_CPP "Enable C++ target support." ON)
-option(SPIRV_CROSS_ENABLE_REFLECT "Enable JSON reflection target support." ON)
-option(SPIRV_CROSS_ENABLE_C_API "Enable C API wrapper support in static library." ON)
-option(SPIRV_CROSS_ENABLE_UTIL "Enable util module support." ON)
-
-option(SPIRV_CROSS_SANITIZE_ADDRESS "Sanitize address" OFF)
-option(SPIRV_CROSS_SANITIZE_MEMORY "Sanitize memory" OFF)
-option(SPIRV_CROSS_SANITIZE_THREADS "Sanitize threads" OFF)
-option(SPIRV_CROSS_SANITIZE_UNDEFINED "Sanitize undefined" OFF)
-
-option(SPIRV_CROSS_NAMESPACE_OVERRIDE "" "Override the namespace used in the C++ API.")
-option(SPIRV_CROSS_FORCE_STL_TYPES "Force use of STL types instead of STL replacements in certain places. Might reduce performance." OFF)
-
-option(SPIRV_CROSS_SKIP_INSTALL "Skips installation targets." OFF)
-
-option(SPIRV_CROSS_WERROR "Fail build on warnings." OFF)
-option(SPIRV_CROSS_MISC_WARNINGS "Misc warnings useful for Travis runs." OFF)
-
-option(SPIRV_CROSS_FORCE_PIC "Force position-independent code for all targets." OFF)
-
-if(${CMAKE_GENERATOR} MATCHES "Makefile")
- if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- message(FATAL_ERROR "Build out of tree to avoid overwriting Makefile")
- endif()
-endif()
-
-set(spirv-compiler-options "")
-set(spirv-compiler-defines "")
-set(spirv-cross-link-flags "")
-
-message(STATUS "SPIRV-Cross: Finding Git version for SPIRV-Cross.")
-set(spirv-cross-build-version "unknown")
-find_package(Git)
-if (GIT_FOUND)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty=+
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE spirv-cross-build-version
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- message(STATUS "SPIRV-Cross: Git hash: ${spirv-cross-build-version}")
-else()
- message(STATUS "SPIRV-Cross: Git not found, using unknown build version.")
-endif()
-
-string(TIMESTAMP spirv-cross-timestamp)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.in.h ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h @ONLY)
-
-if (SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
- set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
- if (NOT MSVC)
- set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions)
- endif()
-endif()
-
-if (SPIRV_CROSS_FORCE_STL_TYPES)
- set(spirv-compiler-defines ${spirv-compiler-defines} SPIRV_CROSS_FORCE_STL_TYPES)
-endif()
-
-if (WIN32)
- set(CMAKE_DEBUG_POSTFIX "d")
-endif()
-
-if (CMAKE_COMPILER_IS_GNUCXX OR ((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") AND NOT MSVC))
- set(spirv-compiler-options ${spirv-compiler-options} -Wall -Wextra -Wshadow -Wno-deprecated-declarations)
- if (SPIRV_CROSS_MISC_WARNINGS)
- if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- set(spirv-compiler-options ${spirv-compiler-options} -Wshorten-64-to-32)
- endif()
- endif()
- if (SPIRV_CROSS_WERROR)
- set(spirv-compiler-options ${spirv-compiler-options} -Werror)
- endif()
-
- if (SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
- set(spirv-compiler-options ${spirv-compiler-options} -fno-exceptions)
- endif()
-
- if (SPIRV_CROSS_SANITIZE_ADDRESS)
- set(spirv-compiler-options ${spirv-compiler-options} -fsanitize=address)
- set(spirv-cross-link-flags "${spirv-cross-link-flags} -fsanitize=address")
- endif()
-
- if (SPIRV_CROSS_SANITIZE_UNDEFINED)
- set(spirv-compiler-options ${spirv-compiler-options} -fsanitize=undefined)
- set(spirv-cross-link-flags "${spirv-cross-link-flags} -fsanitize=undefined")
- endif()
-
- if (SPIRV_CROSS_SANITIZE_MEMORY)
- set(spirv-compiler-options ${spirv-compiler-options} -fsanitize=memory)
- set(spirv-cross-link-flags "${spirv-cross-link-flags} -fsanitize=memory")
- endif()
-
- if (SPIRV_CROSS_SANITIZE_THREADS)
- set(spirv-compiler-options ${spirv-compiler-options} -fsanitize=thread)
- set(spirv-cross-link-flags "${spirv-cross-link-flags} -fsanitize=thread")
- endif()
-elseif (MSVC)
- # AppVeyor spuriously fails in debug build on older MSVC without /bigobj.
- set(spirv-compiler-options ${spirv-compiler-options} /wd4267 /wd4996 $<$:/bigobj>)
-endif()
-
-macro(extract_headers out_abs file_list)
- set(${out_abs}) # absolute paths
- foreach(_a ${file_list})
- # get_filename_component only returns the longest extension, so use a regex
- string(REGEX REPLACE ".*\\.(h|hpp)" "\\1" ext ${_a})
-
- # For shared library, we are only interested in the C header.
- if (SPIRV_CROSS_STATIC)
- if(("${ext}" STREQUAL "h") OR ("${ext}" STREQUAL "hpp"))
- list(APPEND ${out_abs} "${_a}")
- endif()
- else()
- if("${ext}" STREQUAL "h")
- list(APPEND ${out_abs} "${_a}")
- endif()
- endif()
- endforeach()
-endmacro()
-
-macro(spirv_cross_add_library name config_name library_type)
- add_library(${name} ${library_type} ${ARGN})
- extract_headers(hdrs "${ARGN}")
- target_include_directories(${name} PUBLIC
- $
- $)
- set_target_properties(${name} PROPERTIES
- PUBLIC_HEADERS "${hdrs}")
- if (SPIRV_CROSS_FORCE_PIC)
- set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON)
- endif()
- target_compile_options(${name} PRIVATE ${spirv-compiler-options})
- target_compile_definitions(${name} PRIVATE ${spirv-compiler-defines})
- if (SPIRV_CROSS_NAMESPACE_OVERRIDE)
- if (${library_type} MATCHES "STATIC")
- target_compile_definitions(${name} PUBLIC SPIRV_CROSS_NAMESPACE_OVERRIDE=${SPIRV_CROSS_NAMESPACE_OVERRIDE})
- else()
- target_compile_definitions(${name} PRIVATE SPIRV_CROSS_NAMESPACE_OVERRIDE=${SPIRV_CROSS_NAMESPACE_OVERRIDE})
- endif()
- endif()
-
- if (NOT SPIRV_CROSS_SKIP_INSTALL)
- install(TARGETS ${name}
- EXPORT ${config_name}Config
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spirv_cross)
- install(FILES ${hdrs} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spirv_cross)
- install(EXPORT ${config_name}Config DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${config_name}/cmake)
- export(TARGETS ${name} FILE ${config_name}Config.cmake)
- endif()
-endmacro()
-
-set(spirv-cross-core-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/GLSL.std.450.h
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_common.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_containers.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_error_handling.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_parser.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_parser.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_parsed_ir.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_parsed_ir.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.hpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cfg.cpp)
-
-set(spirv-cross-c-sources
- spirv.h
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_c.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_c.h)
-
-set(spirv-cross-glsl-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_glsl.hpp)
-
-set(spirv-cross-cpp-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cpp.hpp)
-
-set(spirv-cross-msl-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp)
-
-set(spirv-cross-hlsl-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.hpp)
-
-set(spirv-cross-reflect-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reflect.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_reflect.hpp)
-
-set(spirv-cross-util-sources
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/spirv_cross_util.hpp)
-
-set(spirv-cross-abi-major 0)
-set(spirv-cross-abi-minor 61)
-set(spirv-cross-abi-patch 0)
-set(SPIRV_CROSS_VERSION ${spirv-cross-abi-major}.${spirv-cross-abi-minor}.${spirv-cross-abi-patch})
-
-if (SPIRV_CROSS_STATIC)
- if (NOT SPIRV_CROSS_SKIP_INSTALL)
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/pkg-config/spirv-cross-c.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/spirv-cross-c.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/spirv-cross-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- endif()
-
- spirv_cross_add_library(spirv-cross-core spirv_cross_core STATIC
- ${spirv-cross-core-sources})
-
- if (SPIRV_CROSS_ENABLE_GLSL)
- spirv_cross_add_library(spirv-cross-glsl spirv_cross_glsl STATIC
- ${spirv-cross-glsl-sources})
- target_link_libraries(spirv-cross-glsl PRIVATE spirv-cross-core)
- endif()
-
- if (SPIRV_CROSS_ENABLE_CPP)
- spirv_cross_add_library(spirv-cross-cpp spirv_cross_cpp STATIC
- ${spirv-cross-cpp-sources})
-
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_link_libraries(spirv-cross-cpp PRIVATE spirv-cross-glsl)
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable C++ support.")
- endif()
- endif()
-
- if (SPIRV_CROSS_ENABLE_REFLECT)
- if (SPIRV_CROSS_ENABLE_GLSL)
- spirv_cross_add_library(spirv-cross-reflect spirv_cross_reflect STATIC
- ${spirv-cross-reflect-sources})
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable JSON reflection support.")
- endif()
- endif()
-
- if (SPIRV_CROSS_ENABLE_MSL)
- spirv_cross_add_library(spirv-cross-msl spirv_cross_msl STATIC
- ${spirv-cross-msl-sources})
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_link_libraries(spirv-cross-msl PRIVATE spirv-cross-glsl)
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable MSL support.")
- endif()
- endif()
-
- if (SPIRV_CROSS_ENABLE_HLSL)
- spirv_cross_add_library(spirv-cross-hlsl spirv_cross_hlsl STATIC
- ${spirv-cross-hlsl-sources})
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_link_libraries(spirv-cross-hlsl PRIVATE spirv-cross-glsl)
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable HLSL support.")
- endif()
- endif()
-
- if (SPIRV_CROSS_ENABLE_UTIL)
- spirv_cross_add_library(spirv-cross-util spirv_cross_util STATIC
- ${spirv-cross-util-sources})
- target_link_libraries(spirv-cross-util PRIVATE spirv-cross-core)
- endif()
-
- if (SPIRV_CROSS_ENABLE_C_API)
- spirv_cross_add_library(spirv-cross-c spirv_cross_c STATIC
- ${spirv-cross-c-sources})
- target_include_directories(spirv-cross-c PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
- target_compile_definitions(spirv-cross-c PRIVATE HAVE_SPIRV_CROSS_GIT_VERSION)
-
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_link_libraries(spirv-cross-c PRIVATE spirv-cross-glsl)
- target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_GLSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_HLSL)
- target_link_libraries(spirv-cross-c PRIVATE spirv-cross-hlsl)
- target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_HLSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_MSL)
- target_link_libraries(spirv-cross-c PRIVATE spirv-cross-msl)
- target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_MSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_CPP)
- target_link_libraries(spirv-cross-c PRIVATE spirv-cross-cpp)
- target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_CPP=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_REFLECT)
- target_link_libraries(spirv-cross-c PRIVATE spirv-cross-reflect)
- target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_REFLECT=1)
- endif()
- endif()
-endif()
-
-if (SPIRV_CROSS_SHARED)
- if (NOT SPIRV_CROSS_SKIP_INSTALL)
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/pkg-config/spirv-cross-c-shared.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/spirv-cross-c-shared.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/spirv-cross-c-shared.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- endif()
-
- spirv_cross_add_library(spirv-cross-c-shared spirv_cross_c_shared SHARED
- ${spirv-cross-core-sources}
- ${spirv-cross-c-sources})
-
- target_include_directories(spirv-cross-c-shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
- target_compile_definitions(spirv-cross-c-shared PRIVATE HAVE_SPIRV_CROSS_GIT_VERSION)
-
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-glsl-sources})
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_GLSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_HLSL)
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-hlsl-sources})
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable HLSL support.")
- endif()
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_HLSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_MSL)
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-msl-sources})
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable MSL support.")
- endif()
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_MSL=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_CPP)
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-cpp-sources})
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable C++ support.")
- endif()
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_CPP=1)
- endif()
-
- if (SPIRV_CROSS_ENABLE_REFLECT)
- if (SPIRV_CROSS_ENABLE_GLSL)
- target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-reflect-sources})
- else()
- message(FATAL_ERROR "Must enable GLSL support to enable JSON reflection support.")
- endif()
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_REFLECT=1)
- endif()
-
- if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
- # Only export the C API.
- target_compile_options(spirv-cross-c-shared PRIVATE -fvisibility=hidden)
- if (NOT APPLE)
- set_target_properties(spirv-cross-c-shared PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
- endif()
- endif()
-
- target_compile_definitions(spirv-cross-c-shared PRIVATE SPVC_EXPORT_SYMBOLS)
-
- set_target_properties(spirv-cross-c-shared PROPERTIES
- VERSION ${SPIRV_CROSS_VERSION}
- SOVERSION ${spirv-cross-abi-major})
-endif()
-
-if (SPIRV_CROSS_CLI)
- if (NOT SPIRV_CROSS_ENABLE_GLSL)
- message(FATAL_ERROR "Must enable GLSL if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_ENABLE_HLSL)
- message(FATAL_ERROR "Must enable HLSL if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_ENABLE_MSL)
- message(FATAL_ERROR "Must enable MSL if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_ENABLE_CPP)
- message(FATAL_ERROR "Must enable C++ if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_ENABLE_REFLECT)
- message(FATAL_ERROR "Must enable reflection if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_ENABLE_UTIL)
- message(FATAL_ERROR "Must enable utils if building CLI.")
- endif()
-
- if (NOT SPIRV_CROSS_STATIC)
- message(FATAL_ERROR "Must build static libraries if building CLI.")
- endif()
- add_executable(spirv-cross main.cpp)
- target_compile_options(spirv-cross PRIVATE ${spirv-compiler-options})
- target_include_directories(spirv-cross PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
- target_compile_definitions(spirv-cross PRIVATE ${spirv-compiler-defines} HAVE_SPIRV_CROSS_GIT_VERSION)
- set_target_properties(spirv-cross PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
- if (NOT SPIRV_CROSS_SKIP_INSTALL)
- install(TARGETS spirv-cross DESTINATION ${CMAKE_INSTALL_BINDIR})
- endif()
- target_link_libraries(spirv-cross PRIVATE
- spirv-cross-glsl
- spirv-cross-hlsl
- spirv-cross-cpp
- spirv-cross-reflect
- spirv-cross-msl
- spirv-cross-util
- spirv-cross-core)
-
- if (SPIRV_CROSS_ENABLE_TESTS)
- # Set up tests, using only the simplest modes of the test_shaders
- # script. You have to invoke the script manually to:
- # - Update the reference files
- # - Get cycle counts from malisc
- # - Keep failing outputs
- if (${CMAKE_VERSION} VERSION_GREATER "3.12")
- find_package(Python3)
- if (${PYTHON3_FOUND})
- set(PYTHONINTERP_FOUND ON)
- set(PYTHON_VERSION_MAJOR 3)
- set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
- else()
- set(PYTHONINTERP_FOUND OFF)
- endif()
- else()
- find_package(PythonInterp)
- endif()
-
- find_program(spirv-cross-glslang NAMES glslangValidator
- PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/glslang-build/output/bin
- NO_DEFAULT_PATH)
- find_program(spirv-cross-spirv-as NAMES spirv-as
- PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/spirv-tools-build/output/bin
- NO_DEFAULT_PATH)
- find_program(spirv-cross-spirv-val NAMES spirv-val
- PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/spirv-tools-build/output/bin
- NO_DEFAULT_PATH)
- find_program(spirv-cross-spirv-opt NAMES spirv-opt
- PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/spirv-tools-build/output/bin
- NO_DEFAULT_PATH)
-
- if ((${spirv-cross-glslang} MATCHES "NOTFOUND") OR (${spirv-cross-spirv-as} MATCHES "NOTFOUND") OR (${spirv-cross-spirv-val} MATCHES "NOTFOUND") OR (${spirv-cross-spirv-opt} MATCHES "NOTFOUND"))
- set(SPIRV_CROSS_ENABLE_TESTS OFF)
- message("SPIRV-Cross: Testing will be disabled for SPIRV-Cross. Could not find glslang or SPIRV-Tools build under external/. To enable testing, run ./checkout_glslang_spirv_tools.sh and ./build_glslang_spirv_tools.sh first.")
- else()
- set(SPIRV_CROSS_ENABLE_TESTS ON)
- message("SPIRV-Cross: Found glslang and SPIRV-Tools. Enabling test suite.")
- message("SPIRV-Cross: Found glslangValidator in: ${spirv-cross-glslang}.")
- message("SPIRV-Cross: Found spirv-as in: ${spirv-cross-spirv-as}.")
- message("SPIRV-Cross: Found spirv-val in: ${spirv-cross-spirv-val}.")
- message("SPIRV-Cross: Found spirv-opt in: ${spirv-cross-spirv-opt}.")
- endif()
-
- set(spirv-cross-externals
- --glslang "${spirv-cross-glslang}"
- --spirv-as "${spirv-cross-spirv-as}"
- --spirv-opt "${spirv-cross-spirv-opt}"
- --spirv-val "${spirv-cross-spirv-val}")
-
- if (${PYTHONINTERP_FOUND} AND SPIRV_CROSS_ENABLE_TESTS)
- if (${PYTHON_VERSION_MAJOR} GREATER 2)
- add_executable(spirv-cross-c-api-test tests-other/c_api_test.c)
- target_link_libraries(spirv-cross-c-api-test spirv-cross-c)
- set_target_properties(spirv-cross-c-api-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-small-vector-test tests-other/small_vector.cpp)
- target_link_libraries(spirv-cross-small-vector-test spirv-cross-core)
- set_target_properties(spirv-cross-small-vector-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-msl-constexpr-test tests-other/msl_constexpr_test.cpp)
- target_link_libraries(spirv-cross-msl-constexpr-test spirv-cross-c)
- set_target_properties(spirv-cross-msl-constexpr-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-msl-resource-binding-test tests-other/msl_resource_bindings.cpp)
- target_link_libraries(spirv-cross-msl-resource-binding-test spirv-cross-c)
- set_target_properties(spirv-cross-msl-resource-binding-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-hlsl-resource-binding-test tests-other/hlsl_resource_bindings.cpp)
- target_link_libraries(spirv-cross-hlsl-resource-binding-test spirv-cross-c)
- set_target_properties(spirv-cross-hlsl-resource-binding-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-msl-ycbcr-conversion-test tests-other/msl_ycbcr_conversion_test.cpp)
- target_link_libraries(spirv-cross-msl-ycbcr-conversion-test spirv-cross-c)
- set_target_properties(spirv-cross-msl-ycbcr-conversion-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- add_executable(spirv-cross-typed-id-test tests-other/typed_id_test.cpp)
- target_link_libraries(spirv-cross-typed-id-test spirv-cross-core)
- set_target_properties(spirv-cross-typed-id-test PROPERTIES LINK_FLAGS "${spirv-cross-link-flags}")
-
- if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang"))
- target_compile_options(spirv-cross-c-api-test PRIVATE -std=c89 -Wall -Wextra)
- endif()
- add_test(NAME spirv-cross-c-api-test
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/c_api_test.spv
- ${spirv-cross-abi-major}
- ${spirv-cross-abi-minor}
- ${spirv-cross-abi-patch})
- add_test(NAME spirv-cross-small-vector-test
- COMMAND $)
- add_test(NAME spirv-cross-msl-constexpr-test
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/msl_constexpr_test.spv)
- add_test(NAME spirv-cross-msl-resource-binding-test
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/msl_resource_binding.spv)
- add_test(NAME spirv-cross-hlsl-resource-binding-test
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/hlsl_resource_binding.spv)
- add_test(NAME spirv-cross-msl-ycbcr-conversion-test
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/msl_ycbcr_conversion_test.spv)
- add_test(NAME spirv-cross-msl-ycbcr-conversion-test-2
- COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/tests-other/msl_ycbcr_conversion_test_2.spv)
- add_test(NAME spirv-cross-typed-id-test
- COMMAND $)
- add_test(NAME spirv-cross-test
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-no-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-no-opt
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-metal
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-metal-no-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl-no-opt
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-hlsl
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-hlsl-no-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl-no-opt
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --opt --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-metal-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --metal --opt --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-msl
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-hlsl-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --hlsl --opt --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-hlsl
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-reflection
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --reflect --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-reflection
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-ue4
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --msl --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-ue4
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-ue4-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --msl --opt --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-ue4
- WORKING_DIRECTORY $)
- add_test(NAME spirv-cross-test-ue4-no-opt
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_shaders.py --msl --parallel
- ${spirv-cross-externals}
- ${CMAKE_CURRENT_SOURCE_DIR}/shaders-ue4-no-opt
- WORKING_DIRECTORY $)
- endif()
- elseif(NOT ${PYTHONINTERP_FOUND})
- message(WARNING "SPIRV-Cross: Testing disabled. Could not find python3. If you have python3 installed try running "
- "cmake with -DPYTHON_EXECUTABLE:FILEPATH=/path/to/python3 to help it find the executable")
- endif()
- endif()
-endif()
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b44eb5e8..00000000
--- a/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-TARGET := spirv-cross
-
-SOURCES := $(wildcard spirv_*.cpp)
-CLI_SOURCES := main.cpp
-
-OBJECTS := $(SOURCES:.cpp=.o)
-CLI_OBJECTS := $(CLI_SOURCES:.cpp=.o)
-
-STATIC_LIB := lib$(TARGET).a
-
-DEPS := $(OBJECTS:.o=.d) $(CLI_OBJECTS:.o=.d)
-
-CXXFLAGS += -std=c++11 -Wall -Wextra -Wshadow -Wno-deprecated-declarations
-
-ifeq ($(DEBUG), 1)
- CXXFLAGS += -O0 -g
-else
- CXXFLAGS += -O2 -DNDEBUG
-endif
-
-ifeq ($(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS), 1)
- CXXFLAGS += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS -fno-exceptions
-endif
-
-all: $(TARGET)
-
--include $(DEPS)
-
-$(TARGET): $(CLI_OBJECTS) $(STATIC_LIB)
- $(CXX) -o $@ $(CLI_OBJECTS) $(STATIC_LIB) $(LDFLAGS)
-
-$(STATIC_LIB): $(OBJECTS)
- $(AR) rcs $@ $(OBJECTS)
-
-%.o: %.cpp
- $(CXX) -c -o $@ $< $(CXXFLAGS) -MMD
-
-clean:
- rm -f $(TARGET) $(OBJECTS) $(CLI_OBJECTS) $(STATIC_LIB) $(DEPS)
-
-.PHONY: clean
diff --git a/Package.swift b/Package.swift
deleted file mode 100644
index 99e60193..00000000
--- a/Package.swift
+++ /dev/null
@@ -1,72 +0,0 @@
-// swift-tools-version:5.5
-// The swift-tools-version declares the minimum version of Swift required to build this package.
-
-// Copyright 2016-2021 The Khronos Group Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-import PackageDescription
-
-let package = Package(
- name: "SPIRV-Cross",
- products: [
- // Products define the executables and libraries a package produces, and make them visible to other packages.
- .library(
- name: "SPIRV-Cross",
- targets: ["SPIRV-Cross"]),
- ],
- dependencies: [
- // Dependencies declare other packages that this package depends on.
- // .package(url: /* package url */, from: "1.0.0"),
- ],
- targets: [
- // Targets are the basic building blocks of a package. A target can define a module or a test suite.
- // Targets can depend on other targets in this package, and on products in packages this package depends on.
- .target(
- name: "SPIRV-Cross",
- dependencies: [],
- path: ".",
- exclude: ["CMakeLists.txt",
- "CODE_OF_CONDUCT.adoc",
- "LICENSE",
- "LICENSES",
- "Makefile",
- "README.md",
- "appveyor.yml",
- "build_glslang_spirv_tools.sh",
- "checkout_glslang_spirv_tools.sh",
- "cmake",
- "format_all.sh",
- "gn",
- "main.cpp",
- "pkg-config",
- "reference",
- "samples",
- "shaders",
- "shaders-hlsl",
- "shaders-hlsl-no-opt",
- "shaders-msl",
- "shaders-msl-no-opt",
- "shaders-no-opt",
- "shaders-other",
- "shaders-reflection",
- "shaders-ue4",
- "shaders-ue4-no-opt",
- "test_shaders.py",
- "test_shaders.sh",
- "tests-other",
- "update_test_shaders.sh"],
- sources: ["spirv_cfg.cpp",
- "spirv_cpp.cpp",
- "spirv_cross.cpp",
- "spirv_cross_c.cpp",
- "spirv_cross_parsed_ir.cpp",
- "spirv_cross_util.cpp",
- "spirv_glsl.cpp",
- "spirv_hlsl.cpp",
- "spirv_msl.cpp",
- "spirv_parser.cpp",
- "spirv_reflect.cpp"],
- publicHeadersPath: "."),
- ],
- cxxLanguageStandard: .cxx14
-)
diff --git a/README.md b/README.md
index 3a89e6c2..5071cf4f 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,7 @@
# SPIRV-Cross
-SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.
-
-[![CI](https://github.com/KhronosGroup/SPIRV-Cross/actions/workflows/main.yml/badge.svg)](https://github.com/KhronosGroup/SPIRV-Cross/actions/workflows/main.yml)
-[![Build Status](https://ci.appveyor.com/api/projects/status/github/KhronosGroup/SPIRV-Cross?svg=true&branch=main)](https://ci.appveyor.com/project/HansKristian-Work/SPIRV-Cross)
+SPIRV-Cross is a SPIR-V transpiler
## Features
@@ -21,534 +18,4 @@ SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader
- Reflection API to modify and tweak OpDecorations
- Supports "all" of vertex, fragment, tessellation, geometry and compute shaders.
-SPIRV-Cross tries hard to emit readable and clean output from the SPIR-V.
-The goal is to emit GLSL or MSL that looks like it was written by a human and not awkward IR/assembly-like code.
-
-NOTE: Individual features are expected to be mostly complete, but it is possible that certain obscure GLSL features are not yet supported.
-However, most missing features are expected to be "trivial" improvements at this stage.
-
-## Building
-
-SPIRV-Cross has been tested on Linux, iOS/OSX, Windows and Android. CMake is the main build system.
-
-### NOTE: main branch rename
-
-On 2023-01-12, `master` was renamed to `main` as per Khronos policy.
-
-### Linux and macOS
-
-Building with CMake is recommended, as it is the only build system which is tested in continuous integration.
-It is also the only build system which has install commands and other useful build system features.
-
-However, you can just run `make` on the command line as a fallback if you only care about the CLI tool.
-
-A non-ancient GCC (4.8+) or Clang (3.x+) compiler is required as SPIRV-Cross uses C++11 extensively.
-
-### Windows
-
-Building with CMake is recommended, which is the only way to target MSVC.
-MinGW-w64 based compilation works with `make` as a fallback.
-
-### Android
-
-SPIRV-Cross is only useful as a library here. Use the CMake build to link SPIRV-Cross to your project.
-
-### C++ exceptions
-
-The make and CMake build flavors offer the option to treat exceptions as assertions. To disable exceptions for make just append `SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=1` to the command line. For CMake append `-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON`. By default exceptions are enabled.
-
-### Static, shared and CLI
-
-You can use `-DSPIRV_CROSS_STATIC=ON/OFF` `-DSPIRV_CROSS_SHARED=ON/OFF` `-DSPIRV_CROSS_CLI=ON/OFF` to control which modules are built (and installed).
-
-### Installing SPIRV-Cross (vcpkg)
-
-Alternatively, you can build and install SPIRV-Cross using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
-
-```
-git clone https://github.com/Microsoft/vcpkg.git
-cd vcpkg
-./bootstrap-vcpkg.sh
-./vcpkg integrate install
-./vcpkg install spirv-cross
-```
-
-The SPIRV-Cross port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
-
-## Usage
-
-### Using the C++ API
-
-The C++ API is the main API for SPIRV-Cross. For more in-depth documentation than what's provided in this README,
-please have a look at the [Wiki](https://github.com/KhronosGroup/SPIRV-Cross/wiki).
-**NOTE**: This API is not guaranteed to be ABI-stable, and it is highly recommended to link against this API statically.
-The API is generally quite stable, but it can change over time, see the C API for more stability.
-
-To perform reflection and convert to other shader languages you can use the SPIRV-Cross API.
-For example:
-
-```c++
-#include "spirv_glsl.hpp"
-#include
-#include
-
-extern std::vector load_spirv_file();
-
-int main()
-{
- // Read SPIR-V from disk or similar.
- std::vector spirv_binary = load_spirv_file();
-
- spirv_cross::CompilerGLSL glsl(std::move(spirv_binary));
-
- // The SPIR-V is now parsed, and we can perform reflection on it.
- spirv_cross::ShaderResources resources = glsl.get_shader_resources();
-
- // Get all sampled images in the shader.
- for (auto &resource : resources.sampled_images)
- {
- unsigned set = glsl.get_decoration(resource.id, spv::DecorationDescriptorSet);
- unsigned binding = glsl.get_decoration(resource.id, spv::DecorationBinding);
- printf("Image %s at set = %u, binding = %u\n", resource.name.c_str(), set, binding);
-
- // Modify the decoration to prepare it for GLSL.
- glsl.unset_decoration(resource.id, spv::DecorationDescriptorSet);
-
- // Some arbitrary remapping if we want.
- glsl.set_decoration(resource.id, spv::DecorationBinding, set * 16 + binding);
- }
-
- // Set some options.
- spirv_cross::CompilerGLSL::Options options;
- options.version = 310;
- options.es = true;
- glsl.set_common_options(options);
-
- // Compile to GLSL, ready to give to GL driver.
- std::string source = glsl.compile();
-}
-```
-
-### Using the C API wrapper
-
-To facilitate C compatibility and compatibility with foreign programming languages, a C89-compatible API wrapper is provided. Unlike the C++ API,
-the goal of this wrapper is to be fully stable, both API and ABI-wise.
-This is the only interface which is supported when building SPIRV-Cross as a shared library.
-
-An important point of the wrapper is that all memory allocations are contained in the `spvc_context`.
-This simplifies the use of the API greatly. However, you should destroy the context as soon as reasonable,
-or use `spvc_context_release_allocations()` if you intend to reuse the `spvc_context` object again soon.
-
-Most functions return a `spvc_result`, where `SPVC_SUCCESS` is the only success code.
-For brevity, the code below does not do any error checking.
-
-```c
-#include
-
-const SpvId *spirv = get_spirv_data();
-size_t word_count = get_spirv_word_count();
-
-spvc_context context = NULL;
-spvc_parsed_ir ir = NULL;
-spvc_compiler compiler_glsl = NULL;
-spvc_compiler_options options = NULL;
-spvc_resources resources = NULL;
-const spvc_reflected_resource *list = NULL;
-const char *result = NULL;
-size_t count;
-size_t i;
-
-// Create context.
-spvc_context_create(&context);
-
-// Set debug callback.
-spvc_context_set_error_callback(context, error_callback, userdata);
-
-// Parse the SPIR-V.
-spvc_context_parse_spirv(context, spirv, word_count, &ir);
-
-// Hand it off to a compiler instance and give it ownership of the IR.
-spvc_context_create_compiler(context, SPVC_BACKEND_GLSL, ir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP, &compiler_glsl);
-
-// Do some basic reflection.
-spvc_compiler_create_shader_resources(compiler_glsl, &resources);
-spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count);
-
-for (i = 0; i < count; i++)
-{
- printf("ID: %u, BaseTypeID: %u, TypeID: %u, Name: %s\n", list[i].id, list[i].base_type_id, list[i].type_id,
- list[i].name);
- printf(" Set: %u, Binding: %u\n",
- spvc_compiler_get_decoration(compiler_glsl, list[i].id, SpvDecorationDescriptorSet),
- spvc_compiler_get_decoration(compiler_glsl, list[i].id, SpvDecorationBinding));
-}
-
-// Modify options.
-spvc_compiler_create_compiler_options(compiler_glsl, &options);
-spvc_compiler_options_set_uint(options, SPVC_COMPILER_OPTION_GLSL_VERSION, 330);
-spvc_compiler_options_set_bool(options, SPVC_COMPILER_OPTION_GLSL_ES, SPVC_FALSE);
-spvc_compiler_install_compiler_options(compiler_glsl, options);
-
-spvc_compiler_compile(compiler_glsl, &result);
-printf("Cross-compiled source: %s\n", result);
-
-// Frees all memory we allocated so far.
-spvc_context_destroy(context);
-```
-
-### Linking
-
-#### CMake add_subdirectory()
-
-This is the recommended way if you are using CMake and want to link against SPIRV-Cross statically.
-
-#### Integrating SPIRV-Cross in a custom build system
-
-To add SPIRV-Cross to your own codebase, just copy the source and header files from root directory
-and build the relevant .cpp files you need. Make sure to build with C++11 support, e.g. `-std=c++11` in GCC and Clang.
-Alternatively, the Makefile generates a libspirv-cross.a static library during build that can be linked in.
-
-#### Linking against SPIRV-Cross as a system library
-
-It is possible to link against SPIRV-Cross when it is installed as a system library,
-which would be mostly relevant for Unix-like platforms.
-
-##### pkg-config
-
-For Unix-based systems, a pkg-config is installed for the C API, e.g.:
-
-```
-$ pkg-config spirv-cross-c-shared --libs --cflags
--I/usr/local/include/spirv_cross -L/usr/local/lib -lspirv-cross-c-shared
-```
-
-##### CMake
-
-If the project is installed, it can be found with `find_package()`, e.g.:
-
-```
-cmake_minimum_required(VERSION 3.5)
-set(CMAKE_C_STANDARD 99)
-project(Test LANGUAGES C)
-
-find_package(spirv_cross_c_shared)
-if (spirv_cross_c_shared_FOUND)
- message(STATUS "Found SPIRV-Cross C API! :)")
-else()
- message(STATUS "Could not find SPIRV-Cross C API! :(")
-endif()
-
-add_executable(test test.c)
-target_link_libraries(test spirv-cross-c-shared)
-```
-
-test.c:
-```c
-#include
-
-int main(void)
-{
- spvc_context context;
- spvc_context_create(&context);
- spvc_context_destroy(context);
-}
-```
-
-### CLI
-
-The CLI is suitable for basic cross-compilation tasks, but it cannot support the full flexibility that the API can.
-Some examples below.
-
-#### Creating a SPIR-V file from GLSL with glslang
-
-```
-glslangValidator -H -V -o test.spv test.frag
-```
-
-#### Converting a SPIR-V file to GLSL ES
-
-```
-glslangValidator -H -V -o test.spv shaders/comp/basic.comp
-./spirv-cross --version 310 --es test.spv
-```
-
-#### Converting to desktop GLSL
-
-```
-glslangValidator -H -V -o test.spv shaders/comp/basic.comp
-./spirv-cross --version 330 --no-es test.spv --output test.comp
-```
-
-#### Disable prettifying optimizations
-
-```
-glslangValidator -H -V -o test.spv shaders/comp/basic.comp
-./spirv-cross --version 310 --es test.spv --output test.comp --force-temporary
-```
-
-### Using shaders generated from C++ backend
-
-Please see `samples/cpp` where some GLSL shaders are compiled to SPIR-V, decompiled to C++ and run with test data.
-Reading through the samples should explain how to use the C++ interface.
-A simple Makefile is included to build all shaders in the directory.
-
-### Implementation notes
-
-When using SPIR-V and SPIRV-Cross as an intermediate step for cross-compiling between high level languages there are some considerations to take into account,
-as not all features used by one high-level language are necessarily supported natively by the target shader language.
-SPIRV-Cross aims to provide the tools needed to handle these scenarios in a clean and robust way, but some manual action is required to maintain compatibility.
-
-#### HLSL source to GLSL
-
-##### HLSL entry points
-
-When using SPIR-V shaders compiled from HLSL, there are some extra things you need to take care of.
-First make sure that the entry point is used correctly.
-If you forget to set the entry point correctly in glslangValidator (-e MyFancyEntryPoint),
-you will likely encounter this error message:
-
-```
-Cannot end a function before ending the current block.
-Likely cause: If this SPIR-V was created from glslang HLSL, make sure the entry point is valid.
-```
-
-##### Vertex/Fragment interface linking
-
-HLSL relies on semantics in order to effectively link together shader stages. In the SPIR-V generated by glslang, the transformation from HLSL to GLSL ends up looking like
-
-```c++
-struct VSOutput {
- // SV_Position is rerouted to gl_Position
- float4 position : SV_Position;
- float4 coord : TEXCOORD0;
-};
-
-VSOutput main(...) {}
-```
-
-```c++
-struct VSOutput {
- float4 coord;
-}
-layout(location = 0) out VSOutput _magicNameGeneratedByGlslang;
-```
-
-While this works, be aware of the type of the struct which is used in the vertex stage and the fragment stage.
-There may be issues if the structure type name differs in vertex stage and fragment stage.
-
-You can make use of the reflection interface to force the name of the struct type.
-
-```
-// Something like this for both vertex outputs and fragment inputs.
-compiler.set_name(varying_resource.base_type_id, "VertexFragmentLinkage");
-```
-
-Some platform may require identical variable name for both vertex outputs and fragment inputs. (for example MacOSX)
-to rename variable base on location, please add
-```
---rename-interface-variable
-```
-
-#### HLSL source to legacy GLSL/ESSL
-
-HLSL tends to emit varying struct types to pass data between vertex and fragment.
-This is not supported in legacy GL/GLES targets, so to support this, varying structs are flattened.
-This is done automatically, but the API user might need to be aware that this is happening in order to support all cases.
-
-Modern GLES code like this:
-```c++
-struct Output {
- vec4 a;
- vec2 b;
-};
-out Output vout;
-```
-
-Is transformed into:
-```c++
-struct Output {
- vec4 a;
- vec2 b;
-};
-varying vec4 Output_a;
-varying vec2 Output_b;
-```
-
-Note that now, both the struct name and the member names will participate in the linking interface between vertex and fragment, so
-API users might want to ensure that both the struct names and member names match so that vertex outputs and fragment inputs can link properly.
-
-
-#### Separate image samplers (HLSL/Vulkan) for backends which do not support it (GLSL)
-
-Another thing you need to remember is when using samplers and textures in HLSL these are separable, and not directly compatible with GLSL. If you need to use this with desktop GL/GLES, you need to call `Compiler::build_combined_image_samplers` first before calling `Compiler::compile`, or you will get an exception.
-
-```c++
-// From main.cpp
-// Builds a mapping for all combinations of images and samplers.
-compiler->build_combined_image_samplers();
-
-// Give the remapped combined samplers new names.
-// Here you can also set up decorations if you want (binding = #N).
-for (auto &remap : compiler->get_combined_image_samplers())
-{
- compiler->set_name(remap.combined_id, join("SPIRV_Cross_Combined", compiler->get_name(remap.image_id),
- compiler->get_name(remap.sampler_id)));
-}
-```
-
-If your target is Vulkan GLSL, `--vulkan-semantics` will emit separate image samplers as you'd expect.
-The command line client calls `Compiler::build_combined_image_samplers` automatically, but if you're calling the library, you'll need to do this yourself.
-
-#### Descriptor sets (Vulkan GLSL) for backends which do not support them (pre HLSL 5.1 / GLSL)
-
-Descriptor sets are unique to Vulkan, so make sure that descriptor set + binding is remapped to a flat binding scheme (set always 0), so that other APIs can make sense of the bindings.
-This can be done with `Compiler::set_decoration(id, spv::DecorationDescriptorSet)`. For other backends like MSL and HLSL, descriptor sets
-can be used, with some minor caveats, see below.
-
-##### MSL 2.0+
-
-Metal supports indirect argument buffers (--msl-argument-buffers). In this case, descriptor sets become argument buffers,
-and bindings are mapped to [[id(N)]] within the argument buffer. One quirk is that arrays of resources consume multiple ids,
-where Vulkan does not. This can be worked around either from shader authoring stage
-or remapping bindings as needed to avoid the overlap.
-There is also a rich API to declare remapping schemes which is intended to work like
-the pipeline layout in Vulkan. See `CompilerMSL::add_msl_resource_binding`. Remapping combined image samplers for example
-must be split into two bindings in MSL, so it's possible to declare an id for the texture and sampler binding separately.
-
-##### HLSL - SM 5.1+
-
-In SM 5.1+, descriptor set bindings are interpreted as register spaces directly. In HLSL however, arrays of resources consume
-multiple binding slots where Vulkan does not, so there might be overlap if the SPIR-V was not authored with this in mind.
-This can be worked around either from shader authoring stage (don't assign overlapping bindings)
-or remap bindings in SPIRV-Cross as needed to avoid the overlap.
-
-#### Linking by name for targets which do not support explicit locations (legacy GLSL/ESSL)
-
-Modern GLSL and HLSL sources (and SPIR-V) relies on explicit layout(location) qualifiers to guide the linking process between shader stages,
-but older GLSL relies on symbol names to perform the linking. When emitting shaders with older versions, these layout statements will be removed,
-so it is important that the API user ensures that the names of I/O variables are sanitized so that linking will work properly.
-The reflection API can rename variables, struct types and struct members to deal with these scenarios using `Compiler::set_name` and friends.
-
-#### Clip-space conventions
-
-SPIRV-Cross can perform some common clip space conversions on gl_Position/SV_Position by enabling `CompilerGLSL::Options.vertex.fixup_clipspace`.
-While this can be convenient, it is recommended to modify the projection matrices instead as that can achieve the same result.
-
-For GLSL targets, enabling this will convert a shader which assumes `[0, w]` depth range (Vulkan / D3D / Metal) into `[-w, w]` range.
-For MSL and HLSL targets, enabling this will convert a shader in `[-w, w]` depth range (OpenGL) to `[0, w]` depth range.
-
-By default, the CLI will not enable `fixup_clipspace`, but in the API you might want to set an explicit value using `CompilerGLSL::set_options()`.
-
-Y-flipping of gl_Position and similar is also supported.
-The use of this is discouraged, because relying on vertex shader Y-flipping tends to get quite messy.
-To enable this, set `CompilerGLSL::Options.vertex.flip_vert_y` or `--flip-vert-y` in CLI.
-
-#### Reserved identifiers
-
-When cross-compiling, certain identifiers are considered to be reserved by the implementation.
-Code generated by SPIRV-Cross cannot emit these identifiers as they are reserved and used for various internal purposes,
-and such variables will typically show up as `_RESERVED_IDENTIFIER_FIXUP_`
-or some similar name to make it more obvious that an identifier has been renamed.
-
-Reflection output will follow the exact name specified in the SPIR-V module. It might not be a valid identifier in the C sense,
-as it may contain non-alphanumeric/non-underscore characters.
-
-Reserved identifiers currently assumed by the implementation are (in pseudo-regex):
-
-- _$digit+, e.g. `_100`, `_2`
-- _$digit+_.+, e.g. `_100_tmp`, `_2_foobar`. `_2Bar` is **not** reserved.
-- gl_- prefix
-- spv- prefix
-- SPIRV_Cross prefix. This prefix is generally used for interface variables where app needs to provide data for workaround purposes.
- This identifier will not be rewritten, but be aware of potential collisions.
-- Double underscores (reserved by all target languages).
-
-Members of structs also have a reserved identifier:
-- _m$digit+$END, e.g. `_m20` and `_m40` are reserved, but not `_m40Foobar`.
-
-## Contributing
-
-Contributions to SPIRV-Cross are welcome. See Testing and Licensing sections for details.
-
-### Testing
-
-SPIRV-Cross maintains a test suite of shaders with reference output of how the output looks after going through a roundtrip through
-glslangValidator/spirv-as then back through SPIRV-Cross again.
-The reference files are stored inside the repository in order to be able to track regressions.
-
-All pull requests should ensure that test output does not change unexpectedly. This can be tested with:
-
-```
-./checkout_glslang_spirv_tools.sh # Checks out glslang and SPIRV-Tools at a fixed revision which matches the reference output.
-./build_glslang_spirv_tools.sh # Builds glslang and SPIRV-Tools.
-./test_shaders.sh # Runs over all changes and makes sure that there are no deltas compared to reference files.
-```
-
-`./test_shaders.sh` currently requires a Makefile setup with GCC/Clang to be set up.
-However, on Windows, this can be rather inconvenient if a MinGW environment is not set up.
-To use a spirv-cross binary you built with CMake (or otherwise), you can pass in an environment variable as such:
-
-```
-SPIRV_CROSS_PATH=path/to/custom/spirv-cross ./test_shaders.sh
-```
-
-However, when improving SPIRV-Cross there are of course legitimate cases where reference output should change.
-In these cases, run:
-
-```
-./update_test_shaders.sh # SPIRV_CROSS_PATH also works here.
-```
-
-to update the reference files and include these changes as part of the pull request.
-Always make sure you are running the correct version of glslangValidator as well as SPIRV-Tools when updating reference files.
-See `checkout_glslang_spirv_tools.sh` which revisions are currently expected. The revisions change regularly.
-
-In short, the main branch should always be able to run `./test_shaders.py shaders` and friends without failure.
-SPIRV-Cross uses Travis CI to test all pull requests, so it is not strictly needed to perform testing yourself if you have problems running it locally.
-A pull request which does not pass testing on Travis will not be accepted however.
-
-When adding support for new features to SPIRV-Cross, a new shader and reference file should be added which covers usage of the new shader features in question.
-Travis CI runs the test suite with the CMake, by running `ctest`. This is a more straight-forward alternative to `./test_shaders.sh`.
-
-### Licensing
-
-Contributors of new files should add a copyright header at the top of every new source code file with their copyright
-along with the Apache 2.0 licensing stub.
-
-### Formatting
-
-SPIRV-Cross uses `clang-format` to automatically format code.
-Please use `clang-format` with the style sheet found in `.clang-format` to automatically format code before submitting a pull request.
-
-To make things easy, the `format_all.sh` script can be used to format all
-source files in the library. In this directory, run the following from the
-command line:
-
- ./format_all.sh
-
-## Regression testing
-
-In shaders/ a collection of shaders are maintained for purposes of regression testing.
-The current reference output is contained in reference/.
-`./test_shaders.py shaders` can be run to perform regression testing.
-
-See `./test_shaders.py --help` for more.
-
-### Metal backend
-
-To test the roundtrip path GLSL -> SPIR-V -> MSL, `--msl` can be added, e.g. `./test_shaders.py --msl shaders-msl`.
-
-### HLSL backend
-
-To test the roundtrip path GLSL -> SPIR-V -> HLSL, `--hlsl` can be added, e.g. `./test_shaders.py --hlsl shaders-hlsl`.
-
-### Updating regression tests
-
-When legitimate changes are found, use `--update` flag to update regression files.
-Otherwise, `./test_shaders.py` will fail with error code.
-
-### Mali Offline Compiler cycle counts
-
-To obtain a CSV of static shader cycle counts before and after going through spirv-cross, add
-`--malisc` flag to `./test_shaders`. This requires the Mali Offline Compiler to be installed in PATH.
-
+\< mucho texto \>
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index cc2fade2..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-environment:
- matrix:
- - GENERATOR: "Visual Studio 12 2013 Win64"
- CONFIG: Debug
-
- - GENERATOR: "Visual Studio 12 2013 Win64"
- CONFIG: Release
-
- - GENERATOR: "Visual Studio 14 2015 Win64"
- CONFIG: Debug
-
- - GENERATOR: "Visual Studio 14 2015 Win64"
- CONFIG: Release
-
- - GENERATOR: "Visual Studio 12 2013"
- CONFIG: Debug
-
- - GENERATOR: "Visual Studio 12 2013"
- CONFIG: Release
-
- - GENERATOR: "Visual Studio 14 2015"
- CONFIG: Debug
-
- - GENERATOR: "Visual Studio 14 2015"
- CONFIG: Release
-
-build_script:
- - git submodule update --init
- - cmake "-G%GENERATOR%" -H. -B_builds
- - cmake --build _builds --config "%CONFIG%"
diff --git a/build_glslang_spirv_tools.sh b/build_glslang_spirv_tools.sh
deleted file mode 100755
index e25aa98e..00000000
--- a/build_glslang_spirv_tools.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-PROFILE=Release
-
-if [ ! -z $1 ]; then
- PROFILE=$1
-fi
-
-if [ ! -z $2 ]; then
- NPROC="--parallel $2"
-fi
-
-echo "Building glslang."
-mkdir -p external/glslang-build
-cd external/glslang-build
-cmake ../glslang -DCMAKE_BUILD_TYPE=$PROFILE -DCMAKE_INSTALL_PREFIX=output -DENABLE_OPT=OFF
-cmake --build . --config $PROFILE --target install ${NPROC}
-cd ../..
-
-echo "Building SPIRV-Tools."
-mkdir -p external/spirv-tools-build
-cd external/spirv-tools-build
-cmake ../spirv-tools -DCMAKE_BUILD_TYPE=$PROFILE -DSPIRV_WERROR=OFF -DCMAKE_INSTALL_PREFIX=output
-cmake --build . --config $PROFILE --target install ${NPROC}
-cd ../..
-
diff --git a/checkout_glslang_spirv_tools.sh b/checkout_glslang_spirv_tools.sh
deleted file mode 100755
index 10d20b0a..00000000
--- a/checkout_glslang_spirv_tools.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-GLSLANG_REV=a7785ea1ff5b10bfc2d8ca77fdad5929562897b7
-SPIRV_TOOLS_REV=afaf8fda2ad0364655909b56c8b634ce89095bb5
-SPIRV_HEADERS_REV=e867c06631767a2d96424cbec530f9ee5e78180f
-PROTOCOL=https
-
-if [ -d external/glslang ]; then
- echo "Updating glslang to revision $GLSLANG_REV."
- cd external/glslang
- git fetch origin
- git checkout $GLSLANG_REV
-else
- echo "Cloning glslang revision $GLSLANG_REV."
- mkdir -p external
- cd external
- git clone $PROTOCOL://github.com/KhronosGroup/glslang.git
- cd glslang
- git checkout $GLSLANG_REV
-fi
-cd ../..
-
-if [ -d external/spirv-tools ]; then
- echo "Updating SPIRV-Tools to revision $SPIRV_TOOLS_REV."
- cd external/spirv-tools
- git fetch origin
- git checkout $SPIRV_TOOLS_REV
-else
- echo "Cloning SPIRV-Tools revision $SPIRV_TOOLS_REV."
- mkdir -p external
- cd external
- git clone $PROTOCOL://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
- cd spirv-tools
- git checkout $SPIRV_TOOLS_REV
-fi
-
-if [ -d external/spirv-headers ]; then
- cd external/spirv-headers
- git fetch origin
- git checkout $SPIRV_HEADERS_REV
- cd ../..
-else
- git clone $PROTOCOL://github.com/KhronosGroup/SPIRV-Headers.git external/spirv-headers
- cd external/spirv-headers
- git checkout $SPIRV_HEADERS_REV
- cd ../..
-fi
-
-cd ../..
-
diff --git a/cmake/gitversion.in.h b/cmake/gitversion.in.h
deleted file mode 100644
index bff73e96..00000000
--- a/cmake/gitversion.in.h
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2016-2021 The Khronos Group Inc.
-// SPDX-License-Identifier: Apache-2.0
-
-#ifndef SPIRV_CROSS_GIT_VERSION_H_
-#define SPIRV_CROSS_GIT_VERSION_H_
-
-#define SPIRV_CROSS_GIT_REVISION "Git commit: @spirv-cross-build-version@ Timestamp: @spirv-cross-timestamp@"
-
-#endif
diff --git a/format_all.sh b/format_all.sh
deleted file mode 100755
index 001c3c5d..00000000
--- a/format_all.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-# Copyright 2016-2021 The Khronos Group Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-#for file in spirv_*.{cpp,hpp} include/spirv_cross/*.{hpp,h} samples/cpp/*.cpp main.cpp
-for file in spirv_*.{cpp,hpp} main.cpp
-do
- echo "Formatting file: $file ..."
- clang-format -style=file -i $file
-done
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
deleted file mode 100644
index 64d019ea..00000000
--- a/gn/BUILD.gn
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright (C) 2019 Google, Inc.
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-config("spirv_cross_public") {
- include_dirs = [ ".." ]
-
- defines = [ "SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" ]
-}
-
-source_set("spirv_cross_sources") {
- public_configs = [ ":spirv_cross_public" ]
-
- sources = [
- "../GLSL.std.450.h",
- "../spirv.hpp",
- "../spirv_cfg.cpp",
- "../spirv_cfg.hpp",
- "../spirv_common.hpp",
- "../spirv_cross.cpp",
- "../spirv_cross.hpp",
- "../spirv_cross_containers.hpp",
- "../spirv_cross_error_handling.hpp",
- "../spirv_cross_parsed_ir.cpp",
- "../spirv_cross_parsed_ir.hpp",
- "../spirv_cross_util.cpp",
- "../spirv_cross_util.hpp",
- "../spirv_glsl.cpp",
- "../spirv_glsl.hpp",
- "../spirv_hlsl.cpp",
- "../spirv_hlsl.hpp",
- "../spirv_msl.cpp",
- "../spirv_msl.hpp",
- "../spirv_parser.cpp",
- "../spirv_parser.hpp",
- "../spirv_reflect.cpp",
- "../spirv_reflect.hpp",
- ]
-
- if (!is_win) {
- cflags = [ "-fno-exceptions" ]
- }
-
- if (is_clang) {
- cflags_cc = [
- "-Wno-extra-semi",
- "-Wno-ignored-qualifiers",
- "-Wno-implicit-fallthrough",
- "-Wno-inconsistent-missing-override",
- "-Wno-missing-field-initializers",
- "-Wno-newline-eof",
- "-Wno-sign-compare",
- "-Wno-unused-variable",
- ]
- }
-}
diff --git a/main.cpp b/main.cpp
deleted file mode 100644
index 6361fc8a..00000000
--- a/main.cpp
+++ /dev/null
@@ -1,2010 +0,0 @@
-/*
- * Copyright 2015-2021 Arm Limited
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * At your option, you may choose to accept this material under either:
- * 1. The Apache License, Version 2.0, found at , or
- * 2. The MIT License, found at .
- */
-
-#include "spirv_cpp.hpp"
-#include "spirv_cross_util.hpp"
-#include "spirv_glsl.hpp"
-#include "spirv_hlsl.hpp"
-#include "spirv_msl.hpp"
-#include "spirv_parser.hpp"
-#include "spirv_reflect.hpp"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#ifdef _WIN32
-#include
-#include
-#endif
-
-#ifdef HAVE_SPIRV_CROSS_GIT_VERSION
-#include "gitversion.h"
-#endif
-
-using namespace spv;
-using namespace SPIRV_CROSS_NAMESPACE;
-using namespace std;
-
-#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
-static inline void THROW(const char *str)
-{
- fprintf(stderr, "SPIRV-Cross will abort: %s\n", str);
- fflush(stderr);
- abort();
-}
-#else
-#define THROW(x) throw runtime_error(x)
-#endif
-
-struct CLIParser;
-struct CLICallbacks
-{
- void add(const char *cli, const function &func)
- {
- callbacks[cli] = func;
- }
- unordered_map> callbacks;
- function error_handler;
- function default_handler;
-};
-
-struct CLIParser
-{
- CLIParser(CLICallbacks cbs_, int argc_, char *argv_[])
- : cbs(std::move(cbs_))
- , argc(argc_)
- , argv(argv_)
- {
- }
-
- bool parse()
- {
-#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
- try
-#endif
- {
- while (argc && !ended_state)
- {
- const char *next = *argv++;
- argc--;
-
- if (*next != '-' && cbs.default_handler)
- {
- cbs.default_handler(next);
- }
- else
- {
- auto itr = cbs.callbacks.find(next);
- if (itr == ::end(cbs.callbacks))
- {
- THROW("Invalid argument");
- }
-
- itr->second(*this);
- }
- }
-
- return true;
- }
-#ifndef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
- catch (...)
- {
- if (cbs.error_handler)
- {
- cbs.error_handler();
- }
- return false;
- }
-#endif
- }
-
- void end()
- {
- ended_state = true;
- }
-
- uint32_t next_uint()
- {
- if (!argc)
- {
- THROW("Tried to parse uint, but nothing left in arguments");
- }
-
- uint64_t val = stoul(*argv);
- if (val > numeric_limits::max())
- {
- THROW("next_uint() out of range");
- }
-
- argc--;
- argv++;
-
- return uint32_t(val);
- }
-
- uint32_t next_hex_uint()
- {
- if (!argc)
- {
- THROW("Tried to parse uint, but nothing left in arguments");
- }
-
- uint64_t val = stoul(*argv, nullptr, 16);
- if (val > numeric_limits::max())
- {
- THROW("next_uint() out of range");
- }
-
- argc--;
- argv++;
-
- return uint32_t(val);
- }
-
- double next_double()
- {
- if (!argc)
- {
- THROW("Tried to parse double, but nothing left in arguments");
- }
-
- double val = stod(*argv);
-
- argc--;
- argv++;
-
- return val;
- }
-
- // Return a string only if it's not prefixed with `--`, otherwise return the default value
- const char *next_value_string(const char *default_value)
- {
- if (!argc)
- {
- return default_value;
- }
-
- if (0 == strncmp("--", *argv, 2))
- {
- return default_value;
- }
-
- return next_string();
- }
-
- const char *next_string()
- {
- if (!argc)
- {
- THROW("Tried to parse string, but nothing left in arguments");
- }
-
- const char *ret = *argv;
- argc--;
- argv++;
- return ret;
- }
-
- CLICallbacks cbs;
- int argc;
- char **argv;
- bool ended_state = false;
-};
-
-#if defined(__clang__) || defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4996)
-#endif
-
-static vector read_spirv_file_stdin()
-{
-#ifdef _WIN32
- setmode(fileno(stdin), O_BINARY);
-#endif
-
- vector buffer;
- uint32_t tmp[256];
- size_t ret;
-
- while ((ret = fread(tmp, sizeof(uint32_t), 256, stdin)))
- buffer.insert(buffer.end(), tmp, tmp + ret);
-
- return buffer;
-}
-
-static vector read_spirv_file(const char *path)
-{
- if (path[0] == '-' && path[1] == '\0')
- return read_spirv_file_stdin();
-
- FILE *file = fopen(path, "rb");
- if (!file)
- {
- fprintf(stderr, "Failed to open SPIR-V file: %s\n", path);
- return {};
- }
-
- fseek(file, 0, SEEK_END);
- long len = ftell(file) / sizeof(uint32_t);
- rewind(file);
-
- vector spirv(len);
- if (fread(spirv.data(), sizeof(uint32_t), len, file) != size_t(len))
- spirv.clear();
-
- fclose(file);
- return spirv;
-}
-
-static bool write_string_to_file(const char *path, const char *string)
-{
- FILE *file = fopen(path, "w");
- if (!file)
- {
- fprintf(stderr, "Failed to write file: %s\n", path);
- return false;
- }
-
- fprintf(file, "%s", string);
- fclose(file);
- return true;
-}
-
-#if defined(__clang__) || defined(__GNUC__)
-#pragma GCC diagnostic pop
-#elif defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
-static void print_resources(const Compiler &compiler, spv::StorageClass storage,
- const SmallVector &resources)
-{
- fprintf(stderr, "%s\n", storage == StorageClassInput ? "builtin inputs" : "builtin outputs");
- fprintf(stderr, "=============\n\n");
- for (auto &res : resources)
- {
- bool active = compiler.has_active_builtin(res.builtin, storage);
- const char *basetype = "?";
- auto &type = compiler.get_type(res.value_type_id);
- switch (type.basetype)
- {
- case SPIRType::Float: basetype = "float"; break;
- case SPIRType::Int: basetype = "int"; break;
- case SPIRType::UInt: basetype = "uint"; break;
- default: break;
- }
-
- uint32_t array_size = 0;
- bool array_size_literal = false;
- if (!type.array.empty())
- {
- array_size = type.array.front();
- array_size_literal = type.array_size_literal.front();
- }
-
- string type_str = basetype;
- if (type.vecsize > 1)
- type_str += std::to_string(type.vecsize);
-
- if (array_size)
- {
- if (array_size_literal)
- type_str += join("[", array_size, "]");
- else
- type_str += join("[", array_size, " (spec constant ID)]");
- }
-
- string builtin_str;
- switch (res.builtin)
- {
- case spv::BuiltInPosition: builtin_str = "Position"; break;
- case spv::BuiltInPointSize: builtin_str = "PointSize"; break;
- case spv::BuiltInCullDistance: builtin_str = "CullDistance"; break;
- case spv::BuiltInClipDistance: builtin_str = "ClipDistance"; break;
- case spv::BuiltInTessLevelInner: builtin_str = "TessLevelInner"; break;
- case spv::BuiltInTessLevelOuter: builtin_str = "TessLevelOuter"; break;
- default: builtin_str = string("builtin #") + to_string(res.builtin);
- }
-
- fprintf(stderr, "Builtin %s (%s) (active: %s).\n", builtin_str.c_str(), type_str.c_str(), active ? "yes" : "no");
- }
- fprintf(stderr, "=============\n\n");
-}
-
-static void print_resources(const Compiler &compiler, const char *tag, const SmallVector &resources)
-{
- fprintf(stderr, "%s\n", tag);
- fprintf(stderr, "=============\n\n");
- bool print_ssbo = !strcmp(tag, "ssbos");
-
- for (auto &res : resources)
- {
- auto &type = compiler.get_type(res.type_id);
-
- if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id))
- continue;
-
- // If we don't have a name, use the fallback for the type instead of the variable
- // for SSBOs and UBOs since those are the only meaningful names to use externally.
- // Push constant blocks are still accessed by name and not block name, even though they are technically Blocks.
- bool is_push_constant = compiler.get_storage_class(res.id) == StorageClassPushConstant;
- bool is_block = compiler.get_decoration_bitset(type.self).get(DecorationBlock) ||
- compiler.get_decoration_bitset(type.self).get(DecorationBufferBlock);
- bool is_sized_block = is_block && (compiler.get_storage_class(res.id) == StorageClassUniform ||
- compiler.get_storage_class(res.id) == StorageClassUniformConstant);
- ID fallback_id = !is_push_constant && is_block ? ID(res.base_type_id) : ID(res.id);
-
- uint32_t block_size = 0;
- uint32_t runtime_array_stride = 0;
- if (is_sized_block)
- {
- auto &base_type = compiler.get_type(res.base_type_id);
- block_size = uint32_t(compiler.get_declared_struct_size(base_type));
- runtime_array_stride = uint32_t(compiler.get_declared_struct_size_runtime_array(base_type, 1) -
- compiler.get_declared_struct_size_runtime_array(base_type, 0));
- }
-
- Bitset mask;
- if (print_ssbo)
- mask = compiler.get_buffer_block_flags(res.id);
- else
- mask = compiler.get_decoration_bitset(res.id);
-
- string array;
- for (auto arr : type.array)
- array = join("[", arr ? convert_to_string(arr) : "", "]") + array;
-
- fprintf(stderr, " ID %03u : %s%s", uint32_t(res.id),
- !res.name.empty() ? res.name.c_str() : compiler.get_fallback_name(fallback_id).c_str(), array.c_str());
-
- if (mask.get(DecorationLocation))
- fprintf(stderr, " (Location : %u)", compiler.get_decoration(res.id, DecorationLocation));
- if (mask.get(DecorationDescriptorSet))
- fprintf(stderr, " (Set : %u)", compiler.get_decoration(res.id, DecorationDescriptorSet));
- if (mask.get(DecorationBinding))
- fprintf(stderr, " (Binding : %u)", compiler.get_decoration(res.id, DecorationBinding));
- if (static_cast(compiler).variable_is_depth_or_compare(res.id))
- fprintf(stderr, " (comparison)");
- if (mask.get(DecorationInputAttachmentIndex))
- fprintf(stderr, " (Attachment : %u)", compiler.get_decoration(res.id, DecorationInputAttachmentIndex));
- if (mask.get(DecorationNonReadable))
- fprintf(stderr, " writeonly");
- if (mask.get(DecorationNonWritable))
- fprintf(stderr, " readonly");
- if (mask.get(DecorationRestrict))
- fprintf(stderr, " restrict");
- if (mask.get(DecorationCoherent))
- fprintf(stderr, " coherent");
- if (mask.get(DecorationVolatile))
- fprintf(stderr, " volatile");
- if (is_sized_block)
- {
- fprintf(stderr, " (BlockSize : %u bytes)", block_size);
- if (runtime_array_stride)
- fprintf(stderr, " (Unsized array stride: %u bytes)", runtime_array_stride);
- }
-
- uint32_t counter_id = 0;
- if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id))
- fprintf(stderr, " (HLSL counter buffer ID: %u)", counter_id);
- fprintf(stderr, "\n");
- }
- fprintf(stderr, "=============\n\n");
-}
-
-static const char *execution_model_to_str(spv::ExecutionModel model)
-{
- switch (model)
- {
- case spv::ExecutionModelVertex:
- return "vertex";
- case spv::ExecutionModelTessellationControl:
- return "tessellation control";
- case ExecutionModelTessellationEvaluation:
- return "tessellation evaluation";
- case ExecutionModelGeometry:
- return "geometry";
- case ExecutionModelFragment:
- return "fragment";
- case ExecutionModelGLCompute:
- return "compute";
- case ExecutionModelRayGenerationNV:
- return "raygenNV";
- case ExecutionModelIntersectionNV:
- return "intersectionNV";
- case ExecutionModelCallableNV:
- return "callableNV";
- case ExecutionModelAnyHitNV:
- return "anyhitNV";
- case ExecutionModelClosestHitNV:
- return "closesthitNV";
- case ExecutionModelMissNV:
- return "missNV";
- default:
- return "???";
- }
-}
-
-static void print_resources(const Compiler &compiler, const ShaderResources &res)
-{
- auto &modes = compiler.get_execution_mode_bitset();
-
- fprintf(stderr, "Entry points:\n");
- auto entry_points = compiler.get_entry_points_and_stages();
- for (auto &e : entry_points)
- fprintf(stderr, " %s (%s)\n", e.name.c_str(), execution_model_to_str(e.execution_model));
- fprintf(stderr, "\n");
-
- fprintf(stderr, "Execution modes:\n");
- modes.for_each_bit([&](uint32_t i) {
- auto mode = static_cast(i);
- uint32_t arg0 = compiler.get_execution_mode_argument(mode, 0);
- uint32_t arg1 = compiler.get_execution_mode_argument(mode, 1);
- uint32_t arg2 = compiler.get_execution_mode_argument(mode, 2);
-
- switch (static_cast(i))
- {
- case ExecutionModeInvocations:
- fprintf(stderr, " Invocations: %u\n", arg0);
- break;
-
- case ExecutionModeLocalSize:
- fprintf(stderr, " LocalSize: (%u, %u, %u)\n", arg0, arg1, arg2);
- break;
-
- case ExecutionModeOutputVertices:
- fprintf(stderr, " OutputVertices: %u\n", arg0);
- break;
-
-#define CHECK_MODE(m) \
- case ExecutionMode##m: \
- fprintf(stderr, " %s\n", #m); \
- break
- CHECK_MODE(SpacingEqual);
- CHECK_MODE(SpacingFractionalEven);
- CHECK_MODE(SpacingFractionalOdd);
- CHECK_MODE(VertexOrderCw);
- CHECK_MODE(VertexOrderCcw);
- CHECK_MODE(PixelCenterInteger);
- CHECK_MODE(OriginUpperLeft);
- CHECK_MODE(OriginLowerLeft);
- CHECK_MODE(EarlyFragmentTests);
- CHECK_MODE(PointMode);
- CHECK_MODE(Xfb);
- CHECK_MODE(DepthReplacing);
- CHECK_MODE(DepthGreater);
- CHECK_MODE(DepthLess);
- CHECK_MODE(DepthUnchanged);
- CHECK_MODE(LocalSizeHint);
- CHECK_MODE(InputPoints);
- CHECK_MODE(InputLines);
- CHECK_MODE(InputLinesAdjacency);
- CHECK_MODE(Triangles);
- CHECK_MODE(InputTrianglesAdjacency);
- CHECK_MODE(Quads);
- CHECK_MODE(Isolines);
- CHECK_MODE(OutputPoints);
- CHECK_MODE(OutputLineStrip);
- CHECK_MODE(OutputTriangleStrip);
- CHECK_MODE(VecTypeHint);
- CHECK_MODE(ContractionOff);
-
- default:
- break;
- }
- });
- fprintf(stderr, "\n");
-
- print_resources(compiler, "subpass inputs", res.subpass_inputs);
- print_resources(compiler, "inputs", res.stage_inputs);
- print_resources(compiler, "outputs", res.stage_outputs);
- print_resources(compiler, "textures", res.sampled_images);
- print_resources(compiler, "separate images", res.separate_images);
- print_resources(compiler, "separate samplers", res.separate_samplers);
- print_resources(compiler, "images", res.storage_images);
- print_resources(compiler, "ssbos", res.storage_buffers);
- print_resources(compiler, "ubos", res.uniform_buffers);
- print_resources(compiler, "push", res.push_constant_buffers);
- print_resources(compiler, "counters", res.atomic_counters);
- print_resources(compiler, "acceleration structures", res.acceleration_structures);
- print_resources(compiler, "record buffers", res.shader_record_buffers);
- print_resources(compiler, spv::StorageClassInput, res.builtin_inputs);
- print_resources(compiler, spv::StorageClassOutput, res.builtin_outputs);
-}
-
-static void print_push_constant_resources(const Compiler &compiler, const SmallVector &res)
-{
- for (auto &block : res)
- {
- auto ranges = compiler.get_active_buffer_ranges(block.id);
- fprintf(stderr, "Active members in buffer: %s\n",
- !block.name.empty() ? block.name.c_str() : compiler.get_fallback_name(block.id).c_str());
-
- fprintf(stderr, "==================\n\n");
- for (auto &range : ranges)
- {
- const auto &name = compiler.get_member_name(block.base_type_id, range.index);
-
- fprintf(stderr, "Member #%3u (%s): Offset: %4u, Range: %4u\n", range.index,
- !name.empty() ? name.c_str() : compiler.get_fallback_member_name(range.index).c_str(),
- unsigned(range.offset), unsigned(range.range));
- }
- fprintf(stderr, "==================\n\n");
- }
-}
-
-static void print_spec_constants(const Compiler &compiler)
-{
- auto spec_constants = compiler.get_specialization_constants();
- fprintf(stderr, "Specialization constants\n");
- fprintf(stderr, "==================\n\n");
- for (auto &c : spec_constants)
- fprintf(stderr, "ID: %u, Spec ID: %u\n", uint32_t(c.id), c.constant_id);
- fprintf(stderr, "==================\n\n");
-}
-
-static void print_capabilities_and_extensions(const Compiler &compiler)
-{
- fprintf(stderr, "Capabilities\n");
- fprintf(stderr, "============\n");
- for (auto &capability : compiler.get_declared_capabilities())
- fprintf(stderr, "Capability: %u\n", static_cast(capability));
- fprintf(stderr, "============\n\n");
-
- fprintf(stderr, "Extensions\n");
- fprintf(stderr, "============\n");
- for (auto &ext : compiler.get_declared_extensions())
- fprintf(stderr, "Extension: %s\n", ext.c_str());
- fprintf(stderr, "============\n\n");
-}
-
-struct PLSArg
-{
- PlsFormat format;
- string name;
-};
-
-struct Remap
-{
- string src_name;
- string dst_name;
- unsigned components;
-};
-
-struct VariableTypeRemap
-{
- string variable_name;
- string new_variable_type;
-};
-
-struct InterfaceVariableRename
-{
- StorageClass storageClass;
- uint32_t location;
- string variable_name;
-};
-
-struct HLSLVertexAttributeRemapNamed
-{
- std::string name;
- std::string semantic;
-};
-
-struct CLIArguments
-{
- const char *input = nullptr;
- const char *output = nullptr;
- const char *cpp_interface_name = nullptr;
- uint32_t version = 0;
- uint32_t shader_model = 0;
- uint32_t msl_version = 0;
- bool es = false;
- bool set_version = false;
- bool set_shader_model = false;
- bool set_msl_version = false;
- bool set_es = false;
- bool dump_resources = false;
- bool force_temporary = false;
- bool flatten_ubo = false;
- bool fixup = false;
- bool yflip = false;
- bool sso = false;
- bool support_nonzero_baseinstance = true;
- bool msl_capture_output_to_buffer = false;
- bool msl_swizzle_texture_samples = false;
- bool msl_ios = false;
- bool msl_pad_fragment_output = false;
- bool msl_domain_lower_left = false;
- bool msl_argument_buffers = false;
- uint32_t msl_argument_buffers_tier = 0; // Tier 1
- bool msl_texture_buffer_native = false;
- bool msl_framebuffer_fetch = false;
- bool msl_invariant_float_math = false;
- bool msl_emulate_cube_array = false;
- bool msl_multiview = false;
- bool msl_multiview_layered_rendering = true;
- bool msl_view_index_from_device_index = false;
- bool msl_dispatch_base = false;
- bool msl_decoration_binding = false;
- bool msl_force_active_argument_buffer_resources = false;
- bool msl_force_native_arrays = false;
- bool msl_enable_frag_depth_builtin = true;
- bool msl_enable_frag_stencil_ref_builtin = true;
- uint32_t msl_enable_frag_output_mask = 0xffffffff;
- bool msl_enable_clip_distance_user_varying = true;
- bool msl_raw_buffer_tese_input = false;
- bool msl_multi_patch_workgroup = false;
- bool msl_vertex_for_tessellation = false;
- uint32_t msl_additional_fixed_sample_mask = 0xffffffff;
- bool msl_arrayed_subpass_input = false;
- uint32_t msl_r32ui_linear_texture_alignment = 4;
- uint32_t msl_r32ui_alignment_constant_id = 65535;
- bool msl_texture_1d_as_2d = false;
- bool msl_ios_use_simdgroup_functions = false;
- bool msl_emulate_subgroups = false;
- uint32_t msl_fixed_subgroup_size = 0;
- bool msl_force_sample_rate_shading = false;
- bool msl_manual_helper_invocation_updates = true;
- bool msl_check_discarded_frag_stores = false;
- bool msl_force_fragment_with_side_effects_execution = false;
- bool msl_sample_dref_lod_array_as_grad = false;
- bool msl_runtime_array_rich_descriptor = false;
- bool msl_replace_recursive_inputs = false;
- bool msl_readwrite_texture_fences = true;
- bool msl_agx_manual_cube_grad_fixup = false;
- bool msl_input_attachment_is_ds_attachment = false;
- const char *msl_combined_sampler_suffix = nullptr;
- bool glsl_emit_push_constant_as_ubo = false;
- bool glsl_emit_ubo_as_plain_uniforms = false;
- bool glsl_force_flattened_io_blocks = false;
- uint32_t glsl_ovr_multiview_view_count = 0;
- SmallVector> glsl_ext_framebuffer_fetch;
- bool glsl_ext_framebuffer_fetch_noncoherent = false;
- bool vulkan_glsl_disable_ext_samplerless_texture_functions = false;
- bool emit_line_directives = false;
- bool enable_storage_image_qualifier_deduction = true;
- bool force_zero_initialized_variables = false;
- bool relax_nan_checks = false;
- uint32_t force_recompile_max_debug_iterations = 3;
- SmallVector msl_discrete_descriptor_sets;
- SmallVector msl_device_argument_buffers;
- SmallVector> msl_dynamic_buffers;
- SmallVector> msl_inline_uniform_blocks;
- SmallVector msl_shader_inputs;
- SmallVector msl_shader_outputs;
- SmallVector pls_in;
- SmallVector pls_out;
- SmallVector remaps;
- SmallVector extensions;
- SmallVector variable_type_remaps;
- SmallVector interface_variable_renames;
- SmallVector hlsl_attr_remap;
- SmallVector hlsl_attr_remap_named;
- SmallVector> masked_stage_outputs;
- SmallVector masked_stage_builtins;
- string entry;
- string entry_stage;
-
- struct Rename
- {
- string old_name;
- string new_name;
- ExecutionModel execution_model;
- };
- SmallVector entry_point_rename;
-
- uint32_t iterations = 1;
- bool cpp = false;
- string reflect;
- bool msl = false;
- bool hlsl = false;
- bool hlsl_compat = false;
-
- bool hlsl_support_nonzero_base = false;
- bool hlsl_base_vertex_index_explicit_binding = false;
- uint32_t hlsl_base_vertex_index_register_index = 0;
- uint32_t hlsl_base_vertex_index_register_space = 0;
-
- bool hlsl_force_storage_buffer_as_uav = false;
- bool hlsl_nonwritable_uav_texture_as_srv = false;
- bool hlsl_enable_16bit_types = false;
- bool hlsl_flatten_matrix_vertex_input_semantics = false;
- bool hlsl_preserve_structured_buffers = false;
- HLSLBindingFlags hlsl_binding_flags = 0;
- bool vulkan_semantics = false;
- bool flatten_multidimensional_arrays = false;
- bool use_420pack_extension = true;
- bool remove_unused = false;
- bool combined_samplers_inherit_bindings = false;
-};
-
-static void print_version()
-{
-#ifdef HAVE_SPIRV_CROSS_GIT_VERSION
- fprintf(stderr, "%s\n", SPIRV_CROSS_GIT_REVISION);
-#else
- fprintf(stderr, "Git revision unknown. Build with CMake to create timestamp and revision info.\n");
-#endif
-}
-
-static void print_help_backend()
-{
- // clang-format off
- fprintf(stderr, "\nSelect backend:\n"
- "\tBy default, OpenGL-style GLSL is the target, with #version and GLSL/ESSL information inherited from the SPIR-V module if present.\n"
- "\t[--vulkan-semantics] or [-V]:\n\t\tEmit Vulkan GLSL instead of plain GLSL. Makes use of Vulkan-only features to match SPIR-V.\n"
- "\t[--msl]:\n\t\tEmit Metal Shading Language (MSL).\n"
- "\t[--hlsl]:\n\t\tEmit HLSL.\n"
- "\t[--reflect]:\n\t\tEmit JSON reflection.\n"
- "\t[--cpp]:\n\t\tDEPRECATED. Emits C++ code.\n"
- );
- // clang-format on
-}
-
-static void print_help_glsl()
-{
- // clang-format off
- fprintf(stderr, "\nGLSL options:\n"
- "\t[--es]:\n\t\tForce ESSL.\n"
- "\t[--no-es]:\n\t\tForce desktop GLSL.\n"
- "\t[--version ]:\n\t\tE.g. --version 450 will emit '#version 450' in shader.\n"
- "\t\tCode generation will depend on the version used.\n"
- "\t[--flatten-ubo]:\n\t\tEmit UBOs as plain uniform arrays which are suitable for use with glUniform4*v().\n"
- "\t\tThis can be an optimization on GL implementations where this is faster or works around buggy driver implementations.\n"
- "\t\tE.g.: uniform MyUBO { vec4 a; float b, c, d, e; }; will be emitted as uniform vec4 MyUBO[2];\n"
- "\t\tCaveat: You cannot mix and match floating-point and integer in the same UBO with this option.\n"
- "\t\tLegacy GLSL/ESSL (where this flattening makes sense) does not support bit-casting, which would have been the obvious workaround.\n"
- "\t[--extension ext]:\n\t\tAdd #extension string of your choosing to GLSL output.\n"
- "\t\tUseful if you use variable name remapping to something that requires an extension unknown to SPIRV-Cross.\n"
- "\t[--remove-unused-variables]:\n\t\tDo not emit interface variables which are not statically accessed by the shader.\n"
- "\t[--separate-shader-objects]:\n\t\tRedeclare gl_PerVertex blocks to be suitable for desktop GL separate shader objects.\n"
- "\t[--glsl-emit-push-constant-as-ubo]:\n\t\tInstead of a plain uniform of struct for push constants, emit a UBO block instead.\n"
- "\t[--glsl-emit-ubo-as-plain-uniforms]:\n\t\tInstead of emitting UBOs, emit them as plain uniform structs.\n"
- "\t[--glsl-remap-ext-framebuffer-fetch input-attachment color-location]:\n\t\tRemaps an input attachment to use GL_EXT_shader_framebuffer_fetch.\n"
- "\t\tgl_LastFragData[location] is read from. The attachment to read from must be declared as an output in the shader.\n"
- "\t[--glsl-ext-framebuffer-fetch-noncoherent]:\n\t\tUses noncoherent qualifier for framebuffer fetch.\n"
- "\t[--vulkan-glsl-disable-ext-samplerless-texture-functions]:\n\t\tDo not allow use of GL_EXT_samperless_texture_functions, even in Vulkan GLSL.\n"
- "\t\tUse of texelFetch and similar might have to create dummy samplers to work around it.\n"
- "\t[--combined-samplers-inherit-bindings]:\n\t\tInherit binding information from the textures when building combined image samplers from separate textures and samplers.\n"
- "\t[--no-support-nonzero-baseinstance]:\n\t\tWhen using gl_InstanceIndex with desktop GL,\n"
- "\t\tassume that base instance is always 0, and do not attempt to fix up gl_InstanceID to match Vulkan semantics.\n"
- "\t[--pls-in format input-name]:\n\t\tRemaps a subpass input with name into a GL_EXT_pixel_local_storage input.\n"
- "\t\tEntry in PLS block is ordered where first --pls-in marks the first entry. Can be called multiple times.\n"
- "\t\tFormats allowed: r11f_g11f_b10f, r32f, rg16f, rg16, rgb10_a2, rgba8, rgba8i, rgba8ui, rg16i, rgb10_a2ui, rg16ui, r32ui.\n"
- "\t\tRequires ESSL.\n"
- "\t[--pls-out format output-name]:\n\t\tRemaps a color output with name into a GL_EXT_pixel_local_storage output.\n"
- "\t\tEntry in PLS block is ordered where first --pls-output marks the first entry. Can be called multiple times.\n"
- "\t\tFormats allowed: r11f_g11f_b10f, r32f, rg16f, rg16, rgb10_a2, rgba8, rgba8i, rgba8ui, rg16i, rgb10_a2ui, rg16ui, r32ui.\n"
- "\t\tRequires ESSL.\n"
- "\t[--remap source_name target_name components]:\n\t\tRemaps a variable to a different name with N components.\n"
- "\t\tMain use case is to remap a subpass input to gl_LastFragDepthARM.\n"
- "\t\tE.g.:\n"
- "\t\tuniform subpassInput uDepth;\n"
- "\t\t--remap uDepth gl_LastFragDepthARM 1 --extension GL_ARM_shader_framebuffer_fetch_depth_stencil\n"
- "\t[--no-420pack-extension]:\n\t\tDo not make use of GL_ARB_shading_language_420pack in older GL targets to support layout(binding).\n"
- "\t[--remap-variable-type ]:\n\t\tRemaps a variable type based on name.\n"
- "\t\tPrimary use case is supporting external samplers in ESSL for video rendering on Android where you could remap a texture to a YUV one.\n"
- "\t[--glsl-force-flattened-io-blocks]:\n\t\tAlways flatten I/O blocks and structs.\n"
- "\t[--glsl-ovr-multiview-view-count count]:\n\t\tIn GL_OVR_multiview2, specify layout(num_views).\n"
- );
- // clang-format on
-}
-
-static void print_help_hlsl()
-{
- // clang-format off
- fprintf(stderr, "\nHLSL options:\n"
- "\t[--shader-model]:\n\t\tEnables a specific shader model, e.g. --shader-model 50 for SM 5.0.\n"
- "\t[--flatten-ubo]:\n\t\tEmit UBOs as plain uniform arrays.\n"
- "\t\tE.g.: uniform MyUBO { vec4 a; float b, c, d, e; }; will be emitted as uniform float4 MyUBO[2];\n"
- "\t\tCaveat: You cannot mix and match floating-point and integer in the same UBO with this option.\n"
- "\t[--hlsl-enable-compat]:\n\t\tAllow point size and point coord to be used, even if they won't work as expected.\n"
- "\t\tPointSize is ignored, and PointCoord returns (0.5, 0.5).\n"
- "\t[--hlsl-support-nonzero-basevertex-baseinstance]:\n\t\tSupport base vertex and base instance by emitting a special cbuffer declared as:\n"
- "\t\tcbuffer SPIRV_Cross_VertexInfo { int SPIRV_Cross_BaseVertex; int SPIRV_Cross_BaseInstance; };\n"
- "\t[--hlsl-basevertex-baseinstance-binding ]:\n\t\tAssign a fixed binding to SPIRV_Cross_VertexInfo.\n"
- "\t[--hlsl-auto-binding (push, cbv, srv, uav, sampler, all)]\n"
- "\t\tDo not emit any : register(#) bindings for specific resource types, and rely on HLSL compiler to assign something.\n"
- "\t[--hlsl-force-storage-buffer-as-uav]:\n\t\tAlways emit SSBOs as UAVs, even when marked as read-only.\n"
- "\t\tNormally, SSBOs marked with NonWritable will be emitted as SRVs.\n"
- "\t[--hlsl-nonwritable-uav-texture-as-srv]:\n\t\tEmit NonWritable storage images as SRV textures instead of UAV.\n"
- "\t\tUsing this option messes with the type system. SPIRV-Cross cannot guarantee that this will work.\n"
- "\t\tOne major problem area with this feature is function arguments, where we won't know if we're seeing a UAV or SRV.\n"
- "\t\tShader must ensure that read/write state is consistent at all call sites.\n"
- "\t[--set-hlsl-vertex-input-semantic ]:\n\t\tEmits a specific vertex input semantic for a given location.\n"
- "\t\tOtherwise, TEXCOORD# is used as semantics, where # is location.\n"
- "\t[--set-hlsl-named-vertex-input-semantic ]:\n\t\tEmits a specific vertex input semantic for a given name.\n"
- "\t\tOpName reflection information must be intact.\n"
- "\t[--hlsl-enable-16bit-types]:\n\t\tEnables native use of half/int16_t/uint16_t and ByteAddressBuffer interaction with these types. Requires SM 6.2.\n"
- "\t[--hlsl-flatten-matrix-vertex-input-semantics]:\n\t\tEmits matrix vertex inputs with input semantics as if they were independent vectors, e.g. TEXCOORD{2,3,4} rather than matrix form TEXCOORD2_{0,1,2}.\n"
- "\t[--hlsl-preserve-structured-buffers]:\n\t\tEmit SturucturedBuffer rather than ByteAddressBuffer. Requires UserTypeGOOGLE to be emitted. Intended for DXC roundtrips.\n"
- );
- // clang-format on
-}
-
-static void print_help_msl()
-{
- // clang-format off
- fprintf(stderr, "\nMSL options:\n"
- "\t[--msl-version ]:\n\t\tUses a specific MSL version, e.g. --msl-version 20100 for MSL 2.1.\n"
- "\t[--msl-capture-output]:\n\t\tWrites geometry varyings to a buffer instead of as stage-outputs.\n"
- "\t[--msl-swizzle-texture-samples]:\n\t\tWorks around lack of support for VkImageView component swizzles.\n"
- "\t\tThis has a massive impact on performance and bloat. Do not use this unless you are absolutely forced to.\n"
- "\t\tTo use this feature, the API side must pass down swizzle buffers.\n"
- "\t\tShould only be used by translation layers as a last resort.\n"
- "\t\tRecent Metal versions do not require this workaround.\n"
- "\t[--msl-ios]:\n\t\tTarget iOS Metal instead of macOS Metal.\n"
- "\t[--msl-pad-fragment-output]:\n\t\tAlways emit color outputs as 4-component variables.\n"
- "\t\tIn Metal, the fragment shader must emit at least as many components as the render target format.\n"
- "\t[--msl-domain-lower-left]:\n\t\tUse a lower-left tessellation domain.\n"
- "\t[--msl-argument-buffers]:\n\t\tEmit Metal argument buffers instead of discrete resource bindings.\n"
- "\t\tRequires MSL 2.0 to be enabled.\n"
- "\t[--msl-argument-buffer-tier]:\n\t\tWhen using Metal argument buffers, indicate the Metal argument buffer tier level supported by the Metal platform.\n"
- "\t\tUses same values as Metal MTLArgumentBuffersTier enumeration (0 = Tier1, 1 = Tier2).\n"
- "\t\tNOTE: Setting this value no longer enables msl-argument-buffers implicitly.\n"
- "\t[--msl-runtime-array-rich-descriptor]:\n\t\tWhen declaring a runtime array of SSBOs, declare an array of {ptr, len} pairs to support OpArrayLength.\n"
- "\t[--msl-replace-recursive-inputs]:\n\t\tWorks around a Metal 3.1 regression bug, which causes an infinite recursion crash during Metal's analysis of an entry point input structure that itself contains internal recursion.\n"
- "\t[--msl-texture-buffer-native]:\n\t\tEnable native support for texel buffers. Otherwise, it is emulated as a normal texture.\n"
- "\t[--msl-input-attachment-is-ds-attachment]:\n\t\tAdds a simple depth passthrough in fragment shaders when they do not modify the depth value.\n"
- "\t\tRequired to force Metal to write to the depth/stencil attachment post fragment execution.\n"
- "\t\tOtherwise, Metal may optimize the write to pre fragment execution which goes against the Vulkan spec.\n"
- "\t\tOnly required if an input attachment and depth/stencil attachment reference the same resource.\n"
- "\t[--msl-framebuffer-fetch]:\n\t\tImplement subpass inputs with frame buffer fetch.\n"
- "\t\tEmits [[color(N)]] inputs in fragment stage.\n"
- "\t\tRequires an Apple GPU.\n"
- "\t[--msl-emulate-cube-array]:\n\t\tEmulate cube arrays with 2D array and manual math.\n"
- "\t[--msl-discrete-descriptor-set ]:\n\t\tWhen using argument buffers, forces a specific descriptor set to be implemented without argument buffers.\n"
- "\t\tUseful for implementing push descriptors in emulation layers.\n"
- "\t\tCan be used multiple times for each descriptor set in question.\n"
- "\t[--msl-device-argument-buffer ]:\n\t\tUse device address space to hold indirect argument buffers instead of constant.\n"
- "\t\tComes up when trying to support argument buffers which are larger than 64 KiB.\n"
- "\t[--msl-multiview]:\n\t\tEnable SPV_KHR_multiview emulation.\n"
- "\t[--msl-multiview-no-layered-rendering]:\n\t\tDon't set [[render_target_array_index]] in multiview shaders.\n"
- "\t\tUseful for devices which don't support layered rendering. Only effective when --msl-multiview is enabled.\n"
- "\t[--msl-view-index-from-device-index]:\n\t\tTreat the view index as the device index instead.\n"
- "\t\tFor multi-GPU rendering.\n"
- "\t[--msl-dispatch-base]:\n\t\tAdd support for vkCmdDispatchBase() or similar APIs.\n"
- "\t\tOffsets the workgroup ID based on a buffer.\n"
- "\t[--msl-dynamic-buffer ]:\n\t\tMarks a buffer as having dynamic offset.\n"
- "\t\tThe offset is applied in the shader with pointer arithmetic.\n"
- "\t\tUseful for argument buffers where it is non-trivial to apply dynamic offset otherwise.\n"
- "\t[--msl-inline-uniform-block ]:\n\t\tIn argument buffers, mark an UBO as being an inline uniform block which is embedded into the argument buffer itself.\n"
- "\t[--msl-decoration-binding]:\n\t\tUse SPIR-V bindings directly as MSL bindings.\n"
- "\t\tThis does not work in the general case as there is no descriptor set support, and combined image samplers are split up.\n"
- "\t\tHowever, if the shader author knows of binding limitations, this option will avoid the need for reflection on Metal side.\n"
- "\t[--msl-force-active-argument-buffer-resources]:\n\t\tAlways emit resources which are part of argument buffers.\n"
- "\t\tThis makes sure that similar shaders with same resource declarations can share the argument buffer as declaring an argument buffer implies an ABI.\n"
- "\t[--msl-force-native-arrays]:\n\t\tRather than implementing array types as a templated value type ala std::array, use plain, native arrays.\n"
- "\t\tThis will lead to worse code-gen, but can work around driver bugs on certain driver revisions of certain Intel-based Macbooks where template arrays break.\n"
- "\t[--msl-disable-frag-depth-builtin]:\n\t\tDisables FragDepth output. Useful if pipeline does not enable depth, as pipeline creation might otherwise fail.\n"
- "\t[--msl-disable-frag-stencil-ref-builtin]:\n\t\tDisable FragStencilRef output. Useful if pipeline does not enable stencil output, as pipeline creation might otherwise fail.\n"
- "\t[--msl-enable-frag-output-mask ]:\n\t\tOnly selectively enable fragment outputs. Useful if pipeline does not enable fragment output for certain locations, as pipeline creation might otherwise fail.\n"
- "\t[--msl-no-clip-distance-user-varying]:\n\t\tDo not emit user varyings to emulate gl_ClipDistance in fragment shaders.\n"
- "\t[--msl-add-shader-input ]:\n\t\tSpecify the format of the shader input at .\n"
- "\t\t can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
- "or other-typed variable. is the vector length of the variable, which must be greater than or equal to that declared in the shader. can be 'vertex', "
- "'primitive', or 'patch' to indicate a per-vertex, per-primitive, or per-patch variable.\n"
- "\t\tUseful if shader stage interfaces don't match up, as pipeline creation might otherwise fail.\n"
- "\t[--msl-add-shader-output ]:\n\t\tSpecify the format of the shader output at .\n"
- "\t\t can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
- "or other-typed variable. is the vector length of the variable, which must be greater than or equal to that declared in the shader. can be 'vertex', "
- "'primitive', or 'patch' to indicate a per-vertex, per-primitive, or per-patch variable.\n"
- "\t\tUseful if shader stage interfaces don't match up, as pipeline creation might otherwise fail.\n"
- "\t[--msl-shader-input ]:\n\t\tSpecify the format of the shader input at .\n"
- "\t\t can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
- "or other-typed variable. is the vector length of the variable, which must be greater than or equal to that declared in the shader."
- "\t\tEquivalent to --msl-add-shader-input with a rate of 'vertex'.\n"
- "\t[--msl-shader-output ]:\n\t\tSpecify the format of the shader output at .\n"
- "\t\t can be 'any32', 'any16', 'u16', 'u8', or 'other', to indicate a 32-bit opaque value, 16-bit opaque value, 16-bit unsigned integer, 8-bit unsigned integer, "
- "or other-typed variable. is the vector length of the variable, which must be greater than or equal to that declared in the shader."
- "\t\tEquivalent to --msl-add-shader-output with a rate of 'vertex'.\n"
- "\t[--msl-raw-buffer-tese-input]:\n\t\tUse raw buffers for tessellation evaluation input.\n"
- "\t\tThis allows the use of nested structures and arrays.\n"
- "\t\tIn a future version of SPIRV-Cross, this will become the default.\n"
- "\t[--msl-multi-patch-workgroup]:\n\t\tUse the new style of tessellation control processing, where multiple patches are processed per workgroup.\n"
- "\t\tThis should increase throughput by ensuring all the GPU's SIMD lanes are occupied, but it is not compatible with the old style.\n"
- "\t\tIn addition, this style also passes input variables in buffers directly instead of using vertex attribute processing.\n"
- "\t\tIn a future version of SPIRV-Cross, this will become the default.\n"
- "\t[--msl-vertex-for-tessellation]:\n\t\tWhen handling a vertex shader, marks it as one that will be used with a new-style tessellation control shader.\n"
- "\t\tThe vertex shader is output to MSL as a compute kernel which outputs vertices to the buffer in the order they are received, rather than in index order as with --msl-capture-output normally.\n"
- "\t[--msl-additional-fixed-sample-mask ]:\n"
- "\t\tSet an additional fixed sample mask. If the shader outputs a sample mask, then the final sample mask will be a bitwise AND of the two.\n"
- "\t[--msl-arrayed-subpass-input]:\n\t\tAssume that images of dimension SubpassData have multiple layers. Layered input attachments are accessed relative to BuiltInLayer.\n"
- "\t\tThis option has no effect if multiview is also enabled.\n"
- "\t[--msl-r32ui-linear-texture-align ]:\n\t\tThe required alignment of linear textures of format MTLPixelFormatR32Uint.\n"
- "\t\tThis is used to align the row stride for atomic accesses to such images.\n"
- "\t[--msl-r32ui-linear-texture-align-constant-id ]:\n\t\tThe function constant ID to use for the linear texture alignment.\n"
- "\t\tOn MSL 1.2 or later, you can override the alignment by setting this function constant.\n"
- "\t[--msl-texture-1d-as-2d]:\n\t\tEmit Image variables of dimension Dim1D as texture2d.\n"
- "\t\tIn Metal, 1D textures do not support all features that 2D textures do. Use this option if your code relies on these features.\n"
- "\t[--msl-ios-use-simdgroup-functions]:\n\t\tUse simd_*() functions for subgroup ops instead of quad_*().\n"
- "\t\tRecent Apple GPUs support SIMD-groups larger than a quad. Use this option to take advantage of this support.\n"
- "\t[--msl-emulate-subgroups]:\n\t\tAssume subgroups of size 1.\n"
- "\t\tIntended for Vulkan Portability implementations where Metal support for SIMD-groups is insufficient for true subgroups.\n"
- "\t[--msl-fixed-subgroup-size ]:\n\t\tAssign a constant to the SubgroupSize builtin.\n"
- "\t\tIntended for Vulkan Portability implementations where VK_EXT_subgroup_size_control is not supported or disabled.\n"
- "\t\tIf 0, assume variable subgroup size as actually exposed by Metal.\n"
- "\t[--msl-force-sample-rate-shading]:\n\t\tForce fragment shaders to run per sample.\n"
- "\t\tThis adds a [[sample_id]] parameter if none is already present.\n"
- "\t[--msl-no-manual-helper-invocation-updates]:\n\t\tDo not manually update the HelperInvocation builtin when a fragment is discarded.\n"
- "\t\tSome Metal devices have a bug where simd_is_helper_thread() does not return true\n"
- "\t\tafter the fragment is discarded. This behavior is required by Vulkan and SPIR-V, however.\n"
- "\t[--msl-check-discarded-frag-stores]:\n\t\tAdd additional checks to resource stores in a fragment shader.\n"
- "\t\tSome Metal devices have a bug where stores to resources from a fragment shader\n"
- "\t\tcontinue to execute, even when the fragment is discarded. These checks\n"
- "\t\tprevent these stores from executing.\n"
- "\t[--msl-force-frag-execution]:\n\t\tEnforces fragment execution to avoid early discard by Metal\n"
- "\t\tMetal will prematurely discard fragments before execution when side effects are present.\n"
- "\t\tThis condition is triggered under the following conditions (side effect operations happen before discard):\n"
- "\t\t\t1. Pre fragment depth test fails.\n"
- "\t\t\t2. Modify depth value in fragment shader to constant value known at compile time.\n"
- "\t\t\t3. Constant value will not pass post fragment depth test.\n"
- "\t\t\t4. Fragment is always discarded in fragment execution.\n"
- "\t\tHowever, Vulkan expects fragment shader to be executed since it cannot be discarded until the discard\n"
- "\t\tpresent in the fragment execution, which would also execute the operations with side effects.\n"
- "\t[--msl-sample-dref-lod-array-as-grad]:\n\t\tUse a gradient instead of a level argument.\n"
- "\t\tSome Metal devices have a bug where the level() argument to\n"
- "\t\tdepth2d_array::sample_compare() in a fragment shader is biased by some\n"
- "\t\tunknown amount. This prevents the bias from being added.\n"
- "\t[--msl-no-readwrite-texture-fences]:\n\t\tDo not insert fences before each read of a\n"
- "\t\tread_write texture. MSL does not guarantee coherence between writes and later reads\n"
- "\t\tof read_write textures. If you don't rely on this, you can disable this for a\n"
- "\t\tpossible performance improvement.\n"
- "\t[--msl-agx-manual-cube-grad-fixup]:\n\t\tManually transform cube texture gradients.\n"
- "\t\tAll released Apple Silicon GPUs to date ignore one of the three partial derivatives\n"
- "\t\tbased on the selected major axis, and expect the remaining derivatives to be\n"
- "\t\tpartially transformed. This fixup gives correct results on Apple Silicon.\n"
- "\t[--msl-combined-sampler-suffix ]:\n\t\tUses a custom suffix for combined samplers.\n");
- // clang-format on
-}
-
-static void print_help_common()
-{
- // clang-format off
- fprintf(stderr, "\nCommon options:\n"
- "\t[--entry name]:\n\t\tUse a specific entry point. By default, the first entry point in the module is used.\n"
- "\t[--stage ]:\n\t\tForces use of a certain shader stage.\n"
- "\t\tCan disambiguate the entry point if more than one entry point exists with same name, but different stage.\n"
- "\t[--emit-line-directives]:\n\t\tIf SPIR-V has OpLine directives, aim to emit those accurately in output code as well.\n"
- "\t[--rename-entry-point ]:\n\t\tRenames an entry point from what is declared in SPIR-V to code output.\n"
- "\t\tMostly relevant for HLSL or MSL.\n"
- "\t[--rename-interface-variable ]:\n\t\tRename an interface variable based on location decoration.\n"
- "\t[--force-zero-initialized-variables]:\n\t\tForces temporary variables to be initialized to zero.\n"
- "\t\tCan be useful in environments where compilers do not allow potentially uninitialized variables.\n"
- "\t\tThis usually comes up with Phi temporaries.\n"
- "\t[--fixup-clipspace]:\n\t\tFixup Z clip-space at the end of a vertex shader. The behavior is backend-dependent.\n"
- "\t\tGLSL: Rewrites [0, w] Z range (D3D/Metal/Vulkan) to GL-style [-w, w].\n"
- "\t\tHLSL/MSL: Rewrites [-w, w] Z range (GL) to D3D/Metal/Vulkan-style [0, w].\n"
- "\t[--flip-vert-y]:\n\t\tInverts gl_Position.y (or equivalent) at the end of a vertex shader. This is equivalent to using negative viewport height.\n"
- "\t[--mask-stage-output-location ]:\n"
- "\t\tIf a stage output variable with matching location and component is active, optimize away the variable if applicable.\n"
- "\t[--mask-stage-output-builtin ]:\n"
- "\t\tIf a stage output variable with matching builtin is active, "
- "optimize away the variable if it can affect cross-stage linking correctness.\n"
- "\t[--relax-nan-checks]:\n\t\tRelax NaN checks for N{Clamp,Min,Max} and ordered vs. unordered compare instructions.\n"
- );
- // clang-format on
-}
-
-static void print_help_obscure()
-{
- // clang-format off
- fprintf(stderr, "\nObscure options:\n"
- "\tThese options are not meant to be used on a regular basis. They have some occasional uses in the test suite.\n"
-
- "\t[--force-temporary]:\n\t\tAggressively emit temporary expressions instead of forwarding expressions. Very rarely used and under-tested.\n"
- "\t[--revision]:\n\t\tPrints build timestamp and Git commit information (updated when cmake is configured).\n"
- "\t[--iterations iter]:\n\t\tRecompiles the same shader over and over, benchmarking related.\n"
- "\t[--disable-storage-image-qualifier-deduction]:\n\t\tIf storage images are received without any nonwritable or nonreadable information,\n"""
- "\t\tdo not attempt to analyze usage, and always emit read/write state.\n"
- "\t[--flatten-multidimensional-arrays]:\n\t\tDo not support multi-dimensional arrays and flatten them to one dimension.\n"
- "\t[--cpp-interface-name ]:\n\t\tEmit a specific class name in C++ codegen.\n"
- "\t[--force-recompile-max-debug-iterations ]:\n\t\tAllow compilation loop to run for N loops.\n"
- "\t\tCan be used to triage workarounds, but should not be used as a crutch, since it masks an implementation bug.\n"
- );
- // clang-format on
-}
-
-static void print_help()
-{
- print_version();
-
- // clang-format off
- fprintf(stderr, "Usage: spirv-cross <...>\n"
- "\nBasic:\n"
- "\t[SPIR-V file] (- is stdin)\n"
- "\t[--output