The SPIR-V Tools project provides an API and commands for processing SPIR-V modules.

Overview

SPIR-V Tools

Overview

The SPIR-V Tools project provides an API and commands for processing SPIR-V modules.

The project includes an assembler, binary module parser, disassembler, validator, and optimizer for SPIR-V. Except for the optimizer, all are based on a common static library. The library contains all of the implementation details, and is used in the standalone tools whilst also enabling integration into other code bases directly. The optimizer implementation resides in its own library, which depends on the core library.

The interfaces have stabilized: We don't anticipate making a breaking change for existing features.

SPIR-V is defined by the Khronos Group Inc. See the SPIR-V Registry for the SPIR-V specification, headers, and XML registry.

Downloads

LinuxLinux Build Status MacOSMacOS Build Status WindowsWindows Build Status

More downloads

Versioning SPIRV-Tools

See CHANGES for a high level summary of recent changes, by version.

SPIRV-Tools project version numbers are of the form vyear.index and with an optional -dev suffix to indicate work in progress. For example, the following versions are ordered from oldest to newest:

  • v2016.0
  • v2016.1-dev
  • v2016.1
  • v2016.2-dev
  • v2016.2

Use the --version option on each command line tool to see the software version. An API call reports the software version as a C-style string.

Releases

Some versions of SPIRV-Tools are tagged as stable releases (see tags on github). These versions undergo extra testing. Releases are not directly related to releases (or versions) of SPIRV-Headers. Releases of SPIRV-Tools are tested against the version of SPIRV-Headers listed in the DEPS file. The release generally uses the most recent compatible version of SPIRV-Headers available at the time of release. No version of SPIRV-Headers other than the one listed in the DEPS file is guaranteed to work with the SPIRV-Tools release.

Supported features

Assembler, binary parser, and disassembler

  • Support for SPIR-V 1.0, through 1.5
    • Based on SPIR-V syntax described by JSON grammar files in the SPIRV-Headers repository.
    • Usually, support for a new version of SPIR-V is ready within days after publication.
  • Support for extended instruction sets:
    • GLSL std450 version 1.0 Rev 3
    • OpenCL version 1.0 Rev 2
  • Assembler only does basic syntax checking. No cross validation of IDs or types is performed, except to check literal arguments to OpConstant, OpSpecConstant, and OpSwitch.

See docs/syntax.md for the assembly language syntax.

Validator

The validator checks validation rules described by the SPIR-V specification.

Khronos recommends that tools that create or transform SPIR-V modules use the validator to ensure their outputs are valid, and that tools that consume SPIR-V modules optionally use the validator to protect themselves from bad inputs. This is especially encouraged for debug and development scenarios.

The validator has one-sided error: it will only return an error when it has implemented a rule check and the module violates that rule.

The validator is incomplete. See the CHANGES file for reports on completed work, and the Validator sub-project for planned and in-progress work.

Note: The validator checks some Universal Limits, from section 2.17 of the SPIR-V spec. The validator will fail on a module that exceeds those minimum upper bound limits. It is future work to parameterize the validator to allow larger limits accepted by a more than minimally capable SPIR-V consumer.

Optimizer

The optimizer is a collection of code transforms, or "passes". Transforms are written for a diverse set of reasons:

  • To restructure, simplify, or normalize the code for further processing.
  • To eliminate undesirable code.
  • To improve code quality in some metric such as size or performance. Note: These transforms are not guaranteed to actually improve any given metric. Users should always measure results for their own situation.

As of this writing, there are 67 transforms including examples such as:

  • Simplification
    • Strip debug info
    • Strip reflection info
  • Specialization Constants
    • Set spec constant default value
    • Freeze spec constant to default value
    • Fold OpSpecConstantOp and OpSpecConstantComposite
    • Unify constants
    • Eliminate dead constant
  • Code Reduction
    • Inline all function calls exhaustively
    • Convert local access chains to inserts/extracts
    • Eliminate local load/store in single block
    • Eliminate local load/store with single store
    • Eliminate local load/store with multiple stores
    • Eliminate local extract from insert
    • Eliminate dead instructions (aggressive)
    • Eliminate dead branches
    • Merge single successor / single predecessor block pairs
    • Eliminate common uniform loads
    • Remove duplicates: Capabilities, extended instruction imports, types, and decorations.
  • Normalization
    • Compact IDs
    • CFG cleanup
    • Flatten decorations
    • Merge returns
    • Convert AMD-specific instructions to KHR instructions
  • Code improvement
    • Conditional constant propagation
    • If-conversion
    • Loop fission
    • Loop fusion
    • Loop-invariant code motion
    • Loop unroll
  • Other
    • Graphics robust access
    • Upgrade memory model to VulkanKHR

Additionally, certain sets of transformations have been packaged into higher-level recipes. These include:

  • Optimization for size (spirv-opt -Os)
  • Optimization for performance (spirv-opt -O)

For the latest list with detailed documentation, please refer to include/spirv-tools/optimizer.hpp.

For suggestions on using the code reduction options, please refer to this white paper.

Linker

Note: The linker is still under development.

Current features:

  • Combine multiple SPIR-V binary modules together.
  • Combine into a library (exports are retained) or an executable (no symbols are exported).

See the CHANGES file for reports on completed work, and the General sub-project for planned and in-progress work.

Reducer

Note: The reducer is still under development.

The reducer simplifies and shrinks a SPIR-V module with respect to a user-supplied interestingness function. For example, given a large SPIR-V module that cause some SPIR-V compiler to fail with a given fatal error message, the reducer could be used to look for a smaller version of the module that causes the compiler to fail with the same fatal error message.

To suggest an additional capability for the reducer, file an issue with "Reducer:" as the start of its title.

Fuzzer

Note: The fuzzer is still under development.

The fuzzer applies semantics-preserving transformations to a SPIR-V binary module, to produce an equivalent module. The original and transformed modules should produce essentially identical results when executed on identical inputs: their results should differ only due to floating-point round-off, if at all. Significant differences in results can pinpoint bugs in tools that process SPIR-V binaries, such as miscompilations. This metamorphic testing approach is similar to the method used by the GraphicsFuzz project for fuzzing of GLSL shaders.

To suggest an additional capability for the fuzzer, file an issue with "Fuzzer:" as the start of its title.

Extras

  • Utility filters
  • Build target spirv-tools-vimsyntax generates file spvasm.vim. Copy that file into your $HOME/.vim/syntax directory to get SPIR-V assembly syntax highlighting in Vim. This build target is not built by default.

Contributing

The SPIR-V Tools project is maintained by members of the The Khronos Group Inc., and is hosted at https://github.com/KhronosGroup/SPIRV-Tools.

Consider joining the [email protected] mailing list, via https://www.khronos.org/spir/spirv-tools-mailing-list/. The mailing list is used to discuss development plans for the SPIRV-Tools as an open source project. Once discussion is resolved, specific work is tracked via issues and sometimes in one of the projects.

(To provide feedback on the SPIR-V specification, file an issue on the SPIRV-Headers GitHub repository.)

See docs/projects.md to see how we use the GitHub Project feature to organize planned and in-progress work.

Contributions via merge request are welcome. Changes should:

We intend to maintain a linear history on the GitHub master branch.

Getting the source

Example of getting sources, assuming SPIRV-Tools is configured as a standalone project:

git clone https://github.com/KhronosGroup/SPIRV-Tools.git   spirv-tools
cd spirv-tools

# Check out sources for dependencies, at versions known to work together,
# as listed in the DEPS file.
python3 utils/git-sync-deps

For some kinds of development, you may need the latest sources from the third-party projects:

git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-tools/external/spirv-headers
git clone https://github.com/google/googletest.git          spirv-tools/external/googletest
git clone https://github.com/google/effcee.git              spirv-tools/external/effcee
git clone https://github.com/google/re2.git                 spirv-tools/external/re2

Dependency on Effcee

Some tests depend on the Effcee library for stateful matching. Effcee itself depends on RE2.

  • If SPIRV-Tools is configured as part of a larger project that already uses Effcee, then that project should include Effcee before SPIRV-Tools.
  • Otherwise, SPIRV-Tools expects Effcee sources to appear in external/effcee and RE2 sources to appear in external/re2.

Source code organization

  • example: demo code of using SPIRV-Tools APIs
  • external/googletest: Intended location for the googletest sources, not provided
  • external/effcee: Location of Effcee sources, if the effcee library is not already configured by an enclosing project.
  • external/re2: Location of RE2 sources, if the re2 library is not already configured by an enclosing project. (The Effcee project already requires RE2.)
  • include/: API clients should add this directory to the include search path
  • external/spirv-headers: Intended location for SPIR-V headers, not provided
  • include/spirv-tools/libspirv.h: C API public interface
  • source/: API implementation
  • test/: Tests, using the googletest framework
  • tools/: Command line executables

Tests

The project contains a number of tests, used to drive development and ensure correctness. The tests are written using the googletest framework. The googletest source is not provided with this project. There are two ways to enable tests:

  • If SPIR-V Tools is configured as part of an enclosing project, then the enclosing project should configure googletest before configuring SPIR-V Tools.
  • If SPIR-V Tools is configured as a standalone project, then download the googletest source into the /external/googletest directory before configuring and building the project.

Build

Note: Prebuilt binaries are available from the downloads page.

First get the sources. Then build using CMake, Bazel, Android ndk-build, or the Emscripten SDK.

Build using CMake

You can build the project using CMake:

cd <spirv-dir>
mkdir build && cd build
cmake [-G <platform-generator>] <spirv-dir>

Once the build files have been generated, build using the appropriate build command (e.g. ninja, make, msbuild, etc.; this depends on the platform generator used above), or use your IDE, or use CMake to run the appropriate build command for you:

cmake --build . [--config Debug]  # runs `make` or `ninja` or `msbuild` etc.

Note about the fuzzer

The SPIR-V fuzzer, spirv-fuzz, can only be built via CMake, and is disabled by default. To build it, clone protobuf and use the SPIRV_BUILD_FUZZER CMake option, like so:

# In 
   
     (the SPIRV-Tools repo root):
   
git clone --depth=1 --branch v3.13.0.1 https://github.com/protocolbuffers/protobuf external/protobuf

# In your build directory:
cmake [-G <platform-generator>] <spirv-dir> -DSPIRV_BUILD_FUZZER=ON
cmake --build . --config Debug

You can also add -DSPIRV_ENABLE_LONG_FUZZER_TESTS=ON to build additional fuzzer tests.

Build using Bazel

You can also use Bazel to build the project.

cd <spirv-dir>
bazel build :all

Build a node.js package using Emscripten

The SPIRV-Tools core library can be built to a WebAssembly node.js module. The resulting SpirvTools WebAssembly module only exports methods to assemble and disassemble SPIR-V modules.

First, make sure you have the Emscripten SDK. Then:

cd <spirv-dir>
./source/wasm/build.sh

The resulting node package, with JavaScript and TypeScript bindings, is written to /out/web .

Note: This builds the package locally. It does not publish it to npm.

To test the result:

node ./test/wasm/test.js

Tools you'll need

For building and testing SPIRV-Tools, the following tools should be installed regardless of your OS:

  • CMake: if using CMake for generating compilation targets, you need to install CMake Version 2.8.12 or later.
  • Python 3: for utility scripts and running the test suite.
  • Bazel (optional): if building the source with Bazel, you need to install Bazel Version 0.29.1 on your machine. Other versions may also work, but are not verified.
  • Emscripten SDK (optional): if building the WebAssembly module.

SPIRV-Tools is regularly tested with the following compilers:

On Linux

  • GCC version 9.3
  • Clang version 10.0

On MacOS

  • AppleClang 11.0

On Windows

  • Visual Studio 2015
  • Visual Studio 2017

Other compilers or later versions may work, but they are not tested.

CMake options

The following CMake options are supported:

  • SPIRV_BUILD_FUZZER={ON|OFF}, default OFF - Build the spirv-fuzz tool.
  • SPIRV_COLOR_TERMINAL={ON|OFF}, default ON - Enables color console output.
  • SPIRV_SKIP_TESTS={ON|OFF}, default OFF- Build only the library and the command line tools. This will prevent the tests from being built.
  • SPIRV_SKIP_EXECUTABLES={ON|OFF}, default OFF- Build only the library, not the command line tools and tests.
  • SPIRV_USE_SANITIZER= , default is no sanitizing - On UNIX platforms with an appropriate version of clang this option enables the use of the sanitizers documented here. This should only be used with a debug build.
  • SPIRV_WARN_EVERYTHING={ON|OFF}, default OFF - On UNIX platforms enable more strict warnings. The code might not compile with this option enabled. For Clang, enables -Weverything. For GCC, enables -Wpedantic. See CMakeLists.txt for details.
  • SPIRV_WERROR={ON|OFF}, default ON - Forces a compilation error on any warnings encountered by enabling the compiler-specific compiler front-end option. No compiler front-end options are enabled when this option is OFF.

Additionally, you can pass additional C preprocessor definitions to SPIRV-Tools via setting SPIRV_TOOLS_EXTRA_DEFINITIONS. For example, by setting it to /D_ITERATOR_DEBUG_LEVEL=0 on Windows, you can disable checked iterators and iterator debugging.

Android ndk-build

SPIR-V Tools supports building static libraries libSPIRV-Tools.a and libSPIRV-Tools-opt.a for Android:

cd 
   
    

export ANDROID_NDK=/path/to/your/ndk

mkdir build && cd build
mkdir libs
mkdir app

$ANDROID_NDK/ndk-build -C ../android_test     \
                      NDK_PROJECT_PATH=.      \
                      NDK_LIBS_OUT=`pwd`/libs \
                      NDK_APP_OUT=`pwd`/app

   

Updating DEPS

Occasionally the entries in DEPS will need to be updated. This is done on demand when there is a request to do this, often due to downstream breakages. To update DEPS, run utils/roll_deps.sh and confirm that tests pass. The script requires Chromium's depot_tools.

Library

Usage

The internals of the library use C++11 features, and are exposed via both a C and C++ API.

In order to use the library from an application, the include path should point to /include , which will enable the application to include the header /include/spirv-tools/libspirv.h{|pp} then linking against the static library in /source/libSPIRV-Tools.a or /source/SPIRV-Tools.lib . For optimization, the header file is /include/spirv-tools/optimizer.hpp , and the static library is /source/libSPIRV-Tools-opt.a or /source/SPIRV-Tools-opt.lib .

  • SPIRV-Tools CMake target: Creates the static library:
    • /source/libSPIRV-Tools.a on Linux and OS X.
    • /source/libSPIRV-Tools.lib on Windows.
  • SPIRV-Tools-opt CMake target: Creates the static library:
    • /source/libSPIRV-Tools-opt.a on Linux and OS X.
    • /source/libSPIRV-Tools-opt.lib on Windows.

Entry points

The interfaces are still under development, and are expected to change.

There are five main entry points into the library in the C interface:

  • spvTextToBinary: An assembler, translating text to a binary SPIR-V module.
  • spvBinaryToText: A disassembler, translating a binary SPIR-V module to text.
  • spvBinaryParse: The entry point to a binary parser API. It issues callbacks for the header and each parsed instruction. The disassembler is implemented as a client of spvBinaryParse.
  • spvValidate implements the validator functionality. Incomplete
  • spvValidateBinary implements the validator functionality. Incomplete

The C++ interface is comprised of three classes, SpirvTools, Optimizer and Linker, all in the spvtools namespace.

  • SpirvTools provides Assemble, Disassemble, and Validate methods.
  • Optimizer provides methods for registering and running optimization passes.
  • Linker provides methods for combining together multiple binaries.

Command line tools

Command line tools, which wrap the above library functions, are provided to assemble or disassemble shader files. It's a convention to name SPIR-V assembly and binary files with suffix .spvasm and .spv, respectively.

Assembler tool

The assembler reads the assembly language text, and emits the binary form.

The standalone assembler is the executable called spirv-as, and is located in /tools/spirv-as . The functionality of the assembler is implemented by the spvTextToBinary library function.

  • spirv-as - the standalone assembler
    • /tools/as

Use option -h to print help.

Disassembler tool

The disassembler reads the binary form, and emits assembly language text.

The standalone disassembler is the executable called spirv-dis, and is located in /tools/spirv-dis . The functionality of the disassembler is implemented by the spvBinaryToText library function.

  • spirv-dis - the standalone disassembler
    • /tools/dis

Use option -h to print help.

The output includes syntax colouring when printing to the standard output stream, on Linux, Windows, and OS X.

Linker tool

The linker combines multiple SPIR-V binary modules together, resulting in a single binary module as output.

This is a work in progress. The linker does not support OpenCL program linking options related to math flags. (See section 5.6.5.2 in OpenCL 1.2)

  • spirv-link - the standalone linker
    • /tools/link

Optimizer tool

The optimizer processes a SPIR-V binary module, applying transformations in the specified order.

This is a work in progress, with initially only few available transformations.

  • spirv-opt - the standalone optimizer
    • /tools/opt

Validator tool

Warning: This functionality is under development, and is incomplete.

The standalone validator is the executable called spirv-val, and is located in /tools/spirv-val . The functionality of the validator is implemented by the spvValidate library function.

The validator operates on the binary form.

  • spirv-val - the standalone validator
    • /tools/val

Reducer tool

The reducer shrinks a SPIR-V binary module, guided by a user-supplied interestingness test.

This is a work in progress, with initially only shrinks a module in a few ways.

  • spirv-reduce - the standalone reducer
    • /tools/reduce

Run spirv-reduce --help to see how to specify interestingness.

Fuzzer tool

The fuzzer transforms a SPIR-V binary module into a semantically-equivalent SPIR-V binary module by applying transformations in a randomized fashion.

This is a work in progress, with initially only a few semantics-preserving transformations.

  • spirv-fuzz - the standalone fuzzer
    • /tools/fuzz

Run spirv-fuzz --help for a detailed list of options.

Control flow dumper tool

The control flow dumper prints the control flow graph for a SPIR-V module as a GraphViz graph.

This is experimental.

  • spirv-cfg - the control flow graph dumper
    • /tools/cfg

Utility filters

  • spirv-lesspipe.sh - Automatically disassembles .spv binary files for the less program, on compatible systems. For example, set the LESSOPEN environment variable as follows, assuming both spirv-lesspipe.sh and spirv-dis are on your executable search path:

     export LESSOPEN='| spirv-lesspipe.sh "%s"'
    

    Then you page through a disassembled module as follows:

    less foo.spv
    
    • The spirv-lesspipe.sh script will pass through any extra arguments to spirv-dis. So, for example, you can turn off colours and friendly ID naming as follows:
      export LESSOPEN='| spirv-lesspipe.sh "%s" --no-color --raw-id'
      
  • vim-spirv - A vim plugin which supports automatic disassembly of .spv files using the :edit command and assembly using the :write command. The plugin also provides additional features which include; syntax highlighting; highlighting of all ID's matching the ID under the cursor; and highlighting errors where the Instruction operand of OpExtInst is used without an appropriate OpExtInstImport.

  • 50spirv-tools.el - Automatically disassembles '.spv' binary files when loaded into the emacs text editor, and re-assembles them when saved, provided any modifications to the file are valid. This functionality must be explicitly requested by defining the symbol SPIRV_TOOLS_INSTALL_EMACS_HELPERS as follows:

    cmake -DSPIRV_TOOLS_INSTALL_EMACS_HELPERS=true ...
    

    In addition, this helper is only installed if the directory /etc/emacs/site-start.d exists, which is typically true if emacs is installed on the system.

    Note that symbol IDs are not currently preserved through a load/edit/save operation. This may change if the ability is added to spirv-as.

Tests

Tests are only built when googletest is found.

Running test with CMake

Use ctest -j to run all the tests. To run tests using all threads:

ctest -j$(nproc)

To run a single test target, use ctest [-j ] -R . For example, you can run all opt tests with:

ctest -R 'spirv-tools-test_opt'

Running test with Bazel

Use bazel test :all to run all tests. This will run tests in parallel by default.

To run a single test target, specify :my_test_target instead of :all. Test target names get printed when you run bazel test :all. For example, you can run opt_def_use_test with:

bazel test :opt_def_use_test

Future Work

See the projects pages for more information.

Assembler and disassembler

  • The disassembler could emit helpful annotations in comments. For example:
    • Use variable name information from debug instructions to annotate key operations on variables.
    • Show control flow information by annotating OpLabel instructions with that basic block's predecessors.
  • Error messages could be improved.

Validator

This is a work in progress.

Linker

  • The linker could accept math transformations such as allowing MADs, or other math flags passed at linking-time in OpenCL.
  • Linkage attributes can not be applied through a group.
  • Check decorations of linked functions attributes.
  • Remove dead instructions, such as OpName targeting imported symbols.

Licence

Full license terms are in LICENSE

Copyright (c) 2015-2016 The Khronos Group Inc.

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.
Comments
  • WIP: Implement a SPIR-V linker

    WIP: Implement a SPIR-V linker

    Still a work-in-progress and I can most likely reuse more code, but at least I adapted the code to use some of the SPIRV-Tools interface/code.

    Missing:

    • [x] Update SPIR-V version support from 1.0 to 1.2
    • [X] Remove duplicate types
    • [x] Remove duplicate decorations
    • [ ] Remove duplicate names
    • [X] Remove duplicate categories
    • [x] Remove duplicate SpvOpExtInstImport
    • [x] Tests
    • [x] Ensure that an import/export pair of variables or functions have the same interface before accepting to link

    Questions:

    • Should the linker require the given binaries to be valid SPIR-V binaries?
    • Should the linker require the given binaries to have the same endianness as the host?
    opened by pierremoreau 36
  • Add validation for structs decorated as Block or BufferBlock.

    Add validation for structs decorated as Block or BufferBlock.

    Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/937

    The following checks are performed for structs that are decorated as Block or BufferBlock:

    • No GLSLShared or GLSLPacked decoration should be used by any members.
    • All members need to have Offset decoration. Arrays should have ArrayStride and matrices MatrixStride decorations.
    • Blocks need to follow std140 rules.
    • BufferBlocks need to follow std430 rules.
    opened by asuonpaa 27
  • CFG Cleanup pass - Remove unreachable blocks.

    CFG Cleanup pass - Remove unreachable blocks.

    This change adds a new CFG cleanup pass to spirv-opt. The intent of the pass is to act as a repository of a variety of common CFG cleanup actions (straightening, removal of unreachable code, etc).

    It's my first change to SPIRV-Tools, so I'm sure it's full of inconsistencies and missing bits. One of the things I've been thinking is that it may make sense to coalesce other existing CFG cleanup passes into this one in the hopes of reducing the number of CFG/IR traversals needed during cleanup.

    Or, perhaps, it's preferable to keep these passes separate. I understand that compile time is not an issue now, but I'm not sure if this might be challenging in the future (in my experience, this tends to be true at some point).

    The code works and passes the trivial test I've added. I need to add more, but I want a first review pass so I can learn preferred idioms and ways of structuring the code.

    Thanks.

    opened by dnovillo 27
  • ADCE: Dead if elimination

    ADCE: Dead if elimination

    This pass essentially eliminates "if" control flow when the "then" and "else" parts are empty.

    Mark structured conditional branches live only if one or more instructions in their associated construct is marked live. After closure, replace dead structured conditional branches with a branch to its merge and remove dead blocks.

    Besides eliminating a not-insignificant amount of dead code (up to %30) from real shaders, this optimization is most necessary for legalization as there are real life codes that are expecting the frontend/optimizer/spirv-generator to eliminate references to objects that are referenced statically but not dynamically under compile-time-constant conditions.

    This code does its own dead block elimination, but will ultimately be replaced with a call the newly integrated cfg cleanup code.

    opened by greg-lunarg 22
  • Should SROA eliminate structs in this shader?

    Should SROA eliminate structs in this shader?

    My understanding is that there is a pass that does SROA (scalar_replacement_pass), so I'm somewhat surprised that in the attached shader it doesn't remove the struct

    Here's a snippet from the shader:

        %152 = OpCompositeInsert %_struct_9 %123 %175 0
        %154 = OpCompositeInsert %_struct_9 %float_0 %152 0 2
        // snip
        %166 = OpCompositeExtract %v4float %154 0
        %168 = OpCompositeExtract %float %166 1
         %94 = OpFNegate %float %168
        %170 = OpCompositeInsert %v4float %94 %166 1
               OpStore %gl_Position %170
    

    The shader has been compiled from HLSL via glslang, so the fact that the original shader has a struct makes sense - this is the struct for the vertex shader output - but it's odd that it's still there after all the optimizations.

    sky.spv.zip

    opened by zeux 21
  • Add DeadBranchElimPass

    Add DeadBranchElimPass

    This is another in a series of passes designed to reduce SPIR-V file size.

    For each entry point function, this pass will look for BranchConditionals with constant condition and convert to a branch. Any resulting dead blocks are eliminated. For all phi functions in merge block, replace all uses with the id corresponding to the living predecessor.

    This pass requires that all control flow be structured to allow optimization.

    This pass is most effective when preceeded by passes which eliminate local loads and stores, effectively propagating constant values into BranchConditionals where possible.

    Note that is pass contains functions and data from previous passes in this series. These will be coalesced under the planned optimization context class.

    opened by greg-lunarg 21
  • Problematic `switch(0u): default` branch idiom in merge return pass

    Problematic `switch(0u): default` branch idiom in merge return pass

    I have opened an issue about this in glslang, before figuring out it's actually due to a recent change in SPIRV-Tools https://github.com/KhronosGroup/glslang/issues/2148

    Let me copy the initial issue here under The only additional information I've uncovered since, is that this is indeed due to a quite recent change in how the merge return pass is implemented: https://github.com/KhronosGroup/SPIRV-Tools/commit/e7afeb060e1637ca964c62517c3e6c225704b7eb which was undertaken under this issue https://github.com/KhronosGroup/SPIRV-Tools/issues/3127


    It seems glslang has come up with (or increased the frequency of), sometimes in the previous months, I think, a rather peculiar pattern which looks something like this (in pseudo-code since the output is actually SPIR-V):

        vec4 _801;
        switch (0u)
        {
            default:
            {
                if (/* ... */)
                {
                    _801 = /* assign a value */;
                    break;
                }
                _801 = /* assign another value */;
                break;
            }
        }
    

    This seems to happen in the HLSL to SPIR-V path at least, when inlining a function that conditionally returns different possible values, although I couldn't reduce my sample far enough to isolate exactly when that happens. Is there a good specific reason for this peculiar idiom ?

    Albeit not incorrect, this kind of code is problematic in the case of D3D related pipelines. When fed to the D3D shader compiler, such code, having gone through glslang at some point, turns out to be highly problematic, as the D3D compiler is both incapable to correctly analyse that no code paths ends up with the variable potentially uninitialized — in the case of those tricky switch statements, and at the same time very picky about reading from unitialized variables, producing hard compile errors in those cases.

    I'm not opening this issue to unequivocally say: it's something glslang should fix, but if you have any insights about how this was introduced and potential ways to workaround this problem. The responsibility of fixing this could be pushed to the next cross compiler in the chain, but it seems a rather complex task, so I'm pessimistic about the feasability. Fixing the D3D compiler itself doesn't seem easily doable either. Finally, would it be conceivable to make this behavior somehow togglable trough some sort of option ?

    opened by hugoam 20
  • spirv-val: Header block is contained in the loop construct but its merge block is not

    spirv-val: Header block is contained in the loop construct but its merge block is not

    Many of my shaders that were previously passing spirv-val (last tested at Vulkan SDK 1.1.121.0) now fail with Vulkan SDK 1.2.131.2. The specific error is:

    c:\vulkansdk\1.2.131.2\Bin\spirv-val shader_0085.spv error: line 956: Header block 12163[%12163] is contained in the loop construct headed by 6548[%6548], but its merge block 17470[%17470] is not %12163 = OpLabel

    An example spir-v file is attached. I was talking to @greg-lunarg about this. The question is whether this is legitimately a bad shader or a spirv-val bug, and then second where in the spirv-opt chain this might get introduced.

    Filing here first to triage the issue, also in case someone else already has hunted this down and knows offhand what the problem is.

    shader_0085.zip

    opened by danginsburg 19
  • The spirv-opt remove-duplicates pass makes a seemingly erroneous transformation of my shader

    The spirv-opt remove-duplicates pass makes a seemingly erroneous transformation of my shader

    I have run into a problem with spirv-opt since the release of Vulkan SDK 1.0.68.0. The remove-duplicates pass seems to be clobbering my shader. Prior to that release, things were fine. This may well be something that I am doing wrong, but I have been unable to determine what thus far.

    spirv-opt from Vulkan SDK 1.0.68.0 self-identifies as:

    SPIRV-Tools v2018.1-dev v2018.0-6-g9e19fc0
    

    The original SPIR-V is constructed by glslangValidator from the same SDK.

    Some relevant bits from my shader:

    layout(set = 0, binding = 5, std140) uniform atmosphere_fragment_uniforms {
    	float sun_radius;
    };
    
    layout(set = 1, binding = 12, std140) uniform planet_dynamic_uniforms {
    	float lod_factor;
    };
    

    Before any optimisation the disassembly shows the following section:

    OpName %planet_dynamic_uniforms "planet_dynamic_uniforms"
    OpMemberName %planet_dynamic_uniforms 0 "lod_factor"
    

    After running just the remove-duplicates pass this has changed to:

    OpName %atmosphere_fragment_uniforms "planet_dynamic_uniforms"
    OpMemberName %atmosphere_fragment_uniforms 0 "lod_factor"
    

    There are other changes, but off the bat this seems odd.

    Running the optimiser with every -O pass except for remove-duplicates generates SPIR-V that appears to work fine.

    I tried using spirv-opt from the CI build from commit 6cd6e5ebef0623a863ca2d8152edda75dd5001df, but with no change in behaviour.

    The following is a cut-down that generates the odd difference when running just remove-duplicates:

    #version 450 core
    
    layout(set = 1, binding = 12, std140) uniform planet_dynamic_uniforms {
    	float lod_factor;
    };
    
    layout(set = 0, binding = 5, std140) uniform atmosphere_fragment_uniforms {
    	float sun_radius;
    };
    
    layout(location = 0) out vec4 out_colour;
    
    void main() {
    	out_colour = vec4(1.0);
    }
    

    To demonstrate the difference:

    glslangValidator -V -o cutdown.spv cutdown.frag
    spirv-opt -o cutdown.opt.spv --remove-duplicates cutdown.spv
    spirv-dis -o cutdown.s cutdown.spv
    spirv-dis -o cutdown.opt.s cutdown.opt.spv
    fc /l cutdown.s cutdown.opt.s
    
    opened by StrayLightning 19
  • spriv-opt producing invalid SPIR-V for shader (crashing two drivers tested on)

    spriv-opt producing invalid SPIR-V for shader (crashing two drivers tested on)

    The attached zip file contains three SPIR-V fragment shaders that demonstrate spirv-opt producing invalid SPIR-V. Unfortunately, the SPIR-V does not fail spirv-val, but it has crashed on two different drivers. Kerch Holt looked at the SPIR-V and determined there was a problem. Specifically:

    The following snippet of SPIRV seems incorrect. It doesn’t seem like it is “structured control flow”. The OpSelectionMerge is pointing to %7205 yet there are jumps outside of this region. Seems like this code is something like : cond ? goto X : goto Y; That isn’t allowed in structured flow: 1987 OpSelectionMerge %7205 None 1988 OpBranchConditional %22516 %21999 %7205 1989 %21999 = OpLabel 1990 OpBranch %24266 1991 %7205 = OpLabel 1992 OpBranch %7840 1993 %7840 = OpLabel 1994 %11181 = OpPhi %float %11180 %21998 %20516 %7205 1995 %14351 = OpPhi %v3float %14347 %21998 %7885 %7205 1996 %12949 = OpPhi %mat3v4float %15174 %21998 %14541 %7205 1997 %16228 = OpPhi %_struct_1268 %15060 %21998 %7120 %7205 1998 %17815 = OpFAdd %float %15154 %float_1 1999 OpBranch %20259 2000 %24266 = OpLabel"

    The shaders attached to the bug are:

    • generic_vfx_ps_1.spv - this is the SPIR-V that comes out of the HLSL front-end of glslang
    • generic.vfx_ps_1.spvopt.spv - this is after running spirv-opt with the following options: spirv-opt.exe --inline-entry-points-exhaustive --convert-local-access-chains --eliminate-local-single-block --eliminate-local-single-store --eliminate-insert-extract --eliminate-dead-code-aggressive --eliminate-dead-branches --merge-blocks --eliminate-local-single-block --eliminate-local-single-store --eliminate-local-multi-store --eliminate-insert-extract --eliminate-dead-code-aggressive
    • generic.vfx_ps_1.spvopt_spvremapper.spv - this is the shader we actually send to the driver which runs spirv-remapper

    Both of the last two shaders are crashing drivers, so spirv-opt alone is enough to cause the crash. I included the last one because it has the code that Kerch identified as being incorrect so hopefully makes it easier to identify the issue.

    spirv_opt_bug.zip

    A secondary issue here is once there is agreement this is invalid spirv, spirv-val should probably get an issue to detect this case since it currently does not.

    opened by danginsburg 19
  • Vulkan conformance test gets access violation in spvValidate

    Vulkan conformance test gets access violation in spvValidate

    Specifics Windows 7, Nvidia GTX 660 Ti, Driver 368.39

    Have Vulkan SDK 1.0.21 installed for validation layers and set environment variable VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_standard_validation

    To reproduce I run all of the dEQP-VK.glsl.functions.control_flow.* tests from the Vulkan Conformance Test Suite

    Message: Exception thrown: read access violation. this was nullptr. (debugger confirms that variable "this" is NULL)

    Location: BasicBlock.h:

    76 /// Returns true if the block is reachable in the CFG
    77 bool reachable() const { return reachable_; }
    

    Call Stack:

        VkLayer_core_validation.dll!libspirv::BasicBlock::reachable() Line 77   C++
    
        VkLayer_core_validation.dll!libspirv::StructuredControlFlowChecks(const libspirv::ValidationState_t & _, const libspirv::Function & function, const std::vector<std::pair<unsigned int,unsigned int>,std::allocator<std::pair<unsigned int,unsigned int> > > & back_edges) Line 349 C++
    
        VkLayer_core_validation.dll!libspirv::PerformCfgChecks(libspirv::ValidationState_t & _) Line 478    C++
    
        VkLayer_core_validation.dll!spvValidate(const spv_context_t * const context, spv_const_binary_t * const binary, spv_diagnostic_t * * pDiagnostic) Line 209  C++
    
        VkLayer_core_validation.dll!core_validation::CreateShaderModule(VkDevice_T * device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule_T * * pShaderModule) Line 9069  C++
    
        VkLayer_object_tracker.dll!object_tracker::CreateShaderModule(VkDevice_T * device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule_T * * pShaderModule) Line 3583    C++
    
        VkLayer_parameter_validation.dll!parameter_validation::CreateShaderModule(VkDevice_T * device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule_T * * pShaderModule) Line 2621    C++
    
        VkLayer_threading.dll!threading::CreateShaderModule(VkDevice_T * device, const VkShaderModuleCreateInfo * pCreateInfo, const VkAllocationCallbacks * pAllocator, VkShaderModule_T * * pShaderModule) Line 1133  C++
    
        deqp-vk.exe!vk::DeviceDriver::createShaderModule(vk::VkDevice_s * device, const vk::VkShaderModuleCreateInfo * pCreateInfo, const vk::VkAllocationCallbacks * pAllocator, vk::Handle<14> * pShaderModule) Line 218  C++
    
        deqp-vk.exe!vk::createShaderModule(const vk::DeviceInterface & vk, vk::VkDevice_s * device, const vk::VkShaderModuleCreateInfo * pCreateInfo, const vk::VkAllocationCallbacks * pAllocator) Line 209    C++
    
        deqp-vk.exe!vk::createShaderModule(const vk::DeviceInterface & deviceInterface, vk::VkDevice_s * device, const vk::ProgramBinary & binary, unsigned int flags) Line 206 C++
        deqp-vk.exe!vkt::`anonymous namespace'::PipelineProgram::PipelineProgram(vkt::Context & context, const glu::sl::ShaderCaseSpecification & spec) Line 745    C++
    
        deqp-vk.exe!vkt::`anonymous namespace'::ShaderCaseInstance::ShaderCaseInstance(vkt::Context & context, const glu::sl::ShaderCaseSpecification & spec) Line 1410 C++
    
        deqp-vk.exe!vkt::`anonymous namespace'::ShaderCase::createInstance(vkt::Context & context) Line 1791    C++
    
        deqp-vk.exe!vkt::TestCaseExecutor::init(tcu::TestCase * testCase, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & casePath) Line 246   C++
    
        deqp-vk.exe!tcu::TestSessionExecutor::enterTestCase(tcu::TestCase * testCase, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & casePath) Line 181   C++
    
        deqp-vk.exe!tcu::TestSessionExecutor::iterate() Line 101    C++
    
        deqp-vk.exe!tcu::App::iterate() Line 172    C++
    
        deqp-vk.exe!main(int argc, const char * * argv) Line 55 C++
        [External Code] 
    

    Bisected to spirv-tools commit: f61db0bcc6717b4b60a7e38e7c3c58ad02110aa8 Validator structured flow checks: back-edge, constructs

    Originally posted by @Tony-LunarG in https://github.com/google/shaderc/issues/234:

    opened by antiagainst 18
  • Unwanted `half` conversion with `--convert-relaxed-to-half` pass

    Unwanted `half` conversion with `--convert-relaxed-to-half` pass

    Given the following GLSL:

    #version 310 es
    
    precision highp float;
    
    layout(location = 10) in highp vec4 vertex_uv01;
    layout(binding = 0, set = 3) uniform sampler2D materialParams_baseColorMap;
    
    layout(location = 0) out vec4 fragColor;
    
    void main() {
      fragColor = texture(materialParams_baseColorMap, vertex_uv01.xy);
    }
    

    After compiling with glslangValidator, optimizing for performance, and running a --convert-relaxed-to-half pass, the texture sample gets translated to the following SPIR-V:

    %18 = OpLoad %v4float %vertex_uv01
    %23 = OpFConvert %v4half %18
    %19 = OpVectorShuffle %v2half %23 %23 0 1
    %20 = OpImageSampleImplicitLod %v4float %14 %19
    

    Cross-compiling results in the following MSL:

    out.fragColor = materialParams_baseColorMap.sample(materialParams_baseColorMapSmplr, float2(half4(in.vertex_uv01).xy));
    

    The half4 conversion seems unnecessary, and destroys the precision of vertex_uv01. A workaround is to mark materialParams_baseColorMap as highp, but if I understand correctly, the precision of a sampler shouldn't affect the UV coordinates' precision.

    Here are the exact steps I'm using to reproduce: reproduce.zip

    $ glslangValidator --version
    Glslang Version: 11:11.13.0
    ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.13.0
    GLSL Version: 4.60 glslang Khronos. 11.13.0
    SPIR-V Version 0x00010600, Revision 1
    GLSL.std.450 Version 100, Revision 1
    Khronos Tool ID 8
    SPIR-V Generator Version 11
    GL_KHR_vulkan_glsl version 100
    ARB_GL_gl_spirv version 100
    
    $ spirv-cross
    Git commit: a89dea3c Timestamp: 2022-12-21T11:05:50
    
    $ spirv-opt --version
    SPIRV-Tools v2022.5-dev v2022.4-46-g01a3b9be
    
    bug component:optimization 
    opened by bejado 3
  • Add Github Actions to test Bazel builds.

    Add Github Actions to test Bazel builds.

    SPIRV-Tools already uses Kokoro to run CI but it requires a member of the organization to manually add tags to the PR to start the CI process. This is somewhat cumbersome if you have contributors from multiple timezones.

    To fix that I'm adding Github Actions to Build/Test this repository using the Bazel builds. The build is relatively slow (~30m) due to the small amount of resources on the freely hosted Github runners. We use caches to bring no-op Linux/Mac builds to ~2m. The Windows ones are unfortunately not working right now but it does not break the build.

    opened by RafaelMarinheiro 2
  • Running dEQP-VK.pipeline.fast_linked_library.misc.interpolate_at_sample_no_sample_shading causes a crash in SPIRV-Tools

    Running dEQP-VK.pipeline.fast_linked_library.misc.interpolate_at_sample_no_sample_shading causes a crash in SPIRV-Tools

    Crash stack trace:

    operator delete(void * block) Line 38
    operator delete(void * block, unsigned __int64 __formal) Line 32
    std::_Deallocate<16,0>(void * _Ptr, unsigned __int64 _Bytes) Line 255
    std::allocator<spvtools::opt::Operand>::deallocate(spvtools::opt::Operand * const _Ptr, const unsigned __int64 _Count) Line 798
    std::vector<spvtools::opt::Operand,std::allocator<spvtools::opt::Operand>>::_Tidy() Line 1754
    std::vector<spvtools::opt::Operand,std::allocator<spvtools::opt::Operand>>::~vector<spvtools::opt::Operand,std::allocator<spvtools::opt::Operand>>() Line 701
    spvtools::opt::Instruction::~Instruction() Line 227
    ...
    spvtools::opt::RedundancyEliminationPass::Process() Line 45
    spvtools::opt::Pass::Run(spvtools::opt::IRContext * ctx) Line 37
    spvtools::opt::PassManager::Run(spvtools::opt::IRContext * context) Line 58
    spvtools::Optimizer::Run(const unsigned int * original_binary, const unsigned __int64 original_binary_size, std::vector<unsigned int,std::allocator<unsigned int>> * optimized_binary, spv_optimizer_options_t * const opt_options) Line 606
    

    Test case 'dEQP-VK.pipeline.fast_linked_library.misc.interpolate_at_sample_no_sample_shading'.. PRE-OPT: ; SPIR-V

    ; Version: 1.0
    ; Generator: Khronos Glslang Reference Front End; 11
    ; Bound: 56
    ; Schema: 0
    OpCapability Shader
    %1 = OpExtInstImport "GLSL.std.450"
    OpMemoryModel Logical GLSL450
    OpEntryPoint Vertex %4 "main" %35 %39 %51
    OpMemberDecorate %33 0 BuiltIn Position
    OpMemberDecorate %33 1 BuiltIn PointSize
    OpMemberDecorate %33 2 BuiltIn ClipDistance
    OpMemberDecorate %33 3 BuiltIn CullDistance
    OpDecorate %33 Block
    OpDecorate %39 BuiltIn VertexIndex
    OpDecorate %51 Location 0
    %2 = OpTypeVoid
    %3 = OpTypeFunction %2
    %6 = OpTypeFloat 32
    %7 = OpTypeVector %6 2
    %8 = OpTypeInt 32 0
    %9 = OpConstant %8 6
    %10 = OpTypeArray %7 %9
    %11 = OpTypePointer Private %10
    %12 = OpVariable %11 Private
    %13 = OpConstant %6 1
    %14 = OpConstantComposite %7 %13 %13
    %15 = OpConstant %6 -1
    %16 = OpConstantComposite %7 %15 %13
    %17 = OpConstantComposite %7 %15 %15
    %18 = OpConstantComposite %7 %13 %15
    %19 = OpConstantComposite %10 %14 %16 %17 %17 %18 %14
    %20 = OpTypeArray %6 %9
    %21 = OpTypePointer Private %20
    %22 = OpVariable %21 Private
    %23 = OpConstant %6 0.100000001
    %24 = OpConstant %6 0.200000003
    %25 = OpConstant %6 0.300000012
    %26 = OpConstant %6 0.400000006
    %27 = OpConstant %6 0.5
    %28 = OpConstant %6 0.600000024
    %29 = OpConstantComposite %20 %23 %24 %25 %26 %27 %28
    %30 = OpTypeVector %6 4
    %31 = OpConstant %8 1
    %32 = OpTypeArray %6 %31
    %33 = OpTypeStruct %30 %6 %32 %32
    %34 = OpTypePointer Output %33
    %35 = OpVariable %34 Output
    %36 = OpTypeInt 32 1
    %37 = OpConstant %36 0
    %38 = OpTypePointer Input %36
    %39 = OpVariable %38 Input
    %41 = OpTypePointer Private %7
    %44 = OpConstant %6 0
    %48 = OpTypePointer Output %30
    %50 = OpTypePointer Output %6
    %51 = OpVariable %50 Output
    %53 = OpTypePointer Private %6
    %4 = OpFunction %2 None %3
    %5 = OpLabel
    OpStore %12 %19
    OpStore %22 %29
    %40 = OpLoad %36 %39
    %42 = OpAccessChain %41 %12 %40
    %43 = OpLoad %7 %42
    %45 = OpCompositeExtract %6 %43 0
    %46 = OpCompositeExtract %6 %43 1
    %47 = OpCompositeConstruct %30 %45 %46 %44 %13
    %49 = OpAccessChain %48 %35 %37
    OpStore %49 %47
    %52 = OpLoad %36 %39
    %54 = OpAccessChain %53 %22 %52
    %55 = OpLoad %6 %54
    OpStore %51 %55
    OpReturn
    OpFunctionEnd
    

    POST-OPT: ; SPIR-V

    ; Version: 1.0
    ; Generator: Khronos Glslang Reference Front End; 11
    ; Bound: 60
    ; Schema: 0
    OpCapability Shader
    %1 = OpExtInstImport "GLSL.std.450"
    OpMemoryModel Logical GLSL450
    OpEntryPoint Vertex %4 "main" %35 %39 %51
    OpMemberDecorate %33 0 BuiltIn Position
    OpMemberDecorate %33 1 BuiltIn PointSize
    OpMemberDecorate %33 2 BuiltIn ClipDistance
    OpMemberDecorate %33 3 BuiltIn CullDistance
    OpDecorate %33 Block
    OpDecorate %39 BuiltIn VertexIndex
    OpDecorate %51 Location 0
    %2 = OpTypeVoid
    %3 = OpTypeFunction %2
    %6 = OpTypeFloat 32
    %7 = OpTypeVector %6 2
    %8 = OpTypeInt 32 0
    %9 = OpConstant %8 6
    %10 = OpTypeArray %7 %9
    %13 = OpConstant %6 1
    %14 = OpConstantComposite %7 %13 %13
    %15 = OpConstant %6 -1
    %16 = OpConstantComposite %7 %15 %13
    %17 = OpConstantComposite %7 %15 %15
    %18 = OpConstantComposite %7 %13 %15
    %19 = OpConstantComposite %10 %14 %16 %17 %17 %18 %14
    %20 = OpTypeArray %6 %9
    %23 = OpConstant %6 0.100000001
    %24 = OpConstant %6 0.200000003
    %25 = OpConstant %6 0.300000012
    %26 = OpConstant %6 0.400000006
    %27 = OpConstant %6 0.5
    %28 = OpConstant %6 0.600000024
    %29 = OpConstantComposite %20 %23 %24 %25 %26 %27 %28
    %30 = OpTypeVector %6 4
    %31 = OpConstant %8 1
    %32 = OpTypeArray %6 %31
    %33 = OpTypeStruct %30 %6 %32 %32
    %34 = OpTypePointer Output %33
    %35 = OpVariable %34 Output
    %36 = OpTypeInt 32 1
    %37 = OpConstant %36 0
    %38 = OpTypePointer Input %36
    %39 = OpVariable %38 Input
    %44 = OpConstant %6 0
    %48 = OpTypePointer Output %30
    %50 = OpTypePointer Output %6
    %51 = OpVariable %50 Output
    %56 = OpTypePointer Function %10
    %57 = OpTypePointer Function %7
    %58 = OpTypePointer Function %20
    %59 = OpTypePointer Function %6
    %4 = OpFunction %2 None %3
    %5 = OpLabel
    %22 = OpVariable %58 Function
    %12 = OpVariable %56 Function
    OpStore %12 %19
    OpStore %22 %29
    %40 = OpLoad %36 %39
    %42 = OpAccessChain %57 %12 %40
    %43 = OpLoad %7 %42
    %45 = OpCompositeExtract %6 %43 0
    %46 = OpCompositeExtract %6 %43 1
    %47 = OpCompositeConstruct %30 %45 %46 %44 %13
    %49 = OpAccessChain %48 %35 %37
    OpStore %49 %47
    %54 = OpAccessChain %59 %22 %40
    %55 = OpLoad %6 %54
    OpStore %51 %55
    OpReturn
    OpFunctionEnd
    
    opened by sugoi1 0
  • Add C Interface for Optimizer

    Add C Interface for Optimizer

    This PR implements a C interface for the Optimizer class. It follows the same pattern established by the existing C interfaces for other classes in SPIRV-Tools.

    opened by daniel-story 1
Releases(v2022.4)
  • v2022.4(Dec 7, 2022)

    v2022.4 2022-10-12

    • General
      • Support Narrow Types in BitCast Folding Rule (#4941)
      • spirv-diff: Allow no SpecId (#4904)
      • build: cmake: Add support for GNU/Hurd (#4895)
      • Implement tool changes for SPV_EXT_mesh_shader. (#4915)
    • Validator
      • spirv-val: Add SPV_ARM_core_builtins validation (#4958)
      • spirv-val: Add an option to use friendly names or not (#4951)
      • spirv-val: Consistently quote ids in messages (#4950)
      • spirv-val: Add initial SPV_EXT_mesh_shader validation (#4924)
      • spirv-val: Make it legal to use arrays of ray queries (#4938)
      • spirv-val: Better message for using OpTypeBool in input/output (#4901)
      • spirv-val: Add SPV_KHR_ray_tracing storage class (#4868)
    • Optimizer
      • spirv-opt: Fix stacked CompositeExtract constant folds (#4932)
      • Improve time to build dominators (#4916)
      • Fix ADCE to mark scope and inlined_at of line instructions as live. (#4910)
      • Improve algorithm to reorder blocks in a function (#4911)
      • Add structs to eliminate dead input components (#4894)
      • spirv-opt: fix copy-propagate-arrays index opti on structs. (#4891)
      • Fix ADCE to not eliminate top level DebugInfo instructions (#4889)
      • Fix array copy propagation (#4890)
    Source code(tar.gz)
    Source code(zip)
  • v2022.3(Dec 7, 2022)

    • General
      • Add SPV_KHR_fragment_shader_barycentric support (#4805)
      • Add support for SPV_KHR_subgroup_rotate (#4786)
      • use exec_tools instead of tools for better RBE compatibility (#4837)
      • Write binary files to stdout in binary on windows. (#4834)
      • Allow spirv-opt print-all to show pretty IDs (#4888)
    • Validator
      • spirv-val: Add PerVertexKHR (#4807)
      • spirv-opt : Add FixFuncCallArgumentsPass (#4775)
      • spirv-val: Add CullMaskKHR support (#4792)
      • Require ColMajor or RowMajor for matrices (#4878)
      • spirv-val: Add SPV_KHR_ray_query (#4848)
      • spirv-val: Add SPV_KHR_ray_tracing instructions (#4871)
      • Implement SPV_NV_bindless_texture related changes (#4847)
      • spirv-val: Add OpConvertUToAccelerationStructureKHR (#4838)
      • spirv-val: Add support for SPV_AMD_shader_early_and_late_fragment_tests (#4812)
    • Optimizer
      • Fold multiply and subtraction into FMA with negation (#4808)
      • Add more folding for composite instructions (#4802)
      • spirv-opt: add pass for interface variable scalar replacement (#4779)
      • Don't try to unroll loop with step count 0. (#4769)
      • spirv-opt: SPV_NV_bindless_texture related changes (#4870)
    • Linker
      • linker: Recalculate interface variables (#4784)
    Source code(tar.gz)
    Source code(zip)
  • v2022.1(Jan 26, 2022)

  • v2021.4(Nov 11, 2021)

  • v2021.3(Sep 10, 2021)

  • v2020.4(Aug 11, 2020)

Owner
The Khronos Group
Connecting Software to Silicon
The Khronos Group
GraphicsFuzz provides tools for automatically finding and simplifying bugs in graphics drivers, specifically graphics shader compilers.

GraphicsFuzz GraphicsFuzz is a set of tools for testing shader compilers GraphicsFuzz provides tools for automatically finding and simplifying bugs in

Google 516 Dec 15, 2022
LLVM IR and optimizer for shaders, including front-end adapters for GLSL and SPIR-V and back-end adapter for GLSL

Licensing LunarGLASS is available via a three clause BSD-style open source license. Goals The primary goals of the LunarGLASS project are: Reduce the

LunarG, Inc. 153 Dec 8, 2022
Suckless-tools - My fork of suckless tools.

suckless-tools Here is my fork of suckless tools. I didn't include tabbed, i was using but not actively. I am using xfce4-terminal instead of st. Beca

null 2 Jan 7, 2022
The Vulkan Profiles Tools are a collection of tools delivered with the Vulkan SDK for Vulkan application developers to leverage Vulkan Profiles while developing a Vulkan application

Copyright © 2021-2022 LunarG, Inc. Vulkan Profiles Tools (BETA) The Vulkan Profiles Tools are a collection of tools delivered with the Vulkan SDK for

The Khronos Group 73 Dec 25, 2022
Allows for multiple SwitchBot buttons and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Meter/Temp Sensor

SwitchBot-MQTT-BLE-ESP32 Switchbot local control using ESP32. no switchbot hub used/required. works with any smarthub that supports MQTT https://githu

null 343 Dec 27, 2022
SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages.

SPIRV-Cross SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages. Features Convert SPIR-V to readable, usable an

The Khronos Group 1.6k Jan 2, 2023
yariv.h is a single C/C++ header to encode and decode SPIR-V shaders into a more compressed form I've called YARI-V.

YARI-V yariv.h is a single C/C++ header to encode and decode SPIR-V shaders into a more compressed form I've called YARI-V. YARI-V is an alternative e

Neil Henning 31 Dec 8, 2022
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.

News Visual Studio 2013 is no longer supported As scheduled, Microsoft Visual Studio 2013 is no longer officially supported. Please upgrade to at leas

The Khronos Group 2.4k Jan 9, 2023
Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactively receive/edit/monitor data and send commands to an embedded system via the serial bus

See wiki for full documentation Serial Data Monitor Description Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactivel

monnoliv 4 Oct 29, 2021
A sketch that not only parses NMEA sentences, but also allows sending UBX commands and decrypt answers from the ublox module

RAK4631-ublox-Commander This is a tokenizer and parser for raw NMEA sentences. This is not intended (yet anyway) for production, but as an exercice in

Kongduino 2 May 29, 2022
Shell program written in C to implement various system calls, with support of executing commands, output redirection and signals.

Use ./shell command to start the shell. $<space>path/executable to run the executable(please specify the path without beginning it with "/"). Eg. type

Ayuj Panchal 1 Nov 15, 2021
32Kb, small memory footprint, single binary that run list of commands in parallel and waits for their termination

await 32K, small memory footprint, single binary that run list of commands in parallel and waits for their termination documentation linux install cur

Slava 56 Oct 2, 2022
Proof of concept userspace filesystem that executes filenames as shell commands and makes the result accessible though reading the file.

ExecFS Proof of concept userspace filesystem that executes filenames as shell commands and makes the result accessible though reading the file. $ ./ex

Camel Coder 42 Jan 7, 2023
This repository contains machine-readable files for the SPIR-V Registry

SPIR-V Headers This repository contains machine-readable files for the SPIR-V Registry. This includes: Header files for various languages. JSON files

The Khronos Group 201 Jan 6, 2023
SMOL-V: like Vulkan/Khronos SPIR-V, but smaller.

SMOL-V: like Vulkan/Khronos SPIR-V, but smaller. Overview SMOL-V encodes Vulkan/Khronos SPIR-V format programs into a form that is smoller, and is mor

Aras Pranckevičius 271 Dec 19, 2022
A sample project for building Zygisk modules

Developing Zygisk Modules This repository hosts a template zygisk module for developers to start developing Zygisk modules. Before developing Zygisk m

John Wu 237 Jan 1, 2023
hooking the execve syscall, to randomly sabotage typed bash commands.

Syscall hooks A small project of hooking the execve() syscall, to randomly sabotage typed bash commands. This project was tested on 5.11.0-38-generic.

ilevi 4 Aug 2, 2022
The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry.

OpenEXR OpenEXR provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the mot

Academy Software Foundation 1.3k Jan 6, 2023
Official examples and tools from the JACK project

JACK example tools This repository holds the official JACK example clients and tools, which have been tracked in the example-clients and tools reposit

JACK Audio Connection Kit 21 Nov 2, 2022